repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
Unidata/siphon
siphon/cdmr/ncstream.py
struct_to_dtype
def struct_to_dtype(struct): """Convert a Structure specification to a numpy structured dtype.""" # str() around name necessary because protobuf gives unicode names, but dtype doesn't # support them on Python 2 fields = [(str(var.name), data_type_to_numpy(var.dataType, var.unsigned)) for v...
python
def struct_to_dtype(struct): """Convert a Structure specification to a numpy structured dtype.""" # str() around name necessary because protobuf gives unicode names, but dtype doesn't # support them on Python 2 fields = [(str(var.name), data_type_to_numpy(var.dataType, var.unsigned)) for v...
[ "def", "struct_to_dtype", "(", "struct", ")", ":", "# str() around name necessary because protobuf gives unicode names, but dtype doesn't", "# support them on Python 2", "fields", "=", "[", "(", "str", "(", "var", ".", "name", ")", ",", "data_type_to_numpy", "(", "var", "...
Convert a Structure specification to a numpy structured dtype.
[ "Convert", "a", "Structure", "specification", "to", "a", "numpy", "structured", "dtype", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L322-L333
train
Unidata/siphon
siphon/cdmr/ncstream.py
unpack_variable
def unpack_variable(var): """Unpack an NCStream Variable into information we can use.""" # If we actually get a structure instance, handle turning that into a variable if var.dataType == stream.STRUCTURE: return None, struct_to_dtype(var), 'Structure' elif var.dataType == stream.SEQUENCE: ...
python
def unpack_variable(var): """Unpack an NCStream Variable into information we can use.""" # If we actually get a structure instance, handle turning that into a variable if var.dataType == stream.STRUCTURE: return None, struct_to_dtype(var), 'Structure' elif var.dataType == stream.SEQUENCE: ...
[ "def", "unpack_variable", "(", "var", ")", ":", "# If we actually get a structure instance, handle turning that into a variable", "if", "var", ".", "dataType", "==", "stream", ".", "STRUCTURE", ":", "return", "None", ",", "struct_to_dtype", "(", "var", ")", ",", "'Str...
Unpack an NCStream Variable into information we can use.
[ "Unpack", "an", "NCStream", "Variable", "into", "information", "we", "can", "use", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L336-L362
train
Unidata/siphon
siphon/cdmr/ncstream.py
unpack_attribute
def unpack_attribute(att): """Unpack an embedded attribute into a python or numpy object.""" if att.unsigned: log.warning('Unsupported unsigned attribute!') # TDS 5.0 now has a dataType attribute that takes precedence if att.len == 0: # Empty val = None elif att.dataType == stream....
python
def unpack_attribute(att): """Unpack an embedded attribute into a python or numpy object.""" if att.unsigned: log.warning('Unsupported unsigned attribute!') # TDS 5.0 now has a dataType attribute that takes precedence if att.len == 0: # Empty val = None elif att.dataType == stream....
[ "def", "unpack_attribute", "(", "att", ")", ":", "if", "att", ".", "unsigned", ":", "log", ".", "warning", "(", "'Unsupported unsigned attribute!'", ")", "# TDS 5.0 now has a dataType attribute that takes precedence", "if", "att", ".", "len", "==", "0", ":", "# Empt...
Unpack an embedded attribute into a python or numpy object.
[ "Unpack", "an", "embedded", "attribute", "into", "a", "python", "or", "numpy", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L373-L397
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_var_int
def read_var_int(file_obj): """Read a variable-length integer. Parameters ---------- file_obj : file-like object The file to read from. Returns ------- int the variable-length value read """ # Read all bytes from here, stopping with the first one that does not have...
python
def read_var_int(file_obj): """Read a variable-length integer. Parameters ---------- file_obj : file-like object The file to read from. Returns ------- int the variable-length value read """ # Read all bytes from here, stopping with the first one that does not have...
[ "def", "read_var_int", "(", "file_obj", ")", ":", "# Read all bytes from here, stopping with the first one that does not have", "# the MSB set. Save the lower 7 bits, and keep stacking to the *left*.", "val", "=", "0", "shift", "=", "0", "while", "True", ":", "# Read next byte", ...
Read a variable-length integer. Parameters ---------- file_obj : file-like object The file to read from. Returns ------- int the variable-length value read
[ "Read", "a", "variable", "-", "length", "integer", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L400-L426
train
Unidata/siphon
siphon/cdmr/cdmremote.py
CDMRemote.fetch_data
def fetch_data(self, **var): """Retrieve data from CDMRemote for one or more variables.""" varstr = ','.join(name + self._convert_indices(ind) for name, ind in var.items()) query = self.query().add_query_parameter(req='data', var=varstr) return self._fetch(query...
python
def fetch_data(self, **var): """Retrieve data from CDMRemote for one or more variables.""" varstr = ','.join(name + self._convert_indices(ind) for name, ind in var.items()) query = self.query().add_query_parameter(req='data', var=varstr) return self._fetch(query...
[ "def", "fetch_data", "(", "self", ",", "*", "*", "var", ")", ":", "varstr", "=", "','", ".", "join", "(", "name", "+", "self", ".", "_convert_indices", "(", "ind", ")", "for", "name", ",", "ind", "in", "var", ".", "items", "(", ")", ")", "query",...
Retrieve data from CDMRemote for one or more variables.
[ "Retrieve", "data", "from", "CDMRemote", "for", "one", "or", "more", "variables", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremote.py#L31-L36
train
Unidata/siphon
siphon/cdmr/cdmremote.py
CDMRemote.query
def query(self): """Generate a new query for CDMRemote. This handles turning on compression if necessary. Returns ------- HTTPQuery The created query. """ q = super(CDMRemote, self).query() # Turn on compression if it's been set on the obje...
python
def query(self): """Generate a new query for CDMRemote. This handles turning on compression if necessary. Returns ------- HTTPQuery The created query. """ q = super(CDMRemote, self).query() # Turn on compression if it's been set on the obje...
[ "def", "query", "(", "self", ")", ":", "q", "=", "super", "(", "CDMRemote", ",", "self", ")", ".", "query", "(", ")", "# Turn on compression if it's been set on the object", "if", "self", ".", "deflate", ":", "q", ".", "add_query_parameter", "(", "deflate", ...
Generate a new query for CDMRemote. This handles turning on compression if necessary. Returns ------- HTTPQuery The created query.
[ "Generate", "a", "new", "query", "for", "CDMRemote", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremote.py#L46-L63
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
check_token
def check_token(func): """检查 access token 是否有效.""" @wraps(func) def wrapper(*args, **kwargs): response = func(*args, **kwargs) if response.status_code == 401: raise InvalidToken('Access token invalid or no longer valid') else: return response return wrappe...
python
def check_token(func): """检查 access token 是否有效.""" @wraps(func) def wrapper(*args, **kwargs): response = func(*args, **kwargs) if response.status_code == 401: raise InvalidToken('Access token invalid or no longer valid') else: return response return wrappe...
[ "def", "check_token", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "response", ".", ...
检查 access token 是否有效.
[ "检查", "access", "token", "是否有效", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L22-L31
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.upload
def upload(self, remote_path, file_content, ondup=None, **kwargs): """上传单个文件(<2G). | 百度PCS服务目前支持最大2G的单个文件上传。 | 如需支持超大文件(>2G)的断点续传,请参考下面的“分片文件上传”方法。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: ...
python
def upload(self, remote_path, file_content, ondup=None, **kwargs): """上传单个文件(<2G). | 百度PCS服务目前支持最大2G的单个文件上传。 | 如需支持超大文件(>2G)的断点续传,请参考下面的“分片文件上传”方法。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: ...
[ "def", "upload", "(", "self", ",", "remote_path", ",", "file_content", ",", "ondup", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'ondup'", ":", "ondup", "}", "files", "=", "{", "'file'", ":"...
上传单个文件(<2G). | 百度PCS服务目前支持最大2G的单个文件上传。 | 如需支持超大文件(>2G)的断点续传,请参考下面的“分片文件上传”方法。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:...
[ "上传单个文件(<2G)", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L103-L135
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.upload_tmpfile
def upload_tmpfile(self, file_content, **kwargs): """分片上传—文件分片及上传. 百度 PCS 服务支持每次直接上传最大2G的单个文件。 如需支持上传超大文件(>2G),则可以通过组合调用分片文件上传的 ``upload_tmpfile`` 方法和 ``upload_superfile`` 方法实现: 1. 首先,将超大文件分割为2G以内的单文件,并调用 ``upload_tmpfile`` 将分片文件依次上传; 2. 其次,调用 ``upload_super...
python
def upload_tmpfile(self, file_content, **kwargs): """分片上传—文件分片及上传. 百度 PCS 服务支持每次直接上传最大2G的单个文件。 如需支持上传超大文件(>2G),则可以通过组合调用分片文件上传的 ``upload_tmpfile`` 方法和 ``upload_superfile`` 方法实现: 1. 首先,将超大文件分割为2G以内的单文件,并调用 ``upload_tmpfile`` 将分片文件依次上传; 2. 其次,调用 ``upload_super...
[ "def", "upload_tmpfile", "(", "self", ",", "file_content", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'type'", ":", "'tmpfile'", "}", "files", "=", "{", "'file'", ":", "(", "'file'", ",", "file_content", ",", "''", ")", "}", "url", "=", ...
分片上传—文件分片及上传. 百度 PCS 服务支持每次直接上传最大2G的单个文件。 如需支持上传超大文件(>2G),则可以通过组合调用分片文件上传的 ``upload_tmpfile`` 方法和 ``upload_superfile`` 方法实现: 1. 首先,将超大文件分割为2G以内的单文件,并调用 ``upload_tmpfile`` 将分片文件依次上传; 2. 其次,调用 ``upload_superfile`` ,完成分片文件的重组。 除此之外,如果应用中需要支持断点续传的功能, 也可...
[ "分片上传—文件分片及上传", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L137-L163
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.upload_superfile
def upload_superfile(self, remote_path, block_list, ondup=None, **kwargs): """分片上传—合并分片文件. 与分片文件上传的 ``upload_tmpfile`` 方法配合使用, 可实现超大文件(>2G)上传,同时也可用于断点续传的场景。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: ...
python
def upload_superfile(self, remote_path, block_list, ondup=None, **kwargs): """分片上传—合并分片文件. 与分片文件上传的 ``upload_tmpfile`` 方法配合使用, 可实现超大文件(>2G)上传,同时也可用于断点续传的场景。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: ...
[ "def", "upload_superfile", "(", "self", ",", "remote_path", ",", "block_list", ",", "ondup", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'ondup'", ":", "ondup", "}", "data", "=", "{", "'param'...
分片上传—合并分片文件. 与分片文件上传的 ``upload_tmpfile`` 方法配合使用, 可实现超大文件(>2G)上传,同时也可用于断点续传的场景。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符...
[ "分片上传—合并分片文件", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L165-L198
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.mkdir
def mkdir(self, remote_path, **kwargs): """为当前用户创建一个目录. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾...
python
def mkdir(self, remote_path, **kwargs): """为当前用户创建一个目录. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾...
[ "def", "mkdir", "(", "self", ",", "remote_path", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'path'", ":", "remote_path", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'mkdir'", ",", "data", "=", "data", ",", "*", "*", "kwa...
为当前用户创建一个目录. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空...
[ "为当前用户创建一个目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L232-L249
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.meta
def meta(self, remote_path, **kwargs): """获取单个文件或目录的元信息. :param remote_path: 网盘中文件/目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名...
python
def meta(self, remote_path, **kwargs): """获取单个文件或目录的元信息. :param remote_path: 网盘中文件/目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名...
[ "def", "meta", "(", "self", ",", "remote_path", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'meta'", ",", "extra_params", "=", "params", ",", "*", "...
获取单个文件或目录的元信息. :param remote_path: 网盘中文件/目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空...
[ "获取单个文件或目录的元信息", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L251-L268
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.list_files
def list_files(self, remote_path, by=None, order=None, limit=None, **kwargs): """获取目录下的文件列表. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " ...
python
def list_files(self, remote_path, by=None, order=None, limit=None, **kwargs): """获取目录下的文件列表. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " ...
[ "def", "list_files", "(", "self", ",", "remote_path", ",", "by", "=", "None", ",", "order", "=", "None", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'by'", ":", "by", ",", ...
获取目录下的文件列表. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白...
[ "获取目录下的文件列表", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L292-L326
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.move
def move(self, from_path, to_path, **kwargs): """移动单个文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`...
python
def move(self, from_path, to_path, **kwargs): """移动单个文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`...
[ "def", "move", "(", "self", ",", "from_path", ",", "to_path", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'from'", ":", "from_path", ",", "'to'", ":", "to_path", ",", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'move'", "...
移动单个文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白字符包括: ...
[ "移动单个文件或目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L328-L354
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.multi_move
def multi_move(self, path_list, **kwargs): """批量移动文件或目录. :param path_list: 源文件地址和目标文件地址对列表: >>> path_list = [ ... ('/apps/test_sdk/test.txt', # 源文件 ... '/apps/test_sdk/testmkdir/b.txt' # 目标文件 ...
python
def multi_move(self, path_list, **kwargs): """批量移动文件或目录. :param path_list: 源文件地址和目标文件地址对列表: >>> path_list = [ ... ('/apps/test_sdk/test.txt', # 源文件 ... '/apps/test_sdk/testmkdir/b.txt' # 目标文件 ...
[ "def", "multi_move", "(", "self", ",", "path_list", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'param'", ":", "json", ".", "dumps", "(", "{", "'list'", ":", "[", "{", "'from'", ":", "x", "[", "0", "]", ",", "'to'", ":", "x", "[", "...
批量移动文件或目录. :param path_list: 源文件地址和目标文件地址对列表: >>> path_list = [ ... ('/apps/test_sdk/test.txt', # 源文件 ... '/apps/test_sdk/testmkdir/b.txt' # 目标文件 ... ), ... ('/apps/test...
[ "批量移动文件或目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L356-L385
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.copy
def copy(self, from_path, to_path, **kwargs): """拷贝文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
python
def copy(self, from_path, to_path, **kwargs): """拷贝文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
[ "def", "copy", "(", "self", ",", "from_path", ",", "to_path", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'from'", ":", "from_path", ",", "'to'", ":", "to_path", ",", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'copy'", "...
拷贝文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白字符包括: ...
[ "拷贝文件或目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L387-L417
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.delete
def delete(self, remote_path, **kwargs): """删除单个文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param remote_path: 网盘中文件/目录的路径,路径必须以 /apps/ 开头。 .. warning:: ...
python
def delete(self, remote_path, **kwargs): """删除单个文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param remote_path: 网盘中文件/目录的路径,路径必须以 /apps/ 开头。 .. warning:: ...
[ "def", "delete", "(", "self", ",", "remote_path", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'path'", ":", "remote_path", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'delete'", ",", "data", "=", "data", ",", "*", "*", "k...
删除单个文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param remote_path: 网盘中文件/目录的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; ...
[ "删除单个文件或目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L450-L473
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.multi_delete
def multi_delete(self, path_list, **kwargs): """批量删除文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param path_list: 网盘中文件/目录的路径列表,路径必须以 /apps/ 开头。 .. warning:: ...
python
def multi_delete(self, path_list, **kwargs): """批量删除文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param path_list: 网盘中文件/目录的路径列表,路径必须以 /apps/ 开头。 .. warning:: ...
[ "def", "multi_delete", "(", "self", ",", "path_list", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'param'", ":", "json", ".", "dumps", "(", "{", "'list'", ":", "[", "{", "'path'", ":", "path", "}", "for", "path", "in", "path_list", "]", ...
批量删除文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param path_list: 网盘中文件/目录的路径列表,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; ...
[ "批量删除文件或目录", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L475-L500
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.search
def search(self, remote_path, keyword, recurrent='0', **kwargs): """按文件名搜索文件(不支持查找目录). :param remote_path: 需要检索的目录路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
python
def search(self, remote_path, keyword, recurrent='0', **kwargs): """按文件名搜索文件(不支持查找目录). :param remote_path: 需要检索的目录路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
[ "def", "search", "(", "self", ",", "remote_path", ",", "keyword", ",", "recurrent", "=", "'0'", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'wd'", ":", "keyword", ",", "'re'", ":", "recurrent", ",", "}",...
按文件名搜索文件(不支持查找目录). :param remote_path: 需要检索的目录路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
[ "按文件名搜索文件(不支持查找目录)", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L502-L529
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.thumbnail
def thumbnail(self, remote_path, height, width, quality=100, **kwargs): """获取指定图片文件的缩略图. :param remote_path: 源图片的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
python
def thumbnail(self, remote_path, height, width, quality=100, **kwargs): """获取指定图片文件的缩略图. :param remote_path: 源图片的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
[ "def", "thumbnail", "(", "self", ",", "remote_path", ",", "height", ",", "width", ",", "quality", "=", "100", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'height'", ":", "height", ",", "'width'", ":", "w...
获取指定图片文件的缩略图. :param remote_path: 源图片的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,...
[ "获取指定图片文件的缩略图", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L531-L566
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.diff
def diff(self, cursor='null', **kwargs): """文件增量更新操作查询接口. 本接口有数秒延迟,但保证返回结果为最终一致. :param cursor: 用于标记更新断点。 * 首次调用cursor=null; * 非首次调用,使用最后一次调用diff接口的返回结果 中的cursor。 :type cursor: str :return: Response 对象 ...
python
def diff(self, cursor='null', **kwargs): """文件增量更新操作查询接口. 本接口有数秒延迟,但保证返回结果为最终一致. :param cursor: 用于标记更新断点。 * 首次调用cursor=null; * 非首次调用,使用最后一次调用diff接口的返回结果 中的cursor。 :type cursor: str :return: Response 对象 ...
[ "def", "diff", "(", "self", ",", "cursor", "=", "'null'", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'cursor'", ":", "cursor", ",", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'diff'", ",", "extra_params", "=", "params",...
文件增量更新操作查询接口. 本接口有数秒延迟,但保证返回结果为最终一致. :param cursor: 用于标记更新断点。 * 首次调用cursor=null; * 非首次调用,使用最后一次调用diff接口的返回结果 中的cursor。 :type cursor: str :return: Response 对象
[ "文件增量更新操作查询接口", ".", "本接口有数秒延迟,但保证返回结果为最终一致", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L568-L584
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.video_convert
def video_convert(self, remote_path, video_type, **kwargs): """对视频文件进行转码,实现实时观看视频功能. 可下载支持 HLS/M3U8 的 `媒体云播放器 SDK <HLSSDK_>`__ 配合使用. .. _HLSSDK: http://developer.baidu.com/wiki/index.php?title=docs/cplat/media/sdk :param remote_path: 需要下载的视频文件路径,以/开头的绝对路径, ...
python
def video_convert(self, remote_path, video_type, **kwargs): """对视频文件进行转码,实现实时观看视频功能. 可下载支持 HLS/M3U8 的 `媒体云播放器 SDK <HLSSDK_>`__ 配合使用. .. _HLSSDK: http://developer.baidu.com/wiki/index.php?title=docs/cplat/media/sdk :param remote_path: 需要下载的视频文件路径,以/开头的绝对路径, ...
[ "def", "video_convert", "(", "self", ",", "remote_path", ",", "video_type", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "'type'", ":", "video_type", ",", "}", "return", "self", ".", "_request", "(", "'file'",...
对视频文件进行转码,实现实时观看视频功能. 可下载支持 HLS/M3U8 的 `媒体云播放器 SDK <HLSSDK_>`__ 配合使用. .. _HLSSDK: http://developer.baidu.com/wiki/index.php?title=docs/cplat/media/sdk :param remote_path: 需要下载的视频文件路径,以/开头的绝对路径, 需含源文件的文件名。 .. warning:: ...
[ "对视频文件进行转码,实现实时观看视频功能", ".", "可下载支持", "HLS", "/", "M3U8", "的", "媒体云播放器", "SDK", "<HLSSDK_", ">", "__", "配合使用", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L586-L645
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.list_streams
def list_streams(self, file_type, start=0, limit=100, filter_path=None, **kwargs): """以视频、音频、图片及文档四种类型的视图获取所创建应用程序下的 文件列表. :param file_type: 类型分为video、audio、image及doc四种。 :param start: 返回条目控制起始值,缺省值为0。 :param limit: 返回条目控制长度,缺省为1000,可配置。 :param filter...
python
def list_streams(self, file_type, start=0, limit=100, filter_path=None, **kwargs): """以视频、音频、图片及文档四种类型的视图获取所创建应用程序下的 文件列表. :param file_type: 类型分为video、audio、image及doc四种。 :param start: 返回条目控制起始值,缺省值为0。 :param limit: 返回条目控制长度,缺省为1000,可配置。 :param filter...
[ "def", "list_streams", "(", "self", ",", "file_type", ",", "start", "=", "0", ",", "limit", "=", "100", ",", "filter_path", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'type'", ":", "file_type", ",", "'start'", ":", "start", ...
以视频、音频、图片及文档四种类型的视图获取所创建应用程序下的 文件列表. :param file_type: 类型分为video、audio、image及doc四种。 :param start: 返回条目控制起始值,缺省值为0。 :param limit: 返回条目控制长度,缺省为1000,可配置。 :param filter_path: 需要过滤的前缀路径,如:/apps/album .. warning:: * 路径长度限制为1...
[ "以视频、音频、图片及文档四种类型的视图获取所创建应用程序下的", "文件列表", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L647-L673
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.download_stream
def download_stream(self, remote_path, **kwargs): """为当前用户下载一个流式文件.其参数和返回结果与下载单个文件的相同. :param remote_path: 需要下载的文件路径,以/开头的绝对路径,含文件名。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
python
def download_stream(self, remote_path, **kwargs): """为当前用户下载一个流式文件.其参数和返回结果与下载单个文件的相同. :param remote_path: 需要下载的文件路径,以/开头的绝对路径,含文件名。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; ...
[ "def", "download_stream", "(", "self", ",", "remote_path", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'path'", ":", "remote_path", ",", "}", "url", "=", "'https://d.pcs.baidu.com/rest/2.0/pcs/file'", "return", "self", ".", "_request", "(", "'strea...
为当前用户下载一个流式文件.其参数和返回结果与下载单个文件的相同. :param remote_path: 需要下载的文件路径,以/开头的绝对路径,含文件名。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
[ "为当前用户下载一个流式文件", ".", "其参数和返回结果与下载单个文件的相同", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L675-L694
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.rapid_upload
def rapid_upload(self, remote_path, content_length, content_md5, content_crc32, slice_md5, ondup=None, **kwargs): """秒传一个文件. .. warning:: * 被秒传文件必须大于256KB(即 256*1024 B)。 * 校验段为文件的前256KB,秒传接口需要提供校验段的MD5。 (非强一致接口,上传后请等待1秒后再读取) :param remote...
python
def rapid_upload(self, remote_path, content_length, content_md5, content_crc32, slice_md5, ondup=None, **kwargs): """秒传一个文件. .. warning:: * 被秒传文件必须大于256KB(即 256*1024 B)。 * 校验段为文件的前256KB,秒传接口需要提供校验段的MD5。 (非强一致接口,上传后请等待1秒后再读取) :param remote...
[ "def", "rapid_upload", "(", "self", ",", "remote_path", ",", "content_length", ",", "content_md5", ",", "content_crc32", ",", "slice_md5", ",", "ondup", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'path'", ":", "remote_path", ",", ...
秒传一个文件. .. warning:: * 被秒传文件必须大于256KB(即 256*1024 B)。 * 校验段为文件的前256KB,秒传接口需要提供校验段的MD5。 (非强一致接口,上传后请等待1秒后再读取) :param remote_path: 上传文件的全路径名。 .. warning:: * 路径长度限制为1000; * 径中不能包...
[ "秒传一个文件", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L696-L732
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.add_download_task
def add_download_task(self, source_url, remote_path, rate_limit=None, timeout=60 * 60, expires=None, callback='', **kwargs): """添加离线下载任务,实现单个文件离线下载. :param source_url: 源文件的URL。 :param remote_path: 下载后的文件保存路径。 .. wa...
python
def add_download_task(self, source_url, remote_path, rate_limit=None, timeout=60 * 60, expires=None, callback='', **kwargs): """添加离线下载任务,实现单个文件离线下载. :param source_url: 源文件的URL。 :param remote_path: 下载后的文件保存路径。 .. wa...
[ "def", "add_download_task", "(", "self", ",", "source_url", ",", "remote_path", ",", "rate_limit", "=", "None", ",", "timeout", "=", "60", "*", "60", ",", "expires", "=", "None", ",", "callback", "=", "''", ",", "*", "*", "kwargs", ")", ":", "data", ...
添加离线下载任务,实现单个文件离线下载. :param source_url: 源文件的URL。 :param remote_path: 下载后的文件保存路径。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
[ "添加离线下载任务,实现单个文件离线下载", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L734-L767
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.query_download_tasks
def query_download_tasks(self, task_ids, operate_type=1, expires=None, **kwargs): """根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1...
python
def query_download_tasks(self, task_ids, operate_type=1, expires=None, **kwargs): """根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1...
[ "def", "query_download_tasks", "(", "self", ",", "task_ids", ",", "operate_type", "=", "1", ",", "expires", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'task_ids'", ":", "','", ".", "join", "(", "map", "(", "str", ",", "task_...
根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1:查进度信息,默认为1 :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象
[ "根据任务ID号,查询离线下载任务信息及进度信息。" ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L769-L789
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.list_download_tasks
def list_download_tasks(self, need_task_info=1, start=0, limit=10, asc=0, create_time=None, status=None, source_url=None, remote_path=None, expires=None, **kwargs): """查询离线下载任务ID列表及任务信息. :param need_task_info: 是否需要返回任务信息: ...
python
def list_download_tasks(self, need_task_info=1, start=0, limit=10, asc=0, create_time=None, status=None, source_url=None, remote_path=None, expires=None, **kwargs): """查询离线下载任务ID列表及任务信息. :param need_task_info: 是否需要返回任务信息: ...
[ "def", "list_download_tasks", "(", "self", ",", "need_task_info", "=", "1", ",", "start", "=", "0", ",", "limit", "=", "10", ",", "asc", "=", "0", ",", "create_time", "=", "None", ",", "status", "=", "None", ",", "source_url", "=", "None", ",", "remo...
查询离线下载任务ID列表及任务信息. :param need_task_info: 是否需要返回任务信息: * 0:不需要 * 1:需要,默认为1 :param start: 查询任务起始位置,默认为0。 :param limit: 设定返回任务数量,默认为10。 :param asc: * 0:降序,默认值 * 1:升序 :param create_...
[ "查询离线下载任务ID列表及任务信息", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L791-L839
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.cancel_download_task
def cancel_download_task(self, task_id, expires=None, **kwargs): """取消离线下载任务. :param task_id: 要取消的任务ID号。 :type task_id: str :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象 """ data = { 'expires': expires, ...
python
def cancel_download_task(self, task_id, expires=None, **kwargs): """取消离线下载任务. :param task_id: 要取消的任务ID号。 :type task_id: str :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象 """ data = { 'expires': expires, ...
[ "def", "cancel_download_task", "(", "self", ",", "task_id", ",", "expires", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'expires'", ":", "expires", ",", "'task_id'", ":", "task_id", ",", "}", "return", "self", ".", "_request", "(...
取消离线下载任务. :param task_id: 要取消的任务ID号。 :type task_id: str :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象
[ "取消离线下载任务", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L841-L856
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.list_recycle_bin
def list_recycle_bin(self, start=0, limit=1000, **kwargs): """获取回收站中的文件及目录列表. :param start: 返回条目的起始值,缺省值为0 :param limit: 返回条目的长度,缺省值为1000 :return: Response 对象 """ params = { 'start': start, 'limit': limit, } return self._request('...
python
def list_recycle_bin(self, start=0, limit=1000, **kwargs): """获取回收站中的文件及目录列表. :param start: 返回条目的起始值,缺省值为0 :param limit: 返回条目的长度,缺省值为1000 :return: Response 对象 """ params = { 'start': start, 'limit': limit, } return self._request('...
[ "def", "list_recycle_bin", "(", "self", ",", "start", "=", "0", ",", "limit", "=", "1000", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'start'", ":", "start", ",", "'limit'", ":", "limit", ",", "}", "return", "self", ".", "_request", "(...
获取回收站中的文件及目录列表. :param start: 返回条目的起始值,缺省值为0 :param limit: 返回条目的长度,缺省值为1000 :return: Response 对象
[ "获取回收站中的文件及目录列表", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L858-L871
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.restore_recycle_bin
def restore_recycle_bin(self, fs_id, **kwargs): """还原单个文件或目录(非强一致接口,调用后请sleep 1秒读取). :param fs_id: 所还原的文件或目录在PCS的临时唯一标识ID。 :type fs_id: str :return: Response 对象 """ data = { 'fs_id': fs_id, } return self._request('file', 'restore', data=data,...
python
def restore_recycle_bin(self, fs_id, **kwargs): """还原单个文件或目录(非强一致接口,调用后请sleep 1秒读取). :param fs_id: 所还原的文件或目录在PCS的临时唯一标识ID。 :type fs_id: str :return: Response 对象 """ data = { 'fs_id': fs_id, } return self._request('file', 'restore', data=data,...
[ "def", "restore_recycle_bin", "(", "self", ",", "fs_id", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'fs_id'", ":", "fs_id", ",", "}", "return", "self", ".", "_request", "(", "'file'", ",", "'restore'", ",", "data", "=", "data", ",", "*", ...
还原单个文件或目录(非强一致接口,调用后请sleep 1秒读取). :param fs_id: 所还原的文件或目录在PCS的临时唯一标识ID。 :type fs_id: str :return: Response 对象
[ "还原单个文件或目录(非强一致接口,调用后请sleep", "1秒读取)", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L873-L884
train
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
PCS.multi_restore_recycle_bin
def multi_restore_recycle_bin(self, fs_ids, **kwargs): """批量还原文件或目录(非强一致接口,调用后请sleep1秒 ). :param fs_ids: 所还原的文件或目录在 PCS 的临时唯一标识 ID 的列表。 :type fs_ids: list or tuple :return: Response 对象 """ data = { 'param': json.dumps({ 'list': [{'fs_id': fs_...
python
def multi_restore_recycle_bin(self, fs_ids, **kwargs): """批量还原文件或目录(非强一致接口,调用后请sleep1秒 ). :param fs_ids: 所还原的文件或目录在 PCS 的临时唯一标识 ID 的列表。 :type fs_ids: list or tuple :return: Response 对象 """ data = { 'param': json.dumps({ 'list': [{'fs_id': fs_...
[ "def", "multi_restore_recycle_bin", "(", "self", ",", "fs_ids", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'param'", ":", "json", ".", "dumps", "(", "{", "'list'", ":", "[", "{", "'fs_id'", ":", "fs_id", "}", "for", "fs_id", "in", "fs_ids"...
批量还原文件或目录(非强一致接口,调用后请sleep1秒 ). :param fs_ids: 所还原的文件或目录在 PCS 的临时唯一标识 ID 的列表。 :type fs_ids: list or tuple :return: Response 对象
[ "批量还原文件或目录(非强一致接口,调用后请sleep1秒", ")", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L886-L899
train
mozillazg/baidu-pcs-python-sdk
baidupcs/tools.py
get_new_access_token
def get_new_access_token(refresh_token, client_id, client_secret, scope=None, **kwargs): """使用 Refresh Token 刷新以获得新的 Access Token. :param refresh_token: 用于刷新 Access Token 用的 Refresh Token; :param client_id: 应用的 API Key; :param client_secret: 应用的 Secret Key; :param scope: 以空...
python
def get_new_access_token(refresh_token, client_id, client_secret, scope=None, **kwargs): """使用 Refresh Token 刷新以获得新的 Access Token. :param refresh_token: 用于刷新 Access Token 用的 Refresh Token; :param client_id: 应用的 API Key; :param client_secret: 应用的 Secret Key; :param scope: 以空...
[ "def", "get_new_access_token", "(", "refresh_token", ",", "client_id", ",", "client_secret", ",", "scope", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'grant_type'", ":", "'refresh_token'", ",", "'refresh_token'", ":", "refresh_token", "...
使用 Refresh Token 刷新以获得新的 Access Token. :param refresh_token: 用于刷新 Access Token 用的 Refresh Token; :param client_id: 应用的 API Key; :param client_secret: 应用的 Secret Key; :param scope: 以空格分隔的权限列表,若不传递此参数,代表请求的数据访问 操作权限与上次获取 Access Token 时一致。通过 Refresh Token 刷新 Access Toke...
[ "使用", "Refresh", "Token", "刷新以获得新的", "Access", "Token", "." ]
12fe3f13b2ecda8f8bdcc5334c876e934776a5cc
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/tools.py#L7-L36
train
persandstrom/python-verisure
verisure/session.py
Session.login
def login(self): """ Login to verisure app api Login before calling any read or write commands """ if os.path.exists(self._cookieFileName): with open(self._cookieFileName, 'r') as cookieFile: self._vid = cookieFile.read().strip() try: ...
python
def login(self): """ Login to verisure app api Login before calling any read or write commands """ if os.path.exists(self._cookieFileName): with open(self._cookieFileName, 'r') as cookieFile: self._vid = cookieFile.read().strip() try: ...
[ "def", "login", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_cookieFileName", ")", ":", "with", "open", "(", "self", ".", "_cookieFileName", ",", "'r'", ")", "as", "cookieFile", ":", "self", ".", "_vid", "=", "...
Login to verisure app api Login before calling any read or write commands
[ "Login", "to", "verisure", "app", "api" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L73-L95
train
persandstrom/python-verisure
verisure/session.py
Session._get_installations
def _get_installations(self): """ Get information about installations """ response = None for base_url in urls.BASE_URLS: urls.BASE_URL = base_url try: response = requests.get( urls.get_installations(self._username), ...
python
def _get_installations(self): """ Get information about installations """ response = None for base_url in urls.BASE_URLS: urls.BASE_URL = base_url try: response = requests.get( urls.get_installations(self._username), ...
[ "def", "_get_installations", "(", "self", ")", ":", "response", "=", "None", "for", "base_url", "in", "urls", ".", "BASE_URLS", ":", "urls", ".", "BASE_URL", "=", "base_url", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "get_ins...
Get information about installations
[ "Get", "information", "about", "installations" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L127-L150
train
persandstrom/python-verisure
verisure/session.py
Session.get_overview
def get_overview(self): """ Get overview for installation """ response = None try: response = requests.get( urls.overview(self._giid), headers={ 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept...
python
def get_overview(self): """ Get overview for installation """ response = None try: response = requests.get( urls.overview(self._giid), headers={ 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept...
[ "def", "get_overview", "(", "self", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "overview", "(", "self", ".", "_giid", ")", ",", "headers", "=", "{", "'Accept'", ":", "'application/json, text/...
Get overview for installation
[ "Get", "overview", "for", "installation" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L160-L174
train
persandstrom/python-verisure
verisure/session.py
Session.set_smartplug_state
def set_smartplug_state(self, device_label, state): """ Turn on or off smartplug Args: device_label (str): Smartplug device label state (boolean): new status, 'True' or 'False' """ response = None try: response = requests.post( ...
python
def set_smartplug_state(self, device_label, state): """ Turn on or off smartplug Args: device_label (str): Smartplug device label state (boolean): new status, 'True' or 'False' """ response = None try: response = requests.post( ...
[ "def", "set_smartplug_state", "(", "self", ",", "device_label", ",", "state", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "post", "(", "urls", ".", "smartplug", "(", "self", ".", "_giid", ")", ",", "headers", "=", "...
Turn on or off smartplug Args: device_label (str): Smartplug device label state (boolean): new status, 'True' or 'False'
[ "Turn", "on", "or", "off", "smartplug" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L176-L195
train
persandstrom/python-verisure
verisure/session.py
Session.get_history
def get_history(self, filters=(), pagesize=15, offset=0): """ Get recent events Args: filters (string set): 'ARM', 'DISARM', 'FIRE', 'INTRUSION', 'TECHNICAL', 'SOS', 'WARNING', 'LOCK', 'UNLOCK' pagesize (int): N...
python
def get_history(self, filters=(), pagesize=15, offset=0): """ Get recent events Args: filters (string set): 'ARM', 'DISARM', 'FIRE', 'INTRUSION', 'TECHNICAL', 'SOS', 'WARNING', 'LOCK', 'UNLOCK' pagesize (int): N...
[ "def", "get_history", "(", "self", ",", "filters", "=", "(", ")", ",", "pagesize", "=", "15", ",", "offset", "=", "0", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "history", "(", "self",...
Get recent events Args: filters (string set): 'ARM', 'DISARM', 'FIRE', 'INTRUSION', 'TECHNICAL', 'SOS', 'WARNING', 'LOCK', 'UNLOCK' pagesize (int): Number of events to display offset (int): Skip pagesize * o...
[ "Get", "recent", "events" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L250-L274
train
persandstrom/python-verisure
verisure/session.py
Session.get_climate
def get_climate(self, device_label): """ Get climate history Args: device_label: device label of climate device """ response = None try: response = requests.get( urls.climate(self._giid), headers={ 'Accep...
python
def get_climate(self, device_label): """ Get climate history Args: device_label: device label of climate device """ response = None try: response = requests.get( urls.climate(self._giid), headers={ 'Accep...
[ "def", "get_climate", "(", "self", ",", "device_label", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "climate", "(", "self", ".", "_giid", ")", ",", "headers", "=", "{", "'Accept'", ":", "'...
Get climate history Args: device_label: device label of climate device
[ "Get", "climate", "history", "Args", ":", "device_label", ":", "device", "label", "of", "climate", "device" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L276-L293
train
persandstrom/python-verisure
verisure/session.py
Session.set_lock_state
def set_lock_state(self, code, device_label, state): """ Lock or unlock Args: code (str): Lock code device_label (str): device label of lock state (str): 'lock' or 'unlock' """ response = None try: response = requests.put( ...
python
def set_lock_state(self, code, device_label, state): """ Lock or unlock Args: code (str): Lock code device_label (str): device label of lock state (str): 'lock' or 'unlock' """ response = None try: response = requests.put( ...
[ "def", "set_lock_state", "(", "self", ",", "code", ",", "device_label", ",", "state", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "put", "(", "urls", ".", "set_lockstate", "(", "self", ".", "_giid", ",", "device_label...
Lock or unlock Args: code (str): Lock code device_label (str): device label of lock state (str): 'lock' or 'unlock'
[ "Lock", "or", "unlock" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L309-L329
train
persandstrom/python-verisure
verisure/session.py
Session.get_lock_state_transaction
def get_lock_state_transaction(self, transaction_id): """ Get lock state transaction status Args: transaction_id: Transaction ID received from set_lock_state """ response = None try: response = requests.get( urls.get_lockstate_transaction(...
python
def get_lock_state_transaction(self, transaction_id): """ Get lock state transaction status Args: transaction_id: Transaction ID received from set_lock_state """ response = None try: response = requests.get( urls.get_lockstate_transaction(...
[ "def", "get_lock_state_transaction", "(", "self", ",", "transaction_id", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "get_lockstate_transaction", "(", "self", ".", "_giid", ",", "transaction_id", ")...
Get lock state transaction status Args: transaction_id: Transaction ID received from set_lock_state
[ "Get", "lock", "state", "transaction", "status" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L331-L347
train
persandstrom/python-verisure
verisure/session.py
Session.get_lock_config
def get_lock_config(self, device_label): """ Get lock configuration Args: device_label (str): device label of lock """ response = None try: response = requests.get( urls.lockconfig(self._giid, device_label), headers={ ...
python
def get_lock_config(self, device_label): """ Get lock configuration Args: device_label (str): device label of lock """ response = None try: response = requests.get( urls.lockconfig(self._giid, device_label), headers={ ...
[ "def", "get_lock_config", "(", "self", ",", "device_label", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "lockconfig", "(", "self", ".", "_giid", ",", "device_label", ")", ",", "headers", "=", ...
Get lock configuration Args: device_label (str): device label of lock
[ "Get", "lock", "configuration" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L349-L365
train
persandstrom/python-verisure
verisure/session.py
Session.set_lock_config
def set_lock_config(self, device_label, volume=None, voice_level=None, auto_lock_enabled=None): """ Set lock configuration Args: device_label (str): device label of lock volume (str): 'SILENCE', 'LOW' or 'HIGH' voice_level (str): 'ESSENTIAL' o...
python
def set_lock_config(self, device_label, volume=None, voice_level=None, auto_lock_enabled=None): """ Set lock configuration Args: device_label (str): device label of lock volume (str): 'SILENCE', 'LOW' or 'HIGH' voice_level (str): 'ESSENTIAL' o...
[ "def", "set_lock_config", "(", "self", ",", "device_label", ",", "volume", "=", "None", ",", "voice_level", "=", "None", ",", "auto_lock_enabled", "=", "None", ")", ":", "response", "=", "None", "data", "=", "{", "}", "if", "volume", ":", "data", "[", ...
Set lock configuration Args: device_label (str): device label of lock volume (str): 'SILENCE', 'LOW' or 'HIGH' voice_level (str): 'ESSENTIAL' or 'NORMAL' auto_lock_enabled (boolean): auto lock enabled
[ "Set", "lock", "configuration" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L367-L394
train
persandstrom/python-verisure
verisure/session.py
Session.capture_image
def capture_image(self, device_label): """ Capture smartcam image Args: device_label (str): device label of camera """ response = None try: response = requests.post( urls.imagecapture(self._giid, device_label), headers={ ...
python
def capture_image(self, device_label): """ Capture smartcam image Args: device_label (str): device label of camera """ response = None try: response = requests.post( urls.imagecapture(self._giid, device_label), headers={ ...
[ "def", "capture_image", "(", "self", ",", "device_label", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "post", "(", "urls", ".", "imagecapture", "(", "self", ".", "_giid", ",", "device_label", ")", ",", "headers", "=",...
Capture smartcam image Args: device_label (str): device label of camera
[ "Capture", "smartcam", "image" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L396-L411
train
persandstrom/python-verisure
verisure/session.py
Session.get_camera_imageseries
def get_camera_imageseries(self, number_of_imageseries=10, offset=0): """ Get smartcam image series Args: number_of_imageseries (int): number of image series to get offset (int): skip offset amount of image series """ response = None try: resp...
python
def get_camera_imageseries(self, number_of_imageseries=10, offset=0): """ Get smartcam image series Args: number_of_imageseries (int): number of image series to get offset (int): skip offset amount of image series """ response = None try: resp...
[ "def", "get_camera_imageseries", "(", "self", ",", "number_of_imageseries", "=", "10", ",", "offset", "=", "0", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "get_imageseries", "(", "self", ".", ...
Get smartcam image series Args: number_of_imageseries (int): number of image series to get offset (int): skip offset amount of image series
[ "Get", "smartcam", "image", "series" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L413-L437
train
persandstrom/python-verisure
verisure/session.py
Session.download_image
def download_image(self, device_label, image_id, file_name): """ Download image taken by a smartcam Args: device_label (str): device label of camera image_id (str): image id from image series file_name (str): path to file """ response = None t...
python
def download_image(self, device_label, image_id, file_name): """ Download image taken by a smartcam Args: device_label (str): device label of camera image_id (str): image id from image series file_name (str): path to file """ response = None t...
[ "def", "download_image", "(", "self", ",", "device_label", ",", "image_id", ",", "file_name", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "get", "(", "urls", ".", "download_image", "(", "self", ".", "_giid", ",", "dev...
Download image taken by a smartcam Args: device_label (str): device label of camera image_id (str): image id from image series file_name (str): path to file
[ "Download", "image", "taken", "by", "a", "smartcam" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L439-L460
train
persandstrom/python-verisure
verisure/session.py
Session.logout
def logout(self): """ Logout and remove vid """ response = None try: response = requests.delete( urls.login(), headers={ 'Cookie': 'vid={}'.format(self._vid)}) except requests.exceptions.RequestException as ex: r...
python
def logout(self): """ Logout and remove vid """ response = None try: response = requests.delete( urls.login(), headers={ 'Cookie': 'vid={}'.format(self._vid)}) except requests.exceptions.RequestException as ex: r...
[ "def", "logout", "(", "self", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "delete", "(", "urls", ".", "login", "(", ")", ",", "headers", "=", "{", "'Cookie'", ":", "'vid={}'", ".", "format", "(", "self", ".", "_...
Logout and remove vid
[ "Logout", "and", "remove", "vid" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L503-L513
train
persandstrom/python-verisure
verisure/session.py
Session.set_heat_pump_mode
def set_heat_pump_mode(self, device_label, mode): """ Set heatpump mode Args: mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO' """ response = None try: response = requests.put( urls.set_heatpump_state(self._giid, device_label), h...
python
def set_heat_pump_mode(self, device_label, mode): """ Set heatpump mode Args: mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO' """ response = None try: response = requests.put( urls.set_heatpump_state(self._giid, device_label), h...
[ "def", "set_heat_pump_mode", "(", "self", ",", "device_label", ",", "mode", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "put", "(", "urls", ".", "set_heatpump_state", "(", "self", ".", "_giid", ",", "device_label", ")",...
Set heatpump mode Args: mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO'
[ "Set", "heatpump", "mode", "Args", ":", "mode", "(", "str", ")", ":", "HEAT", "COOL", "FAN", "or", "AUTO" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L529-L546
train
persandstrom/python-verisure
verisure/session.py
Session.set_heat_pump_feature
def set_heat_pump_feature(self, device_label, feature): """ Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL' """ response = None try: response = requests.put( urls.set_heatpump_feature(self._giid, device_label, feature), ...
python
def set_heat_pump_feature(self, device_label, feature): """ Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL' """ response = None try: response = requests.put( urls.set_heatpump_feature(self._giid, device_label, feature), ...
[ "def", "set_heat_pump_feature", "(", "self", ",", "device_label", ",", "feature", ")", ":", "response", "=", "None", "try", ":", "response", "=", "requests", ".", "put", "(", "urls", ".", "set_heatpump_feature", "(", "self", ".", "_giid", ",", "device_label"...
Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL'
[ "Set", "heatpump", "mode", "Args", ":", "feature", ":", "QUIET", "ECONAVI", "or", "POWERFUL" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/session.py#L605-L621
train
persandstrom/python-verisure
verisure/__main__.py
print_result
def print_result(overview, *names): """ Print the result of a verisure request """ if names: for name in names: toprint = overview for part in name.split('/'): toprint = toprint[part] print(json.dumps(toprint, indent=4, separators=(',', ': '))) els...
python
def print_result(overview, *names): """ Print the result of a verisure request """ if names: for name in names: toprint = overview for part in name.split('/'): toprint = toprint[part] print(json.dumps(toprint, indent=4, separators=(',', ': '))) els...
[ "def", "print_result", "(", "overview", ",", "*", "names", ")", ":", "if", "names", ":", "for", "name", "in", "names", ":", "toprint", "=", "overview", "for", "part", "in", "name", ".", "split", "(", "'/'", ")", ":", "toprint", "=", "toprint", "[", ...
Print the result of a verisure request
[ "Print", "the", "result", "of", "a", "verisure", "request" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/__main__.py#L22-L31
train
persandstrom/python-verisure
verisure/__main__.py
main
def main(): """ Start verisure command line """ parser = argparse.ArgumentParser( description='Read or change status of verisure devices') parser.add_argument( 'username', help='MyPages username') parser.add_argument( 'password', help='MyPages password') parse...
python
def main(): """ Start verisure command line """ parser = argparse.ArgumentParser( description='Read or change status of verisure devices') parser.add_argument( 'username', help='MyPages username') parser.add_argument( 'password', help='MyPages password') parse...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Read or change status of verisure devices'", ")", "parser", ".", "add_argument", "(", "'username'", ",", "help", "=", "'MyPages username'", ")", "parser", "....
Start verisure command line
[ "Start", "verisure", "command", "line" ]
babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8
https://github.com/persandstrom/python-verisure/blob/babd25e7f8fb2b24f12e4109dfa8a04041e8dcb8/verisure/__main__.py#L35-L261
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.type_id
def type_id(self): """ Shortcut to retrieving the ContentType id of the model. """ try: return ContentType.objects.get_for_model(self.model, for_concrete_model=False).id except DatabaseError as e: raise DatabaseError("Unable to fetch ContentType object, is...
python
def type_id(self): """ Shortcut to retrieving the ContentType id of the model. """ try: return ContentType.objects.get_for_model(self.model, for_concrete_model=False).id except DatabaseError as e: raise DatabaseError("Unable to fetch ContentType object, is...
[ "def", "type_id", "(", "self", ")", ":", "try", ":", "return", "ContentType", ".", "objects", ".", "get_for_model", "(", "self", ".", "model", ",", "for_concrete_model", "=", "False", ")", ".", "id", "except", "DatabaseError", "as", "e", ":", "raise", "D...
Shortcut to retrieving the ContentType id of the model.
[ "Shortcut", "to", "retrieving", "the", "ContentType", "id", "of", "the", "model", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L291-L298
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.get_output_cache_key
def get_output_cache_key(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the default cache key which is used to store a rendered item. By default, this function generates the cache key using :func:`get_output_cache_base_key`. """ cachekey = self....
python
def get_output_cache_key(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the default cache key which is used to store a rendered item. By default, this function generates the cache key using :func:`get_output_cache_base_key`. """ cachekey = self....
[ "def", "get_output_cache_key", "(", "self", ",", "placeholder_name", ",", "instance", ")", ":", "cachekey", "=", "self", ".", "get_output_cache_base_key", "(", "placeholder_name", ",", "instance", ")", "if", "self", ".", "cache_output_per_site", ":", "cachekey", "...
.. versionadded:: 0.9 Return the default cache key which is used to store a rendered item. By default, this function generates the cache key using :func:`get_output_cache_base_key`.
[ "..", "versionadded", "::", "0", ".", "9", "Return", "the", "default", "cache", "key", "which", "is", "used", "to", "store", "a", "rendered", "item", ".", "By", "default", "this", "function", "generates", "the", "cache", "key", "using", ":", "func", ":",...
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L339-L359
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.get_output_cache_keys
def get_output_cache_keys(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the possible cache keys for a rendered item. This method should be overwritten when implementing a function :func:`set_cached_output` method or when implementing a :func:`get_o...
python
def get_output_cache_keys(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the possible cache keys for a rendered item. This method should be overwritten when implementing a function :func:`set_cached_output` method or when implementing a :func:`get_o...
[ "def", "get_output_cache_keys", "(", "self", ",", "placeholder_name", ",", "instance", ")", ":", "base_key", "=", "self", ".", "get_output_cache_base_key", "(", "placeholder_name", ",", "instance", ")", "cachekeys", "=", "[", "base_key", ",", "]", "if", "self", ...
.. versionadded:: 0.9 Return the possible cache keys for a rendered item. This method should be overwritten when implementing a function :func:`set_cached_output` method or when implementing a :func:`get_output_cache_key` function. By default, this function generates the cac...
[ "..", "versionadded", "::", "0", ".", "9", "Return", "the", "possible", "cache", "keys", "for", "a", "rendered", "item", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L361-L400
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.get_cached_output
def get_cached_output(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the cached output for a rendered item, or ``None`` if no output is cached. This method can be overwritten to implement custom caching mechanisms. By default, this function generate...
python
def get_cached_output(self, placeholder_name, instance): """ .. versionadded:: 0.9 Return the cached output for a rendered item, or ``None`` if no output is cached. This method can be overwritten to implement custom caching mechanisms. By default, this function generate...
[ "def", "get_cached_output", "(", "self", ",", "placeholder_name", ",", "instance", ")", ":", "cachekey", "=", "self", ".", "get_output_cache_key", "(", "placeholder_name", ",", "instance", ")", "return", "cache", ".", "get", "(", "cachekey", ")" ]
.. versionadded:: 0.9 Return the cached output for a rendered item, or ``None`` if no output is cached. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`get_output_cache_key` and retrieves t...
[ "..", "versionadded", "::", "0", ".", "9", "Return", "the", "cached", "output", "for", "a", "rendered", "item", "or", "None", "if", "no", "output", "is", "cached", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L402-L412
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.set_cached_output
def set_cached_output(self, placeholder_name, instance, output): """ .. versionadded:: 0.9 Store the cached output for a rendered item. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`...
python
def set_cached_output(self, placeholder_name, instance, output): """ .. versionadded:: 0.9 Store the cached output for a rendered item. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`...
[ "def", "set_cached_output", "(", "self", ",", "placeholder_name", ",", "instance", ",", "output", ")", ":", "cachekey", "=", "self", ".", "get_output_cache_key", "(", "placeholder_name", ",", "instance", ")", "if", "self", ".", "cache_timeout", "is", "not", "D...
.. versionadded:: 0.9 Store the cached output for a rendered item. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`~fluent_contents.cache.get_rendering_cache_key` and stores the results in ...
[ "..", "versionadded", "::", "0", ".", "9", "Store", "the", "cached", "output", "for", "a", "rendered", "item", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L414-L434
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.render
def render(self, request, instance, **kwargs): """ The rendering/view function that displays a plugin model instance. :param instance: An instance of the ``model`` the plugin uses. :param request: The Django :class:`~django.http.HttpRequest` class containing the request parameters. ...
python
def render(self, request, instance, **kwargs): """ The rendering/view function that displays a plugin model instance. :param instance: An instance of the ``model`` the plugin uses. :param request: The Django :class:`~django.http.HttpRequest` class containing the request parameters. ...
[ "def", "render", "(", "self", ",", "request", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "render_template", "=", "self", ".", "get_render_template", "(", "request", ",", "instance", ",", "*", "*", "kwargs", ")", "if", "not", "render_template", "...
The rendering/view function that displays a plugin model instance. :param instance: An instance of the ``model`` the plugin uses. :param request: The Django :class:`~django.http.HttpRequest` class containing the request parameters. :param kwargs: An optional slot for any new parameters. ...
[ "The", "rendering", "/", "view", "function", "that", "displays", "a", "plugin", "model", "instance", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L436-L466
train
django-fluent/django-fluent-contents
fluent_contents/extensions/pluginbase.py
ContentPlugin.render_to_string
def render_to_string(self, request, template, context, content_instance=None): """ Render a custom template with the :class:`~PluginContext` as context instance. """ if not content_instance: content_instance = PluginContext(request) content_instance.update(context) ...
python
def render_to_string(self, request, template, context, content_instance=None): """ Render a custom template with the :class:`~PluginContext` as context instance. """ if not content_instance: content_instance = PluginContext(request) content_instance.update(context) ...
[ "def", "render_to_string", "(", "self", ",", "request", ",", "template", ",", "context", ",", "content_instance", "=", "None", ")", ":", "if", "not", "content_instance", ":", "content_instance", "=", "PluginContext", "(", "request", ")", "content_instance", ".",...
Render a custom template with the :class:`~PluginContext` as context instance.
[ "Render", "a", "custom", "template", "with", "the", ":", "class", ":", "~PluginContext", "as", "context", "instance", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/extensions/pluginbase.py#L468-L476
train
django-fluent/django-fluent-contents
fluent_contents/rendering/media.py
register_frontend_media
def register_frontend_media(request, media): """ Add a :class:`~django.forms.Media` class to the current request. This will be rendered by the ``render_plugin_media`` template tag. """ if not hasattr(request, '_fluent_contents_frontend_media'): request._fluent_contents_frontend_media = Media...
python
def register_frontend_media(request, media): """ Add a :class:`~django.forms.Media` class to the current request. This will be rendered by the ``render_plugin_media`` template tag. """ if not hasattr(request, '_fluent_contents_frontend_media'): request._fluent_contents_frontend_media = Media...
[ "def", "register_frontend_media", "(", "request", ",", "media", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_fluent_contents_frontend_media'", ")", ":", "request", ".", "_fluent_contents_frontend_media", "=", "Media", "(", ")", "add_media", "(", "requ...
Add a :class:`~django.forms.Media` class to the current request. This will be rendered by the ``render_plugin_media`` template tag.
[ "Add", "a", ":", "class", ":", "~django", ".", "forms", ".", "Media", "class", "to", "the", "current", "request", ".", "This", "will", "be", "rendered", "by", "the", "render_plugin_media", "template", "tag", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/rendering/media.py#L6-L14
train
django-fluent/django-fluent-contents
fluent_contents/cache.py
get_rendering_cache_key
def get_rendering_cache_key(placeholder_name, contentitem): """ Return a cache key for the content item output. .. seealso:: The :func:`ContentItem.clear_cache() <fluent_contents.models.ContentItem.clear_cache>` function can be used to remove the cache keys of a retrieved object. """ ...
python
def get_rendering_cache_key(placeholder_name, contentitem): """ Return a cache key for the content item output. .. seealso:: The :func:`ContentItem.clear_cache() <fluent_contents.models.ContentItem.clear_cache>` function can be used to remove the cache keys of a retrieved object. """ ...
[ "def", "get_rendering_cache_key", "(", "placeholder_name", ",", "contentitem", ")", ":", "if", "not", "contentitem", ".", "pk", ":", "return", "None", "return", "\"contentitem.@{0}.{1}.{2}\"", ".", "format", "(", "placeholder_name", ",", "contentitem", ".", "plugin"...
Return a cache key for the content item output. .. seealso:: The :func:`ContentItem.clear_cache() <fluent_contents.models.ContentItem.clear_cache>` function can be used to remove the cache keys of a retrieved object.
[ "Return", "a", "cache", "key", "for", "the", "content", "item", "output", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/cache.py#L7-L22
train
django-fluent/django-fluent-contents
fluent_contents/cache.py
get_placeholder_cache_key
def get_placeholder_cache_key(placeholder, language_code): """ Return a cache key for an existing placeholder object. This key is used to cache the entire output of a placeholder. """ return _get_placeholder_cache_key_for_id( placeholder.parent_type_id, placeholder.parent_id, ...
python
def get_placeholder_cache_key(placeholder, language_code): """ Return a cache key for an existing placeholder object. This key is used to cache the entire output of a placeholder. """ return _get_placeholder_cache_key_for_id( placeholder.parent_type_id, placeholder.parent_id, ...
[ "def", "get_placeholder_cache_key", "(", "placeholder", ",", "language_code", ")", ":", "return", "_get_placeholder_cache_key_for_id", "(", "placeholder", ".", "parent_type_id", ",", "placeholder", ".", "parent_id", ",", "placeholder", ".", "slot", ",", "language_code",...
Return a cache key for an existing placeholder object. This key is used to cache the entire output of a placeholder.
[ "Return", "a", "cache", "key", "for", "an", "existing", "placeholder", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/cache.py#L25-L36
train
django-fluent/django-fluent-contents
fluent_contents/cache.py
get_placeholder_cache_key_for_parent
def get_placeholder_cache_key_for_parent(parent_object, placeholder_name, language_code): """ Return a cache key for a placeholder. This key is used to cache the entire output of a placeholder. """ parent_type = ContentType.objects.get_for_model(parent_object) return _get_placeholder_cache_key_...
python
def get_placeholder_cache_key_for_parent(parent_object, placeholder_name, language_code): """ Return a cache key for a placeholder. This key is used to cache the entire output of a placeholder. """ parent_type = ContentType.objects.get_for_model(parent_object) return _get_placeholder_cache_key_...
[ "def", "get_placeholder_cache_key_for_parent", "(", "parent_object", ",", "placeholder_name", ",", "language_code", ")", ":", "parent_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "parent_object", ")", "return", "_get_placeholder_cache_key_for_id", ...
Return a cache key for a placeholder. This key is used to cache the entire output of a placeholder.
[ "Return", "a", "cache", "key", "for", "a", "placeholder", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/cache.py#L39-L51
train
django-fluent/django-fluent-contents
fluent_contents/management/commands/remove_stale_contentitems.py
Command.remove_stale_items
def remove_stale_items(self, stale_cts): """ See if there are items that point to a removed model. """ stale_ct_ids = list(stale_cts.keys()) items = (ContentItem.objects .non_polymorphic() # very important, or polymorphic skips them on fetching derived data ...
python
def remove_stale_items(self, stale_cts): """ See if there are items that point to a removed model. """ stale_ct_ids = list(stale_cts.keys()) items = (ContentItem.objects .non_polymorphic() # very important, or polymorphic skips them on fetching derived data ...
[ "def", "remove_stale_items", "(", "self", ",", "stale_cts", ")", ":", "stale_ct_ids", "=", "list", "(", "stale_cts", ".", "keys", "(", ")", ")", "items", "=", "(", "ContentItem", ".", "objects", ".", "non_polymorphic", "(", ")", "# very important, or polymorph...
See if there are items that point to a removed model.
[ "See", "if", "there", "are", "items", "that", "point", "to", "a", "removed", "model", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/management/commands/remove_stale_contentitems.py#L39-L68
train
django-fluent/django-fluent-contents
fluent_contents/management/commands/remove_stale_contentitems.py
Command.remove_unreferenced_items
def remove_unreferenced_items(self, stale_cts): """ See if there are items that no longer point to an existing parent. """ stale_ct_ids = list(stale_cts.keys()) parent_types = (ContentItem.objects.order_by() .exclude(polymorphic_ctype__in=stale_ct_ids) ...
python
def remove_unreferenced_items(self, stale_cts): """ See if there are items that no longer point to an existing parent. """ stale_ct_ids = list(stale_cts.keys()) parent_types = (ContentItem.objects.order_by() .exclude(polymorphic_ctype__in=stale_ct_ids) ...
[ "def", "remove_unreferenced_items", "(", "self", ",", "stale_cts", ")", ":", "stale_ct_ids", "=", "list", "(", "stale_cts", ".", "keys", "(", ")", ")", "parent_types", "=", "(", "ContentItem", ".", "objects", ".", "order_by", "(", ")", ".", "exclude", "(",...
See if there are items that no longer point to an existing parent.
[ "See", "if", "there", "are", "items", "that", "no", "longer", "point", "to", "an", "existing", "parent", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/management/commands/remove_stale_contentitems.py#L70-L110
train
django-fluent/django-fluent-contents
fluent_contents/admin/genericextensions.py
BaseInitialGenericInlineFormSet.__initial_minus_queryset
def __initial_minus_queryset(self): """ Gives all elements from self._initial having a slot value that is not already in self.get_queryset() """ queryset = self.get_queryset() def initial_not_in_queryset(initial): for x in queryset: if x.slot ...
python
def __initial_minus_queryset(self): """ Gives all elements from self._initial having a slot value that is not already in self.get_queryset() """ queryset = self.get_queryset() def initial_not_in_queryset(initial): for x in queryset: if x.slot ...
[ "def", "__initial_minus_queryset", "(", "self", ")", ":", "queryset", "=", "self", ".", "get_queryset", "(", ")", "def", "initial_not_in_queryset", "(", "initial", ")", ":", "for", "x", "in", "queryset", ":", "if", "x", ".", "slot", "==", "initial", "[", ...
Gives all elements from self._initial having a slot value that is not already in self.get_queryset()
[ "Gives", "all", "elements", "from", "self", ".", "_initial", "having", "a", "slot", "value", "that", "is", "not", "already", "in", "self", ".", "get_queryset", "()" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/admin/genericextensions.py#L60-L74
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/fluent_contents_tags.py
_get_placeholder_arg
def _get_placeholder_arg(arg_name, placeholder): """ Validate and return the Placeholder object that the template variable points to. """ if placeholder is None: raise RuntimeWarning(u"placeholder object is None") elif isinstance(placeholder, Placeholder): return placeholder elif...
python
def _get_placeholder_arg(arg_name, placeholder): """ Validate and return the Placeholder object that the template variable points to. """ if placeholder is None: raise RuntimeWarning(u"placeholder object is None") elif isinstance(placeholder, Placeholder): return placeholder elif...
[ "def", "_get_placeholder_arg", "(", "arg_name", ",", "placeholder", ")", ":", "if", "placeholder", "is", "None", ":", "raise", "RuntimeWarning", "(", "u\"placeholder object is None\"", ")", "elif", "isinstance", "(", "placeholder", ",", "Placeholder", ")", ":", "r...
Validate and return the Placeholder object that the template variable points to.
[ "Validate", "and", "return", "the", "Placeholder", "object", "that", "the", "template", "variable", "points", "to", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/fluent_contents_tags.py#L287-L310
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/fluent_contents_tags.py
_split_js
def _split_js(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._js: return ImmutableMedia.empty_instance needs_local = domain == 'local' new_js = [] for url in media._js: ...
python
def _split_js(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._js: return ImmutableMedia.empty_instance needs_local = domain == 'local' new_js = [] for url in media._js: ...
[ "def", "_split_js", "(", "media", ",", "domain", ")", ":", "# Read internal property without creating new Media instance.", "if", "not", "media", ".", "_js", ":", "return", "ImmutableMedia", ".", "empty_instance", "needs_local", "=", "domain", "==", "'local'", "new_js...
Extract the local or external URLs from a Media object.
[ "Extract", "the", "local", "or", "external", "URLs", "from", "a", "Media", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/fluent_contents_tags.py#L382-L399
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/fluent_contents_tags.py
_split_css
def _split_css(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._css: return ImmutableMedia.empty_instance needs_local = domain == 'local' new_css = {} for medium, url in si...
python
def _split_css(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._css: return ImmutableMedia.empty_instance needs_local = domain == 'local' new_css = {} for medium, url in si...
[ "def", "_split_css", "(", "media", ",", "domain", ")", ":", "# Read internal property without creating new Media instance.", "if", "not", "media", ".", "_css", ":", "return", "ImmutableMedia", ".", "empty_instance", "needs_local", "=", "domain", "==", "'local'", "new_...
Extract the local or external URLs from a Media object.
[ "Extract", "the", "local", "or", "external", "URLs", "from", "a", "Media", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/fluent_contents_tags.py#L402-L419
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/fluent_contents_tags.py
PagePlaceholderNode.parse
def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %} """ bits, as_var = parse_as_var(parser, token) tag_name, args, kwargs = parse_token_kwargs(parser, bits, all...
python
def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %} """ bits, as_var = parse_as_var(parser, token) tag_name, args, kwargs = parse_token_kwargs(parser, bits, all...
[ "def", "parse", "(", "cls", ",", "parser", ",", "token", ")", ":", "bits", ",", "as_var", "=", "parse_as_var", "(", "parser", ",", "token", ")", "tag_name", ",", "args", ",", "kwargs", "=", "parse_token_kwargs", "(", "parser", ",", "bits", ",", "allowe...
Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %}
[ "Parse", "the", "node", "syntax", ":" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/fluent_contents_tags.py#L114-L143
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/fluent_contents_tags.py
PagePlaceholderNode.get_title
def get_title(self): """ Return the string literal that is used in the template. The title is used in the admin screens. """ try: return extract_literal(self.meta_kwargs['title']) except KeyError: slot = self.get_slot() if slot is not N...
python
def get_title(self): """ Return the string literal that is used in the template. The title is used in the admin screens. """ try: return extract_literal(self.meta_kwargs['title']) except KeyError: slot = self.get_slot() if slot is not N...
[ "def", "get_title", "(", "self", ")", ":", "try", ":", "return", "extract_literal", "(", "self", ".", "meta_kwargs", "[", "'title'", "]", ")", "except", "KeyError", ":", "slot", "=", "self", ".", "get_slot", "(", ")", "if", "slot", "is", "not", "None",...
Return the string literal that is used in the template. The title is used in the admin screens.
[ "Return", "the", "string", "literal", "that", "is", "used", "in", "the", "template", ".", "The", "title", "is", "used", "in", "the", "admin", "screens", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/fluent_contents_tags.py#L152-L164
train
django-fluent/django-fluent-contents
fluent_contents/utils/templatetags.py
extract_literal
def extract_literal(templatevar): """ See if a template FilterExpression holds a literal value. :type templatevar: django.template.FilterExpression :rtype: bool|None """ # FilterExpression contains another 'var' that either contains a Variable or SafeData object. if hasattr(templatevar, 'va...
python
def extract_literal(templatevar): """ See if a template FilterExpression holds a literal value. :type templatevar: django.template.FilterExpression :rtype: bool|None """ # FilterExpression contains another 'var' that either contains a Variable or SafeData object. if hasattr(templatevar, 'va...
[ "def", "extract_literal", "(", "templatevar", ")", ":", "# FilterExpression contains another 'var' that either contains a Variable or SafeData object.", "if", "hasattr", "(", "templatevar", ",", "'var'", ")", ":", "templatevar", "=", "templatevar", ".", "var", "if", "isinst...
See if a template FilterExpression holds a literal value. :type templatevar: django.template.FilterExpression :rtype: bool|None
[ "See", "if", "a", "template", "FilterExpression", "holds", "a", "literal", "value", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/utils/templatetags.py#L11-L31
train
django-fluent/django-fluent-contents
fluent_contents/utils/templatetags.py
extract_literal_bool
def extract_literal_bool(templatevar): """ See if a template FilterExpression holds a literal boolean value. :type templatevar: django.template.FilterExpression :rtype: bool|None """ # FilterExpression contains another 'var' that either contains a Variable or SafeData object. if hasattr(tem...
python
def extract_literal_bool(templatevar): """ See if a template FilterExpression holds a literal boolean value. :type templatevar: django.template.FilterExpression :rtype: bool|None """ # FilterExpression contains another 'var' that either contains a Variable or SafeData object. if hasattr(tem...
[ "def", "extract_literal_bool", "(", "templatevar", ")", ":", "# FilterExpression contains another 'var' that either contains a Variable or SafeData object.", "if", "hasattr", "(", "templatevar", ",", "'var'", ")", ":", "templatevar", "=", "templatevar", ".", "var", "if", "i...
See if a template FilterExpression holds a literal boolean value. :type templatevar: django.template.FilterExpression :rtype: bool|None
[ "See", "if", "a", "template", "FilterExpression", "holds", "a", "literal", "boolean", "value", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/utils/templatetags.py#L34-L51
train
django-fluent/django-fluent-contents
fluent_contents/plugins/markup/content_plugins.py
_create_markup_plugin
def _create_markup_plugin(language, model): """ Create a new MarkupPlugin class that represents the plugin type. """ form = type("{0}MarkupItemForm".format(language.capitalize()), (MarkupItemForm,), { 'default_language': language, }) classname = "{0}MarkupPlugin".format(language.capital...
python
def _create_markup_plugin(language, model): """ Create a new MarkupPlugin class that represents the plugin type. """ form = type("{0}MarkupItemForm".format(language.capitalize()), (MarkupItemForm,), { 'default_language': language, }) classname = "{0}MarkupPlugin".format(language.capital...
[ "def", "_create_markup_plugin", "(", "language", ",", "model", ")", ":", "form", "=", "type", "(", "\"{0}MarkupItemForm\"", ".", "format", "(", "language", ".", "capitalize", "(", ")", ")", ",", "(", "MarkupItemForm", ",", ")", ",", "{", "'default_language'"...
Create a new MarkupPlugin class that represents the plugin type.
[ "Create", "a", "new", "MarkupPlugin", "class", "that", "represents", "the", "plugin", "type", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/markup/content_plugins.py#L43-L57
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
get_parent_lookup_kwargs
def get_parent_lookup_kwargs(parent_object): """ Return lookup arguments for the generic ``parent_type`` / ``parent_id`` fields. :param parent_object: The parent object. :type parent_object: :class:`~django.db.models.Model` """ if parent_object is None: return dict( parent_t...
python
def get_parent_lookup_kwargs(parent_object): """ Return lookup arguments for the generic ``parent_type`` / ``parent_id`` fields. :param parent_object: The parent object. :type parent_object: :class:`~django.db.models.Model` """ if parent_object is None: return dict( parent_t...
[ "def", "get_parent_lookup_kwargs", "(", "parent_object", ")", ":", "if", "parent_object", "is", "None", ":", "return", "dict", "(", "parent_type__isnull", "=", "True", ",", "parent_id", "=", "0", ")", "elif", "isinstance", "(", "parent_object", ",", "models", ...
Return lookup arguments for the generic ``parent_type`` / ``parent_id`` fields. :param parent_object: The parent object. :type parent_object: :class:`~django.db.models.Model`
[ "Return", "lookup", "arguments", "for", "the", "generic", "parent_type", "/", "parent_id", "fields", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L201-L219
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
get_parent_active_language_choices
def get_parent_active_language_choices(parent_object, exclude_current=False): """ .. versionadded:: 1.0 Get the currently active languages of an parent object. Note: if there is no content at the page, the language won't be returned. """ assert parent_object is not None, "Missing parent_object...
python
def get_parent_active_language_choices(parent_object, exclude_current=False): """ .. versionadded:: 1.0 Get the currently active languages of an parent object. Note: if there is no content at the page, the language won't be returned. """ assert parent_object is not None, "Missing parent_object...
[ "def", "get_parent_active_language_choices", "(", "parent_object", ",", "exclude_current", "=", "False", ")", ":", "assert", "parent_object", "is", "not", "None", ",", "\"Missing parent_object!\"", "from", ".", "db", "import", "ContentItem", "qs", "=", "ContentItem", ...
.. versionadded:: 1.0 Get the currently active languages of an parent object. Note: if there is no content at the page, the language won't be returned.
[ "..", "versionadded", "::", "1", ".", "0" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L248-L282
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
PlaceholderManager.get_by_slot
def get_by_slot(self, parent_object, slot): """ Return a placeholder by key. """ placeholder = self.parent(parent_object).get(slot=slot) placeholder.parent = parent_object # fill the reverse cache return placeholder
python
def get_by_slot(self, parent_object, slot): """ Return a placeholder by key. """ placeholder = self.parent(parent_object).get(slot=slot) placeholder.parent = parent_object # fill the reverse cache return placeholder
[ "def", "get_by_slot", "(", "self", ",", "parent_object", ",", "slot", ")", ":", "placeholder", "=", "self", ".", "parent", "(", "parent_object", ")", ".", "get", "(", "slot", "=", "slot", ")", "placeholder", ".", "parent", "=", "parent_object", "# fill the...
Return a placeholder by key.
[ "Return", "a", "placeholder", "by", "key", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L28-L34
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
PlaceholderManager.create_for_object
def create_for_object(self, parent_object, slot, role='m', title=None): """ Create a placeholder with the given parameters """ from .db import Placeholder parent_attrs = get_parent_lookup_kwargs(parent_object) obj = self.create( slot=slot, role=rol...
python
def create_for_object(self, parent_object, slot, role='m', title=None): """ Create a placeholder with the given parameters """ from .db import Placeholder parent_attrs = get_parent_lookup_kwargs(parent_object) obj = self.create( slot=slot, role=rol...
[ "def", "create_for_object", "(", "self", ",", "parent_object", ",", "slot", ",", "role", "=", "'m'", ",", "title", "=", "None", ")", ":", "from", ".", "db", "import", "Placeholder", "parent_attrs", "=", "get_parent_lookup_kwargs", "(", "parent_object", ")", ...
Create a placeholder with the given parameters
[ "Create", "a", "placeholder", "with", "the", "given", "parameters" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L36-L49
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemQuerySet.translated
def translated(self, *language_codes): """ .. versionadded:: 1.0 Only return translated objects which of the given languages. When no language codes are given, only the currently active language is returned. """ # this API has the same semantics as django-parler's .tran...
python
def translated(self, *language_codes): """ .. versionadded:: 1.0 Only return translated objects which of the given languages. When no language codes are given, only the currently active language is returned. """ # this API has the same semantics as django-parler's .tran...
[ "def", "translated", "(", "self", ",", "*", "language_codes", ")", ":", "# this API has the same semantics as django-parler's .translated() for familiarity.", "# However, since this package doesn't filter in a related field, the ORM limitations don't apply.", "if", "not", "language_codes",...
.. versionadded:: 1.0 Only return translated objects which of the given languages. When no language codes are given, only the currently active language is returned.
[ "..", "versionadded", "::", "1", ".", "0" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L57-L78
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemQuerySet.parent
def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ lookup = get_parent_lookup_kwargs(parent_object) # Filter the items by default, giving the expected "objects for this parent" items ...
python
def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ lookup = get_parent_lookup_kwargs(parent_object) # Filter the items by default, giving the expected "objects for this parent" items ...
[ "def", "parent", "(", "self", ",", "parent_object", ",", "limit_parent_language", "=", "True", ")", ":", "lookup", "=", "get_parent_lookup_kwargs", "(", "parent_object", ")", "# Filter the items by default, giving the expected \"objects for this parent\" items", "# when the par...
Return all content items which are associated with a given parent object.
[ "Return", "all", "content", "items", "which", "are", "associated", "with", "a", "given", "parent", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L80-L93
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemQuerySet.move_to_placeholder
def move_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0.2 Move the entire queryset to a new object. Returns a queryset with the newly created objects. """ qs = self.all() # Get clone for item in qs: # Change the item directly in...
python
def move_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0.2 Move the entire queryset to a new object. Returns a queryset with the newly created objects. """ qs = self.all() # Get clone for item in qs: # Change the item directly in...
[ "def", "move_to_placeholder", "(", "self", ",", "placeholder", ",", "sort_order", "=", "None", ")", ":", "qs", "=", "self", ".", "all", "(", ")", "# Get clone", "for", "item", "in", "qs", ":", "# Change the item directly in the resultset.", "item", ".", "move_...
.. versionadded: 1.0.2 Move the entire queryset to a new object. Returns a queryset with the newly created objects.
[ "..", "versionadded", ":", "1", ".", "0", ".", "2", "Move", "the", "entire", "queryset", "to", "a", "new", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L107-L120
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemQuerySet.copy_to_placeholder
def copy_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0 Copy the entire queryset to a new object. Returns a queryset with the newly created objects. """ qs = self.all() # Get clone for item in qs: # Change the item directly in t...
python
def copy_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0 Copy the entire queryset to a new object. Returns a queryset with the newly created objects. """ qs = self.all() # Get clone for item in qs: # Change the item directly in t...
[ "def", "copy_to_placeholder", "(", "self", ",", "placeholder", ",", "sort_order", "=", "None", ")", ":", "qs", "=", "self", ".", "all", "(", ")", "# Get clone", "for", "item", "in", "qs", ":", "# Change the item directly in the resultset.", "item", ".", "copy_...
.. versionadded: 1.0 Copy the entire queryset to a new object. Returns a queryset with the newly created objects.
[ "..", "versionadded", ":", "1", ".", "0", "Copy", "the", "entire", "queryset", "to", "a", "new", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L124-L137
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemManager.parent
def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ return self.all().parent(parent_object, limit_parent_language)
python
def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ return self.all().parent(parent_object, limit_parent_language)
[ "def", "parent", "(", "self", ",", "parent_object", ",", "limit_parent_language", "=", "True", ")", ":", "return", "self", ".", "all", "(", ")", ".", "parent", "(", "parent_object", ",", "limit_parent_language", ")" ]
Return all content items which are associated with a given parent object.
[ "Return", "all", "content", "items", "which", "are", "associated", "with", "a", "given", "parent", "object", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L158-L162
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
ContentItemManager.create_for_placeholder
def create_for_placeholder(self, placeholder, sort_order=1, language_code=None, **kwargs): """ Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless ...
python
def create_for_placeholder(self, placeholder, sort_order=1, language_code=None, **kwargs): """ Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless ...
[ "def", "create_for_placeholder", "(", "self", ",", "placeholder", ",", "sort_order", "=", "1", ",", "language_code", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "language_code", "is", "None", ":", "# Could also use get_language() or appsettings.FLUENT_CONT...
Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless the :class:`~fluent_contents.models.managers.PlaceholderManager` methods were used to construct the object, ...
[ "Create", "a", "Content", "Item", "with", "the", "given", "parameters" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L164-L196
train
django-fluent/django-fluent-contents
fluent_contents/admin/placeholderfield.py
PlaceholderFieldAdmin.get_placeholder_data
def get_placeholder_data(self, request, obj=None): """ Return the data of the placeholder fields. """ # Return all placeholder fields in the model. if not hasattr(self.model, '_meta_placeholder_fields'): return [] data = [] for name, field in self.mod...
python
def get_placeholder_data(self, request, obj=None): """ Return the data of the placeholder fields. """ # Return all placeholder fields in the model. if not hasattr(self.model, '_meta_placeholder_fields'): return [] data = [] for name, field in self.mod...
[ "def", "get_placeholder_data", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "# Return all placeholder fields in the model.", "if", "not", "hasattr", "(", "self", ".", "model", ",", "'_meta_placeholder_fields'", ")", ":", "return", "[", "]", "d...
Return the data of the placeholder fields.
[ "Return", "the", "data", "of", "the", "placeholder", "fields", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/admin/placeholderfield.py#L55-L72
train
django-fluent/django-fluent-contents
fluent_contents/admin/placeholderfield.py
PlaceholderFieldAdmin.get_all_allowed_plugins
def get_all_allowed_plugins(self): """ Return which plugins are allowed by the placeholder fields. """ # Get all allowed plugins of the various placeholders together. if not hasattr(self.model, '_meta_placeholder_fields'): # No placeholder fields in the model, no need...
python
def get_all_allowed_plugins(self): """ Return which plugins are allowed by the placeholder fields. """ # Get all allowed plugins of the various placeholders together. if not hasattr(self.model, '_meta_placeholder_fields'): # No placeholder fields in the model, no need...
[ "def", "get_all_allowed_plugins", "(", "self", ")", ":", "# Get all allowed plugins of the various placeholders together.", "if", "not", "hasattr", "(", "self", ".", "model", ",", "'_meta_placeholder_fields'", ")", ":", "# No placeholder fields in the model, no need for inlines."...
Return which plugins are allowed by the placeholder fields.
[ "Return", "which", "plugins", "are", "allowed", "by", "the", "placeholder", "fields", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/admin/placeholderfield.py#L74-L92
train
django-fluent/django-fluent-contents
fluent_contents/plugins/markup/models.py
_create_markup_model
def _create_markup_model(fixed_language): """ Create a new MarkupItem model that saves itself in a single language. """ title = backend.LANGUAGE_NAMES.get(fixed_language) or fixed_language objects = MarkupLanguageManager(fixed_language) def save(self, *args, **kwargs): self.language = ...
python
def _create_markup_model(fixed_language): """ Create a new MarkupItem model that saves itself in a single language. """ title = backend.LANGUAGE_NAMES.get(fixed_language) or fixed_language objects = MarkupLanguageManager(fixed_language) def save(self, *args, **kwargs): self.language = ...
[ "def", "_create_markup_model", "(", "fixed_language", ")", ":", "title", "=", "backend", ".", "LANGUAGE_NAMES", ".", "get", "(", "fixed_language", ")", "or", "fixed_language", "objects", "=", "MarkupLanguageManager", "(", "fixed_language", ")", "def", "save", "(",...
Create a new MarkupItem model that saves itself in a single language.
[ "Create", "a", "new", "MarkupItem", "model", "that", "saves", "itself", "in", "a", "single", "language", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/markup/models.py#L71-L98
train
django-fluent/django-fluent-contents
fluent_contents/models/fields.py
PlaceholderField.formfield
def formfield(self, **kwargs): """ Returns a :class:`PlaceholderFormField` instance for this database Field. """ defaults = { 'label': capfirst(self.verbose_name), 'help_text': self.help_text, 'required': not self.blank, } defaults.upda...
python
def formfield(self, **kwargs): """ Returns a :class:`PlaceholderFormField` instance for this database Field. """ defaults = { 'label': capfirst(self.verbose_name), 'help_text': self.help_text, 'required': not self.blank, } defaults.upda...
[ "def", "formfield", "(", "self", ",", "*", "*", "kwargs", ")", ":", "defaults", "=", "{", "'label'", ":", "capfirst", "(", "self", ".", "verbose_name", ")", ",", "'help_text'", ":", "self", ".", "help_text", ",", "'required'", ":", "not", "self", ".", ...
Returns a :class:`PlaceholderFormField` instance for this database Field.
[ "Returns", "a", ":", "class", ":", "PlaceholderFormField", "instance", "for", "this", "database", "Field", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/fields.py#L175-L185
train
django-fluent/django-fluent-contents
fluent_contents/models/fields.py
PlaceholderField.contribute_to_class
def contribute_to_class(self, cls, name, **kwargs): """ Internal Django method to associate the field with the Model; it assigns the descriptor. """ super(PlaceholderField, self).contribute_to_class(cls, name, **kwargs) # overwrites what instance.<colname> returns; give direct a...
python
def contribute_to_class(self, cls, name, **kwargs): """ Internal Django method to associate the field with the Model; it assigns the descriptor. """ super(PlaceholderField, self).contribute_to_class(cls, name, **kwargs) # overwrites what instance.<colname> returns; give direct a...
[ "def", "contribute_to_class", "(", "self", ",", "cls", ",", "name", ",", "*", "*", "kwargs", ")", ":", "super", "(", "PlaceholderField", ",", "self", ")", ".", "contribute_to_class", "(", "cls", ",", "name", ",", "*", "*", "kwargs", ")", "# overwrites wh...
Internal Django method to associate the field with the Model; it assigns the descriptor.
[ "Internal", "Django", "method", "to", "associate", "the", "field", "with", "the", "Model", ";", "it", "assigns", "the", "descriptor", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/fields.py#L187-L221
train
django-fluent/django-fluent-contents
fluent_contents/models/fields.py
PlaceholderField.plugins
def plugins(self): """ Get the set of plugins that this field may display. """ from fluent_contents import extensions if self._plugins is None: return extensions.plugin_pool.get_plugins() else: try: return extensions.plugin_pool.get...
python
def plugins(self): """ Get the set of plugins that this field may display. """ from fluent_contents import extensions if self._plugins is None: return extensions.plugin_pool.get_plugins() else: try: return extensions.plugin_pool.get...
[ "def", "plugins", "(", "self", ")", ":", "from", "fluent_contents", "import", "extensions", "if", "self", ".", "_plugins", "is", "None", ":", "return", "extensions", ".", "plugin_pool", ".", "get_plugins", "(", ")", "else", ":", "try", ":", "return", "exte...
Get the set of plugins that this field may display.
[ "Get", "the", "set", "of", "plugins", "that", "this", "field", "may", "display", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/fields.py#L224-L235
train
django-fluent/django-fluent-contents
fluent_contents/models/fields.py
PlaceholderField.value_from_object
def value_from_object(self, obj): """ Internal Django method, used to return the placeholder ID when exporting the model instance. """ try: # not using self.attname, access the descriptor instead. placeholder = getattr(obj, self.name) except Placeholder.Do...
python
def value_from_object(self, obj): """ Internal Django method, used to return the placeholder ID when exporting the model instance. """ try: # not using self.attname, access the descriptor instead. placeholder = getattr(obj, self.name) except Placeholder.Do...
[ "def", "value_from_object", "(", "self", ",", "obj", ")", ":", "try", ":", "# not using self.attname, access the descriptor instead.", "placeholder", "=", "getattr", "(", "obj", ",", "self", ".", "name", ")", "except", "Placeholder", ".", "DoesNotExist", ":", "ret...
Internal Django method, used to return the placeholder ID when exporting the model instance.
[ "Internal", "Django", "method", "used", "to", "return", "the", "placeholder", "ID", "when", "exporting", "the", "model", "instance", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/fields.py#L237-L247
train
django-fluent/django-fluent-contents
fluent_contents/rendering/search.py
SearchRenderingPipe.can_use_cached_output
def can_use_cached_output(self, contentitem): """ Read the cached output - only when search needs it. """ return contentitem.plugin.search_output and not contentitem.plugin.search_fields \ and super(SearchRenderingPipe, self).can_use_cached_output(contentitem)
python
def can_use_cached_output(self, contentitem): """ Read the cached output - only when search needs it. """ return contentitem.plugin.search_output and not contentitem.plugin.search_fields \ and super(SearchRenderingPipe, self).can_use_cached_output(contentitem)
[ "def", "can_use_cached_output", "(", "self", ",", "contentitem", ")", ":", "return", "contentitem", ".", "plugin", ".", "search_output", "and", "not", "contentitem", ".", "plugin", ".", "search_fields", "and", "super", "(", "SearchRenderingPipe", ",", "self", ")...
Read the cached output - only when search needs it.
[ "Read", "the", "cached", "output", "-", "only", "when", "search", "needs", "it", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/rendering/search.py#L28-L33
train
django-fluent/django-fluent-contents
fluent_contents/rendering/search.py
SearchRenderingPipe.render_item
def render_item(self, contentitem): """ Render the item - but render as search text instead. """ plugin = contentitem.plugin if not plugin.search_output and not plugin.search_fields: # Only render items when the item was output will be indexed. raise SkipI...
python
def render_item(self, contentitem): """ Render the item - but render as search text instead. """ plugin = contentitem.plugin if not plugin.search_output and not plugin.search_fields: # Only render items when the item was output will be indexed. raise SkipI...
[ "def", "render_item", "(", "self", ",", "contentitem", ")", ":", "plugin", "=", "contentitem", ".", "plugin", "if", "not", "plugin", ".", "search_output", "and", "not", "plugin", ".", "search_fields", ":", "# Only render items when the item was output will be indexed....
Render the item - but render as search text instead.
[ "Render", "the", "item", "-", "but", "render", "as", "search", "text", "instead", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/rendering/search.py#L35-L54
train
django-fluent/django-fluent-contents
fluent_contents/admin/contentitems.py
get_content_item_inlines
def get_content_item_inlines(plugins=None, base=BaseContentItemInline): """ Dynamically generate genuine django inlines for all registered content item types. When the `plugins` parameter is ``None``, all plugin inlines are returned. """ COPY_FIELDS = ( 'form', 'raw_id_fields', 'filter_verti...
python
def get_content_item_inlines(plugins=None, base=BaseContentItemInline): """ Dynamically generate genuine django inlines for all registered content item types. When the `plugins` parameter is ``None``, all plugin inlines are returned. """ COPY_FIELDS = ( 'form', 'raw_id_fields', 'filter_verti...
[ "def", "get_content_item_inlines", "(", "plugins", "=", "None", ",", "base", "=", "BaseContentItemInline", ")", ":", "COPY_FIELDS", "=", "(", "'form'", ",", "'raw_id_fields'", ",", "'filter_vertical'", ",", "'filter_horizontal'", ",", "'radio_fields'", ",", "'prepop...
Dynamically generate genuine django inlines for all registered content item types. When the `plugins` parameter is ``None``, all plugin inlines are returned.
[ "Dynamically", "generate", "genuine", "django", "inlines", "for", "all", "registered", "content", "item", "types", ".", "When", "the", "plugins", "parameter", "is", "None", "all", "plugin", "inlines", "are", "returned", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/admin/contentitems.py#L151-L198
train
django-fluent/django-fluent-contents
fluent_contents/plugins/oembeditem/backend.py
get_oembed_providers
def get_oembed_providers(): """ Get the list of OEmbed providers. """ global _provider_list, _provider_lock if _provider_list is not None: return _provider_list # Allow only one thread to build the list, or make request to embed.ly. _provider_lock.acquire() try: # And ch...
python
def get_oembed_providers(): """ Get the list of OEmbed providers. """ global _provider_list, _provider_lock if _provider_list is not None: return _provider_list # Allow only one thread to build the list, or make request to embed.ly. _provider_lock.acquire() try: # And ch...
[ "def", "get_oembed_providers", "(", ")", ":", "global", "_provider_list", ",", "_provider_lock", "if", "_provider_list", "is", "not", "None", ":", "return", "_provider_list", "# Allow only one thread to build the list, or make request to embed.ly.", "_provider_lock", ".", "ac...
Get the list of OEmbed providers.
[ "Get", "the", "list", "of", "OEmbed", "providers", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/oembeditem/backend.py#L26-L44
train
django-fluent/django-fluent-contents
fluent_contents/plugins/oembeditem/backend.py
_build_provider_list
def _build_provider_list(): """ Construct the provider registry, using the app settings. """ registry = None if appsettings.FLUENT_OEMBED_SOURCE == 'basic': registry = bootstrap_basic() elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly': params = {} if appsettings.MICAWBE...
python
def _build_provider_list(): """ Construct the provider registry, using the app settings. """ registry = None if appsettings.FLUENT_OEMBED_SOURCE == 'basic': registry = bootstrap_basic() elif appsettings.FLUENT_OEMBED_SOURCE == 'embedly': params = {} if appsettings.MICAWBE...
[ "def", "_build_provider_list", "(", ")", ":", "registry", "=", "None", "if", "appsettings", ".", "FLUENT_OEMBED_SOURCE", "==", "'basic'", ":", "registry", "=", "bootstrap_basic", "(", ")", "elif", "appsettings", ".", "FLUENT_OEMBED_SOURCE", "==", "'embedly'", ":",...
Construct the provider registry, using the app settings.
[ "Construct", "the", "provider", "registry", "using", "the", "app", "settings", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/oembeditem/backend.py#L47-L73
train
django-fluent/django-fluent-contents
fluent_contents/plugins/oembeditem/backend.py
get_oembed_data
def get_oembed_data(url, max_width=None, max_height=None, **params): """ Fetch the OEmbed object, return the response as dictionary. """ if max_width: params['maxwidth'] = max_width if max_height: params['maxheight'] = max_height registry = get_oembed_providers() return registry.request(ur...
python
def get_oembed_data(url, max_width=None, max_height=None, **params): """ Fetch the OEmbed object, return the response as dictionary. """ if max_width: params['maxwidth'] = max_width if max_height: params['maxheight'] = max_height registry = get_oembed_providers() return registry.request(ur...
[ "def", "get_oembed_data", "(", "url", ",", "max_width", "=", "None", ",", "max_height", "=", "None", ",", "*", "*", "params", ")", ":", "if", "max_width", ":", "params", "[", "'maxwidth'", "]", "=", "max_width", "if", "max_height", ":", "params", "[", ...
Fetch the OEmbed object, return the response as dictionary.
[ "Fetch", "the", "OEmbed", "object", "return", "the", "response", "as", "dictionary", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/plugins/oembeditem/backend.py#L84-L92
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/placeholder_admin_tags.py
group_plugins_into_categories
def group_plugins_into_categories(plugins): """ Return all plugins, grouped by category. The structure is a {"Categorynane": [list of plugin classes]} """ if not plugins: return {} plugins = sorted(plugins, key=lambda p: p.verbose_name) categories = {} for plugin in plugins: ...
python
def group_plugins_into_categories(plugins): """ Return all plugins, grouped by category. The structure is a {"Categorynane": [list of plugin classes]} """ if not plugins: return {} plugins = sorted(plugins, key=lambda p: p.verbose_name) categories = {} for plugin in plugins: ...
[ "def", "group_plugins_into_categories", "(", "plugins", ")", ":", "if", "not", "plugins", ":", "return", "{", "}", "plugins", "=", "sorted", "(", "plugins", ",", "key", "=", "lambda", "p", ":", "p", ".", "verbose_name", ")", "categories", "=", "{", "}", ...
Return all plugins, grouped by category. The structure is a {"Categorynane": [list of plugin classes]}
[ "Return", "all", "plugins", "grouped", "by", "category", ".", "The", "structure", "is", "a", "{", "Categorynane", ":", "[", "list", "of", "plugin", "classes", "]", "}" ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/placeholder_admin_tags.py#L37-L53
train
django-fluent/django-fluent-contents
fluent_contents/templatetags/placeholder_admin_tags.py
plugin_categories_to_choices
def plugin_categories_to_choices(categories): """ Return a tuple of plugin model choices, suitable for a select field. Each tuple is a ("TypeName", "Title") value. """ choices = [] for category, items in categories.items(): if items: plugin_tuples = tuple((plugin.type_name, p...
python
def plugin_categories_to_choices(categories): """ Return a tuple of plugin model choices, suitable for a select field. Each tuple is a ("TypeName", "Title") value. """ choices = [] for category, items in categories.items(): if items: plugin_tuples = tuple((plugin.type_name, p...
[ "def", "plugin_categories_to_choices", "(", "categories", ")", ":", "choices", "=", "[", "]", "for", "category", ",", "items", "in", "categories", ".", "items", "(", ")", ":", "if", "items", ":", "plugin_tuples", "=", "tuple", "(", "(", "plugin", ".", "t...
Return a tuple of plugin model choices, suitable for a select field. Each tuple is a ("TypeName", "Title") value.
[ "Return", "a", "tuple", "of", "plugin", "model", "choices", "suitable", "for", "a", "select", "field", ".", "Each", "tuple", "is", "a", "(", "TypeName", "Title", ")", "value", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/templatetags/placeholder_admin_tags.py#L66-L81
train
django-fluent/django-fluent-contents
fluent_contents/rendering/utils.py
add_media
def add_media(dest, media): """ Optimized version of django.forms.Media.__add__() that doesn't create new objects. """ if django.VERSION >= (2, 2): dest._css_lists += media._css_lists dest._js_lists += media._js_lists elif django.VERSION >= (2, 0): combined = dest + media ...
python
def add_media(dest, media): """ Optimized version of django.forms.Media.__add__() that doesn't create new objects. """ if django.VERSION >= (2, 2): dest._css_lists += media._css_lists dest._js_lists += media._js_lists elif django.VERSION >= (2, 0): combined = dest + media ...
[ "def", "add_media", "(", "dest", ",", "media", ")", ":", "if", "django", ".", "VERSION", ">=", "(", "2", ",", "2", ")", ":", "dest", ".", "_css_lists", "+=", "media", ".", "_css_lists", "dest", ".", "_js_lists", "+=", "media", ".", "_js_lists", "elif...
Optimized version of django.forms.Media.__add__() that doesn't create new objects.
[ "Optimized", "version", "of", "django", ".", "forms", ".", "Media", ".", "__add__", "()", "that", "doesn", "t", "create", "new", "objects", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/rendering/utils.py#L25-L38
train
django-fluent/django-fluent-contents
fluent_contents/rendering/utils.py
get_dummy_request
def get_dummy_request(language=None): """ Returns a Request instance populated with cms specific attributes. """ if settings.ALLOWED_HOSTS and settings.ALLOWED_HOSTS != "*": host = settings.ALLOWED_HOSTS[0] else: host = Site.objects.get_current().domain request = RequestFactory...
python
def get_dummy_request(language=None): """ Returns a Request instance populated with cms specific attributes. """ if settings.ALLOWED_HOSTS and settings.ALLOWED_HOSTS != "*": host = settings.ALLOWED_HOSTS[0] else: host = Site.objects.get_current().domain request = RequestFactory...
[ "def", "get_dummy_request", "(", "language", "=", "None", ")", ":", "if", "settings", ".", "ALLOWED_HOSTS", "and", "settings", ".", "ALLOWED_HOSTS", "!=", "\"*\"", ":", "host", "=", "settings", ".", "ALLOWED_HOSTS", "[", "0", "]", "else", ":", "host", "=",...
Returns a Request instance populated with cms specific attributes.
[ "Returns", "a", "Request", "instance", "populated", "with", "cms", "specific", "attributes", "." ]
896f14add58471b98d7aa295b2c9e6abedec9003
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/rendering/utils.py#L51-L71
train