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
partition
stringclasses
1 value
ponty/psidialogs
psidialogs/api/tkfiledialog_api.py
askopenfile
def askopenfile(mode="r", **options): "Ask for a filename to open, and returned the opened file" filename = askopenfilename(**options) if filename: return open(filename, mode) return None
python
def askopenfile(mode="r", **options): "Ask for a filename to open, and returned the opened file" filename = askopenfilename(**options) if filename: return open(filename, mode) return None
[ "def", "askopenfile", "(", "mode", "=", "\"r\"", ",", "**", "options", ")", ":", "\"Ask for a filename to open, and returned the opened file\"", "filename", "=", "askopenfilename", "(", "**", "options", ")", "if", "filename", ":", "return", "open", "(", "filename", ...
Ask for a filename to open, and returned the opened file
[ "Ask", "for", "a", "filename", "to", "open", "and", "returned", "the", "opened", "file" ]
e385ab6b48cb43af52b810a1bf76a8135f4585b8
https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/tkfiledialog_api.py#L4-L10
train
ponty/psidialogs
psidialogs/api/tkfiledialog_api.py
askopenfiles
def askopenfiles(mode="r", **options): """Ask for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected """ files = askopenfilenames(**options) if files: ofiles = [] for filename in files: ofi...
python
def askopenfiles(mode="r", **options): """Ask for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected """ files = askopenfilenames(**options) if files: ofiles = [] for filename in files: ofi...
[ "def", "askopenfiles", "(", "mode", "=", "\"r\"", ",", "**", "options", ")", ":", "files", "=", "askopenfilenames", "(", "**", "options", ")", "if", "files", ":", "ofiles", "=", "[", "]", "for", "filename", "in", "files", ":", "ofiles", ".", "append", ...
Ask for multiple filenames and return the open file objects returns a list of open file objects or an empty list if cancel selected
[ "Ask", "for", "multiple", "filenames", "and", "return", "the", "open", "file", "objects" ]
e385ab6b48cb43af52b810a1bf76a8135f4585b8
https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/tkfiledialog_api.py#L13-L27
train
ponty/psidialogs
psidialogs/api/tkfiledialog_api.py
asksaveasfile
def asksaveasfile(mode="w", **options): "Ask for a filename to save as, and returned the opened file" filename = asksaveasfilename(**options) if filename: return open(filename, mode) return None
python
def asksaveasfile(mode="w", **options): "Ask for a filename to save as, and returned the opened file" filename = asksaveasfilename(**options) if filename: return open(filename, mode) return None
[ "def", "asksaveasfile", "(", "mode", "=", "\"w\"", ",", "**", "options", ")", ":", "\"Ask for a filename to save as, and returned the opened file\"", "filename", "=", "asksaveasfilename", "(", "**", "options", ")", "if", "filename", ":", "return", "open", "(", "file...
Ask for a filename to save as, and returned the opened file
[ "Ask", "for", "a", "filename", "to", "save", "as", "and", "returned", "the", "opened", "file" ]
e385ab6b48cb43af52b810a1bf76a8135f4585b8
https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/tkfiledialog_api.py#L30-L36
train
clbarnes/coordinates
coordinates/classes.py
spaced_coordinate
def spaced_coordinate(name, keys, ordered=True): """ Create a subclass of Coordinate, instances of which must have exactly the given keys. Parameters ---------- name : str Name of the new class keys : sequence Keys which instances must exclusively have ordered : bool ...
python
def spaced_coordinate(name, keys, ordered=True): """ Create a subclass of Coordinate, instances of which must have exactly the given keys. Parameters ---------- name : str Name of the new class keys : sequence Keys which instances must exclusively have ordered : bool ...
[ "def", "spaced_coordinate", "(", "name", ",", "keys", ",", "ordered", "=", "True", ")", ":", "def", "validate", "(", "self", ")", ":", "if", "set", "(", "keys", ")", "!=", "set", "(", "self", ")", ":", "raise", "ValueError", "(", "'{} needs keys {} and...
Create a subclass of Coordinate, instances of which must have exactly the given keys. Parameters ---------- name : str Name of the new class keys : sequence Keys which instances must exclusively have ordered : bool Whether to set the class' ``default_order`` based on the ord...
[ "Create", "a", "subclass", "of", "Coordinate", "instances", "of", "which", "must", "have", "exactly", "the", "given", "keys", "." ]
2f5b3ca855da069204407f4bb7e8eb5d4835dfe0
https://github.com/clbarnes/coordinates/blob/2f5b3ca855da069204407f4bb7e8eb5d4835dfe0/coordinates/classes.py#L289-L312
train
clbarnes/coordinates
coordinates/classes.py
MathDict.norm
def norm(self, order=2): """Find the vector norm, with the given order, of the values""" return (sum(val**order for val in abs(self).values()))**(1/order)
python
def norm(self, order=2): """Find the vector norm, with the given order, of the values""" return (sum(val**order for val in abs(self).values()))**(1/order)
[ "def", "norm", "(", "self", ",", "order", "=", "2", ")", ":", "return", "(", "sum", "(", "val", "**", "order", "for", "val", "in", "abs", "(", "self", ")", ".", "values", "(", ")", ")", ")", "**", "(", "1", "/", "order", ")" ]
Find the vector norm, with the given order, of the values
[ "Find", "the", "vector", "norm", "with", "the", "given", "order", "of", "the", "values" ]
2f5b3ca855da069204407f4bb7e8eb5d4835dfe0
https://github.com/clbarnes/coordinates/blob/2f5b3ca855da069204407f4bb7e8eb5d4835dfe0/coordinates/classes.py#L175-L177
train
Xaroth/libzfs-python
libzfs/utils/jsonify.py
jsonify
def jsonify(o, max_depth=-1, parse_enums=PARSE_KEEP): """ Walks through object o, and attempts to get the property instead of the key, if available. This means that for our VDev objects we can easily get a dict of all the 'parsed' values. """ if max_depth == 0: return o max_depth -= 1 ...
python
def jsonify(o, max_depth=-1, parse_enums=PARSE_KEEP): """ Walks through object o, and attempts to get the property instead of the key, if available. This means that for our VDev objects we can easily get a dict of all the 'parsed' values. """ if max_depth == 0: return o max_depth -= 1 ...
[ "def", "jsonify", "(", "o", ",", "max_depth", "=", "-", "1", ",", "parse_enums", "=", "PARSE_KEEP", ")", ":", "if", "max_depth", "==", "0", ":", "return", "o", "max_depth", "-=", "1", "if", "isinstance", "(", "o", ",", "dict", ")", ":", "keyattrs", ...
Walks through object o, and attempts to get the property instead of the key, if available. This means that for our VDev objects we can easily get a dict of all the 'parsed' values.
[ "Walks", "through", "object", "o", "and", "attempts", "to", "get", "the", "property", "instead", "of", "the", "key", "if", "available", ".", "This", "means", "that", "for", "our", "VDev", "objects", "we", "can", "easily", "get", "a", "dict", "of", "all",...
146e5f28de5971bb6eb64fd82b098c5f302f0b33
https://github.com/Xaroth/libzfs-python/blob/146e5f28de5971bb6eb64fd82b098c5f302f0b33/libzfs/utils/jsonify.py#L25-L52
train
gitenberg-dev/gitberg
gitenberg/make.py
NewFilesHandler.copy_files
def copy_files(self): """ Copy the LICENSE and CONTRIBUTING files to each folder repo Generate covers if needed. Dump the metadata. """ files = [u'LICENSE', u'CONTRIBUTING.rst'] this_dir = dirname(abspath(__file__)) for _file in files: sh.cp( ...
python
def copy_files(self): """ Copy the LICENSE and CONTRIBUTING files to each folder repo Generate covers if needed. Dump the metadata. """ files = [u'LICENSE', u'CONTRIBUTING.rst'] this_dir = dirname(abspath(__file__)) for _file in files: sh.cp( ...
[ "def", "copy_files", "(", "self", ")", ":", "files", "=", "[", "u'LICENSE'", ",", "u'CONTRIBUTING.rst'", "]", "this_dir", "=", "dirname", "(", "abspath", "(", "__file__", ")", ")", "for", "_file", "in", "files", ":", "sh", ".", "cp", "(", "'{0}/templates...
Copy the LICENSE and CONTRIBUTING files to each folder repo Generate covers if needed. Dump the metadata.
[ "Copy", "the", "LICENSE", "and", "CONTRIBUTING", "files", "to", "each", "folder", "repo", "Generate", "covers", "if", "needed", ".", "Dump", "the", "metadata", "." ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/make.py#L47-L70
train
ethan-nelson/osm_diff_tool
osmdt/extract.py
_collate_data
def _collate_data(collation, first_axis, second_axis): """ Collects information about the number of edit actions belonging to keys in a supplied dictionary of object or changeset ids. Parameters ---------- collation : dict A dictionary of OpenStreetMap object or changeset ids. firs...
python
def _collate_data(collation, first_axis, second_axis): """ Collects information about the number of edit actions belonging to keys in a supplied dictionary of object or changeset ids. Parameters ---------- collation : dict A dictionary of OpenStreetMap object or changeset ids. firs...
[ "def", "_collate_data", "(", "collation", ",", "first_axis", ",", "second_axis", ")", ":", "if", "first_axis", "not", "in", "collation", ":", "collation", "[", "first_axis", "]", "=", "{", "}", "collation", "[", "first_axis", "]", "[", "\"create\"", "]", "...
Collects information about the number of edit actions belonging to keys in a supplied dictionary of object or changeset ids. Parameters ---------- collation : dict A dictionary of OpenStreetMap object or changeset ids. first_axis : string An object or changeset key for the collatio...
[ "Collects", "information", "about", "the", "number", "of", "edit", "actions", "belonging", "to", "keys", "in", "a", "supplied", "dictionary", "of", "object", "or", "changeset", "ids", "." ]
d5b083100dedd9427ad23c4be5316f89a55ec8f0
https://github.com/ethan-nelson/osm_diff_tool/blob/d5b083100dedd9427ad23c4be5316f89a55ec8f0/osmdt/extract.py#L1-L27
train
ethan-nelson/osm_diff_tool
osmdt/extract.py
extract_changesets
def extract_changesets(objects): """ Provides information about each changeset present in an OpenStreetMap diff file. Parameters ---------- objects : osc_decoder class A class containing OpenStreetMap object dictionaries. Returns ------- changeset_collation : dict A...
python
def extract_changesets(objects): """ Provides information about each changeset present in an OpenStreetMap diff file. Parameters ---------- objects : osc_decoder class A class containing OpenStreetMap object dictionaries. Returns ------- changeset_collation : dict A...
[ "def", "extract_changesets", "(", "objects", ")", ":", "def", "add_changeset_info", "(", "collation", ",", "axis", ",", "item", ")", ":", "if", "axis", "not", "in", "collation", ":", "collation", "[", "axis", "]", "=", "{", "}", "first", "=", "collation"...
Provides information about each changeset present in an OpenStreetMap diff file. Parameters ---------- objects : osc_decoder class A class containing OpenStreetMap object dictionaries. Returns ------- changeset_collation : dict A dictionary of dictionaries with each changes...
[ "Provides", "information", "about", "each", "changeset", "present", "in", "an", "OpenStreetMap", "diff", "file", "." ]
d5b083100dedd9427ad23c4be5316f89a55ec8f0
https://github.com/ethan-nelson/osm_diff_tool/blob/d5b083100dedd9427ad23c4be5316f89a55ec8f0/osmdt/extract.py#L30-L74
train
xlzd/xtls
xtls/util.py
to_str
def to_str(obj): """ convert a object to string """ if isinstance(obj, str): return obj if isinstance(obj, unicode): return obj.encode('utf-8') return str(obj)
python
def to_str(obj): """ convert a object to string """ if isinstance(obj, str): return obj if isinstance(obj, unicode): return obj.encode('utf-8') return str(obj)
[ "def", "to_str", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "str", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "unicode", ")", ":", "return", "obj", ".", "encode", "(", "'utf-8'", ")", "return", "str", "(", "obj"...
convert a object to string
[ "convert", "a", "object", "to", "string" ]
b3cc0ab24197ecaa39adcad7cd828cada9c04a4e
https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/util.py#L33-L41
train
spotify/gordon-gcp
src/gordon_gcp/clients/gdns.py
GDNSClient.get_managed_zone
def get_managed_zone(self, zone): """Get the GDNS managed zone name for a DNS zone. Google uses custom string names with specific `requirements <https://cloud.google.com/dns/api/v1/managedZones#resource>`_ for storing records. The scheme implemented here chooses a managed zone n...
python
def get_managed_zone(self, zone): """Get the GDNS managed zone name for a DNS zone. Google uses custom string names with specific `requirements <https://cloud.google.com/dns/api/v1/managedZones#resource>`_ for storing records. The scheme implemented here chooses a managed zone n...
[ "def", "get_managed_zone", "(", "self", ",", "zone", ")", ":", "if", "zone", ".", "endswith", "(", "'.in-addr.arpa.'", ")", ":", "return", "self", ".", "reverse_prefix", "+", "'-'", ".", "join", "(", "zone", ".", "split", "(", "'.'", ")", "[", "-", "...
Get the GDNS managed zone name for a DNS zone. Google uses custom string names with specific `requirements <https://cloud.google.com/dns/api/v1/managedZones#resource>`_ for storing records. The scheme implemented here chooses a managed zone name which removes the trailing dot and replac...
[ "Get", "the", "GDNS", "managed", "zone", "name", "for", "a", "DNS", "zone", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gdns.py#L81-L106
train
spotify/gordon-gcp
src/gordon_gcp/clients/gdns.py
GDNSClient.get_records_for_zone
async def get_records_for_zone(self, dns_zone, params=None): """Get all resource record sets for a managed zone, using the DNS zone. Args: dns_zone (str): Desired DNS zone to query. params (dict): (optional) Additional query parameters for HTTP requests to the GD...
python
async def get_records_for_zone(self, dns_zone, params=None): """Get all resource record sets for a managed zone, using the DNS zone. Args: dns_zone (str): Desired DNS zone to query. params (dict): (optional) Additional query parameters for HTTP requests to the GD...
[ "async", "def", "get_records_for_zone", "(", "self", ",", "dns_zone", ",", "params", "=", "None", ")", ":", "managed_zone", "=", "self", ".", "get_managed_zone", "(", "dns_zone", ")", "url", "=", "f'{self._base_url}/managedZones/{managed_zone}/rrsets'", "if", "not",...
Get all resource record sets for a managed zone, using the DNS zone. Args: dns_zone (str): Desired DNS zone to query. params (dict): (optional) Additional query parameters for HTTP requests to the GDNS API. Returns: list of dicts representing rrsets.
[ "Get", "all", "resource", "record", "sets", "for", "a", "managed", "zone", "using", "the", "DNS", "zone", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gdns.py#L108-L141
train
spotify/gordon-gcp
src/gordon_gcp/clients/gdns.py
GDNSClient.is_change_done
async def is_change_done(self, zone, change_id): """Check if a DNS change has completed. Args: zone (str): DNS zone of the change. change_id (str): Identifier of the change. Returns: Boolean """ zone_id = self.get_managed_zone(zone) ur...
python
async def is_change_done(self, zone, change_id): """Check if a DNS change has completed. Args: zone (str): DNS zone of the change. change_id (str): Identifier of the change. Returns: Boolean """ zone_id = self.get_managed_zone(zone) ur...
[ "async", "def", "is_change_done", "(", "self", ",", "zone", ",", "change_id", ")", ":", "zone_id", "=", "self", ".", "get_managed_zone", "(", "zone", ")", "url", "=", "f'{self._base_url}/managedZones/{zone_id}/changes/{change_id}'", "resp", "=", "await", "self", "...
Check if a DNS change has completed. Args: zone (str): DNS zone of the change. change_id (str): Identifier of the change. Returns: Boolean
[ "Check", "if", "a", "DNS", "change", "has", "completed", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gdns.py#L143-L155
train
spotify/gordon-gcp
src/gordon_gcp/clients/gdns.py
GDNSClient.publish_changes
async def publish_changes(self, zone, changes): """Post changes to a zone. Args: zone (str): DNS zone of the change. changes (dict): JSON compatible dict of a `Change <https://cloud.google.com/dns/api/v1/changes>`_. Returns: string identifier ...
python
async def publish_changes(self, zone, changes): """Post changes to a zone. Args: zone (str): DNS zone of the change. changes (dict): JSON compatible dict of a `Change <https://cloud.google.com/dns/api/v1/changes>`_. Returns: string identifier ...
[ "async", "def", "publish_changes", "(", "self", ",", "zone", ",", "changes", ")", ":", "zone_id", "=", "self", ".", "get_managed_zone", "(", "zone", ")", "url", "=", "f'{self._base_url}/managedZones/{zone_id}/changes'", "resp", "=", "await", "self", ".", "reques...
Post changes to a zone. Args: zone (str): DNS zone of the change. changes (dict): JSON compatible dict of a `Change <https://cloud.google.com/dns/api/v1/changes>`_. Returns: string identifier of the change.
[ "Post", "changes", "to", "a", "zone", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gdns.py#L157-L170
train
Scille/autobahn-sync
autobahn_sync/session.py
SyncSession.leave
def leave(self, reason=None, message=None): """Actively close this WAMP session. Replace :meth:`autobahn.wamp.interface.IApplicationSession.leave` """ # see https://github.com/crossbario/autobahn-python/issues/605 return self._async_session.leave(reason=reason, log_message=messa...
python
def leave(self, reason=None, message=None): """Actively close this WAMP session. Replace :meth:`autobahn.wamp.interface.IApplicationSession.leave` """ # see https://github.com/crossbario/autobahn-python/issues/605 return self._async_session.leave(reason=reason, log_message=messa...
[ "def", "leave", "(", "self", ",", "reason", "=", "None", ",", "message", "=", "None", ")", ":", "return", "self", ".", "_async_session", ".", "leave", "(", "reason", "=", "reason", ",", "log_message", "=", "message", ")" ]
Actively close this WAMP session. Replace :meth:`autobahn.wamp.interface.IApplicationSession.leave`
[ "Actively", "close", "this", "WAMP", "session", "." ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/session.py#L69-L75
train
Scille/autobahn-sync
autobahn_sync/session.py
SyncSession.call
def call(self, procedure, *args, **kwargs): """Call a remote procedure. Replace :meth:`autobahn.wamp.interface.IApplicationSession.call` """ return self._async_session.call(procedure, *args, **kwargs)
python
def call(self, procedure, *args, **kwargs): """Call a remote procedure. Replace :meth:`autobahn.wamp.interface.IApplicationSession.call` """ return self._async_session.call(procedure, *args, **kwargs)
[ "def", "call", "(", "self", ",", "procedure", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "_async_session", ".", "call", "(", "procedure", ",", "*", "args", ",", "**", "kwargs", ")" ]
Call a remote procedure. Replace :meth:`autobahn.wamp.interface.IApplicationSession.call`
[ "Call", "a", "remote", "procedure", "." ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/session.py#L78-L83
train
Scille/autobahn-sync
autobahn_sync/session.py
SyncSession.register
def register(self, endpoint, procedure=None, options=None): """Register a procedure for remote calling. Replace :meth:`autobahn.wamp.interface.IApplicationSession.register` """ def proxy_endpoint(*args, **kwargs): return self._callbacks_runner.put(partial(endpoint, *args, **...
python
def register(self, endpoint, procedure=None, options=None): """Register a procedure for remote calling. Replace :meth:`autobahn.wamp.interface.IApplicationSession.register` """ def proxy_endpoint(*args, **kwargs): return self._callbacks_runner.put(partial(endpoint, *args, **...
[ "def", "register", "(", "self", ",", "endpoint", ",", "procedure", "=", "None", ",", "options", "=", "None", ")", ":", "def", "proxy_endpoint", "(", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "_callbacks_runner", ".", "put", "("...
Register a procedure for remote calling. Replace :meth:`autobahn.wamp.interface.IApplicationSession.register`
[ "Register", "a", "procedure", "for", "remote", "calling", "." ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/session.py#L86-L93
train
Scille/autobahn-sync
autobahn_sync/session.py
SyncSession.publish
def publish(self, topic, *args, **kwargs): """Publish an event to a topic. Replace :meth:`autobahn.wamp.interface.IApplicationSession.publish` """ return self._async_session.publish(topic, *args, **kwargs)
python
def publish(self, topic, *args, **kwargs): """Publish an event to a topic. Replace :meth:`autobahn.wamp.interface.IApplicationSession.publish` """ return self._async_session.publish(topic, *args, **kwargs)
[ "def", "publish", "(", "self", ",", "topic", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "_async_session", ".", "publish", "(", "topic", ",", "*", "args", ",", "**", "kwargs", ")" ]
Publish an event to a topic. Replace :meth:`autobahn.wamp.interface.IApplicationSession.publish`
[ "Publish", "an", "event", "to", "a", "topic", "." ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/session.py#L100-L105
train
Scille/autobahn-sync
autobahn_sync/session.py
SyncSession.subscribe
def subscribe(self, handler, topic=None, options=None): """Subscribe to a topic for receiving events. Replace :meth:`autobahn.wamp.interface.IApplicationSession.subscribe` """ def proxy_handler(*args, **kwargs): return self._callbacks_runner.put(partial(handler, *args, **kwa...
python
def subscribe(self, handler, topic=None, options=None): """Subscribe to a topic for receiving events. Replace :meth:`autobahn.wamp.interface.IApplicationSession.subscribe` """ def proxy_handler(*args, **kwargs): return self._callbacks_runner.put(partial(handler, *args, **kwa...
[ "def", "subscribe", "(", "self", ",", "handler", ",", "topic", "=", "None", ",", "options", "=", "None", ")", ":", "def", "proxy_handler", "(", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "_callbacks_runner", ".", "put", "(", "...
Subscribe to a topic for receiving events. Replace :meth:`autobahn.wamp.interface.IApplicationSession.subscribe`
[ "Subscribe", "to", "a", "topic", "for", "receiving", "events", "." ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/session.py#L108-L115
train
joeblackwaslike/base58check
base58check/__init__.py
b58encode
def b58encode(val, charset=DEFAULT_CHARSET): """Encode input to base58check encoding. :param bytes val: The value to base58check encode. :param bytes charset: (optional) The character set to use for encoding. :return: the encoded bytestring. :rtype: bytes :raises: TypeError: if `val` is not byt...
python
def b58encode(val, charset=DEFAULT_CHARSET): """Encode input to base58check encoding. :param bytes val: The value to base58check encode. :param bytes charset: (optional) The character set to use for encoding. :return: the encoded bytestring. :rtype: bytes :raises: TypeError: if `val` is not byt...
[ "def", "b58encode", "(", "val", ",", "charset", "=", "DEFAULT_CHARSET", ")", ":", "def", "_b58encode_int", "(", "int_", ",", "default", "=", "bytes", "(", "[", "charset", "[", "0", "]", "]", ")", ")", ":", "if", "not", "int_", "and", "default", ":", ...
Encode input to base58check encoding. :param bytes val: The value to base58check encode. :param bytes charset: (optional) The character set to use for encoding. :return: the encoded bytestring. :rtype: bytes :raises: TypeError: if `val` is not bytes. Usage:: >>> import base58check ...
[ "Encode", "input", "to", "base58check", "encoding", "." ]
417282766e697b8affc926a5f52cb9fcc41978cc
https://github.com/joeblackwaslike/base58check/blob/417282766e697b8affc926a5f52cb9fcc41978cc/base58check/__init__.py#L43-L93
train
joeblackwaslike/base58check
base58check/__init__.py
b58decode
def b58decode(val, charset=DEFAULT_CHARSET): """Decode base58check encoded input to original raw bytes. :param bytes val: The value to base58cheeck decode. :param bytes charset: (optional) The character set to use for decoding. :return: the decoded bytes. :rtype: bytes Usage:: >>> impor...
python
def b58decode(val, charset=DEFAULT_CHARSET): """Decode base58check encoded input to original raw bytes. :param bytes val: The value to base58cheeck decode. :param bytes charset: (optional) The character set to use for decoding. :return: the decoded bytes. :rtype: bytes Usage:: >>> impor...
[ "def", "b58decode", "(", "val", ",", "charset", "=", "DEFAULT_CHARSET", ")", ":", "def", "_b58decode_int", "(", "val", ")", ":", "output", "=", "0", "for", "char", "in", "val", ":", "output", "=", "output", "*", "base", "+", "charset", ".", "index", ...
Decode base58check encoded input to original raw bytes. :param bytes val: The value to base58cheeck decode. :param bytes charset: (optional) The character set to use for decoding. :return: the decoded bytes. :rtype: bytes Usage:: >>> import base58check >>> base58check.b58decode('\x00v...
[ "Decode", "base58check", "encoded", "input", "to", "original", "raw", "bytes", "." ]
417282766e697b8affc926a5f52cb9fcc41978cc
https://github.com/joeblackwaslike/base58check/blob/417282766e697b8affc926a5f52cb9fcc41978cc/base58check/__init__.py#L96-L141
train
zourtney/gpiocrust
gpiocrust/raspberry_pi.py
InputPin.wait_for_edge
def wait_for_edge(self): """ This will remove remove any callbacks you might have specified """ GPIO.remove_event_detect(self._pin) GPIO.wait_for_edge(self._pin, self._edge)
python
def wait_for_edge(self): """ This will remove remove any callbacks you might have specified """ GPIO.remove_event_detect(self._pin) GPIO.wait_for_edge(self._pin, self._edge)
[ "def", "wait_for_edge", "(", "self", ")", ":", "GPIO", ".", "remove_event_detect", "(", "self", ".", "_pin", ")", "GPIO", ".", "wait_for_edge", "(", "self", ".", "_pin", ",", "self", ".", "_edge", ")" ]
This will remove remove any callbacks you might have specified
[ "This", "will", "remove", "remove", "any", "callbacks", "you", "might", "have", "specified" ]
4973d467754c50510647ddf855fdc7a73be8a5f6
https://github.com/zourtney/gpiocrust/blob/4973d467754c50510647ddf855fdc7a73be8a5f6/gpiocrust/raspberry_pi.py#L148-L153
train
indietyp/django-automated-logging
automated_logging/signals/request.py
request_finished_callback
def request_finished_callback(sender, **kwargs): """This function logs if the user acceses the page""" logger = logging.getLogger(__name__) level = settings.AUTOMATED_LOGGING['loglevel']['request'] user = get_current_user() uri, application, method, status = get_current_environ() excludes = se...
python
def request_finished_callback(sender, **kwargs): """This function logs if the user acceses the page""" logger = logging.getLogger(__name__) level = settings.AUTOMATED_LOGGING['loglevel']['request'] user = get_current_user() uri, application, method, status = get_current_environ() excludes = se...
[ "def", "request_finished_callback", "(", "sender", ",", "**", "kwargs", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "level", "=", "settings", ".", "AUTOMATED_LOGGING", "[", "'loglevel'", "]", "[", "'request'", "]", "user", "="...
This function logs if the user acceses the page
[ "This", "function", "logs", "if", "the", "user", "acceses", "the", "page" ]
095dfc6df62dca45f7db4516bc35e52085d0a01c
https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/request.py#L20-L48
train
indietyp/django-automated-logging
automated_logging/signals/request.py
request_exception
def request_exception(sender, request, **kwargs): """ Automated request exception logging. The function can also return an WSGIRequest exception, which does not supply either status_code or reason_phrase. """ if not isinstance(request, WSGIRequest): logger = logging.getLogger(__name__) ...
python
def request_exception(sender, request, **kwargs): """ Automated request exception logging. The function can also return an WSGIRequest exception, which does not supply either status_code or reason_phrase. """ if not isinstance(request, WSGIRequest): logger = logging.getLogger(__name__) ...
[ "def", "request_exception", "(", "sender", ",", "request", ",", "**", "kwargs", ")", ":", "if", "not", "isinstance", "(", "request", ",", "WSGIRequest", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "level", "=", "CRITICAL", ...
Automated request exception logging. The function can also return an WSGIRequest exception, which does not supply either status_code or reason_phrase.
[ "Automated", "request", "exception", "logging", "." ]
095dfc6df62dca45f7db4516bc35e52085d0a01c
https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/request.py#L52-L68
train
gitenberg-dev/gitberg
gitenberg/util/pg.py
source_start
def source_start(base='', book_id='book'): """ chooses a starting source file in the 'base' directory for id = book_id """ repo_htm_path = "{book_id}-h/{book_id}-h.htm".format(book_id=book_id) possible_paths = ["book.asciidoc", repo_htm_path, "{}-0.tx...
python
def source_start(base='', book_id='book'): """ chooses a starting source file in the 'base' directory for id = book_id """ repo_htm_path = "{book_id}-h/{book_id}-h.htm".format(book_id=book_id) possible_paths = ["book.asciidoc", repo_htm_path, "{}-0.tx...
[ "def", "source_start", "(", "base", "=", "''", ",", "book_id", "=", "'book'", ")", ":", "repo_htm_path", "=", "\"{book_id}-h/{book_id}-h.htm\"", ".", "format", "(", "book_id", "=", "book_id", ")", "possible_paths", "=", "[", "\"book.asciidoc\"", ",", "repo_htm_p...
chooses a starting source file in the 'base' directory for id = book_id
[ "chooses", "a", "starting", "source", "file", "in", "the", "base", "directory", "for", "id", "=", "book_id" ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/util/pg.py#L3-L24
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
pretty_dump
def pretty_dump(fn): """ Decorator used to output prettified JSON. ``response.content_type`` is set to ``application/json; charset=utf-8``. Args: fn (fn pointer): Function returning any basic python data structure. Returns: str: Data converted to prettified JSON. """ @wrap...
python
def pretty_dump(fn): """ Decorator used to output prettified JSON. ``response.content_type`` is set to ``application/json; charset=utf-8``. Args: fn (fn pointer): Function returning any basic python data structure. Returns: str: Data converted to prettified JSON. """ @wrap...
[ "def", "pretty_dump", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "pretty_dump_wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "response", ".", "content_type", "=", "\"application/json; charset=utf-8\"", "return", "json", ".", "dumps...
Decorator used to output prettified JSON. ``response.content_type`` is set to ``application/json; charset=utf-8``. Args: fn (fn pointer): Function returning any basic python data structure. Returns: str: Data converted to prettified JSON.
[ "Decorator", "used", "to", "output", "prettified", "JSON", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L22-L46
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
decode_json_body
def decode_json_body(): """ Decode ``bottle.request.body`` to JSON. Returns: obj: Structure decoded by ``json.loads()``. Raises: HTTPError: 400 in case the data was malformed. """ raw_data = request.body.read() try: return json.loads(raw_data) except ValueError...
python
def decode_json_body(): """ Decode ``bottle.request.body`` to JSON. Returns: obj: Structure decoded by ``json.loads()``. Raises: HTTPError: 400 in case the data was malformed. """ raw_data = request.body.read() try: return json.loads(raw_data) except ValueError...
[ "def", "decode_json_body", "(", ")", ":", "raw_data", "=", "request", ".", "body", ".", "read", "(", ")", "try", ":", "return", "json", ".", "loads", "(", "raw_data", ")", "except", "ValueError", "as", "e", ":", "raise", "HTTPError", "(", "400", ",", ...
Decode ``bottle.request.body`` to JSON. Returns: obj: Structure decoded by ``json.loads()``. Raises: HTTPError: 400 in case the data was malformed.
[ "Decode", "bottle", ".", "request", ".", "body", "to", "JSON", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L49-L64
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
handle_type_error
def handle_type_error(fn): """ Convert ``TypeError`` to ``bottle.HTTPError`` with ``400`` code and message about wrong parameters. Raises: HTTPError: 400 in case too many/too little function parameters were \ given. """ @wraps(fn) def handle_type_error_wrapper(*ar...
python
def handle_type_error(fn): """ Convert ``TypeError`` to ``bottle.HTTPError`` with ``400`` code and message about wrong parameters. Raises: HTTPError: 400 in case too many/too little function parameters were \ given. """ @wraps(fn) def handle_type_error_wrapper(*ar...
[ "def", "handle_type_error", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "handle_type_error_wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "def", "any_match", "(", "string_list", ",", "obj", ")", ":", "return", "filter", "(", "...
Convert ``TypeError`` to ``bottle.HTTPError`` with ``400`` code and message about wrong parameters. Raises: HTTPError: 400 in case too many/too little function parameters were \ given.
[ "Convert", "TypeError", "to", "bottle", ".", "HTTPError", "with", "400", "code", "and", "message", "about", "wrong", "parameters", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L91-L119
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
json_to_params
def json_to_params(fn=None, return_json=True): """ Convert JSON in the body of the request to the parameters for the wrapped function. If the JSON is list, add it to ``*args``. If dict, add it to ``**kwargs`` in non-rewrite mode (no key in ``**kwargs`` will be overwritten). If single valu...
python
def json_to_params(fn=None, return_json=True): """ Convert JSON in the body of the request to the parameters for the wrapped function. If the JSON is list, add it to ``*args``. If dict, add it to ``**kwargs`` in non-rewrite mode (no key in ``**kwargs`` will be overwritten). If single valu...
[ "def", "json_to_params", "(", "fn", "=", "None", ",", "return_json", "=", "True", ")", ":", "def", "json_to_params_decorator", "(", "fn", ")", ":", "@", "handle_type_error", "@", "wraps", "(", "fn", ")", "def", "json_to_params_wrapper", "(", "*", "args", "...
Convert JSON in the body of the request to the parameters for the wrapped function. If the JSON is list, add it to ``*args``. If dict, add it to ``**kwargs`` in non-rewrite mode (no key in ``**kwargs`` will be overwritten). If single value, add it to ``*args``. Args: return_json (boo...
[ "Convert", "JSON", "in", "the", "body", "of", "the", "request", "to", "the", "parameters", "for", "the", "wrapped", "function", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L122-L167
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
json_to_data
def json_to_data(fn=None, return_json=True): """ Decode JSON from the request and add it as ``data`` parameter for wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON? """ def json_to_data_decora...
python
def json_to_data(fn=None, return_json=True): """ Decode JSON from the request and add it as ``data`` parameter for wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON? """ def json_to_data_decora...
[ "def", "json_to_data", "(", "fn", "=", "None", ",", "return_json", "=", "True", ")", ":", "def", "json_to_data_decorator", "(", "fn", ")", ":", "@", "handle_type_error", "@", "wraps", "(", "fn", ")", "def", "get_data_wrapper", "(", "*", "args", ",", "**"...
Decode JSON from the request and add it as ``data`` parameter for wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON?
[ "Decode", "JSON", "from", "the", "request", "and", "add", "it", "as", "data", "parameter", "for", "wrapped", "function", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L170-L197
train
Bystroushaak/bottle-rest
src/bottle_rest/__init__.py
form_to_params
def form_to_params(fn=None, return_json=True): """ Convert bottle forms request to parameters for the wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON? """ def forms_to_params_decorator(fn): ...
python
def form_to_params(fn=None, return_json=True): """ Convert bottle forms request to parameters for the wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON? """ def forms_to_params_decorator(fn): ...
[ "def", "form_to_params", "(", "fn", "=", "None", ",", "return_json", "=", "True", ")", ":", "def", "forms_to_params_decorator", "(", "fn", ")", ":", "@", "handle_type_error", "@", "wraps", "(", "fn", ")", "def", "forms_to_params_wrapper", "(", "*", "args", ...
Convert bottle forms request to parameters for the wrapped function. Args: return_json (bool, default True): Should the decorator automatically convert returned value to JSON?
[ "Convert", "bottle", "forms", "request", "to", "parameters", "for", "the", "wrapped", "function", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/src/bottle_rest/__init__.py#L200-L228
train
ethan-nelson/osm_diff_tool
osmdt/fetch.py
fetch
def fetch(sequence, time='hour'): """ Fetch an OpenStreetMap diff file. Parameters ---------- sequence : string or integer Diff file sequence desired. Maximum of 9 characters allowed. The value should follow the two directory and file name structure from the site, e.g. https...
python
def fetch(sequence, time='hour'): """ Fetch an OpenStreetMap diff file. Parameters ---------- sequence : string or integer Diff file sequence desired. Maximum of 9 characters allowed. The value should follow the two directory and file name structure from the site, e.g. https...
[ "def", "fetch", "(", "sequence", ",", "time", "=", "'hour'", ")", ":", "import", "StringIO", "import", "gzip", "import", "requests", "if", "time", "not", "in", "[", "'minute'", ",", "'hour'", ",", "'day'", "]", ":", "raise", "ValueError", "(", "'The supp...
Fetch an OpenStreetMap diff file. Parameters ---------- sequence : string or integer Diff file sequence desired. Maximum of 9 characters allowed. The value should follow the two directory and file name structure from the site, e.g. https://planet.osm.org/replication/hour/NNN/NNN/NNN...
[ "Fetch", "an", "OpenStreetMap", "diff", "file", "." ]
d5b083100dedd9427ad23c4be5316f89a55ec8f0
https://github.com/ethan-nelson/osm_diff_tool/blob/d5b083100dedd9427ad23c4be5316f89a55ec8f0/osmdt/fetch.py#L1-L42
train
indietyp/django-automated-logging
automated_logging/signals/m2m.py
m2m_callback
def m2m_callback(sender, instance, action, reverse, model, pk_set, using, **kwargs): """ Many 2 Many relationship signall receivver. Detect Many 2 Many relationship changes and append these to existing model or create if needed. These get not recorded from the pre_save or post_save method and must ther...
python
def m2m_callback(sender, instance, action, reverse, model, pk_set, using, **kwargs): """ Many 2 Many relationship signall receivver. Detect Many 2 Many relationship changes and append these to existing model or create if needed. These get not recorded from the pre_save or post_save method and must ther...
[ "def", "m2m_callback", "(", "sender", ",", "instance", ",", "action", ",", "reverse", ",", "model", ",", "pk_set", ",", "using", ",", "**", "kwargs", ")", ":", "if", "validate_instance", "(", "instance", ")", "and", "settings", ".", "AUTOMATED_LOGGING", "[...
Many 2 Many relationship signall receivver. Detect Many 2 Many relationship changes and append these to existing model or create if needed. These get not recorded from the pre_save or post_save method and must therefor be received from another method. This method to be precise.
[ "Many", "2", "Many", "relationship", "signall", "receivver", "." ]
095dfc6df62dca45f7db4516bc35e52085d0a01c
https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/m2m.py#L13-L73
train
gitenberg-dev/gitberg
gitenberg/util/tenprintcover.py
Image.font
def font(self, name, properties): """ Return a tuple that contains font properties required for rendering. """ size, slant, weight = (properties) return (name, (self.ty(size), slant, weight))
python
def font(self, name, properties): """ Return a tuple that contains font properties required for rendering. """ size, slant, weight = (properties) return (name, (self.ty(size), slant, weight))
[ "def", "font", "(", "self", ",", "name", ",", "properties", ")", ":", "size", ",", "slant", ",", "weight", "=", "(", "properties", ")", "return", "(", "name", ",", "(", "self", ".", "ty", "(", "size", ")", ",", "slant", ",", "weight", ")", ")" ]
Return a tuple that contains font properties required for rendering.
[ "Return", "a", "tuple", "that", "contains", "font", "properties", "required", "for", "rendering", "." ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/util/tenprintcover.py#L222-L227
train
Xorso/pyalarmdotcom
pyalarmdotcom/pyalarmdotcom.py
Alarmdotcom.async_update
def async_update(self): """Fetch the latest state.""" _LOGGER.debug('Calling update on Alarm.com') response = None if not self._login_info: yield from self.async_login() try: with async_timeout.timeout(10, loop=self._loop): response = yield...
python
def async_update(self): """Fetch the latest state.""" _LOGGER.debug('Calling update on Alarm.com') response = None if not self._login_info: yield from self.async_login() try: with async_timeout.timeout(10, loop=self._loop): response = yield...
[ "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'Calling update on Alarm.com'", ")", "response", "=", "None", "if", "not", "self", ".", "_login_info", ":", "yield", "from", "self", ".", "async_login", "(", ")", "try", ":", "wit...
Fetch the latest state.
[ "Fetch", "the", "latest", "state", "." ]
9d2cfe1968d52bb23533aeda80ca5efbfb692304
https://github.com/Xorso/pyalarmdotcom/blob/9d2cfe1968d52bb23533aeda80ca5efbfb692304/pyalarmdotcom/pyalarmdotcom.py#L209-L249
train
gitenberg-dev/gitberg
gitenberg/push.py
GithubRepo.create_api_handler
def create_api_handler(self): """ Creates an api handler and sets it on self """ try: self.github = github3.login(username=config.data['gh_user'], password=config.data['gh_password']) except KeyError as e: raise config.NotConfigured(e) ...
python
def create_api_handler(self): """ Creates an api handler and sets it on self """ try: self.github = github3.login(username=config.data['gh_user'], password=config.data['gh_password']) except KeyError as e: raise config.NotConfigured(e) ...
[ "def", "create_api_handler", "(", "self", ")", ":", "try", ":", "self", ".", "github", "=", "github3", ".", "login", "(", "username", "=", "config", ".", "data", "[", "'gh_user'", "]", ",", "password", "=", "config", ".", "data", "[", "'gh_password'", ...
Creates an api handler and sets it on self
[ "Creates", "an", "api", "handler", "and", "sets", "it", "on", "self" ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/push.py#L72-L86
train
dstanek/snake-guice
snakeguice/decorators.py
_validate_func_args
def _validate_func_args(func, kwargs): """Validate decorator args when used to decorate a function.""" args, varargs, varkw, defaults = inspect.getargspec(func) if set(kwargs.keys()) != set(args[1:]): # chop off self raise TypeError("decorator kwargs do not match %s()'s kwargs" ...
python
def _validate_func_args(func, kwargs): """Validate decorator args when used to decorate a function.""" args, varargs, varkw, defaults = inspect.getargspec(func) if set(kwargs.keys()) != set(args[1:]): # chop off self raise TypeError("decorator kwargs do not match %s()'s kwargs" ...
[ "def", "_validate_func_args", "(", "func", ",", "kwargs", ")", ":", "args", ",", "varargs", ",", "varkw", ",", "defaults", "=", "inspect", ".", "getargspec", "(", "func", ")", "if", "set", "(", "kwargs", ".", "keys", "(", ")", ")", "!=", "set", "(", ...
Validate decorator args when used to decorate a function.
[ "Validate", "decorator", "args", "when", "used", "to", "decorate", "a", "function", "." ]
d20b62de3ee31e84119c801756398c35ed803fb3
https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/decorators.py#L52-L58
train
dstanek/snake-guice
snakeguice/decorators.py
enclosing_frame
def enclosing_frame(frame=None, level=2): """Get an enclosing frame that skips decorator code""" frame = frame or sys._getframe(level) while frame.f_globals.get('__name__') == __name__: frame = frame.f_back return frame
python
def enclosing_frame(frame=None, level=2): """Get an enclosing frame that skips decorator code""" frame = frame or sys._getframe(level) while frame.f_globals.get('__name__') == __name__: frame = frame.f_back return frame
[ "def", "enclosing_frame", "(", "frame", "=", "None", ",", "level", "=", "2", ")", ":", "frame", "=", "frame", "or", "sys", ".", "_getframe", "(", "level", ")", "while", "frame", ".", "f_globals", ".", "get", "(", "'__name__'", ")", "==", "__name__", ...
Get an enclosing frame that skips decorator code
[ "Get", "an", "enclosing", "frame", "that", "skips", "decorator", "code" ]
d20b62de3ee31e84119c801756398c35ed803fb3
https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/decorators.py#L61-L65
train
spotify/gordon-gcp
src/gordon_gcp/plugins/service/__init__.py
get_event_consumer
def get_event_consumer(config, success_channel, error_channel, metrics, **kwargs): """Get a GPSEventConsumer client. A factory function that validates configuration, creates schema validator and parser clients, creates an auth and a pubsub client, and returns an event consumer (:...
python
def get_event_consumer(config, success_channel, error_channel, metrics, **kwargs): """Get a GPSEventConsumer client. A factory function that validates configuration, creates schema validator and parser clients, creates an auth and a pubsub client, and returns an event consumer (:...
[ "def", "get_event_consumer", "(", "config", ",", "success_channel", ",", "error_channel", ",", "metrics", ",", "**", "kwargs", ")", ":", "builder", "=", "event_consumer", ".", "GPSEventConsumerBuilder", "(", "config", ",", "success_channel", ",", "error_channel", ...
Get a GPSEventConsumer client. A factory function that validates configuration, creates schema validator and parser clients, creates an auth and a pubsub client, and returns an event consumer (:interface:`gordon.interfaces. IRunnable` and :interface:`gordon.interfaces.IMessageHandler`) provider. ...
[ "Get", "a", "GPSEventConsumer", "client", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/service/__init__.py#L34-L60
train
spotify/gordon-gcp
src/gordon_gcp/plugins/service/__init__.py
get_enricher
def get_enricher(config, metrics, **kwargs): """Get a GCEEnricher client. A factory function that validates configuration and returns an enricher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Compute Engine API related configuration. ...
python
def get_enricher(config, metrics, **kwargs): """Get a GCEEnricher client. A factory function that validates configuration and returns an enricher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Compute Engine API related configuration. ...
[ "def", "get_enricher", "(", "config", ",", "metrics", ",", "**", "kwargs", ")", ":", "builder", "=", "enricher", ".", "GCEEnricherBuilder", "(", "config", ",", "metrics", ",", "**", "kwargs", ")", "return", "builder", ".", "build_enricher", "(", ")" ]
Get a GCEEnricher client. A factory function that validates configuration and returns an enricher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Compute Engine API related configuration. metrics (obj): :interface:`IMetricRelay` implementat...
[ "Get", "a", "GCEEnricher", "client", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/service/__init__.py#L63-L80
train
spotify/gordon-gcp
src/gordon_gcp/plugins/service/__init__.py
get_gdns_publisher
def get_gdns_publisher(config, metrics, **kwargs): """Get a GDNSPublisher client. A factory function that validates configuration and returns a publisher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Cloud DNS API related configuration. ...
python
def get_gdns_publisher(config, metrics, **kwargs): """Get a GDNSPublisher client. A factory function that validates configuration and returns a publisher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Cloud DNS API related configuration. ...
[ "def", "get_gdns_publisher", "(", "config", ",", "metrics", ",", "**", "kwargs", ")", ":", "builder", "=", "gdns_publisher", ".", "GDNSPublisherBuilder", "(", "config", ",", "metrics", ",", "**", "kwargs", ")", "return", "builder", ".", "build_publisher", "(",...
Get a GDNSPublisher client. A factory function that validates configuration and returns a publisher client (:interface:`gordon.interfaces.IMessageHandler`) provider. Args: config (dict): Google Cloud DNS API related configuration. metrics (obj): :interface:`IMetricRelay` implementation...
[ "Get", "a", "GDNSPublisher", "client", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/service/__init__.py#L83-L100
train
openvax/mhcnames
mhcnames/normalization.py
normalize_allele_name
def normalize_allele_name(raw_allele, omit_dra1=False, infer_class2_pair=True): """MHC alleles are named with a frustratingly loose system. It's not uncommon to see dozens of different forms for the same allele. Note: this function works with both class I and class II allele names (including alpha/beta...
python
def normalize_allele_name(raw_allele, omit_dra1=False, infer_class2_pair=True): """MHC alleles are named with a frustratingly loose system. It's not uncommon to see dozens of different forms for the same allele. Note: this function works with both class I and class II allele names (including alpha/beta...
[ "def", "normalize_allele_name", "(", "raw_allele", ",", "omit_dra1", "=", "False", ",", "infer_class2_pair", "=", "True", ")", ":", "cache_key", "=", "(", "raw_allele", ",", "omit_dra1", ",", "infer_class2_pair", ")", "if", "cache_key", "in", "_normalized_allele_c...
MHC alleles are named with a frustratingly loose system. It's not uncommon to see dozens of different forms for the same allele. Note: this function works with both class I and class II allele names (including alpha/beta pairs). For example, these all refer to the same MHC sequence: - HLA-A*02...
[ "MHC", "alleles", "are", "named", "with", "a", "frustratingly", "loose", "system", ".", "It", "s", "not", "uncommon", "to", "see", "dozens", "of", "different", "forms", "for", "the", "same", "allele", "." ]
71694b9d620db68ceee44da1b8422ff436f15bd3
https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/normalization.py#L28-L101
train
Bystroushaak/bottle-rest
docs/__init__.py
getVersion
def getVersion(data): """ Parse version from changelog written in RST format. """ data = data.splitlines() return next(( v for v, u in zip(data, data[1:]) # v = version, u = underline if len(v) == len(u) and allSame(u) and hasDigit(v) and "." in v ))
python
def getVersion(data): """ Parse version from changelog written in RST format. """ data = data.splitlines() return next(( v for v, u in zip(data, data[1:]) # v = version, u = underline if len(v) == len(u) and allSame(u) and hasDigit(v) and "." in v ))
[ "def", "getVersion", "(", "data", ")", ":", "data", "=", "data", ".", "splitlines", "(", ")", "return", "next", "(", "(", "v", "for", "v", ",", "u", "in", "zip", "(", "data", ",", "data", "[", "1", ":", "]", ")", "if", "len", "(", "v", ")", ...
Parse version from changelog written in RST format.
[ "Parse", "version", "from", "changelog", "written", "in", "RST", "format", "." ]
428ef68a632ac092cdd49e2f03a664dbaccb0b86
https://github.com/Bystroushaak/bottle-rest/blob/428ef68a632ac092cdd49e2f03a664dbaccb0b86/docs/__init__.py#L16-L25
train
openvax/mhcnames
mhcnames/species.py
split_species_prefix
def split_species_prefix(name, seps="-:_ "): """ Splits off the species component of the allele name from the rest of it. Given "HLA-A*02:01", returns ("HLA", "A*02:01"). """ species = None name_upper = name.upper() name_len = len(name) for curr_prefix in _all_prefixes: n = len(...
python
def split_species_prefix(name, seps="-:_ "): """ Splits off the species component of the allele name from the rest of it. Given "HLA-A*02:01", returns ("HLA", "A*02:01"). """ species = None name_upper = name.upper() name_len = len(name) for curr_prefix in _all_prefixes: n = len(...
[ "def", "split_species_prefix", "(", "name", ",", "seps", "=", "\"-:_ \"", ")", ":", "species", "=", "None", "name_upper", "=", "name", ".", "upper", "(", ")", "name_len", "=", "len", "(", "name", ")", "for", "curr_prefix", "in", "_all_prefixes", ":", "n"...
Splits off the species component of the allele name from the rest of it. Given "HLA-A*02:01", returns ("HLA", "A*02:01").
[ "Splits", "off", "the", "species", "component", "of", "the", "allele", "name", "from", "the", "rest", "of", "it", "." ]
71694b9d620db68ceee44da1b8422ff436f15bd3
https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/species.py#L93-L110
train
SergeySatskiy/cdm-flowparser
utils/run.py
formatFlow
def formatFlow(s): """Reformats the control flow output""" result = "" shifts = [] # positions of opening '<' pos = 0 # symbol position in a line nextIsList = False def IsNextList(index, maxIndex, buf): if index == maxIndex: return False if buf[index + 1]...
python
def formatFlow(s): """Reformats the control flow output""" result = "" shifts = [] # positions of opening '<' pos = 0 # symbol position in a line nextIsList = False def IsNextList(index, maxIndex, buf): if index == maxIndex: return False if buf[index + 1]...
[ "def", "formatFlow", "(", "s", ")", ":", "result", "=", "\"\"", "shifts", "=", "[", "]", "pos", "=", "0", "nextIsList", "=", "False", "def", "IsNextList", "(", "index", ",", "maxIndex", ",", "buf", ")", ":", "if", "index", "==", "maxIndex", ":", "r...
Reformats the control flow output
[ "Reformats", "the", "control", "flow", "output" ]
0af20325eeafd964c684d66a31cd2efd51fd25a6
https://github.com/SergeySatskiy/cdm-flowparser/blob/0af20325eeafd964c684d66a31cd2efd51fd25a6/utils/run.py#L26-L78
train
pqn/neural
neural/neural.py
NeuralNetwork.train
def train(self, training_set, iterations=500): """Trains itself using the sequence data.""" if len(training_set) > 2: self.__X = np.matrix([example[0] for example in training_set]) if self.__num_labels == 1: self.__y = np.matrix([example[1] for example in training...
python
def train(self, training_set, iterations=500): """Trains itself using the sequence data.""" if len(training_set) > 2: self.__X = np.matrix([example[0] for example in training_set]) if self.__num_labels == 1: self.__y = np.matrix([example[1] for example in training...
[ "def", "train", "(", "self", ",", "training_set", ",", "iterations", "=", "500", ")", ":", "if", "len", "(", "training_set", ")", ">", "2", ":", "self", ".", "__X", "=", "np", ".", "matrix", "(", "[", "example", "[", "0", "]", "for", "example", "...
Trains itself using the sequence data.
[ "Trains", "itself", "using", "the", "sequence", "data", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L20-L46
train
pqn/neural
neural/neural.py
NeuralNetwork.predict
def predict(self, X): """Returns predictions of input test cases.""" return self.__cost(self.__unroll(self.__thetas), 0, np.matrix(X))
python
def predict(self, X): """Returns predictions of input test cases.""" return self.__cost(self.__unroll(self.__thetas), 0, np.matrix(X))
[ "def", "predict", "(", "self", ",", "X", ")", ":", "return", "self", ".", "__cost", "(", "self", ".", "__unroll", "(", "self", ".", "__thetas", ")", ",", "0", ",", "np", ".", "matrix", "(", "X", ")", ")" ]
Returns predictions of input test cases.
[ "Returns", "predictions", "of", "input", "test", "cases", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L48-L50
train
pqn/neural
neural/neural.py
NeuralNetwork.__cost
def __cost(self, params, phase, X): """Computes activation, cost function, and derivative.""" params = self.__roll(params) a = np.concatenate((np.ones((X.shape[0], 1)), X), axis=1) # This is a1 calculated_a = [a] # a1 is at index 0, a_n is at index n-1 calculated_z = [0] # There ...
python
def __cost(self, params, phase, X): """Computes activation, cost function, and derivative.""" params = self.__roll(params) a = np.concatenate((np.ones((X.shape[0], 1)), X), axis=1) # This is a1 calculated_a = [a] # a1 is at index 0, a_n is at index n-1 calculated_z = [0] # There ...
[ "def", "__cost", "(", "self", ",", "params", ",", "phase", ",", "X", ")", ":", "params", "=", "self", ".", "__roll", "(", "params", ")", "a", "=", "np", ".", "concatenate", "(", "(", "np", ".", "ones", "(", "(", "X", ".", "shape", "[", "0", "...
Computes activation, cost function, and derivative.
[ "Computes", "activation", "cost", "function", "and", "derivative", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L60-L99
train
pqn/neural
neural/neural.py
NeuralNetwork.__roll
def __roll(self, unrolled): """Converts parameter array back into matrices.""" rolled = [] index = 0 for count in range(len(self.__sizes) - 1): in_size = self.__sizes[count] out_size = self.__sizes[count+1] theta_unrolled = np.matrix(unrolled[index:ind...
python
def __roll(self, unrolled): """Converts parameter array back into matrices.""" rolled = [] index = 0 for count in range(len(self.__sizes) - 1): in_size = self.__sizes[count] out_size = self.__sizes[count+1] theta_unrolled = np.matrix(unrolled[index:ind...
[ "def", "__roll", "(", "self", ",", "unrolled", ")", ":", "rolled", "=", "[", "]", "index", "=", "0", "for", "count", "in", "range", "(", "len", "(", "self", ".", "__sizes", ")", "-", "1", ")", ":", "in_size", "=", "self", ".", "__sizes", "[", "...
Converts parameter array back into matrices.
[ "Converts", "parameter", "array", "back", "into", "matrices", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L101-L112
train
pqn/neural
neural/neural.py
NeuralNetwork.__unroll
def __unroll(self, rolled): """Converts parameter matrices into an array.""" return np.array(np.concatenate([matrix.flatten() for matrix in rolled], axis=1)).reshape(-1)
python
def __unroll(self, rolled): """Converts parameter matrices into an array.""" return np.array(np.concatenate([matrix.flatten() for matrix in rolled], axis=1)).reshape(-1)
[ "def", "__unroll", "(", "self", ",", "rolled", ")", ":", "return", "np", ".", "array", "(", "np", ".", "concatenate", "(", "[", "matrix", ".", "flatten", "(", ")", "for", "matrix", "in", "rolled", "]", ",", "axis", "=", "1", ")", ")", ".", "resha...
Converts parameter matrices into an array.
[ "Converts", "parameter", "matrices", "into", "an", "array", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L114-L116
train
pqn/neural
neural/neural.py
NeuralNetwork.sigmoid_grad
def sigmoid_grad(self, z): """Gradient of sigmoid function.""" return np.multiply(self.sigmoid(z), 1-self.sigmoid(z))
python
def sigmoid_grad(self, z): """Gradient of sigmoid function.""" return np.multiply(self.sigmoid(z), 1-self.sigmoid(z))
[ "def", "sigmoid_grad", "(", "self", ",", "z", ")", ":", "return", "np", ".", "multiply", "(", "self", ".", "sigmoid", "(", "z", ")", ",", "1", "-", "self", ".", "sigmoid", "(", "z", ")", ")" ]
Gradient of sigmoid function.
[ "Gradient", "of", "sigmoid", "function", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L122-L124
train
pqn/neural
neural/neural.py
NeuralNetwork.grad
def grad(self, params, epsilon=0.0001): """Used to check gradient estimation through slope approximation.""" grad = [] for x in range(len(params)): temp = np.copy(params) temp[x] += epsilon temp2 = np.copy(params) temp2[x] -= epsilon gr...
python
def grad(self, params, epsilon=0.0001): """Used to check gradient estimation through slope approximation.""" grad = [] for x in range(len(params)): temp = np.copy(params) temp[x] += epsilon temp2 = np.copy(params) temp2[x] -= epsilon gr...
[ "def", "grad", "(", "self", ",", "params", ",", "epsilon", "=", "0.0001", ")", ":", "grad", "=", "[", "]", "for", "x", "in", "range", "(", "len", "(", "params", ")", ")", ":", "temp", "=", "np", ".", "copy", "(", "params", ")", "temp", "[", "...
Used to check gradient estimation through slope approximation.
[ "Used", "to", "check", "gradient", "estimation", "through", "slope", "approximation", "." ]
505d8fb1c58868a7292c40caab4a22b577615886
https://github.com/pqn/neural/blob/505d8fb1c58868a7292c40caab4a22b577615886/neural/neural.py#L126-L135
train
rfverbruggen/rachiopy
rachiopy/notification.py
Notification.postWebhook
def postWebhook(self, dev_id, external_id, url, event_types): """Add a webhook to a device. externalId can be used as opaque data that is tied to your company, and passed back in each webhook event response. """ path = 'notification/webhook' payload = {'device': ...
python
def postWebhook(self, dev_id, external_id, url, event_types): """Add a webhook to a device. externalId can be used as opaque data that is tied to your company, and passed back in each webhook event response. """ path = 'notification/webhook' payload = {'device': ...
[ "def", "postWebhook", "(", "self", ",", "dev_id", ",", "external_id", ",", "url", ",", "event_types", ")", ":", "path", "=", "'notification/webhook'", "payload", "=", "{", "'device'", ":", "{", "'id'", ":", "dev_id", "}", ",", "'externalId'", ":", "externa...
Add a webhook to a device. externalId can be used as opaque data that is tied to your company, and passed back in each webhook event response.
[ "Add", "a", "webhook", "to", "a", "device", "." ]
c91abc9984f0f453e60fa905285c1b640c3390ae
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/notification.py#L24-L34
train
rfverbruggen/rachiopy
rachiopy/notification.py
Notification.putWebhook
def putWebhook(self, hook_id, external_id, url, event_types): """Update a webhook.""" path = 'notification/webhook' payload = {'id': hook_id, 'externalId': external_id, 'url': url, 'eventTypes': event_types} return self.rachio.put(path, payload)
python
def putWebhook(self, hook_id, external_id, url, event_types): """Update a webhook.""" path = 'notification/webhook' payload = {'id': hook_id, 'externalId': external_id, 'url': url, 'eventTypes': event_types} return self.rachio.put(path, payload)
[ "def", "putWebhook", "(", "self", ",", "hook_id", ",", "external_id", ",", "url", ",", "event_types", ")", ":", "path", "=", "'notification/webhook'", "payload", "=", "{", "'id'", ":", "hook_id", ",", "'externalId'", ":", "external_id", ",", "'url'", ":", ...
Update a webhook.
[ "Update", "a", "webhook", "." ]
c91abc9984f0f453e60fa905285c1b640c3390ae
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/notification.py#L36-L41
train
rfverbruggen/rachiopy
rachiopy/notification.py
Notification.deleteWebhook
def deleteWebhook(self, hook_id): """Remove a webhook.""" path = '/'.join(['notification', 'webhook', hook_id]) return self.rachio.delete(path)
python
def deleteWebhook(self, hook_id): """Remove a webhook.""" path = '/'.join(['notification', 'webhook', hook_id]) return self.rachio.delete(path)
[ "def", "deleteWebhook", "(", "self", ",", "hook_id", ")", ":", "path", "=", "'/'", ".", "join", "(", "[", "'notification'", ",", "'webhook'", ",", "hook_id", "]", ")", "return", "self", ".", "rachio", ".", "delete", "(", "path", ")" ]
Remove a webhook.
[ "Remove", "a", "webhook", "." ]
c91abc9984f0f453e60fa905285c1b640c3390ae
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/notification.py#L43-L46
train
rfverbruggen/rachiopy
rachiopy/notification.py
Notification.get
def get(self, hook_id): """Get a webhook.""" path = '/'.join(['notification', 'webhook', hook_id]) return self.rachio.get(path)
python
def get(self, hook_id): """Get a webhook.""" path = '/'.join(['notification', 'webhook', hook_id]) return self.rachio.get(path)
[ "def", "get", "(", "self", ",", "hook_id", ")", ":", "path", "=", "'/'", ".", "join", "(", "[", "'notification'", ",", "'webhook'", ",", "hook_id", "]", ")", "return", "self", ".", "rachio", ".", "get", "(", "path", ")" ]
Get a webhook.
[ "Get", "a", "webhook", "." ]
c91abc9984f0f453e60fa905285c1b640c3390ae
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/notification.py#L48-L51
train
OrangeTux/einder
einder/client.py
Client.connect
def connect(self): """ Connect sets up the connection with the Horizon box. """ self.con = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.con.connect((self.ip, self.port)) log.debug('Connected with set-top box at %s:%s.', self.ip, self.port)
python
def connect(self): """ Connect sets up the connection with the Horizon box. """ self.con = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.con.connect((self.ip, self.port)) log.debug('Connected with set-top box at %s:%s.', self.ip, self.port)
[ "def", "connect", "(", "self", ")", ":", "self", ".", "con", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "self", ".", "con", ".", "connect", "(", "(", "self", ".", "ip", ",", "self", ".", "...
Connect sets up the connection with the Horizon box.
[ "Connect", "sets", "up", "the", "connection", "with", "the", "Horizon", "box", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L23-L29
train
OrangeTux/einder
einder/client.py
Client.disconnect
def disconnect(self): """ Disconnect closes the connection to the Horizon box. """ if self.con is not None: self.con.close() log.debug('Closed connection with with set-top box at %s:%s.', self.ip, self.port)
python
def disconnect(self): """ Disconnect closes the connection to the Horizon box. """ if self.con is not None: self.con.close() log.debug('Closed connection with with set-top box at %s:%s.', self.ip, self.port)
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "con", "is", "not", "None", ":", "self", ".", "con", ".", "close", "(", ")", "log", ".", "debug", "(", "'Closed connection with with set-top box at %s:%s.'", ",", "self", ".", "ip", ",", "sel...
Disconnect closes the connection to the Horizon box.
[ "Disconnect", "closes", "the", "connection", "to", "the", "Horizon", "box", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L31-L36
train
OrangeTux/einder
einder/client.py
Client.authorize
def authorize(self): """ Use the magic of a unicorn and summon the set-top box to listen to us. / ,.. / ,' '; ,,.__ _,' /'; . :',' ~~~~ '. '~ :' ( ) )::, '. '. .=----=..-~ .;'...
python
def authorize(self): """ Use the magic of a unicorn and summon the set-top box to listen to us. / ,.. / ,' '; ,,.__ _,' /'; . :',' ~~~~ '. '~ :' ( ) )::, '. '. .=----=..-~ .;'...
[ "def", "authorize", "(", "self", ")", ":", "version", "=", "self", ".", "con", ".", "makefile", "(", ")", ".", "readline", "(", ")", "self", ".", "con", ".", "send", "(", "version", ".", "encode", "(", ")", ")", "self", ".", "con", ".", "recv", ...
Use the magic of a unicorn and summon the set-top box to listen to us. / ,.. / ,' '; ,,.__ _,' /'; . :',' ~~~~ '. '~ :' ( ) )::, '. '. .=----=..-~ .;' ' ;' :: ':. '" ...
[ "Use", "the", "magic", "of", "a", "unicorn", "and", "summon", "the", "set", "-", "top", "box", "to", "listen", "to", "us", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L38-L78
train
OrangeTux/einder
einder/client.py
Client.send_key
def send_key(self, key): """ Send a key to the Horizon box. """ cmd = struct.pack(">BBBBBBH", 4, 1, 0, 0, 0, 0, key) self.con.send(cmd) cmd = struct.pack(">BBBBBBH", 4, 0, 0, 0, 0, 0, key) self.con.send(cmd)
python
def send_key(self, key): """ Send a key to the Horizon box. """ cmd = struct.pack(">BBBBBBH", 4, 1, 0, 0, 0, 0, key) self.con.send(cmd) cmd = struct.pack(">BBBBBBH", 4, 0, 0, 0, 0, 0, key) self.con.send(cmd)
[ "def", "send_key", "(", "self", ",", "key", ")", ":", "cmd", "=", "struct", ".", "pack", "(", "\">BBBBBBH\"", ",", "4", ",", "1", ",", "0", ",", "0", ",", "0", ",", "0", ",", "key", ")", "self", ".", "con", ".", "send", "(", "cmd", ")", "cm...
Send a key to the Horizon box.
[ "Send", "a", "key", "to", "the", "Horizon", "box", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L80-L86
train
OrangeTux/einder
einder/client.py
Client.is_powered_on
def is_powered_on(self): """ Get power status of device. The set-top box can't explicitly powered on or powered off the device. The power can only be toggled. To find out the power status of the device a little trick is used. When the set-top box is powered a web server is runn...
python
def is_powered_on(self): """ Get power status of device. The set-top box can't explicitly powered on or powered off the device. The power can only be toggled. To find out the power status of the device a little trick is used. When the set-top box is powered a web server is runn...
[ "def", "is_powered_on", "(", "self", ")", ":", "host", "=", "'{0}:62137'", ".", "format", "(", "self", ".", "ip", ")", "try", ":", "HTTPConnection", "(", "host", ",", "timeout", "=", "2", ")", ".", "request", "(", "'GET'", ",", "'/DeviceDescription.xml'"...
Get power status of device. The set-top box can't explicitly powered on or powered off the device. The power can only be toggled. To find out the power status of the device a little trick is used. When the set-top box is powered a web server is running on port 62137 of the devi...
[ "Get", "power", "status", "of", "device", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L88-L112
train
OrangeTux/einder
einder/client.py
Client.power_on
def power_on(self): """ Power on the set-top box. """ if not self.is_powered_on(): log.debug('Powering on set-top box at %s:%s.', self.ip, self.port) self.send_key(keys.POWER)
python
def power_on(self): """ Power on the set-top box. """ if not self.is_powered_on(): log.debug('Powering on set-top box at %s:%s.', self.ip, self.port) self.send_key(keys.POWER)
[ "def", "power_on", "(", "self", ")", ":", "if", "not", "self", ".", "is_powered_on", "(", ")", ":", "log", ".", "debug", "(", "'Powering on set-top box at %s:%s.'", ",", "self", ".", "ip", ",", "self", ".", "port", ")", "self", ".", "send_key", "(", "k...
Power on the set-top box.
[ "Power", "on", "the", "set", "-", "top", "box", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L114-L118
train
OrangeTux/einder
einder/client.py
Client.select_channel
def select_channel(self, channel): """ Select a channel. :param channel: Number of channel. """ for i in str(channel): key = int(i) + 0xe300 self.send_key(key)
python
def select_channel(self, channel): """ Select a channel. :param channel: Number of channel. """ for i in str(channel): key = int(i) + 0xe300 self.send_key(key)
[ "def", "select_channel", "(", "self", ",", "channel", ")", ":", "for", "i", "in", "str", "(", "channel", ")", ":", "key", "=", "int", "(", "i", ")", "+", "0xe300", "self", ".", "send_key", "(", "key", ")" ]
Select a channel. :param channel: Number of channel.
[ "Select", "a", "channel", "." ]
deb2c5f79a69b684257fe939659c3bd751556fd5
https://github.com/OrangeTux/einder/blob/deb2c5f79a69b684257fe939659c3bd751556fd5/einder/client.py#L126-L133
train
inveniosoftware/invenio-webhooks
invenio_webhooks/signatures.py
get_hmac
def get_hmac(message): """Calculate HMAC value of message using ``WEBHOOKS_SECRET_KEY``. :param message: String to calculate HMAC for. """ key = current_app.config['WEBHOOKS_SECRET_KEY'] hmac_value = hmac.new( key.encode('utf-8') if hasattr(key, 'encode') else key, message.encode('u...
python
def get_hmac(message): """Calculate HMAC value of message using ``WEBHOOKS_SECRET_KEY``. :param message: String to calculate HMAC for. """ key = current_app.config['WEBHOOKS_SECRET_KEY'] hmac_value = hmac.new( key.encode('utf-8') if hasattr(key, 'encode') else key, message.encode('u...
[ "def", "get_hmac", "(", "message", ")", ":", "key", "=", "current_app", ".", "config", "[", "'WEBHOOKS_SECRET_KEY'", "]", "hmac_value", "=", "hmac", ".", "new", "(", "key", ".", "encode", "(", "'utf-8'", ")", "if", "hasattr", "(", "key", ",", "'encode'",...
Calculate HMAC value of message using ``WEBHOOKS_SECRET_KEY``. :param message: String to calculate HMAC for.
[ "Calculate", "HMAC", "value", "of", "message", "using", "WEBHOOKS_SECRET_KEY", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/signatures.py#L33-L44
train
inveniosoftware/invenio-webhooks
invenio_webhooks/signatures.py
check_x_hub_signature
def check_x_hub_signature(signature, message): """Check X-Hub-Signature used by GitHub to sign requests. :param signature: HMAC signature extracted from request. :param message: Request message. """ hmac_value = get_hmac(message) if hmac_value == signature or \ (signature.find('=') > -1 ...
python
def check_x_hub_signature(signature, message): """Check X-Hub-Signature used by GitHub to sign requests. :param signature: HMAC signature extracted from request. :param message: Request message. """ hmac_value = get_hmac(message) if hmac_value == signature or \ (signature.find('=') > -1 ...
[ "def", "check_x_hub_signature", "(", "signature", ",", "message", ")", ":", "hmac_value", "=", "get_hmac", "(", "message", ")", "if", "hmac_value", "==", "signature", "or", "(", "signature", ".", "find", "(", "'='", ")", ">", "-", "1", "and", "hmac_value",...
Check X-Hub-Signature used by GitHub to sign requests. :param signature: HMAC signature extracted from request. :param message: Request message.
[ "Check", "X", "-", "Hub", "-", "Signature", "used", "by", "GitHub", "to", "sign", "requests", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/signatures.py#L47-L58
train
spotify/gordon-gcp
src/gordon_gcp/clients/gcrm.py
GCRMClient.list_all_active_projects
async def list_all_active_projects(self, page_size=1000): """Get all active projects. You can find the endpoint documentation `here <https://cloud. google.com/resource-manager/reference/rest/v1/projects/list>`__. Args: page_size (int): hint for the client to only retrieve u...
python
async def list_all_active_projects(self, page_size=1000): """Get all active projects. You can find the endpoint documentation `here <https://cloud. google.com/resource-manager/reference/rest/v1/projects/list>`__. Args: page_size (int): hint for the client to only retrieve u...
[ "async", "def", "list_all_active_projects", "(", "self", ",", "page_size", "=", "1000", ")", ":", "url", "=", "f'{self.BASE_URL}/{self.api_version}/projects'", "params", "=", "{", "'pageSize'", ":", "page_size", "}", "responses", "=", "await", "self", ".", "list_a...
Get all active projects. You can find the endpoint documentation `here <https://cloud. google.com/resource-manager/reference/rest/v1/projects/list>`__. Args: page_size (int): hint for the client to only retrieve up to this number of results per API call. Ret...
[ "Get", "all", "active", "projects", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gcrm.py#L85-L105
train
dstanek/snake-guice
snakeguice/modules.py
Module.install
def install(self, binder, module): """Add another module's bindings to a binder.""" ModuleAdapter(module, self._injector).configure(binder)
python
def install(self, binder, module): """Add another module's bindings to a binder.""" ModuleAdapter(module, self._injector).configure(binder)
[ "def", "install", "(", "self", ",", "binder", ",", "module", ")", ":", "ModuleAdapter", "(", "module", ",", "self", ".", "_injector", ")", ".", "configure", "(", "binder", ")" ]
Add another module's bindings to a binder.
[ "Add", "another", "module", "s", "bindings", "to", "a", "binder", "." ]
d20b62de3ee31e84119c801756398c35ed803fb3
https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/modules.py#L23-L25
train
dstanek/snake-guice
snakeguice/modules.py
PrivateModule.expose
def expose(self, binder, interface, annotation=None): """Expose the child injector to the parent inject for a binding.""" private_module = self class Provider(object): def get(self): return private_module.private_injector.get_instance( interfac...
python
def expose(self, binder, interface, annotation=None): """Expose the child injector to the parent inject for a binding.""" private_module = self class Provider(object): def get(self): return private_module.private_injector.get_instance( interfac...
[ "def", "expose", "(", "self", ",", "binder", ",", "interface", ",", "annotation", "=", "None", ")", ":", "private_module", "=", "self", "class", "Provider", "(", "object", ")", ":", "def", "get", "(", "self", ")", ":", "return", "private_module", ".", ...
Expose the child injector to the parent inject for a binding.
[ "Expose", "the", "child", "injector", "to", "the", "parent", "inject", "for", "a", "binding", "." ]
d20b62de3ee31e84119c801756398c35ed803fb3
https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/modules.py#L57-L66
train
spotify/gordon-gcp
src/gordon_gcp/plugins/service/enricher.py
GCEEnricherBuilder._call_validators
def _call_validators(self): """Actually run all the validations. Returns: list(str): Error messages from the validators. """ msg = [] msg.extend(self._validate_keyfile()) msg.extend(self._validate_dns_zone()) msg.extend(self._validate_retries()) ...
python
def _call_validators(self): """Actually run all the validations. Returns: list(str): Error messages from the validators. """ msg = [] msg.extend(self._validate_keyfile()) msg.extend(self._validate_dns_zone()) msg.extend(self._validate_retries()) ...
[ "def", "_call_validators", "(", "self", ")", ":", "msg", "=", "[", "]", "msg", ".", "extend", "(", "self", ".", "_validate_keyfile", "(", ")", ")", "msg", ".", "extend", "(", "self", ".", "_validate_dns_zone", "(", ")", ")", "msg", ".", "extend", "("...
Actually run all the validations. Returns: list(str): Error messages from the validators.
[ "Actually", "run", "all", "the", "validations", "." ]
5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da
https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/service/enricher.py#L93-L104
train
gitenberg-dev/gitberg
gitenberg/util/catalog.py
BookMetadata.parse_rdf
def parse_rdf(self): """ Parses the relevant PG rdf file """ try: self.metadata = pg_rdf_to_json(self.rdf_path) except IOError as e: raise NoRDFError(e) if not self.authnames(): self.author = '' elif len(self.authnames()) == 1: ...
python
def parse_rdf(self): """ Parses the relevant PG rdf file """ try: self.metadata = pg_rdf_to_json(self.rdf_path) except IOError as e: raise NoRDFError(e) if not self.authnames(): self.author = '' elif len(self.authnames()) == 1: ...
[ "def", "parse_rdf", "(", "self", ")", ":", "try", ":", "self", ".", "metadata", "=", "pg_rdf_to_json", "(", "self", ".", "rdf_path", ")", "except", "IOError", "as", "e", ":", "raise", "NoRDFError", "(", "e", ")", "if", "not", "self", ".", "authnames", ...
Parses the relevant PG rdf file
[ "Parses", "the", "relevant", "PG", "rdf", "file" ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/util/catalog.py#L93-L106
train
gitenberg-dev/gitberg
gitenberg/util/catalog.py
Rdfcache.download_rdf
def download_rdf(self, force=False): """Ensures a fresh-enough RDF file is downloaded and extracted. Returns True on error.""" if self.downloading: return True if not force and (os.path.exists(RDF_PATH) and (time.time() - os.path.getmtime(RDF_PATH)) < RDF_MA...
python
def download_rdf(self, force=False): """Ensures a fresh-enough RDF file is downloaded and extracted. Returns True on error.""" if self.downloading: return True if not force and (os.path.exists(RDF_PATH) and (time.time() - os.path.getmtime(RDF_PATH)) < RDF_MA...
[ "def", "download_rdf", "(", "self", ",", "force", "=", "False", ")", ":", "if", "self", ".", "downloading", ":", "return", "True", "if", "not", "force", "and", "(", "os", ".", "path", ".", "exists", "(", "RDF_PATH", ")", "and", "(", "time", ".", "t...
Ensures a fresh-enough RDF file is downloaded and extracted. Returns True on error.
[ "Ensures", "a", "fresh", "-", "enough", "RDF", "file", "is", "downloaded", "and", "extracted", "." ]
3f6db8b5a22ccdd2110d3199223c30db4e558b5c
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/util/catalog.py#L134-L172
train
Scille/autobahn-sync
autobahn_sync/core.py
AutobahnSync.run
def run(self, url=DEFAULT_AUTOBAHN_ROUTER, realm=DEFAULT_AUTOBAHN_REALM, authmethods=None, authid=None, authrole=None, authextra=None, blocking=False, callback=None, **kwargs): """ Start the background twisted thread and create the WAMP connection :param blocking: If ``F...
python
def run(self, url=DEFAULT_AUTOBAHN_ROUTER, realm=DEFAULT_AUTOBAHN_REALM, authmethods=None, authid=None, authrole=None, authextra=None, blocking=False, callback=None, **kwargs): """ Start the background twisted thread and create the WAMP connection :param blocking: If ``F...
[ "def", "run", "(", "self", ",", "url", "=", "DEFAULT_AUTOBAHN_ROUTER", ",", "realm", "=", "DEFAULT_AUTOBAHN_REALM", ",", "authmethods", "=", "None", ",", "authid", "=", "None", ",", "authrole", "=", "None", ",", "authextra", "=", "None", ",", "blocking", "...
Start the background twisted thread and create the WAMP connection :param blocking: If ``False`` (default) this method will spawn a new thread that will be used to run the callback events (e.i. registered and subscribed functions). If ``True`` this method will not returns and use the cu...
[ "Start", "the", "background", "twisted", "thread", "and", "create", "the", "WAMP", "connection" ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/core.py#L91-L110
train
Scille/autobahn-sync
autobahn_sync/core.py
AutobahnSync.stop
def stop(self): """ Terminate the WAMP session .. note:: If the :meth:`AutobahnSync.run` has been run with ``blocking=True``, it will returns then. """ if not self._started: raise NotRunningError("This AutobahnSync instance is not started") ...
python
def stop(self): """ Terminate the WAMP session .. note:: If the :meth:`AutobahnSync.run` has been run with ``blocking=True``, it will returns then. """ if not self._started: raise NotRunningError("This AutobahnSync instance is not started") ...
[ "def", "stop", "(", "self", ")", ":", "if", "not", "self", ".", "_started", ":", "raise", "NotRunningError", "(", "\"This AutobahnSync instance is not started\"", ")", "self", ".", "_callbacks_runner", ".", "stop", "(", ")", "self", ".", "_started", "=", "Fals...
Terminate the WAMP session .. note:: If the :meth:`AutobahnSync.run` has been run with ``blocking=True``, it will returns then.
[ "Terminate", "the", "WAMP", "session" ]
d75fceff0d1aee61fa6dd0168eb1cd40794ad827
https://github.com/Scille/autobahn-sync/blob/d75fceff0d1aee61fa6dd0168eb1cd40794ad827/autobahn_sync/core.py#L112-L123
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
process_event
def process_event(self, event_id): """Process event in Celery.""" with db.session.begin_nested(): event = Event.query.get(event_id) event._celery_task = self # internal binding to a Celery task event.receiver.run(event) # call run directly to avoid circular calls flag_modified(...
python
def process_event(self, event_id): """Process event in Celery.""" with db.session.begin_nested(): event = Event.query.get(event_id) event._celery_task = self # internal binding to a Celery task event.receiver.run(event) # call run directly to avoid circular calls flag_modified(...
[ "def", "process_event", "(", "self", ",", "event_id", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "event", "=", "Event", ".", "query", ".", "get", "(", "event_id", ")", "event", ".", "_celery_task", "=", "self", "event",...
Process event in Celery.
[ "Process", "event", "in", "Celery", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L143-L152
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
_json_column
def _json_column(**kwargs): """Return JSON column.""" return db.Column( JSONType().with_variant( postgresql.JSON(none_as_null=True), 'postgresql', ), nullable=True, **kwargs )
python
def _json_column(**kwargs): """Return JSON column.""" return db.Column( JSONType().with_variant( postgresql.JSON(none_as_null=True), 'postgresql', ), nullable=True, **kwargs )
[ "def", "_json_column", "(", "**", "kwargs", ")", ":", "return", "db", ".", "Column", "(", "JSONType", "(", ")", ".", "with_variant", "(", "postgresql", ".", "JSON", "(", "none_as_null", "=", "True", ")", ",", "'postgresql'", ",", ")", ",", "nullable", ...
Return JSON column.
[ "Return", "JSON", "column", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L197-L206
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Receiver.delete
def delete(self, event): """Mark event as deleted.""" assert self.receiver_id == event.receiver_id event.response = {'status': 410, 'message': 'Gone.'} event.response_code = 410
python
def delete(self, event): """Mark event as deleted.""" assert self.receiver_id == event.receiver_id event.response = {'status': 410, 'message': 'Gone.'} event.response_code = 410
[ "def", "delete", "(", "self", ",", "event", ")", ":", "assert", "self", ".", "receiver_id", "==", "event", ".", "receiver_id", "event", ".", "response", "=", "{", "'status'", ":", "410", ",", "'message'", ":", "'Gone.'", "}", "event", ".", "response_code...
Mark event as deleted.
[ "Mark", "event", "as", "deleted", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L81-L85
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Receiver.get_hook_url
def get_hook_url(self, access_token): """Get URL for webhook. In debug and testing mode the hook URL can be overwritten using ``WEBHOOKS_DEBUG_RECEIVER_URLS`` configuration variable to allow testing webhooks via services such as e.g. Ultrahook. .. code-block:: python ...
python
def get_hook_url(self, access_token): """Get URL for webhook. In debug and testing mode the hook URL can be overwritten using ``WEBHOOKS_DEBUG_RECEIVER_URLS`` configuration variable to allow testing webhooks via services such as e.g. Ultrahook. .. code-block:: python ...
[ "def", "get_hook_url", "(", "self", ",", "access_token", ")", ":", "if", "(", "current_app", ".", "debug", "or", "current_app", ".", "testing", ")", "and", "current_app", ".", "config", ".", "get", "(", "'WEBHOOKS_DEBUG_RECEIVER_URLS'", ",", "None", ")", ":"...
Get URL for webhook. In debug and testing mode the hook URL can be overwritten using ``WEBHOOKS_DEBUG_RECEIVER_URLS`` configuration variable to allow testing webhooks via services such as e.g. Ultrahook. .. code-block:: python WEBHOOKS_DEBUG_RECEIVER_URLS = dict( ...
[ "Get", "URL", "for", "webhook", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L87-L112
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Receiver.check_signature
def check_signature(self): """Check signature of signed request.""" if not self.signature: return True signature_value = request.headers.get(self.signature, None) if signature_value: validator = 'check_' + re.sub(r'[-]', '_', self.signature).lower() ch...
python
def check_signature(self): """Check signature of signed request.""" if not self.signature: return True signature_value = request.headers.get(self.signature, None) if signature_value: validator = 'check_' + re.sub(r'[-]', '_', self.signature).lower() ch...
[ "def", "check_signature", "(", "self", ")", ":", "if", "not", "self", ".", "signature", ":", "return", "True", "signature_value", "=", "request", ".", "headers", ".", "get", "(", "self", ".", "signature", ",", "None", ")", "if", "signature_value", ":", "...
Check signature of signed request.
[ "Check", "signature", "of", "signed", "request", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L117-L127
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Receiver.extract_payload
def extract_payload(self): """Extract payload from request.""" if not self.check_signature(): raise InvalidSignature('Invalid Signature') if request.is_json: # Request.get_json() could be first called with silent=True. delete_cached_json_for(request) ...
python
def extract_payload(self): """Extract payload from request.""" if not self.check_signature(): raise InvalidSignature('Invalid Signature') if request.is_json: # Request.get_json() could be first called with silent=True. delete_cached_json_for(request) ...
[ "def", "extract_payload", "(", "self", ")", ":", "if", "not", "self", ".", "check_signature", "(", ")", ":", "raise", "InvalidSignature", "(", "'Invalid Signature'", ")", "if", "request", ".", "is_json", ":", "delete_cached_json_for", "(", "request", ")", "ret...
Extract payload from request.
[ "Extract", "payload", "from", "request", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L129-L139
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
CeleryReceiver.delete
def delete(self, event): """Abort running task if it exists.""" super(CeleryReceiver, self).delete(event) AsyncResult(event.id).revoke(terminate=True)
python
def delete(self, event): """Abort running task if it exists.""" super(CeleryReceiver, self).delete(event) AsyncResult(event.id).revoke(terminate=True)
[ "def", "delete", "(", "self", ",", "event", ")", ":", "super", "(", "CeleryReceiver", ",", "self", ")", ".", "delete", "(", "event", ")", "AsyncResult", "(", "event", ".", "id", ")", ".", "revoke", "(", "terminate", "=", "True", ")" ]
Abort running task if it exists.
[ "Abort", "running", "task", "if", "it", "exists", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L191-L194
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Event.validate_receiver
def validate_receiver(self, key, value): """Validate receiver identifier.""" if value not in current_webhooks.receivers: raise ReceiverDoesNotExist(self.receiver_id) return value
python
def validate_receiver(self, key, value): """Validate receiver identifier.""" if value not in current_webhooks.receivers: raise ReceiverDoesNotExist(self.receiver_id) return value
[ "def", "validate_receiver", "(", "self", ",", "key", ",", "value", ")", ":", "if", "value", "not", "in", "current_webhooks", ".", "receivers", ":", "raise", "ReceiverDoesNotExist", "(", "self", ".", "receiver_id", ")", "return", "value" ]
Validate receiver identifier.
[ "Validate", "receiver", "identifier", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L251-L255
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Event.create
def create(cls, receiver_id, user_id=None): """Create an event instance.""" event = cls(id=uuid.uuid4(), receiver_id=receiver_id, user_id=user_id) event.payload = event.receiver.extract_payload() return event
python
def create(cls, receiver_id, user_id=None): """Create an event instance.""" event = cls(id=uuid.uuid4(), receiver_id=receiver_id, user_id=user_id) event.payload = event.receiver.extract_payload() return event
[ "def", "create", "(", "cls", ",", "receiver_id", ",", "user_id", "=", "None", ")", ":", "event", "=", "cls", "(", "id", "=", "uuid", ".", "uuid4", "(", ")", ",", "receiver_id", "=", "receiver_id", ",", "user_id", "=", "user_id", ")", "event", ".", ...
Create an event instance.
[ "Create", "an", "event", "instance", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L258-L262
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Event.receiver
def receiver(self): """Return registered receiver.""" try: return current_webhooks.receivers[self.receiver_id] except KeyError: raise ReceiverDoesNotExist(self.receiver_id)
python
def receiver(self): """Return registered receiver.""" try: return current_webhooks.receivers[self.receiver_id] except KeyError: raise ReceiverDoesNotExist(self.receiver_id)
[ "def", "receiver", "(", "self", ")", ":", "try", ":", "return", "current_webhooks", ".", "receivers", "[", "self", ".", "receiver_id", "]", "except", "KeyError", ":", "raise", "ReceiverDoesNotExist", "(", "self", ".", "receiver_id", ")" ]
Return registered receiver.
[ "Return", "registered", "receiver", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L265-L270
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Event.receiver
def receiver(self, value): """Set receiver instance.""" assert isinstance(value, Receiver) self.receiver_id = value.receiver_id
python
def receiver(self, value): """Set receiver instance.""" assert isinstance(value, Receiver) self.receiver_id = value.receiver_id
[ "def", "receiver", "(", "self", ",", "value", ")", ":", "assert", "isinstance", "(", "value", ",", "Receiver", ")", "self", ".", "receiver_id", "=", "value", ".", "receiver_id" ]
Set receiver instance.
[ "Set", "receiver", "instance", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L273-L276
train
inveniosoftware/invenio-webhooks
invenio_webhooks/models.py
Event.process
def process(self): """Process current event.""" try: self.receiver(self) # TODO RESTException except Exception as e: current_app.logger.exception('Could not process event.') self.response_code = 500 self.response = dict(status=500, message=...
python
def process(self): """Process current event.""" try: self.receiver(self) # TODO RESTException except Exception as e: current_app.logger.exception('Could not process event.') self.response_code = 500 self.response = dict(status=500, message=...
[ "def", "process", "(", "self", ")", ":", "try", ":", "self", ".", "receiver", "(", "self", ")", "except", "Exception", "as", "e", ":", "current_app", ".", "logger", ".", "exception", "(", "'Could not process event.'", ")", "self", ".", "response_code", "="...
Process current event.
[ "Process", "current", "event", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/models.py#L278-L287
train
GrahamDumpleton/autowrapt
src/bootstrap.py
register_bootstrap_functions
def register_bootstrap_functions(): '''Discover and register all post import hooks named in the 'AUTOWRAPT_BOOTSTRAP' environment variable. The value of the environment variable must be a comma separated list. ''' # This can be called twice if '.pth' file bootstrapping works and # the 'autowra...
python
def register_bootstrap_functions(): '''Discover and register all post import hooks named in the 'AUTOWRAPT_BOOTSTRAP' environment variable. The value of the environment variable must be a comma separated list. ''' # This can be called twice if '.pth' file bootstrapping works and # the 'autowra...
[ "def", "register_bootstrap_functions", "(", ")", ":", "global", "_registered", "if", "_registered", ":", "return", "_registered", "=", "True", "from", "wrapt", "import", "discover_post_import_hooks", "for", "name", "in", "os", ".", "environ", ".", "get", "(", "'...
Discover and register all post import hooks named in the 'AUTOWRAPT_BOOTSTRAP' environment variable. The value of the environment variable must be a comma separated list.
[ "Discover", "and", "register", "all", "post", "import", "hooks", "named", "in", "the", "AUTOWRAPT_BOOTSTRAP", "environment", "variable", ".", "The", "value", "of", "the", "environment", "variable", "must", "be", "a", "comma", "separated", "list", "." ]
d4770e4f511c19012055deaab68ef0ec8aa54ba4
https://github.com/GrahamDumpleton/autowrapt/blob/d4770e4f511c19012055deaab68ef0ec8aa54ba4/src/bootstrap.py#L13-L39
train
GrahamDumpleton/autowrapt
src/bootstrap.py
bootstrap
def bootstrap(): '''Patches the 'site' module such that the bootstrap functions for registering the post import hook callback functions are called as the last thing done when initialising the Python interpreter. This function would normally be called from the special '.pth' file. ''' global _p...
python
def bootstrap(): '''Patches the 'site' module such that the bootstrap functions for registering the post import hook callback functions are called as the last thing done when initialising the Python interpreter. This function would normally be called from the special '.pth' file. ''' global _p...
[ "def", "bootstrap", "(", ")", ":", "global", "_patched", "if", "_patched", ":", "return", "_patched", "=", "True", "site", ".", "execsitecustomize", "=", "_execsitecustomize_wrapper", "(", "site", ".", "execsitecustomize", ")", "site", ".", "execusercustomize", ...
Patches the 'site' module such that the bootstrap functions for registering the post import hook callback functions are called as the last thing done when initialising the Python interpreter. This function would normally be called from the special '.pth' file.
[ "Patches", "the", "site", "module", "such", "that", "the", "bootstrap", "functions", "for", "registering", "the", "post", "import", "hook", "callback", "functions", "are", "called", "as", "the", "last", "thing", "done", "when", "initialising", "the", "Python", ...
d4770e4f511c19012055deaab68ef0ec8aa54ba4
https://github.com/GrahamDumpleton/autowrapt/blob/d4770e4f511c19012055deaab68ef0ec8aa54ba4/src/bootstrap.py#L67-L100
train
architv/harvey
harvey/get_tldr.py
get_rules
def get_rules(license): """Gets can, cannot and must rules from github license API""" can = [] cannot = [] must = [] req = requests.get("{base_url}/licenses/{license}".format( base_url=BASE_URL, license=license), headers=_HEADERS) if req.status_code == requests.codes.ok: data = re...
python
def get_rules(license): """Gets can, cannot and must rules from github license API""" can = [] cannot = [] must = [] req = requests.get("{base_url}/licenses/{license}".format( base_url=BASE_URL, license=license), headers=_HEADERS) if req.status_code == requests.codes.ok: data = re...
[ "def", "get_rules", "(", "license", ")", ":", "can", "=", "[", "]", "cannot", "=", "[", "]", "must", "=", "[", "]", "req", "=", "requests", ".", "get", "(", "\"{base_url}/licenses/{license}\"", ".", "format", "(", "base_url", "=", "BASE_URL", ",", "lic...
Gets can, cannot and must rules from github license API
[ "Gets", "can", "cannot", "and", "must", "rules", "from", "github", "license", "API" ]
2b96d57b7a1e0dd706f1f00aba3d92a7ae702960
https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/get_tldr.py#L26-L41
train
architv/harvey
harvey/get_tldr.py
main
def main(): """Gets all the license information and stores it in json format""" all_summary = {} for license in RESOURCES: req = requests.get(RESOURCES[license]) if req.status_code == requests.codes.ok: summary = get_summary(req.text) can, cannot, must = get_rules(license) all_summa...
python
def main(): """Gets all the license information and stores it in json format""" all_summary = {} for license in RESOURCES: req = requests.get(RESOURCES[license]) if req.status_code == requests.codes.ok: summary = get_summary(req.text) can, cannot, must = get_rules(license) all_summa...
[ "def", "main", "(", ")", ":", "all_summary", "=", "{", "}", "for", "license", "in", "RESOURCES", ":", "req", "=", "requests", ".", "get", "(", "RESOURCES", "[", "license", "]", ")", "if", "req", ".", "status_code", "==", "requests", ".", "codes", "."...
Gets all the license information and stores it in json format
[ "Gets", "all", "the", "license", "information", "and", "stores", "it", "in", "json", "format" ]
2b96d57b7a1e0dd706f1f00aba3d92a7ae702960
https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/get_tldr.py#L44-L66
train
costastf/toonlib
_CI/bin/bump.py
get_arguments
def get_arguments(): """ This get us the cli arguments. Returns the args as parsed from the argsparser. """ # https://docs.python.org/3/library/argparse.html parser = argparse.ArgumentParser( description='Handles bumping of the artifact version') parser.add_argument('--log-config', ...
python
def get_arguments(): """ This get us the cli arguments. Returns the args as parsed from the argsparser. """ # https://docs.python.org/3/library/argparse.html parser = argparse.ArgumentParser( description='Handles bumping of the artifact version') parser.add_argument('--log-config', ...
[ "def", "get_arguments", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Handles bumping of the artifact version'", ")", "parser", ".", "add_argument", "(", "'--log-config'", ",", "'-l'", ",", "action", "=", "'store'", ",...
This get us the cli arguments. Returns the args as parsed from the argsparser.
[ "This", "get", "us", "the", "cli", "arguments", "." ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/_CI/bin/bump.py#L21-L68
train
costastf/toonlib
_CI/bin/bump.py
setup_logging
def setup_logging(args): """ This sets up the logging. Needs the args to get the log level supplied :param args: The command line arguments """ handler = logging.StreamHandler() handler.setLevel(args.log_level) formatter = logging.Formatter(('%(asctime)s - ' ...
python
def setup_logging(args): """ This sets up the logging. Needs the args to get the log level supplied :param args: The command line arguments """ handler = logging.StreamHandler() handler.setLevel(args.log_level) formatter = logging.Formatter(('%(asctime)s - ' ...
[ "def", "setup_logging", "(", "args", ")", ":", "handler", "=", "logging", ".", "StreamHandler", "(", ")", "handler", ".", "setLevel", "(", "args", ".", "log_level", ")", "formatter", "=", "logging", ".", "Formatter", "(", "(", "'%(asctime)s - '", "'%(name)s ...
This sets up the logging. Needs the args to get the log level supplied :param args: The command line arguments
[ "This", "sets", "up", "the", "logging", "." ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/_CI/bin/bump.py#L71-L85
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
make_response
def make_response(event): """Make a response from webhook event.""" code, message = event.status response = jsonify(**event.response) response.headers['X-Hub-Event'] = event.receiver_id response.headers['X-Hub-Delivery'] = event.id if message: response.headers['X-Hub-Info'] = message ...
python
def make_response(event): """Make a response from webhook event.""" code, message = event.status response = jsonify(**event.response) response.headers['X-Hub-Event'] = event.receiver_id response.headers['X-Hub-Delivery'] = event.id if message: response.headers['X-Hub-Info'] = message ...
[ "def", "make_response", "(", "event", ")", ":", "code", ",", "message", "=", "event", ".", "status", "response", "=", "jsonify", "(", "**", "event", ".", "response", ")", "response", ".", "headers", "[", "'X-Hub-Event'", "]", "=", "event", ".", "receiver...
Make a response from webhook event.
[ "Make", "a", "response", "from", "webhook", "event", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L69-L81
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
error_handler
def error_handler(f): """Return a json payload and appropriate status code on expection.""" @wraps(f) def inner(*args, **kwargs): try: return f(*args, **kwargs) except ReceiverDoesNotExist: return jsonify( status=404, description='Recei...
python
def error_handler(f): """Return a json payload and appropriate status code on expection.""" @wraps(f) def inner(*args, **kwargs): try: return f(*args, **kwargs) except ReceiverDoesNotExist: return jsonify( status=404, description='Recei...
[ "def", "error_handler", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "return", "f", "(", "*", "args", ",", "**", "kwargs", ")", "except", "ReceiverDoesNotExist", ":", ...
Return a json payload and appropriate status code on expection.
[ "Return", "a", "json", "payload", "and", "appropriate", "status", "code", "on", "expection", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L87-L109
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
ReceiverEventListResource.post
def post(self, receiver_id=None): """Handle POST request.""" try: user_id = request.oauth.access_token.user_id except AttributeError: user_id = current_user.get_id() event = Event.create( receiver_id=receiver_id, user_id=user_id ) ...
python
def post(self, receiver_id=None): """Handle POST request.""" try: user_id = request.oauth.access_token.user_id except AttributeError: user_id = current_user.get_id() event = Event.create( receiver_id=receiver_id, user_id=user_id ) ...
[ "def", "post", "(", "self", ",", "receiver_id", "=", "None", ")", ":", "try", ":", "user_id", "=", "request", ".", "oauth", ".", "access_token", ".", "user_id", "except", "AttributeError", ":", "user_id", "=", "current_user", ".", "get_id", "(", ")", "ev...
Handle POST request.
[ "Handle", "POST", "request", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L121-L138
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
ReceiverEventResource._get_event
def _get_event(receiver_id, event_id): """Find event and check access rights.""" event = Event.query.filter_by( receiver_id=receiver_id, id=event_id ).first_or_404() try: user_id = request.oauth.access_token.user_id except AttributeError: user...
python
def _get_event(receiver_id, event_id): """Find event and check access rights.""" event = Event.query.filter_by( receiver_id=receiver_id, id=event_id ).first_or_404() try: user_id = request.oauth.access_token.user_id except AttributeError: user...
[ "def", "_get_event", "(", "receiver_id", ",", "event_id", ")", ":", "event", "=", "Event", ".", "query", ".", "filter_by", "(", "receiver_id", "=", "receiver_id", ",", "id", "=", "event_id", ")", ".", "first_or_404", "(", ")", "try", ":", "user_id", "=",...
Find event and check access rights.
[ "Find", "event", "and", "check", "access", "rights", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L149-L163
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
ReceiverEventResource.get
def get(self, receiver_id=None, event_id=None): """Handle GET request.""" event = self._get_event(receiver_id, event_id) return make_response(event)
python
def get(self, receiver_id=None, event_id=None): """Handle GET request.""" event = self._get_event(receiver_id, event_id) return make_response(event)
[ "def", "get", "(", "self", ",", "receiver_id", "=", "None", ",", "event_id", "=", "None", ")", ":", "event", "=", "self", ".", "_get_event", "(", "receiver_id", ",", "event_id", ")", "return", "make_response", "(", "event", ")" ]
Handle GET request.
[ "Handle", "GET", "request", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L168-L171
train
inveniosoftware/invenio-webhooks
invenio_webhooks/views.py
ReceiverEventResource.delete
def delete(self, receiver_id=None, event_id=None): """Handle DELETE request.""" event = self._get_event(receiver_id, event_id) event.delete() db.session.commit() return make_response(event)
python
def delete(self, receiver_id=None, event_id=None): """Handle DELETE request.""" event = self._get_event(receiver_id, event_id) event.delete() db.session.commit() return make_response(event)
[ "def", "delete", "(", "self", ",", "receiver_id", "=", "None", ",", "event_id", "=", "None", ")", ":", "event", "=", "self", ".", "_get_event", "(", "receiver_id", ",", "event_id", ")", "event", ".", "delete", "(", ")", "db", ".", "session", ".", "co...
Handle DELETE request.
[ "Handle", "DELETE", "request", "." ]
f407cb2245464543ee474a81189fb9d3978bdde5
https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/views.py#L176-L181
train
architv/harvey
harvey/harvey.py
_stripslashes
def _stripslashes(s): '''Removes trailing and leading backslashes from string''' r = re.sub(r"\\(n|r)", "\n", s) r = re.sub(r"\\", "", r) return r
python
def _stripslashes(s): '''Removes trailing and leading backslashes from string''' r = re.sub(r"\\(n|r)", "\n", s) r = re.sub(r"\\", "", r) return r
[ "def", "_stripslashes", "(", "s", ")", ":", "r", "=", "re", ".", "sub", "(", "r\"\\\\(n|r)\"", ",", "\"\\n\"", ",", "s", ")", "r", "=", "re", ".", "sub", "(", "r\"\\\\\"", ",", "\"\"", ",", "r", ")", "return", "r" ]
Removes trailing and leading backslashes from string
[ "Removes", "trailing", "and", "leading", "backslashes", "from", "string" ]
2b96d57b7a1e0dd706f1f00aba3d92a7ae702960
https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/harvey.py#L46-L50
train
architv/harvey
harvey/harvey.py
_get_config_name
def _get_config_name(): '''Get git config user name''' p = subprocess.Popen('git config --get user.name', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.stdout.readlines() return _stripslashes(output[0])
python
def _get_config_name(): '''Get git config user name''' p = subprocess.Popen('git config --get user.name', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = p.stdout.readlines() return _stripslashes(output[0])
[ "def", "_get_config_name", "(", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "'git config --get user.name'", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "output", "...
Get git config user name
[ "Get", "git", "config", "user", "name" ]
2b96d57b7a1e0dd706f1f00aba3d92a7ae702960
https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/harvey.py#L53-L58
train
architv/harvey
harvey/harvey.py
_get_licences
def _get_licences(): """ Lists all the licenses on command line """ licenses = _LICENSES for license in licenses: print("{license_name} [{license_code}]".format( license_name=licenses[license], license_code=license))
python
def _get_licences(): """ Lists all the licenses on command line """ licenses = _LICENSES for license in licenses: print("{license_name} [{license_code}]".format( license_name=licenses[license], license_code=license))
[ "def", "_get_licences", "(", ")", ":", "licenses", "=", "_LICENSES", "for", "license", "in", "licenses", ":", "print", "(", "\"{license_name} [{license_code}]\"", ".", "format", "(", "license_name", "=", "licenses", "[", "license", "]", ",", "license_code", "=",...
Lists all the licenses on command line
[ "Lists", "all", "the", "licenses", "on", "command", "line" ]
2b96d57b7a1e0dd706f1f00aba3d92a7ae702960
https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/harvey.py#L61-L67
train