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
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
234,700
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): """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...
[ "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
234,701
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): """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') {...
[ "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
234,702
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): """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 ...
[ "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
234,703
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): """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...
[ "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
234,704
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): """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 ...
[ "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
234,705
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): """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...
[ "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
234,706
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): """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...
[ "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
234,707
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): """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. ...
[ "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
234,708
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): """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', ...
[ "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
234,709
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): """Finds peers in the DHT that can provide a specific value. .. code-block:: python >>> c.dht_findprovs("QmNPXDC6wTXVmZ9Uoc8X1oqxRRJr4f1sDuyQu … mpW2") [{'ID': 'QmaxqKpiYNr62uSFBhxJAMmEMkT6dvc3oHkrZNpH2VMTLZ', ...
[ "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
234,710
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): """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...
[ "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
234,711
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): """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...
[ "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
234,712
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): """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") ...
[ "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
234,713
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): """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, ...
[ "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
234,714
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
234,715
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
234,716
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): """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...
[ "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
234,717
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): """Lists contents of a directory in the MFS. .. code-block:: python >>> c.files_ls("/") {'Entries': [ {'Size': 0, 'Hash': '', 'Name': 'Software', 'Type': 0} ]} Parameters ---------- path : ...
[ "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
234,718
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): """Creates a directory within the MFS. .. code-block:: python >>> c.files_mkdir("/test") b'' Parameters ---------- path : str Filepath within the MFS parents : bool Cr...
[ "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
234,719
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): """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...
[ "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
234,720
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): """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 ...
[ "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
234,721
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): """Writes to a mutable file in the MFS. .. code-block:: python >>> c.files_write("/test/file", io.BytesIO(b"hi"), create=True) b'' Parameters --...
[ "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
234,722
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): """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 ...
[ "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
234,723
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): """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 ...
[ "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
234,724
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): """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 ...
[ "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
234,725
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): """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...
[ "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
234,726
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): """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(...
[ "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
234,727
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): """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))`...
[ "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
234,728
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): """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...
[ "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
234,729
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): """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...
[ "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
234,730
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): """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...
[ "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
234,731
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): """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 :...
[ "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
234,732
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): """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...
[ "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
234,733
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): """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 ------ ...
[ "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
234,734
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 two revisions together, creating a new revision file""" _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
234,735
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): """Revert to a previous version""" _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
234,736
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): """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
[ "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
234,737
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): """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...
[ "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
234,738
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'): """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...
[ "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
234,739
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): """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(...
[ "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
234,740
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): """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, ...
[ "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
234,741
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): """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)
[ "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
234,742
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): """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: ...
[ "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
234,743
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): """ 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...
[ "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
234,744
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): """ Send a GET request on the session object found using the given `alias` ``alias`` that...
[ "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
234,745
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): """ Send a POST request on the session object found using ...
[ "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
234,746
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): """ Send a DELETE request on the session object found using the given `a...
[ "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
234,747
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): """ Send a HEAD request on the session object found using the given `alias` ``alias`` that will be used to identify the Session object i...
[ "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
234,748
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): """ Send an OPTIONS request on the session object found using the given `alias` ``alias`` that will be used to identify the Session o...
[ "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
234,749
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): """ 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
[ "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
234,750
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): """ 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=( '...
[ "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
234,751
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 ): """ 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...
[ "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
234,752
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 ): """ 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...
[ "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
234,753
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): """ 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...
[ "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
234,754
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): """ 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 ...
[ "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
234,755
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
234,756
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
234,757
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
234,758
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
234,759
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
234,760
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
234,761
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): """ 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...
[ "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
234,762
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
234,763
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): """ 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...
[ "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
234,764
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
234,765
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
234,766
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
234,767
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): """ 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...
[ "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
234,768
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
234,769
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
234,770
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
234,771
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): """ 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...
[ "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
234,772
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): """ 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)...
[ "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
234,773
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): """ 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) ...
[ "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
234,774
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): """ 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 []) ...
[ "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
234,775
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): """ 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...
[ "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
234,776
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): """ 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...
[ "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
234,777
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): """ 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: ...
[ "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
234,778
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): """ 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: ...
[ "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
234,779
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'): """ 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> ...
[ "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
234,780
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): """ 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: ...
[ "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
234,781
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): """ 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...
[ "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
234,782
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): """ 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...
[ "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
234,783
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): """ 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...
[ "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
234,784
jrief/django-angular
djng/views/crud.py
NgCRUDView.ng_delete
def ng_delete(self, request, *args, **kwargs): """ Delete object and return it's data in JSON encoding The response is build before the object is actually deleted so that we can still retrieve a serialization in the response even with a m2m relationship """ if 'pk...
python
def ng_delete(self, request, *args, **kwargs): """ Delete object and return it's data in JSON encoding The response is build before the object is actually deleted so that we can still retrieve a serialization in the response even with a m2m relationship """ if 'pk...
[ "def", "ng_delete", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'pk'", "not", "in", "request", ".", "GET", ":", "raise", "NgMissingParameterError", "(", "\"Object id is required to delete.\"", ")", "obj", "=", "...
Delete object and return it's data in JSON encoding The response is build before the object is actually deleted so that we can still retrieve a serialization in the response even with a m2m relationship
[ "Delete", "object", "and", "return", "it", "s", "data", "in", "JSON", "encoding", "The", "response", "is", "build", "before", "the", "object", "is", "actually", "deleted", "so", "that", "we", "can", "still", "retrieve", "a", "serialization", "in", "the", "...
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/views/crud.py#L170-L183
234,785
jrief/django-angular
djng/forms/angular_model.py
NgModelFormMixin._post_clean
def _post_clean(self): """ Rewrite the error dictionary, so that its keys correspond to the model fields. """ super(NgModelFormMixin, self)._post_clean() if self._errors and self.prefix: self._errors = ErrorDict((self.add_prefix(name), value) for name, value in self._...
python
def _post_clean(self): """ Rewrite the error dictionary, so that its keys correspond to the model fields. """ super(NgModelFormMixin, self)._post_clean() if self._errors and self.prefix: self._errors = ErrorDict((self.add_prefix(name), value) for name, value in self._...
[ "def", "_post_clean", "(", "self", ")", ":", "super", "(", "NgModelFormMixin", ",", "self", ")", ".", "_post_clean", "(", ")", "if", "self", ".", "_errors", "and", "self", ".", "prefix", ":", "self", ".", "_errors", "=", "ErrorDict", "(", "(", "self", ...
Rewrite the error dictionary, so that its keys correspond to the model fields.
[ "Rewrite", "the", "error", "dictionary", "so", "that", "its", "keys", "correspond", "to", "the", "model", "fields", "." ]
9f2f8247027173e3b3ad3b245ca299a9c9f31b40
https://github.com/jrief/django-angular/blob/9f2f8247027173e3b3ad3b245ca299a9c9f31b40/djng/forms/angular_model.py#L42-L48
234,786
WoLpH/python-progressbar
progressbar/bar.py
ProgressBar.percentage
def percentage(self): '''Return current percentage, returns None if no max_value is given >>> progress = ProgressBar() >>> progress.max_value = 10 >>> progress.min_value = 0 >>> progress.value = 0 >>> progress.percentage 0.0 >>> >>> progress.value...
python
def percentage(self): '''Return current percentage, returns None if no max_value is given >>> progress = ProgressBar() >>> progress.max_value = 10 >>> progress.min_value = 0 >>> progress.value = 0 >>> progress.percentage 0.0 >>> >>> progress.value...
[ "def", "percentage", "(", "self", ")", ":", "if", "self", ".", "max_value", "is", "None", "or", "self", ".", "max_value", "is", "base", ".", "UnknownLength", ":", "return", "None", "elif", "self", ".", "max_value", ":", "todo", "=", "self", ".", "value...
Return current percentage, returns None if no max_value is given >>> progress = ProgressBar() >>> progress.max_value = 10 >>> progress.min_value = 0 >>> progress.value = 0 >>> progress.percentage 0.0 >>> >>> progress.value = 1 >>> progress.percent...
[ "Return", "current", "percentage", "returns", "None", "if", "no", "max_value", "is", "given" ]
963617a1bb9d81624ecf31f3457185992cd97bfa
https://github.com/WoLpH/python-progressbar/blob/963617a1bb9d81624ecf31f3457185992cd97bfa/progressbar/bar.py#L297-L337
234,787
WoLpH/python-progressbar
examples.py
example
def example(fn): '''Wrap the examples so they generate readable output''' @functools.wraps(fn) def wrapped(): try: sys.stdout.write('Running: %s\n' % fn.__name__) fn() sys.stdout.write('\n') except KeyboardInterrupt: sys.stdout.write('\nSkippi...
python
def example(fn): '''Wrap the examples so they generate readable output''' @functools.wraps(fn) def wrapped(): try: sys.stdout.write('Running: %s\n' % fn.__name__) fn() sys.stdout.write('\n') except KeyboardInterrupt: sys.stdout.write('\nSkippi...
[ "def", "example", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrapped", "(", ")", ":", "try", ":", "sys", ".", "stdout", ".", "write", "(", "'Running: %s\\n'", "%", "fn", ".", "__name__", ")", "fn", "(", ")", "sys...
Wrap the examples so they generate readable output
[ "Wrap", "the", "examples", "so", "they", "generate", "readable", "output" ]
963617a1bb9d81624ecf31f3457185992cd97bfa
https://github.com/WoLpH/python-progressbar/blob/963617a1bb9d81624ecf31f3457185992cd97bfa/examples.py#L16-L31
234,788
rigetti/quantumflow
quantumflow/datasets/__init__.py
load_stdgraphs
def load_stdgraphs(size: int) -> List[nx.Graph]: """Load standard graph validation sets For each size (from 6 to 32 graph nodes) the dataset consists of 100 graphs drawn from the Erdős-Rényi ensemble with edge probability 50%. """ from pkg_resources import resource_stream if size < 6 or si...
python
def load_stdgraphs(size: int) -> List[nx.Graph]: """Load standard graph validation sets For each size (from 6 to 32 graph nodes) the dataset consists of 100 graphs drawn from the Erdős-Rényi ensemble with edge probability 50%. """ from pkg_resources import resource_stream if size < 6 or si...
[ "def", "load_stdgraphs", "(", "size", ":", "int", ")", "->", "List", "[", "nx", ".", "Graph", "]", ":", "from", "pkg_resources", "import", "resource_stream", "if", "size", "<", "6", "or", "size", ">", "32", ":", "raise", "ValueError", "(", "'Size out of ...
Load standard graph validation sets For each size (from 6 to 32 graph nodes) the dataset consists of 100 graphs drawn from the Erdős-Rényi ensemble with edge probability 50%.
[ "Load", "standard", "graph", "validation", "sets" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/datasets/__init__.py#L23-L37
234,789
rigetti/quantumflow
quantumflow/datasets/__init__.py
load_mnist
def load_mnist(size: int = None, border: int = _MNIST_BORDER, blank_corners: bool = False, nums: List[int] = None) \ -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: """Download and rescale the MNIST database of handwritten digits MNIST is a dataset...
python
def load_mnist(size: int = None, border: int = _MNIST_BORDER, blank_corners: bool = False, nums: List[int] = None) \ -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: """Download and rescale the MNIST database of handwritten digits MNIST is a dataset...
[ "def", "load_mnist", "(", "size", ":", "int", "=", "None", ",", "border", ":", "int", "=", "_MNIST_BORDER", ",", "blank_corners", ":", "bool", "=", "False", ",", "nums", ":", "List", "[", "int", "]", "=", "None", ")", "->", "Tuple", "[", "np", ".",...
Download and rescale the MNIST database of handwritten digits MNIST is a dataset of 60,000 28x28 grayscale images handwritten digits, along with a test set of 10,000 images. We use Keras to download and access the dataset. The first invocation of this method may take a while as the dataset has to be do...
[ "Download", "and", "rescale", "the", "MNIST", "database", "of", "handwritten", "digits" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/datasets/__init__.py#L43-L127
234,790
rigetti/quantumflow
quantumflow/backend/tensorflow2bk.py
astensor
def astensor(array: TensorLike) -> BKTensor: """Covert numpy array to tensorflow tensor""" tensor = tf.convert_to_tensor(value=array, dtype=CTYPE) return tensor
python
def astensor(array: TensorLike) -> BKTensor: """Covert numpy array to tensorflow tensor""" tensor = tf.convert_to_tensor(value=array, dtype=CTYPE) return tensor
[ "def", "astensor", "(", "array", ":", "TensorLike", ")", "->", "BKTensor", ":", "tensor", "=", "tf", ".", "convert_to_tensor", "(", "value", "=", "array", ",", "dtype", "=", "CTYPE", ")", "return", "tensor" ]
Covert numpy array to tensorflow tensor
[ "Covert", "numpy", "array", "to", "tensorflow", "tensor" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/backend/tensorflow2bk.py#L74-L77
234,791
rigetti/quantumflow
quantumflow/backend/tensorflow2bk.py
inner
def inner(tensor0: BKTensor, tensor1: BKTensor) -> BKTensor: """Return the inner product between two states""" # Note: Relying on fact that vdot flattens arrays N = rank(tensor0) axes = list(range(N)) return tf.tensordot(tf.math.conj(tensor0), tensor1, axes=(axes, axes))
python
def inner(tensor0: BKTensor, tensor1: BKTensor) -> BKTensor: """Return the inner product between two states""" # Note: Relying on fact that vdot flattens arrays N = rank(tensor0) axes = list(range(N)) return tf.tensordot(tf.math.conj(tensor0), tensor1, axes=(axes, axes))
[ "def", "inner", "(", "tensor0", ":", "BKTensor", ",", "tensor1", ":", "BKTensor", ")", "->", "BKTensor", ":", "# Note: Relying on fact that vdot flattens arrays", "N", "=", "rank", "(", "tensor0", ")", "axes", "=", "list", "(", "range", "(", "N", ")", ")", ...
Return the inner product between two states
[ "Return", "the", "inner", "product", "between", "two", "states" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/backend/tensorflow2bk.py#L92-L97
234,792
rigetti/quantumflow
quantumflow/qaoa.py
graph_cuts
def graph_cuts(graph: nx.Graph) -> np.ndarray: """For the given graph, return the cut value for all binary assignments of the graph. """ N = len(graph) diag_hamiltonian = np.zeros(shape=([2]*N), dtype=np.double) for q0, q1 in graph.edges(): for index, _ in np.ndenumerate(diag_hamiltonia...
python
def graph_cuts(graph: nx.Graph) -> np.ndarray: """For the given graph, return the cut value for all binary assignments of the graph. """ N = len(graph) diag_hamiltonian = np.zeros(shape=([2]*N), dtype=np.double) for q0, q1 in graph.edges(): for index, _ in np.ndenumerate(diag_hamiltonia...
[ "def", "graph_cuts", "(", "graph", ":", "nx", ".", "Graph", ")", "->", "np", ".", "ndarray", ":", "N", "=", "len", "(", "graph", ")", "diag_hamiltonian", "=", "np", ".", "zeros", "(", "shape", "=", "(", "[", "2", "]", "*", "N", ")", ",", "dtype...
For the given graph, return the cut value for all binary assignments of the graph.
[ "For", "the", "given", "graph", "return", "the", "cut", "value", "for", "all", "binary", "assignments", "of", "the", "graph", "." ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/qaoa.py#L68-L81
234,793
rigetti/quantumflow
quantumflow/dagcircuit.py
DAGCircuit.depth
def depth(self, local: bool = True) -> int: """Return the circuit depth. Args: local: If True include local one-qubit gates in depth calculation. Else return the multi-qubit gate depth. """ G = self.graph if not local: def remove_local(da...
python
def depth(self, local: bool = True) -> int: """Return the circuit depth. Args: local: If True include local one-qubit gates in depth calculation. Else return the multi-qubit gate depth. """ G = self.graph if not local: def remove_local(da...
[ "def", "depth", "(", "self", ",", "local", ":", "bool", "=", "True", ")", "->", "int", ":", "G", "=", "self", ".", "graph", "if", "not", "local", ":", "def", "remove_local", "(", "dagc", ":", "DAGCircuit", ")", "->", "Generator", "[", "Operation", ...
Return the circuit depth. Args: local: If True include local one-qubit gates in depth calculation. Else return the multi-qubit gate depth.
[ "Return", "the", "circuit", "depth", "." ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/dagcircuit.py#L97-L113
234,794
rigetti/quantumflow
quantumflow/dagcircuit.py
DAGCircuit.components
def components(self) -> List['DAGCircuit']: """Split DAGCircuit into independent components""" comps = nx.weakly_connected_component_subgraphs(self.graph) return [DAGCircuit(comp) for comp in comps]
python
def components(self) -> List['DAGCircuit']: """Split DAGCircuit into independent components""" comps = nx.weakly_connected_component_subgraphs(self.graph) return [DAGCircuit(comp) for comp in comps]
[ "def", "components", "(", "self", ")", "->", "List", "[", "'DAGCircuit'", "]", ":", "comps", "=", "nx", ".", "weakly_connected_component_subgraphs", "(", "self", ".", "graph", ")", "return", "[", "DAGCircuit", "(", "comp", ")", "for", "comp", "in", "comps"...
Split DAGCircuit into independent components
[ "Split", "DAGCircuit", "into", "independent", "components" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/dagcircuit.py#L124-L127
234,795
rigetti/quantumflow
quantumflow/states.py
zero_state
def zero_state(qubits: Union[int, Qubits]) -> State: """Return the all-zero state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0,) * N] = 1 return State(ket, qubits)
python
def zero_state(qubits: Union[int, Qubits]) -> State: """Return the all-zero state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0,) * N] = 1 return State(ket, qubits)
[ "def", "zero_state", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "State", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "ket", "=", "np", ".", "zeros", "(", "shape", "=", "[", "2", "]", "*", "...
Return the all-zero state on N qubits
[ "Return", "the", "all", "-", "zero", "state", "on", "N", "qubits" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L186-L191
234,796
rigetti/quantumflow
quantumflow/states.py
w_state
def w_state(qubits: Union[int, Qubits]) -> State: """Return a W state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) for n in range(N): idx = np.zeros(shape=N, dtype=int) idx[n] += 1 ket[tuple(idx)] = 1 / sqrt(N) return State(ket, qubits)
python
def w_state(qubits: Union[int, Qubits]) -> State: """Return a W state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) for n in range(N): idx = np.zeros(shape=N, dtype=int) idx[n] += 1 ket[tuple(idx)] = 1 / sqrt(N) return State(ket, qubits)
[ "def", "w_state", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "State", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "ket", "=", "np", ".", "zeros", "(", "shape", "=", "[", "2", "]", "*", "N",...
Return a W state on N qubits
[ "Return", "a", "W", "state", "on", "N", "qubits" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L194-L202
234,797
rigetti/quantumflow
quantumflow/states.py
ghz_state
def ghz_state(qubits: Union[int, Qubits]) -> State: """Return a GHZ state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0, ) * N] = 1 / sqrt(2) ket[(1, ) * N] = 1 / sqrt(2) return State(ket, qubits)
python
def ghz_state(qubits: Union[int, Qubits]) -> State: """Return a GHZ state on N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0, ) * N] = 1 / sqrt(2) ket[(1, ) * N] = 1 / sqrt(2) return State(ket, qubits)
[ "def", "ghz_state", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "State", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "ket", "=", "np", ".", "zeros", "(", "shape", "=", "[", "2", "]", "*", "N...
Return a GHZ state on N qubits
[ "Return", "a", "GHZ", "state", "on", "N", "qubits" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L205-L211
234,798
rigetti/quantumflow
quantumflow/states.py
random_state
def random_state(qubits: Union[int, Qubits]) -> State: """Return a random state from the space of N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.random.normal(size=([2] * N)) \ + 1j * np.random.normal(size=([2] * N)) return State(ket, qubits).normalize()
python
def random_state(qubits: Union[int, Qubits]) -> State: """Return a random state from the space of N qubits""" N, qubits = qubits_count_tuple(qubits) ket = np.random.normal(size=([2] * N)) \ + 1j * np.random.normal(size=([2] * N)) return State(ket, qubits).normalize()
[ "def", "random_state", "(", "qubits", ":", "Union", "[", "int", ",", "Qubits", "]", ")", "->", "State", ":", "N", ",", "qubits", "=", "qubits_count_tuple", "(", "qubits", ")", "ket", "=", "np", ".", "random", ".", "normal", "(", "size", "=", "(", "...
Return a random state from the space of N qubits
[ "Return", "a", "random", "state", "from", "the", "space", "of", "N", "qubits" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L214-L219
234,799
rigetti/quantumflow
quantumflow/states.py
join_states
def join_states(*states: State) -> State: """Join two state vectors into a larger qubit state""" vectors = [ket.vec for ket in states] vec = reduce(outer_product, vectors) return State(vec.tensor, vec.qubits)
python
def join_states(*states: State) -> State: """Join two state vectors into a larger qubit state""" vectors = [ket.vec for ket in states] vec = reduce(outer_product, vectors) return State(vec.tensor, vec.qubits)
[ "def", "join_states", "(", "*", "states", ":", "State", ")", "->", "State", ":", "vectors", "=", "[", "ket", ".", "vec", "for", "ket", "in", "states", "]", "vec", "=", "reduce", "(", "outer_product", ",", "vectors", ")", "return", "State", "(", "vec"...
Join two state vectors into a larger qubit state
[ "Join", "two", "state", "vectors", "into", "a", "larger", "qubit", "state" ]
13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L225-L229