id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
248,500
ipfs/py-ipfs-api
ipfsapi/client.py
Client.bitswap_wantlist
def bitswap_wantlist(self, peer=None, **kwargs): """Returns blocks currently on the bitswap wantlist. .. code-block:: python >>> c.bitswap_wantlist() {'Keys': [ 'QmeV6C6XVt1wf7V7as7Yak3mxPma8jzpqyhtRtCvpKcfBb', 'QmdCWFLDXqgdWQY9kVubbEHBbkieKd3uo7...
python
def bitswap_wantlist(self, peer=None, **kwargs): args = (peer,) return self._client.request('/bitswap/wantlist', args, decoder='json', **kwargs)
[ "def", "bitswap_wantlist", "(", "self", ",", "peer", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "peer", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/bitswap/wantlist'", ",", "args", ",", "decoder", "=", "...
Returns blocks currently on the bitswap wantlist. .. code-block:: python >>> c.bitswap_wantlist() {'Keys': [ 'QmeV6C6XVt1wf7V7as7Yak3mxPma8jzpqyhtRtCvpKcfBb', 'QmdCWFLDXqgdWQY9kVubbEHBbkieKd3uo7MtCm7nTZZE9K', 'QmVQ1XvYGF19X4eJqz1s7FJYJqAx...
[ "Returns", "blocks", "currently", "on", "the", "bitswap", "wantlist", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L370-L393
248,501
ipfs/py-ipfs-api
ipfsapi/client.py
Client.bitswap_unwant
def bitswap_unwant(self, key, **kwargs): """ Remove a given block from wantlist. Parameters ---------- key : str Key to remove from wantlist. """ args = (key,) return self._client.request('/bitswap/unwant', args, **kwargs)
python
def bitswap_unwant(self, key, **kwargs): args = (key,) return self._client.request('/bitswap/unwant', args, **kwargs)
[ "def", "bitswap_unwant", "(", "self", ",", "key", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "key", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/bitswap/unwant'", ",", "args", ",", "*", "*", "kwargs", ")" ]
Remove a given block from wantlist. Parameters ---------- key : str Key to remove from wantlist.
[ "Remove", "a", "given", "block", "from", "wantlist", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L424-L434
248,502
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_data
def object_data(self, multihash, **kwargs): r"""Returns the raw bytes in an IPFS object. .. code-block:: python >>> c.object_data('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') b'\x08\x01' Parameters ---------- multihash : str Key of the ...
python
def object_data(self, multihash, **kwargs): r"""Returns the raw bytes in an IPFS object. .. code-block:: python >>> c.object_data('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') b'\x08\x01' Parameters ---------- multihash : str Key of the ...
[ "def", "object_data", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/object/data'", ",", "args", ",", "*", "*", "kwargs", ")" ]
r"""Returns the raw bytes in an IPFS object. .. code-block:: python >>> c.object_data('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') b'\x08\x01' Parameters ---------- multihash : str Key of the object to retrieve, in base58-encoded multihash form...
[ "r", "Returns", "the", "raw", "bytes", "in", "an", "IPFS", "object", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L436-L454
248,503
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_new
def object_new(self, template=None, **kwargs): """Creates a new object from an IPFS template. By default this creates and returns a new empty merkledag node, but you may pass an optional template argument to create a preformatted node. .. code-block:: python >>> c.object_n...
python
def object_new(self, template=None, **kwargs): args = (template,) if template is not None else () return self._client.request('/object/new', args, decoder='json', **kwargs)
[ "def", "object_new", "(", "self", ",", "template", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "template", ",", ")", "if", "template", "is", "not", "None", "else", "(", ")", "return", "self", ".", "_client", ".", "request", "(...
Creates a new object from an IPFS template. By default this creates and returns a new empty merkledag node, but you may pass an optional template argument to create a preformatted node. .. code-block:: python >>> c.object_new() {'Hash': 'QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqF...
[ "Creates", "a", "new", "object", "from", "an", "IPFS", "template", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L456-L481
248,504
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_links
def object_links(self, multihash, **kwargs): """Returns the links pointed to by the specified object. .. code-block:: python >>> c.object_links('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDx … ca7D') {'Hash': 'QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D', 'Links': [ ...
python
def object_links(self, multihash, **kwargs): args = (multihash,) return self._client.request('/object/links', args, decoder='json', **kwargs)
[ "def", "object_links", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/object/links'", ",", "args", ",", "decoder", "=", "'json'", ",",...
Returns the links pointed to by the specified object. .. code-block:: python >>> c.object_links('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDx … ca7D') {'Hash': 'QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D', 'Links': [ {'Hash': 'Qmd2xkBfEwEs9oMTk77A6jrsgurpF3ug...
[ "Returns", "the", "links", "pointed", "to", "by", "the", "specified", "object", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L483-L513
248,505
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_get
def object_get(self, multihash, **kwargs): """Get and serialize the DAG node named by multihash. .. code-block:: python >>> c.object_get('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') {'Data': '\x08\x01', 'Links': [ {'Hash': 'Qmd2xkBfEwEs9oMTk77A...
python
def object_get(self, multihash, **kwargs): args = (multihash,) return self._client.request('/object/get', args, decoder='json', **kwargs)
[ "def", "object_get", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/object/get'", ",", "args", ",", "decoder", "=", "'json'", ",", "...
Get and serialize the DAG node named by multihash. .. code-block:: python >>> c.object_get('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') {'Data': '\x08\x01', 'Links': [ {'Hash': 'Qmd2xkBfEwEs9oMTk77A6jrsgurpF3ugXSg7dtPNFkcNMV', 'Name': ...
[ "Get", "and", "serialize", "the", "DAG", "node", "named", "by", "multihash", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L515-L545
248,506
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_put
def object_put(self, file, **kwargs): """Stores input as a DAG object and returns its key. .. code-block:: python >>> c.object_put(io.BytesIO(b''' ... { ... "Data": "another", ... "Links": [ { ... "Name...
python
def object_put(self, file, **kwargs): body, headers = multipart.stream_files(file, self.chunk_size) return self._client.request('/object/put', decoder='json', data=body, headers=headers, **kwargs)
[ "def", "object_put", "(", "self", ",", "file", ",", "*", "*", "kwargs", ")", ":", "body", ",", "headers", "=", "multipart", ".", "stream_files", "(", "file", ",", "self", ".", "chunk_size", ")", "return", "self", ".", "_client", ".", "request", "(", ...
Stores input as a DAG object and returns its key. .. code-block:: python >>> c.object_put(io.BytesIO(b''' ... { ... "Data": "another", ... "Links": [ { ... "Name": "some link", ... "Ha...
[ "Stores", "input", "as", "a", "DAG", "object", "and", "returns", "its", "key", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L547-L581
248,507
ipfs/py-ipfs-api
ipfsapi/client.py
Client.object_stat
def object_stat(self, multihash, **kwargs): """Get stats for the DAG node named by multihash. .. code-block:: python >>> c.object_stat('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') {'LinksSize': 256, 'NumLinks': 5, 'Hash': 'QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aD...
python
def object_stat(self, multihash, **kwargs): args = (multihash,) return self._client.request('/object/stat', args, decoder='json', **kwargs)
[ "def", "object_stat", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/object/stat'", ",", "args", ",", "decoder", "=", "'json'", ",", ...
Get stats for the DAG node named by multihash. .. code-block:: python >>> c.object_stat('QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D') {'LinksSize': 256, 'NumLinks': 5, 'Hash': 'QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D', 'BlockSize': 258, 'CumulativeS...
[ "Get", "stats", "for", "the", "DAG", "node", "named", "by", "multihash", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L583-L604
248,508
ipfs/py-ipfs-api
ipfsapi/client.py
Client.file_ls
def file_ls(self, multihash, **kwargs): """Lists directory contents for Unix filesystem objects. The result contains size information. For files, the child size is the total size of the file contents. For directories, the child size is the IPFS link size. The path can be a pref...
python
def file_ls(self, multihash, **kwargs): args = (multihash,) return self._client.request('/file/ls', args, decoder='json', **kwargs)
[ "def", "file_ls", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/file/ls'", ",", "args", ",", "decoder", "=", "'json'", ",", "*", ...
Lists directory contents for Unix filesystem objects. The result contains size information. For files, the child size is the total size of the file contents. For directories, the child size is the IPFS link size. The path can be a prefixless reference; in this case, it is assumed ...
[ "Lists", "directory", "contents", "for", "Unix", "filesystem", "objects", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L728-L773
248,509
ipfs/py-ipfs-api
ipfsapi/client.py
Client.resolve
def resolve(self, name, recursive=False, **kwargs): """Accepts an identifier and resolves it to the referenced item. There are a number of mutable name protocols that can link among themselves and into IPNS. For example IPNS references can (currently) point at an IPFS object, and DNS li...
python
def resolve(self, name, recursive=False, **kwargs): kwargs.setdefault("opts", {"recursive": recursive}) args = (name,) return self._client.request('/resolve', args, decoder='json', **kwargs)
[ "def", "resolve", "(", "self", ",", "name", ",", "recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"recursive\"", ":", "recursive", "}", ")", "args", "=", "(", "name", ",", ")", ...
Accepts an identifier and resolves it to the referenced item. There are a number of mutable name protocols that can link among themselves and into IPNS. For example IPNS references can (currently) point at an IPFS object, and DNS links can point at other DNS links, IPNS entries, or IPFS...
[ "Accepts", "an", "identifier", "and", "resolves", "it", "to", "the", "referenced", "item", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L775-L805
248,510
ipfs/py-ipfs-api
ipfsapi/client.py
Client.key_gen
def key_gen(self, key_name, type, size=2048, **kwargs): """Adds a new public key that can be used for name_publish. .. code-block:: python >>> c.key_gen('example_key_name') {'Name': 'example_key_name', 'Id': 'QmQLaT5ZrCfSkXTH6rUKtVidcxj8jrW3X2h75Lug1AV7g8'} ...
python
def key_gen(self, key_name, type, size=2048, **kwargs): opts = {"type": type, "size": size} kwargs.setdefault("opts", opts) args = (key_name,) return self._client.request('/key/gen', args, decoder='json', **kwargs)
[ "def", "key_gen", "(", "self", ",", "key_name", ",", "type", ",", "size", "=", "2048", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"type\"", ":", "type", ",", "\"size\"", ":", "size", "}", "kwargs", ".", "setdefault", "(", "\"opts\"", ",...
Adds a new public key that can be used for name_publish. .. code-block:: python >>> c.key_gen('example_key_name') {'Name': 'example_key_name', 'Id': 'QmQLaT5ZrCfSkXTH6rUKtVidcxj8jrW3X2h75Lug1AV7g8'} Parameters ---------- key_name : str ...
[ "Adds", "a", "new", "public", "key", "that", "can", "be", "used", "for", "name_publish", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L825-L856
248,511
ipfs/py-ipfs-api
ipfsapi/client.py
Client.key_rm
def key_rm(self, key_name, *key_names, **kwargs): """Remove a keypair .. code-block:: python >>> c.key_rm("bla") {"Keys": [ {"Name": "bla", "Id": "QmfJpR6paB6h891y7SYXGe6gapyNgepBeAYMbyejWA4FWA"} ]} Parameters ------...
python
def key_rm(self, key_name, *key_names, **kwargs): args = (key_name,) + key_names return self._client.request('/key/rm', args, decoder='json', **kwargs)
[ "def", "key_rm", "(", "self", ",", "key_name", ",", "*", "key_names", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "key_name", ",", ")", "+", "key_names", "return", "self", ".", "_client", ".", "request", "(", "'/key/rm'", ",", "args", ",", ...
Remove a keypair .. code-block:: python >>> c.key_rm("bla") {"Keys": [ {"Name": "bla", "Id": "QmfJpR6paB6h891y7SYXGe6gapyNgepBeAYMbyejWA4FWA"} ]} Parameters ---------- key_name : str Name of the key(s) to...
[ "Remove", "a", "keypair" ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L858-L879
248,512
ipfs/py-ipfs-api
ipfsapi/client.py
Client.key_rename
def key_rename(self, key_name, new_key_name, **kwargs): """Rename a keypair .. code-block:: python >>> c.key_rename("bla", "personal") {"Was": "bla", "Now": "personal", "Id": "QmeyrRNxXaasZaoDXcCZgryoBCga9shaHQ4suHAYXbNZF3", "Overwrite": F...
python
def key_rename(self, key_name, new_key_name, **kwargs): args = (key_name, new_key_name) return self._client.request('/key/rename', args, decoder='json', **kwargs)
[ "def", "key_rename", "(", "self", ",", "key_name", ",", "new_key_name", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "key_name", ",", "new_key_name", ")", "return", "self", ".", "_client", ".", "request", "(", "'/key/rename'", ",", "args", ",", ...
Rename a keypair .. code-block:: python >>> c.key_rename("bla", "personal") {"Was": "bla", "Now": "personal", "Id": "QmeyrRNxXaasZaoDXcCZgryoBCga9shaHQ4suHAYXbNZF3", "Overwrite": False} Parameters ---------- key_name : str...
[ "Rename", "a", "keypair" ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L881-L905
248,513
ipfs/py-ipfs-api
ipfsapi/client.py
Client.name_publish
def name_publish(self, ipfs_path, resolve=True, lifetime="24h", ttl=None, key=None, **kwargs): """Publishes an object to IPNS. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In publish, the ...
python
def name_publish(self, ipfs_path, resolve=True, lifetime="24h", ttl=None, key=None, **kwargs): opts = {"lifetime": lifetime, "resolve": resolve} if ttl: opts["ttl"] = ttl if key: opts["key"] = key kwargs.setdefault("opts", opts) args ...
[ "def", "name_publish", "(", "self", ",", "ipfs_path", ",", "resolve", "=", "True", ",", "lifetime", "=", "\"24h\"", ",", "ttl", "=", "None", ",", "key", "=", "None", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"lifetime\"", ":", "lifetime"...
Publishes an object to IPNS. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In publish, the default value of *name* is your own identity public key. .. code-block:: python >>> c.name_publish('...
[ "Publishes", "an", "object", "to", "IPNS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L907-L957
248,514
ipfs/py-ipfs-api
ipfsapi/client.py
Client.name_resolve
def name_resolve(self, name=None, recursive=False, nocache=False, **kwargs): """Gets the value currently published at an IPNS name. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In resolve, th...
python
def name_resolve(self, name=None, recursive=False, nocache=False, **kwargs): kwargs.setdefault("opts", {"recursive": recursive, "nocache": nocache}) args = (name,) if name is not None else () return self._client.request('/name/resolve', arg...
[ "def", "name_resolve", "(", "self", ",", "name", "=", "None", ",", "recursive", "=", "False", ",", "nocache", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"recursive\"", ":", "recursive", ",...
Gets the value currently published at an IPNS name. IPNS is a PKI namespace, where names are the hashes of public keys, and the private key enables publishing new (signed) values. In resolve, the default value of ``name`` is your own identity public key. .. code-block:: python ...
[ "Gets", "the", "value", "currently", "published", "at", "an", "IPNS", "name", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L959-L989
248,515
ipfs/py-ipfs-api
ipfsapi/client.py
Client.dns
def dns(self, domain_name, recursive=False, **kwargs): """Resolves DNS links to the referenced object. Multihashes are hard to remember, but domain names are usually easy to remember. To create memorable aliases for multihashes, DNS TXT records can point to other DNS links, IPFS objects...
python
def dns(self, domain_name, recursive=False, **kwargs): kwargs.setdefault("opts", {"recursive": recursive}) args = (domain_name,) return self._client.request('/dns', args, decoder='json', **kwargs)
[ "def", "dns", "(", "self", ",", "domain_name", ",", "recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"recursive\"", ":", "recursive", "}", ")", "args", "=", "(", "domain_name", ",",...
Resolves DNS links to the referenced object. Multihashes are hard to remember, but domain names are usually easy to remember. To create memorable aliases for multihashes, DNS TXT records can point to other DNS links, IPFS objects, IPNS keys, etc. This command resolves those links to the...
[ "Resolves", "DNS", "links", "to", "the", "referenced", "object", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L991-L1025
248,516
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_add
def pin_add(self, path, *paths, **kwargs): """Pins objects to local storage. Stores an IPFS object(s) from a given path locally to disk. .. code-block:: python >>> c.pin_add("QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d") {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZM...
python
def pin_add(self, path, *paths, **kwargs): #PY2: No support for kw-only parameters after glob parameters if "recursive" in kwargs: kwargs.setdefault("opts", {"recursive": kwargs.pop("recursive")}) args = (path,) + paths return self._client.request('/pin/add', args, decoder='...
[ "def", "pin_add", "(", "self", ",", "path", ",", "*", "paths", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"recursive\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{",...
Pins objects to local storage. Stores an IPFS object(s) from a given path locally to disk. .. code-block:: python >>> c.pin_add("QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d") {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ----------...
[ "Pins", "objects", "to", "local", "storage", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1027-L1053
248,517
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_rm
def pin_rm(self, path, *paths, **kwargs): """Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {...
python
def pin_rm(self, path, *paths, **kwargs): #PY2: No support for kw-only parameters after glob parameters if "recursive" in kwargs: kwargs.setdefault("opts", {"recursive": kwargs["recursive"]}) del kwargs["recursive"] args = (path,) + paths return self._client.requ...
[ "def", "pin_rm", "(", "self", ",", "path", ",", "*", "paths", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"recursive\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", ...
Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyG...
[ "Removes", "a", "pinned", "object", "from", "local", "storage", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1055-L1083
248,518
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_ls
def pin_ls(self, type="all", **kwargs): """Lists objects pinned to local storage. By default, all pinned objects are returned, but the ``type`` flag or arguments can restrict that to a specific pin type or to some specific objects respectively. .. code-block:: python ...
python
def pin_ls(self, type="all", **kwargs): kwargs.setdefault("opts", {"type": type}) return self._client.request('/pin/ls', decoder='json', **kwargs)
[ "def", "pin_ls", "(", "self", ",", "type", "=", "\"all\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"type\"", ":", "type", "}", ")", "return", "self", ".", "_client", ".", "request", "(", "'/pin/ls'...
Lists objects pinned to local storage. By default, all pinned objects are returned, but the ``type`` flag or arguments can restrict that to a specific pin type or to some specific objects respectively. .. code-block:: python >>> c.pin_ls() {'Keys': { ...
[ "Lists", "objects", "pinned", "to", "local", "storage", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1085-L1118
248,519
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_update
def pin_update(self, from_path, to_path, **kwargs): """Replaces one pin with another. Updates one pin to another, making sure that all objects in the new pin are local. Then removes the old pin. This is an optimized version of using first using :meth:`~ipfsapi.Client.pin_add` to add a n...
python
def pin_update(self, from_path, to_path, **kwargs): #PY2: No support for kw-only parameters after glob parameters if "unpin" in kwargs: kwargs.setdefault("opts", {"unpin": kwargs["unpin"]}) del kwargs["unpin"] args = (from_path, to_path) return self._client.reque...
[ "def", "pin_update", "(", "self", ",", "from_path", ",", "to_path", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"unpin\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", ...
Replaces one pin with another. Updates one pin to another, making sure that all objects in the new pin are local. Then removes the old pin. This is an optimized version of using first using :meth:`~ipfsapi.Client.pin_add` to add a new pin for an object and then using :meth:`~ipfsapi.Cli...
[ "Replaces", "one", "pin", "with", "another", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1120-L1156
248,520
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_verify
def pin_verify(self, path, *paths, **kwargs): """Verify that recursive pins are complete. Scan the repo for pinned object graphs and check their integrity. Issues will be reported back with a helpful human-readable error message to aid in error recovery. This is useful to help recover ...
python
def pin_verify(self, path, *paths, **kwargs): #PY2: No support for kw-only parameters after glob parameters if "verbose" in kwargs: kwargs.setdefault("opts", {"verbose": kwargs["verbose"]}) del kwargs["verbose"] args = (path,) + paths return self._client.request(...
[ "def", "pin_verify", "(", "self", ",", "path", ",", "*", "paths", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"verbose\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{"...
Verify that recursive pins are complete. Scan the repo for pinned object graphs and check their integrity. Issues will be reported back with a helpful human-readable error message to aid in error recovery. This is useful to help recover from datastore corruptions (such as when accidenta...
[ "Verify", "that", "recursive", "pins", "are", "complete", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1158-L1199
248,521
ipfs/py-ipfs-api
ipfsapi/client.py
Client.id
def id(self, peer=None, **kwargs): """Shows IPFS Node ID info. Returns the PublicKey, ProtocolVersion, ID, AgentVersion and Addresses of the connected daemon or some other node. .. code-block:: python >>> c.id() {'ID': 'QmVgNoP89mzpgEAAqK8owYoDEyB97MkcGvoWZir8o...
python
def id(self, peer=None, **kwargs): args = (peer,) if peer is not None else () return self._client.request('/id', args, decoder='json', **kwargs)
[ "def", "id", "(", "self", ",", "peer", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "peer", ",", ")", "if", "peer", "is", "not", "None", "else", "(", ")", "return", "self", ".", "_client", ".", "request", "(", "'/id'", ",",...
Shows IPFS Node ID info. Returns the PublicKey, ProtocolVersion, ID, AgentVersion and Addresses of the connected daemon or some other node. .. code-block:: python >>> c.id() {'ID': 'QmVgNoP89mzpgEAAqK8owYoDEyB97MkcGvoWZir8otE9Uc', 'PublicKey': 'CAASpgIwggEi...
[ "Shows", "IPFS", "Node", "ID", "info", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1254-L1289
248,522
ipfs/py-ipfs-api
ipfsapi/client.py
Client.bootstrap_add
def bootstrap_add(self, peer, *peers, **kwargs): """Adds peers to the bootstrap list. Parameters ---------- peer : str IPFS MultiAddr of a peer to add to the list Returns ------- dict """ args = (peer,) + peers return self...
python
def bootstrap_add(self, peer, *peers, **kwargs): args = (peer,) + peers return self._client.request('/bootstrap/add', args, decoder='json', **kwargs)
[ "def", "bootstrap_add", "(", "self", ",", "peer", ",", "*", "peers", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "peer", ",", ")", "+", "peers", "return", "self", ".", "_client", ".", "request", "(", "'/bootstrap/add'", ",", "args", ",", "...
Adds peers to the bootstrap list. Parameters ---------- peer : str IPFS MultiAddr of a peer to add to the list Returns ------- dict
[ "Adds", "peers", "to", "the", "bootstrap", "list", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1317-L1331
248,523
ipfs/py-ipfs-api
ipfsapi/client.py
Client.swarm_filters_add
def swarm_filters_add(self, address, *addresses, **kwargs): """Adds a given multiaddr filter to the filter list. This will add an address filter to the daemons swarm. Filters applied this way will not persist daemon reboots, to achieve that, add your filters to the configuration file. ...
python
def swarm_filters_add(self, address, *addresses, **kwargs): args = (address,) + addresses return self._client.request('/swarm/filters/add', args, decoder='json', **kwargs)
[ "def", "swarm_filters_add", "(", "self", ",", "address", ",", "*", "addresses", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "address", ",", ")", "+", "addresses", "return", "self", ".", "_client", ".", "request", "(", "'/swarm/filters/add'", ","...
Adds a given multiaddr filter to the filter list. This will add an address filter to the daemons swarm. Filters applied this way will not persist daemon reboots, to achieve that, add your filters to the configuration file. .. code-block:: python >>> c.swarm_filters_add("/i...
[ "Adds", "a", "given", "multiaddr", "filter", "to", "the", "filter", "list", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1456-L1479
248,524
ipfs/py-ipfs-api
ipfsapi/client.py
Client.dht_query
def dht_query(self, peer_id, *peer_ids, **kwargs): """Finds the closest Peer IDs to a given Peer ID by querying the DHT. .. code-block:: python >>> c.dht_query("/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDM … uvuJ") [{'ID': 'QmPkFbxAQ7DeKD5VGSh9HQrdS574pyNzDmxJeGrRJxoucF', ...
python
def dht_query(self, peer_id, *peer_ids, **kwargs): args = (peer_id,) + peer_ids return self._client.request('/dht/query', args, decoder='json', **kwargs)
[ "def", "dht_query", "(", "self", ",", "peer_id", ",", "*", "peer_ids", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "peer_id", ",", ")", "+", "peer_ids", "return", "self", ".", "_client", ".", "request", "(", "'/dht/query'", ",", "args", ",",...
Finds the closest Peer IDs to a given Peer ID by querying the DHT. .. code-block:: python >>> c.dht_query("/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDM … uvuJ") [{'ID': 'QmPkFbxAQ7DeKD5VGSh9HQrdS574pyNzDmxJeGrRJxoucF', 'Extra': '', 'Type': 2, 'Responses': None}, ...
[ "Finds", "the", "closest", "Peer", "IDs", "to", "a", "given", "Peer", "ID", "by", "querying", "the", "DHT", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1506-L1533
248,525
ipfs/py-ipfs-api
ipfsapi/client.py
Client.dht_findprovs
def dht_findprovs(self, multihash, *multihashes, **kwargs): """Finds peers in the DHT that can provide a specific value. .. code-block:: python >>> c.dht_findprovs("QmNPXDC6wTXVmZ9Uoc8X1oqxRRJr4f1sDuyQu … mpW2") [{'ID': 'QmaxqKpiYNr62uSFBhxJAMmEMkT6dvc3oHkrZNpH2VMTLZ', ...
python
def dht_findprovs(self, multihash, *multihashes, **kwargs): args = (multihash,) + multihashes return self._client.request('/dht/findprovs', args, decoder='json', **kwargs)
[ "def", "dht_findprovs", "(", "self", ",", "multihash", ",", "*", "multihashes", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "multihash", ",", ")", "+", "multihashes", "return", "self", ".", "_client", ".", "request", "(", "'/dht/findprovs'", ","...
Finds peers in the DHT that can provide a specific value. .. code-block:: python >>> c.dht_findprovs("QmNPXDC6wTXVmZ9Uoc8X1oqxRRJr4f1sDuyQu … mpW2") [{'ID': 'QmaxqKpiYNr62uSFBhxJAMmEMkT6dvc3oHkrZNpH2VMTLZ', 'Extra': '', 'Type': 6, 'Responses': None}, {'ID': '...
[ "Finds", "peers", "in", "the", "DHT", "that", "can", "provide", "a", "specific", "value", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1535-L1572
248,526
ipfs/py-ipfs-api
ipfsapi/client.py
Client.dht_get
def dht_get(self, key, *keys, **kwargs): """Queries the DHT for its best value related to given key. There may be several different values for a given key stored in the DHT; in this context *best* means the record that is most desirable. There is no one metric for *best*: it depends ent...
python
def dht_get(self, key, *keys, **kwargs): args = (key,) + keys res = self._client.request('/dht/get', args, decoder='json', **kwargs) if isinstance(res, dict) and "Extra" in res: return res["Extra"] else: for r in res: if "Extra" in r and len(r["Ex...
[ "def", "dht_get", "(", "self", ",", "key", ",", "*", "keys", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "key", ",", ")", "+", "keys", "res", "=", "self", ".", "_client", ".", "request", "(", "'/dht/get'", ",", "args", ",", "decoder", ...
Queries the DHT for its best value related to given key. There may be several different values for a given key stored in the DHT; in this context *best* means the record that is most desirable. There is no one metric for *best*: it depends entirely on the key type. For IPNS, *best* is t...
[ "Queries", "the", "DHT", "for", "its", "best", "value", "related", "to", "given", "key", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1610-L1638
248,527
ipfs/py-ipfs-api
ipfsapi/client.py
Client.ping
def ping(self, peer, *peers, **kwargs): """Provides round-trip latency information for the routing system. Finds nodes via the routing system, sends pings, waits for pongs, and prints out round-trip latency information. .. code-block:: python >>> c.ping("QmTzQ1JRkWErjk39mr...
python
def ping(self, peer, *peers, **kwargs): #PY2: No support for kw-only parameters after glob parameters if "count" in kwargs: kwargs.setdefault("opts", {"count": kwargs["count"]}) del kwargs["count"] args = (peer,) + peers return self._client.request('/ping', args,...
[ "def", "ping", "(", "self", ",", "peer", ",", "*", "peers", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"count\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"c...
Provides round-trip latency information for the routing system. Finds nodes via the routing system, sends pings, waits for pongs, and prints out round-trip latency information. .. code-block:: python >>> c.ping("QmTzQ1JRkWErjk39mryYw2WVaphAZNAREyMchXzYQ7c15n") [{'Succe...
[ "Provides", "round", "-", "trip", "latency", "information", "for", "the", "routing", "system", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1685-L1716
248,528
ipfs/py-ipfs-api
ipfsapi/client.py
Client.config
def config(self, key, value=None, **kwargs): """Controls configuration variables. .. code-block:: python >>> c.config("Addresses.Gateway") {'Key': 'Addresses.Gateway', 'Value': '/ip4/127.0.0.1/tcp/8080'} >>> c.config("Addresses.Gateway", "/ip4/127.0.0.1/tcp/8081") ...
python
def config(self, key, value=None, **kwargs): args = (key, value) return self._client.request('/config', args, decoder='json', **kwargs)
[ "def", "config", "(", "self", ",", "key", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "key", ",", "value", ")", "return", "self", ".", "_client", ".", "request", "(", "'/config'", ",", "args", ",", "decoder", "...
Controls configuration variables. .. code-block:: python >>> c.config("Addresses.Gateway") {'Key': 'Addresses.Gateway', 'Value': '/ip4/127.0.0.1/tcp/8080'} >>> c.config("Addresses.Gateway", "/ip4/127.0.0.1/tcp/8081") {'Key': 'Addresses.Gateway', 'Value': '/ip4/1...
[ "Controls", "configuration", "variables", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1718-L1740
248,529
ipfs/py-ipfs-api
ipfsapi/client.py
Client.config_replace
def config_replace(self, *args, **kwargs): """Replaces the existing config with a user-defined config. Make sure to back up the config file first if neccessary, as this operation can't be undone. """ return self._client.request('/config/replace', args, ...
python
def config_replace(self, *args, **kwargs): return self._client.request('/config/replace', args, decoder='json', **kwargs)
[ "def", "config_replace", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_client", ".", "request", "(", "'/config/replace'", ",", "args", ",", "decoder", "=", "'json'", ",", "*", "*", "kwargs", ")" ]
Replaces the existing config with a user-defined config. Make sure to back up the config file first if neccessary, as this operation can't be undone.
[ "Replaces", "the", "existing", "config", "with", "a", "user", "-", "defined", "config", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1766-L1773
248,530
ipfs/py-ipfs-api
ipfsapi/client.py
Client.log_level
def log_level(self, subsystem, level, **kwargs): r"""Changes the logging output of a running daemon. .. code-block:: python >>> c.log_level("path", "info") {'Message': "Changed log level of 'path' to 'info'\n"} Parameters ---------- subsystem : str ...
python
def log_level(self, subsystem, level, **kwargs): r"""Changes the logging output of a running daemon. .. code-block:: python >>> c.log_level("path", "info") {'Message': "Changed log level of 'path' to 'info'\n"} Parameters ---------- subsystem : str ...
[ "def", "log_level", "(", "self", ",", "subsystem", ",", "level", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "subsystem", ",", "level", ")", "return", "self", ".", "_client", ".", "request", "(", "'/log/level'", ",", "args", ",", "decoder", ...
r"""Changes the logging output of a running daemon. .. code-block:: python >>> c.log_level("path", "info") {'Message': "Changed log level of 'path' to 'info'\n"} Parameters ---------- subsystem : str The subsystem logging identifier (Use ``"all"`` f...
[ "r", "Changes", "the", "logging", "output", "of", "a", "running", "daemon", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1775-L1803
248,531
ipfs/py-ipfs-api
ipfsapi/client.py
Client.log_tail
def log_tail(self, **kwargs): r"""Reads log outputs as they are written. This function returns an iterator needs to be closed using a context manager (``with``-statement) or using the ``.close()`` method. .. code-block:: python >>> with c.log_tail() as log_tail_iter: ...
python
def log_tail(self, **kwargs): r"""Reads log outputs as they are written. This function returns an iterator needs to be closed using a context manager (``with``-statement) or using the ``.close()`` method. .. code-block:: python >>> with c.log_tail() as log_tail_iter: ...
[ "def", "log_tail", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_client", ".", "request", "(", "'/log/tail'", ",", "decoder", "=", "'json'", ",", "stream", "=", "True", ",", "*", "*", "kwargs", ")" ]
r"""Reads log outputs as they are written. This function returns an iterator needs to be closed using a context manager (``with``-statement) or using the ``.close()`` method. .. code-block:: python >>> with c.log_tail() as log_tail_iter: ... for item in log_tail_it...
[ "r", "Reads", "log", "outputs", "as", "they", "are", "written", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1836-L1872
248,532
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_cp
def files_cp(self, source, dest, **kwargs): """Copies files within the MFS. Due to the nature of IPFS this will not actually involve any of the file's content being copied. .. code-block:: python >>> c.files_ls("/") {'Entries': [ {'Size': 0, 'Ha...
python
def files_cp(self, source, dest, **kwargs): args = (source, dest) return self._client.request('/files/cp', args, **kwargs)
[ "def", "files_cp", "(", "self", ",", "source", ",", "dest", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "source", ",", "dest", ")", "return", "self", ".", "_client", ".", "request", "(", "'/files/cp'", ",", "args", ",", "*", "*", "kwargs",...
Copies files within the MFS. Due to the nature of IPFS this will not actually involve any of the file's content being copied. .. code-block:: python >>> c.files_ls("/") {'Entries': [ {'Size': 0, 'Hash': '', 'Name': 'Software', 'Type': 0}, ...
[ "Copies", "files", "within", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1889-L1920
248,533
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_ls
def files_ls(self, path, **kwargs): """Lists contents of a directory in the MFS. .. code-block:: python >>> c.files_ls("/") {'Entries': [ {'Size': 0, 'Hash': '', 'Name': 'Software', 'Type': 0} ]} Parameters ---------- path : ...
python
def files_ls(self, path, **kwargs): args = (path,) return self._client.request('/files/ls', args, decoder='json', **kwargs)
[ "def", "files_ls", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "path", ",", ")", "return", "self", ".", "_client", ".", "request", "(", "'/files/ls'", ",", "args", ",", "decoder", "=", "'json'", ",", "*", "*", "...
Lists contents of a directory in the MFS. .. code-block:: python >>> c.files_ls("/") {'Entries': [ {'Size': 0, 'Hash': '', 'Name': 'Software', 'Type': 0} ]} Parameters ---------- path : str Filepath within the MFS ...
[ "Lists", "contents", "of", "a", "directory", "in", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1922-L1943
248,534
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_mkdir
def files_mkdir(self, path, parents=False, **kwargs): """Creates a directory within the MFS. .. code-block:: python >>> c.files_mkdir("/test") b'' Parameters ---------- path : str Filepath within the MFS parents : bool Cr...
python
def files_mkdir(self, path, parents=False, **kwargs): kwargs.setdefault("opts", {"parents": parents}) args = (path,) return self._client.request('/files/mkdir', args, **kwargs)
[ "def", "files_mkdir", "(", "self", ",", "path", ",", "parents", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"parents\"", ":", "parents", "}", ")", "args", "=", "(", "path", ",", ")", "r...
Creates a directory within the MFS. .. code-block:: python >>> c.files_mkdir("/test") b'' Parameters ---------- path : str Filepath within the MFS parents : bool Create parent directories as needed and do not raise an exception ...
[ "Creates", "a", "directory", "within", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1945-L1964
248,535
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_rm
def files_rm(self, path, recursive=False, **kwargs): """Removes a file from the MFS. .. code-block:: python >>> c.files_rm("/bla/file") b'' Parameters ---------- path : str Filepath within the MFS recursive : bool Recursi...
python
def files_rm(self, path, recursive=False, **kwargs): kwargs.setdefault("opts", {"recursive": recursive}) args = (path,) return self._client.request('/files/rm', args, **kwargs)
[ "def", "files_rm", "(", "self", ",", "path", ",", "recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"recursive\"", ":", "recursive", "}", ")", "args", "=", "(", "path", ",", ")", ...
Removes a file from the MFS. .. code-block:: python >>> c.files_rm("/bla/file") b'' Parameters ---------- path : str Filepath within the MFS recursive : bool Recursively remove directories?
[ "Removes", "a", "file", "from", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1989-L2007
248,536
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_read
def files_read(self, path, offset=0, count=None, **kwargs): """Reads a file stored in the MFS. .. code-block:: python >>> c.files_read("/bla/file") b'hi' Parameters ---------- path : str Filepath within the MFS offset : int ...
python
def files_read(self, path, offset=0, count=None, **kwargs): opts = {"offset": offset} if count is not None: opts["count"] = count kwargs.setdefault("opts", opts) args = (path,) return self._client.request('/files/read', args, **kwargs)
[ "def", "files_read", "(", "self", ",", "path", ",", "offset", "=", "0", ",", "count", "=", "None", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"offset\"", ":", "offset", "}", "if", "count", "is", "not", "None", ":", "opts", "[", "\"cou...
Reads a file stored in the MFS. .. code-block:: python >>> c.files_read("/bla/file") b'hi' Parameters ---------- path : str Filepath within the MFS offset : int Byte offset at which to begin reading at count : int ...
[ "Reads", "a", "file", "stored", "in", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2009-L2036
248,537
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_write
def files_write(self, path, file, offset=0, create=False, truncate=False, count=None, **kwargs): """Writes to a mutable file in the MFS. .. code-block:: python >>> c.files_write("/test/file", io.BytesIO(b"hi"), create=True) b'' Parameters --...
python
def files_write(self, path, file, offset=0, create=False, truncate=False, count=None, **kwargs): opts = {"offset": offset, "create": create, "truncate": truncate} if count is not None: opts["count"] = count kwargs.setdefault("opts", opts) args = (path,) ...
[ "def", "files_write", "(", "self", ",", "path", ",", "file", ",", "offset", "=", "0", ",", "create", "=", "False", ",", "truncate", "=", "False", ",", "count", "=", "None", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "{", "\"offset\"", ":", "...
Writes to a mutable file in the MFS. .. code-block:: python >>> c.files_write("/test/file", io.BytesIO(b"hi"), create=True) b'' Parameters ---------- path : str Filepath within the MFS file : io.RawIOBase IO stream object with da...
[ "Writes", "to", "a", "mutable", "file", "in", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2038-L2070
248,538
ipfs/py-ipfs-api
ipfsapi/client.py
Client.files_mv
def files_mv(self, source, dest, **kwargs): """Moves files and directories within the MFS. .. code-block:: python >>> c.files_mv("/test/file", "/bla/file") b'' Parameters ---------- source : str Existing filepath within the MFS dest ...
python
def files_mv(self, source, dest, **kwargs): args = (source, dest) return self._client.request('/files/mv', args, **kwargs)
[ "def", "files_mv", "(", "self", ",", "source", ",", "dest", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "source", ",", "dest", ")", "return", "self", ".", "_client", ".", "request", "(", "'/files/mv'", ",", "args", ",", "*", "*", "kwargs",...
Moves files and directories within the MFS. .. code-block:: python >>> c.files_mv("/test/file", "/bla/file") b'' Parameters ---------- source : str Existing filepath within the MFS dest : str Destination to which the file will be...
[ "Moves", "files", "and", "directories", "within", "the", "MFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2072-L2088
248,539
ipfs/py-ipfs-api
ipfsapi/client.py
Client.add_bytes
def add_bytes(self, data, **kwargs): """Adds a set of bytes as a file to IPFS. .. code-block:: python >>> c.add_bytes(b"Mary had a little lamb") 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab' Also accepts and will stream generator objects. Parameters ...
python
def add_bytes(self, data, **kwargs): body, headers = multipart.stream_bytes(data, self.chunk_size) return self._client.request('/add', decoder='json', data=body, headers=headers, **kwargs)
[ "def", "add_bytes", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "body", ",", "headers", "=", "multipart", ".", "stream_bytes", "(", "data", ",", "self", ".", "chunk_size", ")", "return", "self", ".", "_client", ".", "request", "(", "...
Adds a set of bytes as a file to IPFS. .. code-block:: python >>> c.add_bytes(b"Mary had a little lamb") 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab' Also accepts and will stream generator objects. Parameters ---------- data : bytes Con...
[ "Adds", "a", "set", "of", "bytes", "as", "a", "file", "to", "IPFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2109-L2130
248,540
ipfs/py-ipfs-api
ipfsapi/client.py
Client.add_str
def add_str(self, string, **kwargs): """Adds a Python string as a file to IPFS. .. code-block:: python >>> c.add_str(u"Mary had a little lamb") 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab' Also accepts and will stream generator objects. Parameters ...
python
def add_str(self, string, **kwargs): body, headers = multipart.stream_text(string, self.chunk_size) return self._client.request('/add', decoder='json', data=body, headers=headers, **kwargs)
[ "def", "add_str", "(", "self", ",", "string", ",", "*", "*", "kwargs", ")", ":", "body", ",", "headers", "=", "multipart", ".", "stream_text", "(", "string", ",", "self", ".", "chunk_size", ")", "return", "self", ".", "_client", ".", "request", "(", ...
Adds a Python string as a file to IPFS. .. code-block:: python >>> c.add_str(u"Mary had a little lamb") 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab' Also accepts and will stream generator objects. Parameters ---------- string : str Cont...
[ "Adds", "a", "Python", "string", "as", "a", "file", "to", "IPFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2133-L2154
248,541
ipfs/py-ipfs-api
ipfsapi/client.py
Client.add_json
def add_json(self, json_obj, **kwargs): """Adds a json-serializable Python dict as a json file to IPFS. .. code-block:: python >>> c.add_json({'one': 1, 'two': 2, 'three': 3}) 'QmVz9g7m5u3oHiNKHj2CJX1dbG1gtismRS3g9NaPBBLbob' Parameters ---------- json_o...
python
def add_json(self, json_obj, **kwargs): return self.add_bytes(encoding.Json().encode(json_obj), **kwargs)
[ "def", "add_json", "(", "self", ",", "json_obj", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "add_bytes", "(", "encoding", ".", "Json", "(", ")", ".", "encode", "(", "json_obj", ")", ",", "*", "*", "kwargs", ")" ]
Adds a json-serializable Python dict as a json file to IPFS. .. code-block:: python >>> c.add_json({'one': 1, 'two': 2, 'three': 3}) 'QmVz9g7m5u3oHiNKHj2CJX1dbG1gtismRS3g9NaPBBLbob' Parameters ---------- json_obj : dict A json-serializable Python di...
[ "Adds", "a", "json", "-", "serializable", "Python", "dict", "as", "a", "json", "file", "to", "IPFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2156-L2173
248,542
ipfs/py-ipfs-api
ipfsapi/client.py
Client.add_pyobj
def add_pyobj(self, py_obj, **kwargs): """Adds a picklable Python object as a file to IPFS. .. deprecated:: 0.4.2 The ``*_pyobj`` APIs allow for arbitrary code execution if abused. Either switch to :meth:`~ipfsapi.Client.add_json` or use ``client.add_bytes(pickle.dumps(...
python
def add_pyobj(self, py_obj, **kwargs): warnings.warn("Using `*_pyobj` on untrusted data is a security risk", DeprecationWarning) return self.add_bytes(encoding.Pickle().encode(py_obj), **kwargs)
[ "def", "add_pyobj", "(", "self", ",", "py_obj", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"Using `*_pyobj` on untrusted data is a security risk\"", ",", "DeprecationWarning", ")", "return", "self", ".", "add_bytes", "(", "encoding", ".", ...
Adds a picklable Python object as a file to IPFS. .. deprecated:: 0.4.2 The ``*_pyobj`` APIs allow for arbitrary code execution if abused. Either switch to :meth:`~ipfsapi.Client.add_json` or use ``client.add_bytes(pickle.dumps(py_obj))`` instead. Please see :meth:`~ip...
[ "Adds", "a", "picklable", "Python", "object", "as", "a", "file", "to", "IPFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2194-L2221
248,543
ipfs/py-ipfs-api
ipfsapi/client.py
Client.get_pyobj
def get_pyobj(self, multihash, **kwargs): """Loads a pickled Python object from IPFS. .. deprecated:: 0.4.2 The ``*_pyobj`` APIs allow for arbitrary code execution if abused. Either switch to :meth:`~ipfsapi.Client.get_json` or use ``pickle.loads(client.cat(multihash))`...
python
def get_pyobj(self, multihash, **kwargs): warnings.warn("Using `*_pyobj` on untrusted data is a security risk", DeprecationWarning) return self.cat(multihash, decoder='pickle', **kwargs)
[ "def", "get_pyobj", "(", "self", ",", "multihash", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"Using `*_pyobj` on untrusted data is a security risk\"", ",", "DeprecationWarning", ")", "return", "self", ".", "cat", "(", "multihash", ",", "...
Loads a pickled Python object from IPFS. .. deprecated:: 0.4.2 The ``*_pyobj`` APIs allow for arbitrary code execution if abused. Either switch to :meth:`~ipfsapi.Client.get_json` or use ``pickle.loads(client.cat(multihash))`` instead. .. caution:: The pic...
[ "Loads", "a", "pickled", "Python", "object", "from", "IPFS", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2223-L2257
248,544
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pubsub_peers
def pubsub_peers(self, topic=None, **kwargs): """List the peers we are pubsubbing with. Lists the id's of other IPFS users who we are connected to via some topic. Without specifying a topic, IPFS peers from all subscribed topics will be returned in the data. If a topic is specif...
python
def pubsub_peers(self, topic=None, **kwargs): args = (topic,) if topic is not None else () return self._client.request('/pubsub/peers', args, decoder='json', **kwargs)
[ "def", "pubsub_peers", "(", "self", ",", "topic", "=", "None", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "topic", ",", ")", "if", "topic", "is", "not", "None", "else", "(", ")", "return", "self", ".", "_client", ".", "request", "(", "'...
List the peers we are pubsubbing with. Lists the id's of other IPFS users who we are connected to via some topic. Without specifying a topic, IPFS peers from all subscribed topics will be returned in the data. If a topic is specified only the IPFS id's of the peers from the spec...
[ "List", "the", "peers", "we", "are", "pubsubbing", "with", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2282-L2330
248,545
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pubsub_pub
def pubsub_pub(self, topic, payload, **kwargs): """Publish a message to a given pubsub topic Publishing will publish the given payload (string) to everyone currently subscribed to the given topic. All data (including the id of the publisher) is automatically base64 encoded when...
python
def pubsub_pub(self, topic, payload, **kwargs): args = (topic, payload) return self._client.request('/pubsub/pub', args, decoder='json', **kwargs)
[ "def", "pubsub_pub", "(", "self", ",", "topic", ",", "payload", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "topic", ",", "payload", ")", "return", "self", ".", "_client", ".", "request", "(", "'/pubsub/pub'", ",", "args", ",", "decoder", "=...
Publish a message to a given pubsub topic Publishing will publish the given payload (string) to everyone currently subscribed to the given topic. All data (including the id of the publisher) is automatically base64 encoded when published. .. code-block:: python # ...
[ "Publish", "a", "message", "to", "a", "given", "pubsub", "topic" ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2332-L2359
248,546
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pubsub_sub
def pubsub_sub(self, topic, discover=False, **kwargs): """Subscribe to mesages on a given topic Subscribing to a topic in IPFS means anytime a message is published to a topic, the subscribers will be notified of the publication. The connection with the pubsub topic is opened an...
python
def pubsub_sub(self, topic, discover=False, **kwargs): args = (topic, discover) return SubChannel(self._client.request('/pubsub/sub', args, stream=True, decoder='json'))
[ "def", "pubsub_sub", "(", "self", ",", "topic", ",", "discover", "=", "False", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "topic", ",", "discover", ")", "return", "SubChannel", "(", "self", ".", "_client", ".", "request", "(", "'/pubsub/sub'"...
Subscribe to mesages on a given topic Subscribing to a topic in IPFS means anytime a message is published to a topic, the subscribers will be notified of the publication. The connection with the pubsub topic is opened and read. The Subscription returned should be used inside a ...
[ "Subscribe", "to", "mesages", "on", "a", "given", "topic" ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L2361-L2409
248,547
ipfs/py-ipfs-api
ipfsapi/utils.py
guess_mimetype
def guess_mimetype(filename): """Guesses the mimetype of a file based on the given ``filename``. .. code-block:: python >>> guess_mimetype('example.txt') 'text/plain' >>> guess_mimetype('/foo/bar/example') 'application/octet-stream' Parameters ---------- filename :...
python
def guess_mimetype(filename): fn = os.path.basename(filename) return mimetypes.guess_type(fn)[0] or 'application/octet-stream'
[ "def", "guess_mimetype", "(", "filename", ")", ":", "fn", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "return", "mimetypes", ".", "guess_type", "(", "fn", ")", "[", "0", "]", "or", "'application/octet-stream'" ]
Guesses the mimetype of a file based on the given ``filename``. .. code-block:: python >>> guess_mimetype('example.txt') 'text/plain' >>> guess_mimetype('/foo/bar/example') 'application/octet-stream' Parameters ---------- filename : str The file name or path fo...
[ "Guesses", "the", "mimetype", "of", "a", "file", "based", "on", "the", "given", "filename", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/utils.py#L13-L29
248,548
ipfs/py-ipfs-api
ipfsapi/utils.py
ls_dir
def ls_dir(dirname): """Returns files and subdirectories within a given directory. Returns a pair of lists, containing the names of directories and files in ``dirname``. Raises ------ OSError : Accessing the given directory path failed Parameters ---------- dirname : str T...
python
def ls_dir(dirname): ls = os.listdir(dirname) files = [p for p in ls if os.path.isfile(os.path.join(dirname, p))] dirs = [p for p in ls if os.path.isdir(os.path.join(dirname, p))] return files, dirs
[ "def", "ls_dir", "(", "dirname", ")", ":", "ls", "=", "os", ".", "listdir", "(", "dirname", ")", "files", "=", "[", "p", "for", "p", "in", "ls", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "dirname", ",", ...
Returns files and subdirectories within a given directory. Returns a pair of lists, containing the names of directories and files in ``dirname``. Raises ------ OSError : Accessing the given directory path failed Parameters ---------- dirname : str The path of the directory to ...
[ "Returns", "files", "and", "subdirectories", "within", "a", "given", "directory", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/utils.py#L32-L50
248,549
ipfs/py-ipfs-api
ipfsapi/utils.py
clean_files
def clean_files(files): """Generates tuples with a ``file``-like object and a close indicator. This is a generator of tuples, where the first element is the file object and the second element is a boolean which is True if this module opened the file (and thus should close it). Raises ------ ...
python
def clean_files(files): if isinstance(files, (list, tuple)): for f in files: yield clean_file(f) else: yield clean_file(files)
[ "def", "clean_files", "(", "files", ")", ":", "if", "isinstance", "(", "files", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "f", "in", "files", ":", "yield", "clean_file", "(", "f", ")", "else", ":", "yield", "clean_file", "(", "files", "...
Generates tuples with a ``file``-like object and a close indicator. This is a generator of tuples, where the first element is the file object and the second element is a boolean which is True if this module opened the file (and thus should close it). Raises ------ OSError : Accessing the given...
[ "Generates", "tuples", "with", "a", "file", "-", "like", "object", "and", "a", "close", "indicator", "." ]
7574dad04877b45dbe4ad321dcfa9e880eb2d90c
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/utils.py#L75-L95
248,550
miguelgrinberg/Flask-Migrate
flask_migrate/cli.py
merge
def merge(directory, message, branch_label, rev_id, revisions): """Merge two revisions together, creating a new revision file""" _merge(directory, revisions, message, branch_label, rev_id)
python
def merge(directory, message, branch_label, rev_id, revisions): _merge(directory, revisions, message, branch_label, rev_id)
[ "def", "merge", "(", "directory", ",", "message", ",", "branch_label", ",", "rev_id", ",", "revisions", ")", ":", "_merge", "(", "directory", ",", "revisions", ",", "message", ",", "branch_label", ",", "rev_id", ")" ]
Merge two revisions together, creating a new revision file
[ "Merge", "two", "revisions", "together", "creating", "a", "new", "revision", "file" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/cli.py#L114-L116
248,551
miguelgrinberg/Flask-Migrate
flask_migrate/cli.py
downgrade
def downgrade(directory, sql, tag, x_arg, revision): """Revert to a previous version""" _downgrade(directory, revision, sql, tag, x_arg)
python
def downgrade(directory, sql, tag, x_arg, revision): _downgrade(directory, revision, sql, tag, x_arg)
[ "def", "downgrade", "(", "directory", ",", "sql", ",", "tag", ",", "x_arg", ",", "revision", ")", ":", "_downgrade", "(", "directory", ",", "revision", ",", "sql", ",", "tag", ",", "x_arg", ")" ]
Revert to a previous version
[ "Revert", "to", "a", "previous", "version" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/cli.py#L150-L152
248,552
miguelgrinberg/Flask-Migrate
flask_migrate/templates/flask-multidb/env.py
get_metadata
def get_metadata(bind): """Return the metadata for a bind.""" if bind == '': bind = None m = MetaData() for t in target_metadata.tables.values(): if t.info.get('bind_key') == bind: t.tometadata(m) return m
python
def get_metadata(bind): if bind == '': bind = None m = MetaData() for t in target_metadata.tables.values(): if t.info.get('bind_key') == bind: t.tometadata(m) return m
[ "def", "get_metadata", "(", "bind", ")", ":", "if", "bind", "==", "''", ":", "bind", "=", "None", "m", "=", "MetaData", "(", ")", "for", "t", "in", "target_metadata", ".", "tables", ".", "values", "(", ")", ":", "if", "t", ".", "info", ".", "get"...
Return the metadata for a bind.
[ "Return", "the", "metadata", "for", "a", "bind", "." ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/templates/flask-multidb/env.py#L44-L52
248,553
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
init
def init(directory=None, multidb=False): """Creates a new migration repository""" if directory is None: directory = current_app.extensions['migrate'].directory config = Config() config.set_main_option('script_location', directory) config.config_file_name = os.path.join(directory, 'alembic.in...
python
def init(directory=None, multidb=False): if directory is None: directory = current_app.extensions['migrate'].directory config = Config() config.set_main_option('script_location', directory) config.config_file_name = os.path.join(directory, 'alembic.ini') config = current_app.extensions['migr...
[ "def", "init", "(", "directory", "=", "None", ",", "multidb", "=", "False", ")", ":", "if", "directory", "is", "None", ":", "directory", "=", "current_app", ".", "extensions", "[", "'migrate'", "]", ".", "directory", "config", "=", "Config", "(", ")", ...
Creates a new migration repository
[ "Creates", "a", "new", "migration", "repository" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L122-L134
248,554
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
edit
def edit(directory=None, revision='current'): """Edit current revision.""" if alembic_version >= (0, 8, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.edit(config, revision) else: raise RuntimeError('Alembic 0.8.0 or greater is requi...
python
def edit(directory=None, revision='current'): if alembic_version >= (0, 8, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.edit(config, revision) else: raise RuntimeError('Alembic 0.8.0 or greater is required')
[ "def", "edit", "(", "directory", "=", "None", ",", "revision", "=", "'current'", ")", ":", "if", "alembic_version", ">=", "(", "0", ",", "8", ",", "0", ")", ":", "config", "=", "current_app", ".", "extensions", "[", "'migrate'", "]", ".", "migrate", ...
Edit current revision.
[ "Edit", "current", "revision", "." ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L226-L233
248,555
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
merge
def merge(directory=None, revisions='', message=None, branch_label=None, rev_id=None): """Merge two revisions together. Creates a new migration file""" if alembic_version >= (0, 7, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.merge(...
python
def merge(directory=None, revisions='', message=None, branch_label=None, rev_id=None): if alembic_version >= (0, 7, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.merge(config, revisions, message=message, branch_label...
[ "def", "merge", "(", "directory", "=", "None", ",", "revisions", "=", "''", ",", "message", "=", "None", ",", "branch_label", "=", "None", ",", "rev_id", "=", "None", ")", ":", "if", "alembic_version", ">=", "(", "0", ",", "7", ",", "0", ")", ":", ...
Merge two revisions together. Creates a new migration file
[ "Merge", "two", "revisions", "together", ".", "Creates", "a", "new", "migration", "file" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L249-L258
248,556
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
heads
def heads(directory=None, verbose=False, resolve_dependencies=False): """Show current available heads in the script directory""" if alembic_version >= (0, 7, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.heads(config, verbose=verbose, ...
python
def heads(directory=None, verbose=False, resolve_dependencies=False): if alembic_version >= (0, 7, 0): config = current_app.extensions['migrate'].migrate.get_config( directory) command.heads(config, verbose=verbose, resolve_dependencies=resolve_dependencies) els...
[ "def", "heads", "(", "directory", "=", "None", ",", "verbose", "=", "False", ",", "resolve_dependencies", "=", "False", ")", ":", "if", "alembic_version", ">=", "(", "0", ",", "7", ",", "0", ")", ":", "config", "=", "current_app", ".", "extensions", "[...
Show current available heads in the script directory
[ "Show", "current", "available", "heads", "in", "the", "script", "directory" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L353-L361
248,557
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
branches
def branches(directory=None, verbose=False): """Show current branch points""" config = current_app.extensions['migrate'].migrate.get_config(directory) if alembic_version >= (0, 7, 0): command.branches(config, verbose=verbose) else: command.branches(config)
python
def branches(directory=None, verbose=False): config = current_app.extensions['migrate'].migrate.get_config(directory) if alembic_version >= (0, 7, 0): command.branches(config, verbose=verbose) else: command.branches(config)
[ "def", "branches", "(", "directory", "=", "None", ",", "verbose", "=", "False", ")", ":", "config", "=", "current_app", ".", "extensions", "[", "'migrate'", "]", ".", "migrate", ".", "get_config", "(", "directory", ")", "if", "alembic_version", ">=", "(", ...
Show current branch points
[ "Show", "current", "branch", "points" ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L370-L376
248,558
miguelgrinberg/Flask-Migrate
flask_migrate/__init__.py
current
def current(directory=None, verbose=False, head_only=False): """Display the current revision for each database.""" config = current_app.extensions['migrate'].migrate.get_config(directory) if alembic_version >= (0, 7, 0): command.current(config, verbose=verbose, head_only=head_only) else: ...
python
def current(directory=None, verbose=False, head_only=False): config = current_app.extensions['migrate'].migrate.get_config(directory) if alembic_version >= (0, 7, 0): command.current(config, verbose=verbose, head_only=head_only) else: command.current(config)
[ "def", "current", "(", "directory", "=", "None", ",", "verbose", "=", "False", ",", "head_only", "=", "False", ")", ":", "config", "=", "current_app", ".", "extensions", "[", "'migrate'", "]", ".", "migrate", ".", "get_config", "(", "directory", ")", "if...
Display the current revision for each database.
[ "Display", "the", "current", "revision", "for", "each", "database", "." ]
65fbd978681bdf2eddf8940edd04ed7272a94480
https://github.com/miguelgrinberg/Flask-Migrate/blob/65fbd978681bdf2eddf8940edd04ed7272a94480/flask_migrate/__init__.py#L388-L394
248,559
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.to_json
def to_json(self, content, pretty_print=False): """ Convert a string to a JSON object ``content`` String content to convert into JSON ``pretty_print`` If defined, will output JSON is pretty print format """ if PY3: if isinstance(content, bytes): cont...
python
def to_json(self, content, pretty_print=False): if PY3: if isinstance(content, bytes): content = content.decode(encoding='utf-8') if pretty_print: json_ = self._json_pretty_print(content) else: json_ = json.loads(content) logger.info('T...
[ "def", "to_json", "(", "self", ",", "content", ",", "pretty_print", "=", "False", ")", ":", "if", "PY3", ":", "if", "isinstance", "(", "content", ",", "bytes", ")", ":", "content", "=", "content", ".", "decode", "(", "encoding", "=", "'utf-8'", ")", ...
Convert a string to a JSON object ``content`` String content to convert into JSON ``pretty_print`` If defined, will output JSON is pretty print format
[ "Convert", "a", "string", "to", "a", "JSON", "object" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L460-L477
248,560
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.get_request
def get_request( self, alias, uri, headers=None, json=None, params=None, allow_redirects=None, timeout=None): """ Send a GET request on the session object found using the given `alias` ``alias`` that...
python
def get_request( self, alias, uri, headers=None, json=None, params=None, allow_redirects=None, timeout=None): session = self._cache.switch(alias) redir = True if allow_redirects is None else allow_redirects ...
[ "def", "get_request", "(", "self", ",", "alias", ",", "uri", ",", "headers", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ",", "allow_redirects", "=", "None", ",", "timeout", "=", "None", ")", ":", "session", "=", "self", ".", ...
Send a GET request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object in the cache ``uri`` to send the GET request to ``params`` url parameters to append to the uri ``headers`` a dictionary of headers to use with the...
[ "Send", "a", "GET", "request", "on", "the", "session", "object", "found", "using", "the", "given", "alias" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L479-L515
248,561
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.post_request
def post_request( self, alias, uri, data=None, json=None, params=None, headers=None, files=None, allow_redirects=None, timeout=None): """ Send a POST request on the session object found using ...
python
def post_request( self, alias, uri, data=None, json=None, params=None, headers=None, files=None, allow_redirects=None, timeout=None): session = self._cache.switch(alias) if not files: ...
[ "def", "post_request", "(", "self", ",", "alias", ",", "uri", ",", "data", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "files", "=", "None", ",", "allow_redirects", "=", "None", ",", "timeout",...
Send a POST request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object in the cache ``uri`` to send the POST request to ``data`` a dictionary of key-value pairs that will be urlencoded and sent as POST data ...
[ "Send", "a", "POST", "request", "on", "the", "session", "object", "found", "using", "the", "given", "alias" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L550-L607
248,562
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.delete_request
def delete_request( self, alias, uri, data=None, json=None, params=None, headers=None, allow_redirects=None, timeout=None): """ Send a DELETE request on the session object found using the given `a...
python
def delete_request( self, alias, uri, data=None, json=None, params=None, headers=None, allow_redirects=None, timeout=None): session = self._cache.switch(alias) data = self._format_data_according_t...
[ "def", "delete_request", "(", "self", ",", "alias", ",", "uri", ",", "data", "=", "None", ",", "json", "=", "None", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "allow_redirects", "=", "None", ",", "timeout", "=", "None", ")", ":", ...
Send a DELETE request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object in the cache ``uri`` to send the DELETE request to ``json`` a value that will be json encoded and sent as request data if data is not spe...
[ "Send", "a", "DELETE", "request", "on", "the", "session", "object", "found", "using", "the", "given", "alias" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L864-L902
248,563
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.head_request
def head_request( self, alias, uri, headers=None, allow_redirects=None, timeout=None): """ Send a HEAD request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object i...
python
def head_request( self, alias, uri, headers=None, allow_redirects=None, timeout=None): session = self._cache.switch(alias) redir = False if allow_redirects is None else allow_redirects response = self._head_request(session, ...
[ "def", "head_request", "(", "self", ",", "alias", ",", "uri", ",", "headers", "=", "None", ",", "allow_redirects", "=", "None", ",", "timeout", "=", "None", ")", ":", "session", "=", "self", ".", "_cache", ".", "switch", "(", "alias", ")", "redir", "...
Send a HEAD request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object in the cache ``uri`` to send the HEAD request to ``allow_redirects`` Boolean. Set to True if POST/PUT/DELETE redirect following is allowed. ``hea...
[ "Send", "a", "HEAD", "request", "on", "the", "session", "object", "found", "using", "the", "given", "alias" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L937-L961
248,564
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords.options_request
def options_request( self, alias, uri, headers=None, allow_redirects=None, timeout=None): """ Send an OPTIONS request on the session object found using the given `alias` ``alias`` that will be used to identify the Session o...
python
def options_request( self, alias, uri, headers=None, allow_redirects=None, timeout=None): session = self._cache.switch(alias) redir = True if allow_redirects is None else allow_redirects response = self._options_request(sess...
[ "def", "options_request", "(", "self", ",", "alias", ",", "uri", ",", "headers", "=", "None", ",", "allow_redirects", "=", "None", ",", "timeout", "=", "None", ")", ":", "session", "=", "self", ".", "_cache", ".", "switch", "(", "alias", ")", "redir", ...
Send an OPTIONS request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object in the cache ``uri`` to send the OPTIONS request to ``allow_redirects`` Boolean. Set to True if POST/PUT/DELETE redirect following is allowed. ...
[ "Send", "an", "OPTIONS", "request", "on", "the", "session", "object", "found", "using", "the", "given", "alias" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L990-L1015
248,565
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords._get_url
def _get_url(self, session, uri): """ Helper method to get the full url """ url = session.url if uri: slash = '' if uri.startswith('/') else '/' url = "%s%s%s" % (session.url, slash, uri) return url
python
def _get_url(self, session, uri): url = session.url if uri: slash = '' if uri.startswith('/') else '/' url = "%s%s%s" % (session.url, slash, uri) return url
[ "def", "_get_url", "(", "self", ",", "session", ",", "uri", ")", ":", "url", "=", "session", ".", "url", "if", "uri", ":", "slash", "=", "''", "if", "uri", ".", "startswith", "(", "'/'", ")", "else", "'/'", "url", "=", "\"%s%s%s\"", "%", "(", "se...
Helper method to get the full url
[ "Helper", "method", "to", "get", "the", "full", "url" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L1174-L1182
248,566
bulkan/robotframework-requests
src/RequestsLibrary/RequestsKeywords.py
RequestsKeywords._json_pretty_print
def _json_pretty_print(self, content): """ Pretty print a JSON object ``content`` JSON object to pretty print """ temp = json.loads(content) return json.dumps( temp, sort_keys=True, indent=4, separators=( '...
python
def _json_pretty_print(self, content): temp = json.loads(content) return json.dumps( temp, sort_keys=True, indent=4, separators=( ',', ': '))
[ "def", "_json_pretty_print", "(", "self", ",", "content", ")", ":", "temp", "=", "json", ".", "loads", "(", "content", ")", "return", "json", ".", "dumps", "(", "temp", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ",", "separators", "=", "...
Pretty print a JSON object ``content`` JSON object to pretty print
[ "Pretty", "print", "a", "JSON", "object" ]
11baa3277f1cb728712e26d996200703c15254a8
https://github.com/bulkan/robotframework-requests/blob/11baa3277f1cb728712e26d996200703c15254a8/src/RequestsLibrary/RequestsKeywords.py#L1215-L1228
248,567
coddingtonbear/python-myfitnesspal
myfitnesspal/client.py
Client.get_measurements
def get_measurements( self, measurement='Weight', lower_bound=None, upper_bound=None ): """ Returns measurements of a given name between two dates.""" if upper_bound is None: upper_bound = datetime.date.today() if lower_bound is None: lower_bound = upper_bound...
python
def get_measurements( self, measurement='Weight', lower_bound=None, upper_bound=None ): if upper_bound is None: upper_bound = datetime.date.today() if lower_bound is None: lower_bound = upper_bound - datetime.timedelta(days=30) # If they entered the dates in ...
[ "def", "get_measurements", "(", "self", ",", "measurement", "=", "'Weight'", ",", "lower_bound", "=", "None", ",", "upper_bound", "=", "None", ")", ":", "if", "upper_bound", "is", "None", ":", "upper_bound", "=", "datetime", ".", "date", ".", "today", "(",...
Returns measurements of a given name between two dates.
[ "Returns", "measurements", "of", "a", "given", "name", "between", "two", "dates", "." ]
29aad88d31adc025eacaddd3390cb521b6012b73
https://github.com/coddingtonbear/python-myfitnesspal/blob/29aad88d31adc025eacaddd3390cb521b6012b73/myfitnesspal/client.py#L524-L586
248,568
coddingtonbear/python-myfitnesspal
myfitnesspal/client.py
Client.set_measurements
def set_measurements( self, measurement='Weight', value=None ): """ Sets measurement for today's date.""" if value is None: raise ValueError( "Cannot update blank value." ) # get the URL for the main check in page # this is left in bec...
python
def set_measurements( self, measurement='Weight', value=None ): if value is None: raise ValueError( "Cannot update blank value." ) # get the URL for the main check in page # this is left in because we need to parse # the 'measurement' ...
[ "def", "set_measurements", "(", "self", ",", "measurement", "=", "'Weight'", ",", "value", "=", "None", ")", ":", "if", "value", "is", "None", ":", "raise", "ValueError", "(", "\"Cannot update blank value.\"", ")", "# get the URL for the main check in page", "# this...
Sets measurement for today's date.
[ "Sets", "measurement", "for", "today", "s", "date", "." ]
29aad88d31adc025eacaddd3390cb521b6012b73
https://github.com/coddingtonbear/python-myfitnesspal/blob/29aad88d31adc025eacaddd3390cb521b6012b73/myfitnesspal/client.py#L588-L667
248,569
coddingtonbear/python-myfitnesspal
myfitnesspal/client.py
Client.get_measurement_id_options
def get_measurement_id_options(self): """ Returns list of measurement choices.""" # get the URL for the main check in page document = self._get_document_for_url( self._get_url_for_measurements() ) # gather the IDs for all measurement types measurement_ids = s...
python
def get_measurement_id_options(self): # get the URL for the main check in page document = self._get_document_for_url( self._get_url_for_measurements() ) # gather the IDs for all measurement types measurement_ids = self._get_measurement_ids(document) return me...
[ "def", "get_measurement_id_options", "(", "self", ")", ":", "# get the URL for the main check in page", "document", "=", "self", ".", "_get_document_for_url", "(", "self", ".", "_get_url_for_measurements", "(", ")", ")", "# gather the IDs for all measurement types", "measurem...
Returns list of measurement choices.
[ "Returns", "list", "of", "measurement", "choices", "." ]
29aad88d31adc025eacaddd3390cb521b6012b73
https://github.com/coddingtonbear/python-myfitnesspal/blob/29aad88d31adc025eacaddd3390cb521b6012b73/myfitnesspal/client.py#L709-L718
248,570
joerick/pyinstrument
pyinstrument/__main__.py
file_supports_color
def file_supports_color(file_obj): """ Returns True if the running system's terminal supports color. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py """ plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or ...
python
def file_supports_color(file_obj): plat = sys.platform supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ) is_a_tty = file_is_a_tty(file_obj) return (supported_platform and is_a_tty)
[ "def", "file_supports_color", "(", "file_obj", ")", ":", "plat", "=", "sys", ".", "platform", "supported_platform", "=", "plat", "!=", "'Pocket PC'", "and", "(", "plat", "!=", "'win32'", "or", "'ANSICON'", "in", "os", ".", "environ", ")", "is_a_tty", "=", ...
Returns True if the running system's terminal supports color. Borrowed from Django https://github.com/django/django/blob/master/django/core/management/color.py
[ "Returns", "True", "if", "the", "running", "system", "s", "terminal", "supports", "color", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/__main__.py#L198-L211
248,571
joerick/pyinstrument
pyinstrument/__main__.py
load_report
def load_report(identifier=None): ''' Returns the session referred to by identifier ''' path = os.path.join( report_dir(), identifier + '.pyireport' ) return ProfilerSession.load(path)
python
def load_report(identifier=None): ''' Returns the session referred to by identifier ''' path = os.path.join( report_dir(), identifier + '.pyireport' ) return ProfilerSession.load(path)
[ "def", "load_report", "(", "identifier", "=", "None", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "report_dir", "(", ")", ",", "identifier", "+", "'.pyireport'", ")", "return", "ProfilerSession", ".", "load", "(", "path", ")" ]
Returns the session referred to by identifier
[ "Returns", "the", "session", "referred", "to", "by", "identifier" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/__main__.py#L245-L253
248,572
joerick/pyinstrument
pyinstrument/__main__.py
save_report
def save_report(session): ''' Saves the session to a temp file, and returns that path. Also prunes the number of reports to 10 so there aren't loads building up. ''' # prune this folder to contain the last 10 sessions previous_reports = glob.glob(os.path.join(report_dir(), '*.pyireport')) pr...
python
def save_report(session): ''' Saves the session to a temp file, and returns that path. Also prunes the number of reports to 10 so there aren't loads building up. ''' # prune this folder to contain the last 10 sessions previous_reports = glob.glob(os.path.join(report_dir(), '*.pyireport')) pr...
[ "def", "save_report", "(", "session", ")", ":", "# prune this folder to contain the last 10 sessions", "previous_reports", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "report_dir", "(", ")", ",", "'*.pyireport'", ")", ")", "previous_reports...
Saves the session to a temp file, and returns that path. Also prunes the number of reports to 10 so there aren't loads building up.
[ "Saves", "the", "session", "to", "a", "temp", "file", "and", "returns", "that", "path", ".", "Also", "prunes", "the", "number", "of", "reports", "to", "10", "so", "there", "aren", "t", "loads", "building", "up", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/__main__.py#L255-L274
248,573
joerick/pyinstrument
pyinstrument/session.py
ProfilerSession.root_frame
def root_frame(self, trim_stem=True): ''' Parses the internal frame records and returns a tree of Frame objects ''' root_frame = None frame_stack = [] for frame_tuple in self.frame_records: identifier_stack = frame_tuple[0] time = frame_tuple[1]...
python
def root_frame(self, trim_stem=True): ''' Parses the internal frame records and returns a tree of Frame objects ''' root_frame = None frame_stack = [] for frame_tuple in self.frame_records: identifier_stack = frame_tuple[0] time = frame_tuple[1]...
[ "def", "root_frame", "(", "self", ",", "trim_stem", "=", "True", ")", ":", "root_frame", "=", "None", "frame_stack", "=", "[", "]", "for", "frame_tuple", "in", "self", ".", "frame_records", ":", "identifier_stack", "=", "frame_tuple", "[", "0", "]", "time"...
Parses the internal frame records and returns a tree of Frame objects
[ "Parses", "the", "internal", "frame", "records", "and", "returns", "a", "tree", "of", "Frame", "objects" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/session.py#L52-L95
248,574
joerick/pyinstrument
pyinstrument/frame.py
BaseFrame.remove_from_parent
def remove_from_parent(self): ''' Removes this frame from its parent, and nulls the parent link ''' if self.parent: self.parent._children.remove(self) self.parent._invalidate_time_caches() self.parent = None
python
def remove_from_parent(self): ''' Removes this frame from its parent, and nulls the parent link ''' if self.parent: self.parent._children.remove(self) self.parent._invalidate_time_caches() self.parent = None
[ "def", "remove_from_parent", "(", "self", ")", ":", "if", "self", ".", "parent", ":", "self", ".", "parent", ".", "_children", ".", "remove", "(", "self", ")", "self", ".", "parent", ".", "_invalidate_time_caches", "(", ")", "self", ".", "parent", "=", ...
Removes this frame from its parent, and nulls the parent link
[ "Removes", "this", "frame", "from", "its", "parent", "and", "nulls", "the", "parent", "link" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/frame.py#L11-L18
248,575
joerick/pyinstrument
pyinstrument/frame.py
Frame.add_child
def add_child(self, frame, after=None): ''' Adds a child frame, updating the parent link. Optionally, insert the frame in a specific position by passing the frame to insert this one after. ''' frame.remove_from_parent() frame.parent = self if after is None...
python
def add_child(self, frame, after=None): ''' Adds a child frame, updating the parent link. Optionally, insert the frame in a specific position by passing the frame to insert this one after. ''' frame.remove_from_parent() frame.parent = self if after is None...
[ "def", "add_child", "(", "self", ",", "frame", ",", "after", "=", "None", ")", ":", "frame", ".", "remove_from_parent", "(", ")", "frame", ".", "parent", "=", "self", "if", "after", "is", "None", ":", "self", ".", "_children", ".", "append", "(", "fr...
Adds a child frame, updating the parent link. Optionally, insert the frame in a specific position by passing the frame to insert this one after.
[ "Adds", "a", "child", "frame", "updating", "the", "parent", "link", ".", "Optionally", "insert", "the", "frame", "in", "a", "specific", "position", "by", "passing", "the", "frame", "to", "insert", "this", "one", "after", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/frame.py#L99-L113
248,576
joerick/pyinstrument
pyinstrument/frame.py
Frame.add_children
def add_children(self, frames, after=None): ''' Convenience method to add multiple frames at once. ''' if after is not None: # if there's an 'after' parameter, add the frames in reverse so the order is # preserved. for frame in reversed(frames): ...
python
def add_children(self, frames, after=None): ''' Convenience method to add multiple frames at once. ''' if after is not None: # if there's an 'after' parameter, add the frames in reverse so the order is # preserved. for frame in reversed(frames): ...
[ "def", "add_children", "(", "self", ",", "frames", ",", "after", "=", "None", ")", ":", "if", "after", "is", "not", "None", ":", "# if there's an 'after' parameter, add the frames in reverse so the order is", "# preserved.", "for", "frame", "in", "reversed", "(", "f...
Convenience method to add multiple frames at once.
[ "Convenience", "method", "to", "add", "multiple", "frames", "at", "once", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/frame.py#L115-L126
248,577
joerick/pyinstrument
pyinstrument/frame.py
Frame.file_path_short
def file_path_short(self): """ Return the path resolved against the closest entry in sys.path """ if not hasattr(self, '_file_path_short'): if self.file_path: result = None for path in sys.path: # On Windows, if self.file_path and path are...
python
def file_path_short(self): if not hasattr(self, '_file_path_short'): if self.file_path: result = None for path in sys.path: # On Windows, if self.file_path and path are on different drives, relpath # will result in exception, b...
[ "def", "file_path_short", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_file_path_short'", ")", ":", "if", "self", ".", "file_path", ":", "result", "=", "None", "for", "path", "in", "sys", ".", "path", ":", "# On Windows, if self.file...
Return the path resolved against the closest entry in sys.path
[ "Return", "the", "path", "resolved", "against", "the", "closest", "entry", "in", "sys", ".", "path" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/frame.py#L151-L173
248,578
joerick/pyinstrument
pyinstrument/frame.py
FrameGroup.exit_frames
def exit_frames(self): ''' Returns a list of frames whose children include a frame outside of the group ''' if self._exit_frames is None: exit_frames = [] for frame in self.frames: if any(c.group != self for c in frame.children): ...
python
def exit_frames(self): ''' Returns a list of frames whose children include a frame outside of the group ''' if self._exit_frames is None: exit_frames = [] for frame in self.frames: if any(c.group != self for c in frame.children): ...
[ "def", "exit_frames", "(", "self", ")", ":", "if", "self", ".", "_exit_frames", "is", "None", ":", "exit_frames", "=", "[", "]", "for", "frame", "in", "self", ".", "frames", ":", "if", "any", "(", "c", ".", "group", "!=", "self", "for", "c", "in", ...
Returns a list of frames whose children include a frame outside of the group
[ "Returns", "a", "list", "of", "frames", "whose", "children", "include", "a", "frame", "outside", "of", "the", "group" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/frame.py#L286-L297
248,579
joerick/pyinstrument
pyinstrument/profiler.py
Profiler.first_interesting_frame
def first_interesting_frame(self): """ Traverse down the frame hierarchy until a frame is found with more than one child """ root_frame = self.root_frame() frame = root_frame while len(frame.children) <= 1: if frame.children: frame = frame.chi...
python
def first_interesting_frame(self): root_frame = self.root_frame() frame = root_frame while len(frame.children) <= 1: if frame.children: frame = frame.children[0] else: # there are no branches return root_frame retu...
[ "def", "first_interesting_frame", "(", "self", ")", ":", "root_frame", "=", "self", ".", "root_frame", "(", ")", "frame", "=", "root_frame", "while", "len", "(", "frame", ".", "children", ")", "<=", "1", ":", "if", "frame", ".", "children", ":", "frame",...
Traverse down the frame hierarchy until a frame is found with more than one child
[ "Traverse", "down", "the", "frame", "hierarchy", "until", "a", "frame", "is", "found", "with", "more", "than", "one", "child" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/profiler.py#L119-L133
248,580
joerick/pyinstrument
pyinstrument/processors.py
aggregate_repeated_calls
def aggregate_repeated_calls(frame, options): ''' Converts a timeline into a time-aggregate summary. Adds together calls along the same call stack, so that repeated calls appear as the same frame. Removes time-linearity - frames are sorted according to total time spent. Useful for outputs that dis...
python
def aggregate_repeated_calls(frame, options): ''' Converts a timeline into a time-aggregate summary. Adds together calls along the same call stack, so that repeated calls appear as the same frame. Removes time-linearity - frames are sorted according to total time spent. Useful for outputs that dis...
[ "def", "aggregate_repeated_calls", "(", "frame", ",", "options", ")", ":", "if", "frame", "is", "None", ":", "return", "None", "children_by_identifier", "=", "{", "}", "# iterate over a copy of the children since it's going to mutate while we're iterating", "for", "child", ...
Converts a timeline into a time-aggregate summary. Adds together calls along the same call stack, so that repeated calls appear as the same frame. Removes time-linearity - frames are sorted according to total time spent. Useful for outputs that display a summary of execution (e.g. text and html outputs)
[ "Converts", "a", "timeline", "into", "a", "time", "-", "aggregate", "summary", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/processors.py#L31-L70
248,581
joerick/pyinstrument
pyinstrument/processors.py
merge_consecutive_self_time
def merge_consecutive_self_time(frame, options): ''' Combines consecutive 'self time' frames ''' if frame is None: return None previous_self_time_frame = None for child in frame.children: if isinstance(child, SelfTimeFrame): if previous_self_time_frame: ...
python
def merge_consecutive_self_time(frame, options): ''' Combines consecutive 'self time' frames ''' if frame is None: return None previous_self_time_frame = None for child in frame.children: if isinstance(child, SelfTimeFrame): if previous_self_time_frame: ...
[ "def", "merge_consecutive_self_time", "(", "frame", ",", "options", ")", ":", "if", "frame", "is", "None", ":", "return", "None", "previous_self_time_frame", "=", "None", "for", "child", "in", "frame", ".", "children", ":", "if", "isinstance", "(", "child", ...
Combines consecutive 'self time' frames
[ "Combines", "consecutive", "self", "time", "frames" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/processors.py#L101-L125
248,582
joerick/pyinstrument
pyinstrument/processors.py
remove_unnecessary_self_time_nodes
def remove_unnecessary_self_time_nodes(frame, options): ''' When a frame has only one child, and that is a self-time frame, remove that node, since it's unnecessary - it clutters the output and offers no additional information. ''' if frame is None: return None if len(frame.children) ==...
python
def remove_unnecessary_self_time_nodes(frame, options): ''' When a frame has only one child, and that is a self-time frame, remove that node, since it's unnecessary - it clutters the output and offers no additional information. ''' if frame is None: return None if len(frame.children) ==...
[ "def", "remove_unnecessary_self_time_nodes", "(", "frame", ",", "options", ")", ":", "if", "frame", "is", "None", ":", "return", "None", "if", "len", "(", "frame", ".", "children", ")", "==", "1", "and", "isinstance", "(", "frame", ".", "children", "[", ...
When a frame has only one child, and that is a self-time frame, remove that node, since it's unnecessary - it clutters the output and offers no additional information.
[ "When", "a", "frame", "has", "only", "one", "child", "and", "that", "is", "a", "self", "-", "time", "frame", "remove", "that", "node", "since", "it", "s", "unnecessary", "-", "it", "clutters", "the", "output", "and", "offers", "no", "additional", "inform...
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/processors.py#L128-L144
248,583
joerick/pyinstrument
pyinstrument/renderers/html.py
HTMLRenderer.open_in_browser
def open_in_browser(self, session, output_filename=None): """ Open the rendered HTML in a webbrowser. If output_filename=None (the default), a tempfile is used. The filename of the HTML file is returned. """ if output_filename is None: output_file = tempfil...
python
def open_in_browser(self, session, output_filename=None): if output_filename is None: output_file = tempfile.NamedTemporaryFile(suffix='.html', delete=False) output_filename = output_file.name with codecs.getwriter('utf-8')(output_file) as f: f.write(self.rend...
[ "def", "open_in_browser", "(", "self", ",", "session", ",", "output_filename", "=", "None", ")", ":", "if", "output_filename", "is", "None", ":", "output_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.html'", ",", "delete", "=", "F...
Open the rendered HTML in a webbrowser. If output_filename=None (the default), a tempfile is used. The filename of the HTML file is returned.
[ "Open", "the", "rendered", "HTML", "in", "a", "webbrowser", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/renderers/html.py#L43-L64
248,584
joerick/pyinstrument
setup.py
BuildPyCommand.run
def run(self): '''compile the JS, then run superclass implementation''' if subprocess.call(['npm', '--version']) != 0: raise RuntimeError('npm is required to build the HTML renderer.') self.check_call(['npm', 'install'], cwd=HTML_RENDERER_DIR) self.check_call(['npm', 'run',...
python
def run(self): '''compile the JS, then run superclass implementation''' if subprocess.call(['npm', '--version']) != 0: raise RuntimeError('npm is required to build the HTML renderer.') self.check_call(['npm', 'install'], cwd=HTML_RENDERER_DIR) self.check_call(['npm', 'run',...
[ "def", "run", "(", "self", ")", ":", "if", "subprocess", ".", "call", "(", "[", "'npm'", ",", "'--version'", "]", ")", "!=", "0", ":", "raise", "RuntimeError", "(", "'npm is required to build the HTML renderer.'", ")", "self", ".", "check_call", "(", "[", ...
compile the JS, then run superclass implementation
[ "compile", "the", "JS", "then", "run", "superclass", "implementation" ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/setup.py#L19-L30
248,585
joerick/pyinstrument
pyinstrument/util.py
deprecated
def deprecated(func, *args, **kwargs): ''' Marks a function as deprecated. ''' warnings.warn( '{} is deprecated and should no longer be used.'.format(func), DeprecationWarning, stacklevel=3 ) return func(*args, **kwargs)
python
def deprecated(func, *args, **kwargs): ''' Marks a function as deprecated. ''' warnings.warn( '{} is deprecated and should no longer be used.'.format(func), DeprecationWarning, stacklevel=3 ) return func(*args, **kwargs)
[ "def", "deprecated", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "'{} is deprecated and should no longer be used.'", ".", "format", "(", "func", ")", ",", "DeprecationWarning", ",", "stacklevel", "=", "3", ...
Marks a function as deprecated.
[ "Marks", "a", "function", "as", "deprecated", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/util.py#L18-L25
248,586
joerick/pyinstrument
pyinstrument/util.py
deprecated_option
def deprecated_option(option_name, message=''): ''' Marks an option as deprecated. ''' def caller(func, *args, **kwargs): if option_name in kwargs: warnings.warn( '{} is deprecated. {}'.format(option_name, message), DeprecationWarning, stacklev...
python
def deprecated_option(option_name, message=''): ''' Marks an option as deprecated. ''' def caller(func, *args, **kwargs): if option_name in kwargs: warnings.warn( '{} is deprecated. {}'.format(option_name, message), DeprecationWarning, stacklev...
[ "def", "deprecated_option", "(", "option_name", ",", "message", "=", "''", ")", ":", "def", "caller", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "option_name", "in", "kwargs", ":", "warnings", ".", "warn", "(", "'{} is depr...
Marks an option as deprecated.
[ "Marks", "an", "option", "as", "deprecated", "." ]
cc4f3f6fc1b493d7cd058ecf41ad012e0030a512
https://github.com/joerick/pyinstrument/blob/cc4f3f6fc1b493d7cd058ecf41ad012e0030a512/pyinstrument/util.py#L27-L38
248,587
jrief/django-angular
djng/app_settings.py
AppSettings.THUMBNAIL_OPTIONS
def THUMBNAIL_OPTIONS(self): """ Set the size as a 2-tuple for thumbnailed images after uploading them. """ from django.core.exceptions import ImproperlyConfigured size = self._setting('DJNG_THUMBNAIL_SIZE', (200, 200)) if not (isinstance(size, (list, tuple)) and len(siz...
python
def THUMBNAIL_OPTIONS(self): from django.core.exceptions import ImproperlyConfigured size = self._setting('DJNG_THUMBNAIL_SIZE', (200, 200)) if not (isinstance(size, (list, tuple)) and len(size) == 2 and isinstance(size[0], int) and isinstance(size[1], int)): raise ImproperlyConfigu...
[ "def", "THUMBNAIL_OPTIONS", "(", "self", ")", ":", "from", "django", ".", "core", ".", "exceptions", "import", "ImproperlyConfigured", "size", "=", "self", ".", "_setting", "(", "'DJNG_THUMBNAIL_SIZE'", ",", "(", "200", ",", "200", ")", ")", "if", "not", "...
Set the size as a 2-tuple for thumbnailed images after uploading them.
[ "Set", "the", "size", "as", "a", "2", "-", "tuple", "for", "thumbnailed", "images", "after", "uploading", "them", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/app_settings.py#L20-L29
248,588
jrief/django-angular
djng/forms/angular_base.py
NgWidgetMixin.get_context
def get_context(self, name, value, attrs): """ Some widgets require a modified rendering context, if they contain angular directives. """ context = super(NgWidgetMixin, self).get_context(name, value, attrs) if callable(getattr(self._field, 'update_widget_rendering_context', None)...
python
def get_context(self, name, value, attrs): context = super(NgWidgetMixin, self).get_context(name, value, attrs) if callable(getattr(self._field, 'update_widget_rendering_context', None)): self._field.update_widget_rendering_context(context) return context
[ "def", "get_context", "(", "self", ",", "name", ",", "value", ",", "attrs", ")", ":", "context", "=", "super", "(", "NgWidgetMixin", ",", "self", ")", ".", "get_context", "(", "name", ",", "value", ",", "attrs", ")", "if", "callable", "(", "getattr", ...
Some widgets require a modified rendering context, if they contain angular directives.
[ "Some", "widgets", "require", "a", "modified", "rendering", "context", "if", "they", "contain", "angular", "directives", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L156-L163
248,589
jrief/django-angular
djng/forms/angular_base.py
NgBoundField.errors
def errors(self): """ Returns a TupleErrorList for this field. This overloaded method adds additional error lists to the errors as detected by the form validator. """ if not hasattr(self, '_errors_cache'): self._errors_cache = self.form.get_field_errors(self) ...
python
def errors(self): if not hasattr(self, '_errors_cache'): self._errors_cache = self.form.get_field_errors(self) return self._errors_cache
[ "def", "errors", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_errors_cache'", ")", ":", "self", ".", "_errors_cache", "=", "self", ".", "form", ".", "get_field_errors", "(", "self", ")", "return", "self", ".", "_errors_cache" ]
Returns a TupleErrorList for this field. This overloaded method adds additional error lists to the errors as detected by the form validator.
[ "Returns", "a", "TupleErrorList", "for", "this", "field", ".", "This", "overloaded", "method", "adds", "additional", "error", "lists", "to", "the", "errors", "as", "detected", "by", "the", "form", "validator", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L168-L175
248,590
jrief/django-angular
djng/forms/angular_base.py
NgBoundField.css_classes
def css_classes(self, extra_classes=None): """ Returns a string of space-separated CSS classes for the wrapping element of this input field. """ if hasattr(extra_classes, 'split'): extra_classes = extra_classes.split() extra_classes = set(extra_classes or []) ...
python
def css_classes(self, extra_classes=None): if hasattr(extra_classes, 'split'): extra_classes = extra_classes.split() extra_classes = set(extra_classes or []) # field_css_classes is an optional member of a Form optimized for django-angular field_css_classes = getattr(self.form...
[ "def", "css_classes", "(", "self", ",", "extra_classes", "=", "None", ")", ":", "if", "hasattr", "(", "extra_classes", ",", "'split'", ")", ":", "extra_classes", "=", "extra_classes", ".", "split", "(", ")", "extra_classes", "=", "set", "(", "extra_classes",...
Returns a string of space-separated CSS classes for the wrapping element of this input field.
[ "Returns", "a", "string", "of", "space", "-", "separated", "CSS", "classes", "for", "the", "wrapping", "element", "of", "this", "input", "field", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L177-L203
248,591
jrief/django-angular
djng/forms/angular_base.py
NgFormBaseMixin.get_field_errors
def get_field_errors(self, field): """ Return server side errors. Shall be overridden by derived forms to add their extra errors for AngularJS. """ identifier = format_html('{0}[\'{1}\']', self.form_name, field.name) errors = self.errors.get(field.html_name, []) r...
python
def get_field_errors(self, field): identifier = format_html('{0}[\'{1}\']', self.form_name, field.name) errors = self.errors.get(field.html_name, []) return self.error_class([SafeTuple( (identifier, self.field_error_css_classes, '$pristine', '$pristine', 'invalid', e)) for e in error...
[ "def", "get_field_errors", "(", "self", ",", "field", ")", ":", "identifier", "=", "format_html", "(", "'{0}[\\'{1}\\']'", ",", "self", ".", "form_name", ",", "field", ".", "name", ")", "errors", "=", "self", ".", "errors", ".", "get", "(", "field", ".",...
Return server side errors. Shall be overridden by derived forms to add their extra errors for AngularJS.
[ "Return", "server", "side", "errors", ".", "Shall", "be", "overridden", "by", "derived", "forms", "to", "add", "their", "extra", "errors", "for", "AngularJS", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L330-L338
248,592
jrief/django-angular
djng/forms/angular_base.py
NgFormBaseMixin.update_widget_attrs
def update_widget_attrs(self, bound_field, attrs): """ Updated the widget attributes which shall be added to the widget when rendering this field. """ if bound_field.field.has_subwidgets() is False: widget_classes = getattr(self, 'widget_css_classes', None) if wid...
python
def update_widget_attrs(self, bound_field, attrs): if bound_field.field.has_subwidgets() is False: widget_classes = getattr(self, 'widget_css_classes', None) if widget_classes: if 'class' in attrs: attrs['class'] += ' ' + widget_classes ...
[ "def", "update_widget_attrs", "(", "self", ",", "bound_field", ",", "attrs", ")", ":", "if", "bound_field", ".", "field", ".", "has_subwidgets", "(", ")", "is", "False", ":", "widget_classes", "=", "getattr", "(", "self", ",", "'widget_css_classes'", ",", "N...
Updated the widget attributes which shall be added to the widget when rendering this field.
[ "Updated", "the", "widget", "attributes", "which", "shall", "be", "added", "to", "the", "widget", "when", "rendering", "this", "field", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L354-L365
248,593
jrief/django-angular
djng/forms/angular_base.py
NgFormBaseMixin.rectify_multipart_form_data
def rectify_multipart_form_data(self, data): """ If a widget was converted and the Form data was submitted through a multipart request, then these data fields must be converted to suit the Django Form validation """ for name, field in self.base_fields.items(): try: ...
python
def rectify_multipart_form_data(self, data): for name, field in self.base_fields.items(): try: field.implode_multi_values(name, data) except AttributeError: pass return data
[ "def", "rectify_multipart_form_data", "(", "self", ",", "data", ")", ":", "for", "name", ",", "field", "in", "self", ".", "base_fields", ".", "items", "(", ")", ":", "try", ":", "field", ".", "implode_multi_values", "(", "name", ",", "data", ")", "except...
If a widget was converted and the Form data was submitted through a multipart request, then these data fields must be converted to suit the Django Form validation
[ "If", "a", "widget", "was", "converted", "and", "the", "Form", "data", "was", "submitted", "through", "a", "multipart", "request", "then", "these", "data", "fields", "must", "be", "converted", "to", "suit", "the", "Django", "Form", "validation" ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L380-L390
248,594
jrief/django-angular
djng/forms/angular_base.py
NgFormBaseMixin.rectify_ajax_form_data
def rectify_ajax_form_data(self, data): """ If a widget was converted and the Form data was submitted through an Ajax request, then these data fields must be converted to suit the Django Form validation """ for name, field in self.base_fields.items(): try: ...
python
def rectify_ajax_form_data(self, data): for name, field in self.base_fields.items(): try: data[name] = field.convert_ajax_data(data.get(name, {})) except AttributeError: pass return data
[ "def", "rectify_ajax_form_data", "(", "self", ",", "data", ")", ":", "for", "name", ",", "field", "in", "self", ".", "base_fields", ".", "items", "(", ")", ":", "try", ":", "data", "[", "name", "]", "=", "field", ".", "convert_ajax_data", "(", "data", ...
If a widget was converted and the Form data was submitted through an Ajax request, then these data fields must be converted to suit the Django Form validation
[ "If", "a", "widget", "was", "converted", "and", "the", "Form", "data", "was", "submitted", "through", "an", "Ajax", "request", "then", "these", "data", "fields", "must", "be", "converted", "to", "suit", "the", "Django", "Form", "validation" ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_base.py#L392-L402
248,595
jrief/django-angular
djng/templatetags/djng_tags.py
djng_locale_script
def djng_locale_script(context, default_language='en'): """ Returns a script tag for including the proper locale script in any HTML page. This tag determines the current language with its locale. Usage: <script src="{% static 'node_modules/angular-i18n/' %}{% djng_locale_script %}"></script> ...
python
def djng_locale_script(context, default_language='en'): language = get_language_from_request(context['request']) if not language: language = default_language return format_html('angular-locale_{}.js', language.lower())
[ "def", "djng_locale_script", "(", "context", ",", "default_language", "=", "'en'", ")", ":", "language", "=", "get_language_from_request", "(", "context", "[", "'request'", "]", ")", "if", "not", "language", ":", "language", "=", "default_language", "return", "f...
Returns a script tag for including the proper locale script in any HTML page. This tag determines the current language with its locale. Usage: <script src="{% static 'node_modules/angular-i18n/' %}{% djng_locale_script %}"></script> or, if used with a default language: <script src="{% stati...
[ "Returns", "a", "script", "tag", "for", "including", "the", "proper", "locale", "script", "in", "any", "HTML", "page", ".", "This", "tag", "determines", "the", "current", "language", "with", "its", "locale", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/templatetags/djng_tags.py#L101-L114
248,596
jrief/django-angular
djng/forms/fields.py
DefaultFieldMixin.update_widget_attrs
def update_widget_attrs(self, bound_field, attrs): """ Update the dictionary of attributes used while rendering the input widget """ bound_field.form.update_widget_attrs(bound_field, attrs) widget_classes = self.widget.attrs.get('class', None) if widget_classes: ...
python
def update_widget_attrs(self, bound_field, attrs): bound_field.form.update_widget_attrs(bound_field, attrs) widget_classes = self.widget.attrs.get('class', None) if widget_classes: if 'class' in attrs: attrs['class'] += ' ' + widget_classes else: ...
[ "def", "update_widget_attrs", "(", "self", ",", "bound_field", ",", "attrs", ")", ":", "bound_field", ".", "form", ".", "update_widget_attrs", "(", "bound_field", ",", "attrs", ")", "widget_classes", "=", "self", ".", "widget", ".", "attrs", ".", "get", "(",...
Update the dictionary of attributes used while rendering the input widget
[ "Update", "the", "dictionary", "of", "attributes", "used", "while", "rendering", "the", "input", "widget" ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/fields.py#L100-L111
248,597
jrief/django-angular
djng/forms/fields.py
MultipleChoiceField.implode_multi_values
def implode_multi_values(self, name, data): """ Due to the way Angular organizes it model, when Form data is sent via a POST request, then for this kind of widget, the posted data must to be converted into a format suitable for Django's Form validation. """ mkeys = [k for...
python
def implode_multi_values(self, name, data): mkeys = [k for k in data.keys() if k.startswith(name + '.')] mvls = [data.pop(k)[0] for k in mkeys] if mvls: data.setlist(name, mvls)
[ "def", "implode_multi_values", "(", "self", ",", "name", ",", "data", ")", ":", "mkeys", "=", "[", "k", "for", "k", "in", "data", ".", "keys", "(", ")", "if", "k", ".", "startswith", "(", "name", "+", "'.'", ")", "]", "mvls", "=", "[", "data", ...
Due to the way Angular organizes it model, when Form data is sent via a POST request, then for this kind of widget, the posted data must to be converted into a format suitable for Django's Form validation.
[ "Due", "to", "the", "way", "Angular", "organizes", "it", "model", "when", "Form", "data", "is", "sent", "via", "a", "POST", "request", "then", "for", "this", "kind", "of", "widget", "the", "posted", "data", "must", "to", "be", "converted", "into", "a", ...
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/fields.py#L355-L364
248,598
jrief/django-angular
djng/forms/fields.py
MultipleChoiceField.convert_ajax_data
def convert_ajax_data(self, field_data): """ Due to the way Angular organizes it model, when this Form data is sent using Ajax, then for this kind of widget, the sent data has to be converted into a format suitable for Django's Form validation. """ data = [key for key, va...
python
def convert_ajax_data(self, field_data): data = [key for key, val in field_data.items() if val] return data
[ "def", "convert_ajax_data", "(", "self", ",", "field_data", ")", ":", "data", "=", "[", "key", "for", "key", ",", "val", "in", "field_data", ".", "items", "(", ")", "if", "val", "]", "return", "data" ]
Due to the way Angular organizes it model, when this Form data is sent using Ajax, then for this kind of widget, the sent data has to be converted into a format suitable for Django's Form validation.
[ "Due", "to", "the", "way", "Angular", "organizes", "it", "model", "when", "this", "Form", "data", "is", "sent", "using", "Ajax", "then", "for", "this", "kind", "of", "widget", "the", "sent", "data", "has", "to", "be", "converted", "into", "a", "format", ...
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/fields.py#L366-L373
248,599
jrief/django-angular
djng/middleware.py
AngularUrlMiddleware.process_request
def process_request(self, request): """ Reads url name, args, kwargs from GET parameters, reverses the url and resolves view function Returns the result of resolved view function, called with provided args and kwargs Since the view function is called directly, it isn't ran through middle...
python
def process_request(self, request): if request.path == self.ANGULAR_REVERSE: url_name = request.GET.get('djng_url_name') url_args = request.GET.getlist('djng_url_args', []) url_kwargs = {} # Remove falsy values (empty strings) url_args = filter(lambda...
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "if", "request", ".", "path", "==", "self", ".", "ANGULAR_REVERSE", ":", "url_name", "=", "request", ".", "GET", ".", "get", "(", "'djng_url_name'", ")", "url_args", "=", "request", ".", "G...
Reads url name, args, kwargs from GET parameters, reverses the url and resolves view function Returns the result of resolved view function, called with provided args and kwargs Since the view function is called directly, it isn't ran through middlewares, so the middlewares must be added manually...
[ "Reads", "url", "name", "args", "kwargs", "from", "GET", "parameters", "reverses", "the", "url", "and", "resolves", "view", "function", "Returns", "the", "result", "of", "resolved", "view", "function", "called", "with", "provided", "args", "and", "kwargs", "Si...
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/middleware.py#L21-L73