repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
log2timeline/plaso
plaso/parsers/winreg_plugins/mrulistex.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/mrulistex.py#L250-L288
def _ParseMRUListExEntryValue( self, parser_mediator, registry_key, entry_index, entry_number, codepage='cp1252', **kwargs): """Parses the MRUListEx entry value. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and d...
[ "def", "_ParseMRUListExEntryValue", "(", "self", ",", "parser_mediator", ",", "registry_key", ",", "entry_index", ",", "entry_number", ",", "codepage", "=", "'cp1252'", ",", "*", "*", "kwargs", ")", ":", "value_string", "=", "''", "value", "=", "registry_key", ...
Parses the MRUListEx entry value. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. registry_key (dfwinreg.WinRegistryKey): Windows Registry key that contains the MRUListEx value. entry_index (int): ...
[ "Parses", "the", "MRUListEx", "entry", "value", "." ]
python
train
36.025641
Robpol86/libnl
libnl/linux_private/netlink.py
https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/linux_private/netlink.py#L172-L174
def nlmsg_flags(self, value): """Message flags setter.""" self.bytearray[self._get_slicers(2)] = bytearray(c_uint16(value or 0))
[ "def", "nlmsg_flags", "(", "self", ",", "value", ")", ":", "self", ".", "bytearray", "[", "self", ".", "_get_slicers", "(", "2", ")", "]", "=", "bytearray", "(", "c_uint16", "(", "value", "or", "0", ")", ")" ]
Message flags setter.
[ "Message", "flags", "setter", "." ]
python
train
47.333333
OpenVolunteeringPlatform/django-ovp-search
ovp_search/signals.py
https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/signals.py#L87-L89
def handle_profile_save(self, sender, instance, **kwargs): """ Custom handler for user profile save """ self.handle_save(instance.user.__class__, instance.user)
[ "def", "handle_profile_save", "(", "self", ",", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "self", ".", "handle_save", "(", "instance", ".", "user", ".", "__class__", ",", "instance", ".", "user", ")" ]
Custom handler for user profile save
[ "Custom", "handler", "for", "user", "profile", "save" ]
python
train
55.333333
django-de/django-simple-ratings
ratings/models.py
https://github.com/django-de/django-simple-ratings/blob/f876f1284943b4913d865757f5d46b4515e26683/ratings/models.py#L153-L239
def create_manager(self, instance, superclass): """ Dynamically create a RelatedManager to handle the back side of the (G)FK """ rel_model = self.rating_model rated_model = self.rated_model class RelatedManager(superclass): def get_query_set(self): ...
[ "def", "create_manager", "(", "self", ",", "instance", ",", "superclass", ")", ":", "rel_model", "=", "self", ".", "rating_model", "rated_model", "=", "self", ".", "rated_model", "class", "RelatedManager", "(", "superclass", ")", ":", "def", "get_query_set", "...
Dynamically create a RelatedManager to handle the back side of the (G)FK
[ "Dynamically", "create", "a", "RelatedManager", "to", "handle", "the", "back", "side", "of", "the", "(", "G", ")", "FK" ]
python
train
38.701149
boriel/zxbasic
api/check.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/check.py#L258-L265
def is_static(*p): """ A static value (does not change at runtime) which is known at compile time """ return all(is_CONST(x) or is_number(x) or is_const(x) for x in p)
[ "def", "is_static", "(", "*", "p", ")", ":", "return", "all", "(", "is_CONST", "(", "x", ")", "or", "is_number", "(", "x", ")", "or", "is_const", "(", "x", ")", "for", "x", "in", "p", ")" ]
A static value (does not change at runtime) which is known at compile time
[ "A", "static", "value", "(", "does", "not", "change", "at", "runtime", ")", "which", "is", "known", "at", "compile", "time" ]
python
train
27.625
softlayer/softlayer-python
SoftLayer/shell/core.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/shell/core.py#L91-L102
def get_env_args(env): """Yield options to inject into the slcli command from the environment.""" for arg, val in env.vars.get('global_args', {}).items(): if val is True: yield '--%s' % arg elif isinstance(val, int): for _ in range(val): yield '--%s' % arg...
[ "def", "get_env_args", "(", "env", ")", ":", "for", "arg", ",", "val", "in", "env", ".", "vars", ".", "get", "(", "'global_args'", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "val", "is", "True", ":", "yield", "'--%s'", "%", "arg", "...
Yield options to inject into the slcli command from the environment.
[ "Yield", "options", "to", "inject", "into", "the", "slcli", "command", "from", "the", "environment", "." ]
python
train
34.25
gem/oq-engine
openquake/hazardlib/sourceconverter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L80-L97
def collect(cls, sources): """ :param sources: dictionaries with a key 'tectonicRegion' :returns: an ordered list of SourceGroup instances """ source_stats_dict = {} for src in sources: trt = src['tectonicRegion'] if trt not in source_stats_dict: ...
[ "def", "collect", "(", "cls", ",", "sources", ")", ":", "source_stats_dict", "=", "{", "}", "for", "src", "in", "sources", ":", "trt", "=", "src", "[", "'tectonicRegion'", "]", "if", "trt", "not", "in", "source_stats_dict", ":", "source_stats_dict", "[", ...
:param sources: dictionaries with a key 'tectonicRegion' :returns: an ordered list of SourceGroup instances
[ ":", "param", "sources", ":", "dictionaries", "with", "a", "key", "tectonicRegion", ":", "returns", ":", "an", "ordered", "list", "of", "SourceGroup", "instances" ]
python
train
38.833333
arista-eosplus/pyeapi
pyeapi/api/vrrp.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/vrrp.py#L738-L781
def set_mac_addr_adv_interval(self, name, vrid, value=None, disable=False, default=False, run=True): """Set the mac_addr_adv_interval property of the vrrp Args: name (string): The interface to configure. vrid (integer): The vrid number for the v...
[ "def", "set_mac_addr_adv_interval", "(", "self", ",", "name", ",", "vrid", ",", "value", "=", "None", ",", "disable", "=", "False", ",", "default", "=", "False", ",", "run", "=", "True", ")", ":", "if", "not", "default", "and", "not", "disable", ":", ...
Set the mac_addr_adv_interval property of the vrrp Args: name (string): The interface to configure. vrid (integer): The vrid number for the vrrp to be managed. value (integer): mac-address advertisement-interval value to assign to the vrrp. disabl...
[ "Set", "the", "mac_addr_adv_interval", "property", "of", "the", "vrrp" ]
python
train
40.136364
ultrabug/py3status
py3status/modules/i3pystatus.py
https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/modules/i3pystatus.py#L87-L112
def get_backends(): """ Get backends info so that we can find the correct one. We just look in the directory structure to find modules. """ IGNORE_DIRS = ["core", "tools", "utils"] global backends if backends is None: backends = {} i3pystatus_dir = os.path.dirname(i3pystatus...
[ "def", "get_backends", "(", ")", ":", "IGNORE_DIRS", "=", "[", "\"core\"", ",", "\"tools\"", ",", "\"utils\"", "]", "global", "backends", "if", "backends", "is", "None", ":", "backends", "=", "{", "}", "i3pystatus_dir", "=", "os", ".", "path", ".", "dirn...
Get backends info so that we can find the correct one. We just look in the directory structure to find modules.
[ "Get", "backends", "info", "so", "that", "we", "can", "find", "the", "correct", "one", ".", "We", "just", "look", "in", "the", "directory", "structure", "to", "find", "modules", "." ]
python
train
32.153846
aio-libs/aioredis
aioredis/connection.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/connection.py#L306-L351
def execute(self, command, *args, encoding=_NOTSET): """Executes redis command and returns Future waiting for the answer. Raises: * TypeError if any of args can not be encoded as bytes. * ReplyError on redis '-ERR' responses. * ProtocolError when response can not be decoded mean...
[ "def", "execute", "(", "self", ",", "command", ",", "*", "args", ",", "encoding", "=", "_NOTSET", ")", ":", "if", "self", ".", "_reader", "is", "None", "or", "self", ".", "_reader", ".", "at_eof", "(", ")", ":", "msg", "=", "self", ".", "_close_msg...
Executes redis command and returns Future waiting for the answer. Raises: * TypeError if any of args can not be encoded as bytes. * ReplyError on redis '-ERR' responses. * ProtocolError when response can not be decoded meaning connection is broken. * ConnectionClosedEr...
[ "Executes", "redis", "command", "and", "returns", "Future", "waiting", "for", "the", "answer", "." ]
python
train
43.021739
google/grumpy
third_party/pythonparser/parser.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1278-L1289
def with_stmt__26(self, with_loc, context, with_var, colon_loc, body): """(2.6, 3.0) with_stmt: 'with' test [ with_var ] ':' suite""" if with_var: as_loc, optional_vars = with_var item = ast.withitem(context_expr=context, optional_vars=optional_vars, ...
[ "def", "with_stmt__26", "(", "self", ",", "with_loc", ",", "context", ",", "with_var", ",", "colon_loc", ",", "body", ")", ":", "if", "with_var", ":", "as_loc", ",", "optional_vars", "=", "with_var", "item", "=", "ast", ".", "withitem", "(", "context_expr"...
(2.6, 3.0) with_stmt: 'with' test [ with_var ] ':' suite
[ "(", "2", ".", "6", "3", ".", "0", ")", "with_stmt", ":", "with", "test", "[", "with_var", "]", ":", "suite" ]
python
valid
57.5
ns1/ns1-python
ns1/__init__.py
https://github.com/ns1/ns1-python/blob/f3e1d90a3b76a1bd18f855f2c622a8a49d4b585e/ns1/__init__.py#L80-L87
def scope_groups(self): """ Return a new raw REST interface to scope_group resources :rtype: :py:class:`ns1.rest.ipam.Scopegroups` """ import ns1.rest.ipam return ns1.rest.ipam.Scopegroups(self.config)
[ "def", "scope_groups", "(", "self", ")", ":", "import", "ns1", ".", "rest", ".", "ipam", "return", "ns1", ".", "rest", ".", "ipam", ".", "Scopegroups", "(", "self", ".", "config", ")" ]
Return a new raw REST interface to scope_group resources :rtype: :py:class:`ns1.rest.ipam.Scopegroups`
[ "Return", "a", "new", "raw", "REST", "interface", "to", "scope_group", "resources" ]
python
train
30.375
chaoss/grimoirelab-sortinghat
sortinghat/cmd/withdraw.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/withdraw.py#L78-L95
def run(self, *args): """Withdraw a unique identity from an organization.""" params = self.parser.parse_args(args) uuid = params.uuid organization = params.organization try: from_date = utils.str_to_datetime(params.from_date) to_date = utils.str_to_date...
[ "def", "run", "(", "self", ",", "*", "args", ")", ":", "params", "=", "self", ".", "parser", ".", "parse_args", "(", "args", ")", "uuid", "=", "params", ".", "uuid", "organization", "=", "params", ".", "organization", "try", ":", "from_date", "=", "u...
Withdraw a unique identity from an organization.
[ "Withdraw", "a", "unique", "identity", "from", "an", "organization", "." ]
python
train
28.5
apache/incubator-mxnet
python/mxnet/model.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L150-L160
def _update_params_on_kvstore(param_arrays, grad_arrays, kvstore, param_names): """Perform update of param_arrays from grad_arrays on kvstore.""" for index, pair in enumerate(zip(param_arrays, grad_arrays)): arg_list, grad_list = pair if grad_list[0] is None: continue name = ...
[ "def", "_update_params_on_kvstore", "(", "param_arrays", ",", "grad_arrays", ",", "kvstore", ",", "param_names", ")", ":", "for", "index", ",", "pair", "in", "enumerate", "(", "zip", "(", "param_arrays", ",", "grad_arrays", ")", ")", ":", "arg_list", ",", "g...
Perform update of param_arrays from grad_arrays on kvstore.
[ "Perform", "update", "of", "param_arrays", "from", "grad_arrays", "on", "kvstore", "." ]
python
train
47.363636
Infinidat/infi.projector
src/infi/projector/commandline_parser/__init__.py
https://github.com/Infinidat/infi.projector/blob/4a0d098f4f8f14ffb3e7536c7515fa79a21c1134/src/infi/projector/commandline_parser/__init__.py#L8-L19
def parse_docopt_string(docopt_string): """returns a 2-tuple (usage, options)""" from re import match, DOTALL only_usage_pattern = r"""\s+Usage:\s+(?P<usage>.*)\s+""" usage_and_options_pattern = r"""\s+Usage:\s+(?P<usage>.*)\s+Options:\s+(?P<options>.*)\s+""" usage, options = '', '' if match(usa...
[ "def", "parse_docopt_string", "(", "docopt_string", ")", ":", "from", "re", "import", "match", ",", "DOTALL", "only_usage_pattern", "=", "r\"\"\"\\s+Usage:\\s+(?P<usage>.*)\\s+\"\"\"", "usage_and_options_pattern", "=", "r\"\"\"\\s+Usage:\\s+(?P<usage>.*)\\s+Options:\\s+(?P<options>...
returns a 2-tuple (usage, options)
[ "returns", "a", "2", "-", "tuple", "(", "usage", "options", ")" ]
python
train
59.75
olitheolix/qtmacs
qtmacs/qtmacsmain.py
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/qtmacsmain.py#L2025-L2098
def qteAddMiniApplet(self, appletObj: QtmacsApplet): """ Install ``appletObj`` as the mini applet in the window layout. At any given point there can ever only be one mini applet in the entire Qtmacs application, irrespective of how many windows are open. Note that this ...
[ "def", "qteAddMiniApplet", "(", "self", ",", "appletObj", ":", "QtmacsApplet", ")", ":", "# Do nothing if a custom mini applet has already been", "# installed.", "if", "self", ".", "_qteMiniApplet", "is", "not", "None", ":", "msg", "=", "'Cannot replace mini applet more t...
Install ``appletObj`` as the mini applet in the window layout. At any given point there can ever only be one mini applet in the entire Qtmacs application, irrespective of how many windows are open. Note that this method does nothing if a custom mini applet is already active. Us...
[ "Install", "appletObj", "as", "the", "mini", "applet", "in", "the", "window", "layout", "." ]
python
train
36.648649
saltstack/salt
salt/proxy/cimc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/cimc.py#L110-L139
def init(opts): ''' This function gets called when the proxy starts up. ''' if 'host' not in opts['proxy']: log.critical('No \'host\' key found in pillar for this proxy.') return False if 'username' not in opts['proxy']: log.critical('No \'username\' key found in pillar for t...
[ "def", "init", "(", "opts", ")", ":", "if", "'host'", "not", "in", "opts", "[", "'proxy'", "]", ":", "log", ".", "critical", "(", "'No \\'host\\' key found in pillar for this proxy.'", ")", "return", "False", "if", "'username'", "not", "in", "opts", "[", "'p...
This function gets called when the proxy starts up.
[ "This", "function", "gets", "called", "when", "the", "proxy", "starts", "up", "." ]
python
train
38.466667
heuer/segno
segno/encoder.py
https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/encoder.py#L330-L355
def write_segment(buff, segment, ver, ver_range, eci=False): """\ Writes a segment. :param buff: The byte buffer. :param _Segment segment: The segment to serialize. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param ver_rang...
[ "def", "write_segment", "(", "buff", ",", "segment", ",", "ver", ",", "ver_range", ",", "eci", "=", "False", ")", ":", "mode", "=", "segment", ".", "mode", "append_bits", "=", "buff", ".", "append_bits", "# Write ECI header if requested", "if", "eci", "and",...
\ Writes a segment. :param buff: The byte buffer. :param _Segment segment: The segment to serialize. :param ver: ``None`` if a QR Code is written, "M1", "M2", "M3", or "M4" if a Micro QR Code is written. :param ver_range: "M1", "M2", "M3", or "M4" if a Micro QR Code is written, ...
[ "\\", "Writes", "a", "segment", "." ]
python
train
43.192308
toumorokoshi/jenks
jenks/__init__.py
https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/__init__.py#L59-L71
def _get_jenks_config(): """ retrieve the jenks configuration object """ config_file = (get_configuration_file() or os.path.expanduser(os.path.join("~", CONFIG_FILE_NAME))) if not os.path.exists(config_file): open(config_file, 'w').close() with open(config_file, 'r') as fh: ...
[ "def", "_get_jenks_config", "(", ")", ":", "config_file", "=", "(", "get_configuration_file", "(", ")", "or", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "join", "(", "\"~\"", ",", "CONFIG_FILE_NAME", ")", ")", ")", "if", "not", ...
retrieve the jenks configuration object
[ "retrieve", "the", "jenks", "configuration", "object" ]
python
train
34.076923
limodou/uliweb
uliweb/lib/werkzeug/script.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L186-L192
def find_actions(namespace, action_prefix): """Find all the actions in the namespace.""" actions = {} for key, value in iteritems(namespace): if key.startswith(action_prefix): actions[key[len(action_prefix):]] = analyse_action(value) return actions
[ "def", "find_actions", "(", "namespace", ",", "action_prefix", ")", ":", "actions", "=", "{", "}", "for", "key", ",", "value", "in", "iteritems", "(", "namespace", ")", ":", "if", "key", ".", "startswith", "(", "action_prefix", ")", ":", "actions", "[", ...
Find all the actions in the namespace.
[ "Find", "all", "the", "actions", "in", "the", "namespace", "." ]
python
train
39.714286
projectatomic/osbs-client
osbs/build/plugins_configuration.py
https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L239-L266
def render_customizations(self): """ Customize template for site user specified customizations """ disable_plugins = self.pt.customize_conf.get('disable_plugins', []) if not disable_plugins: logger.debug('No site-user specified plugins to disable') else: ...
[ "def", "render_customizations", "(", "self", ")", ":", "disable_plugins", "=", "self", ".", "pt", ".", "customize_conf", ".", "get", "(", "'disable_plugins'", ",", "[", "]", ")", "if", "not", "disable_plugins", ":", "logger", ".", "debug", "(", "'No site-use...
Customize template for site user specified customizations
[ "Customize", "template", "for", "site", "user", "specified", "customizations" ]
python
train
46.035714
wummel/linkchecker
linkcheck/checker/ftpurl.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/ftpurl.py#L211-L218
def close_connection (self): """Release the open connection from the connection pool.""" if self.url_connection is not None: try: self.url_connection.quit() except Exception: pass self.url_connection = None
[ "def", "close_connection", "(", "self", ")", ":", "if", "self", ".", "url_connection", "is", "not", "None", ":", "try", ":", "self", ".", "url_connection", ".", "quit", "(", ")", "except", "Exception", ":", "pass", "self", ".", "url_connection", "=", "No...
Release the open connection from the connection pool.
[ "Release", "the", "open", "connection", "from", "the", "connection", "pool", "." ]
python
train
35.375
pschmitt/pykeepass
pykeepass/kdbx_parsing/kdbx4.py
https://github.com/pschmitt/pykeepass/blob/85da3630d6e410b2a10d3e711cd69308b51d401d/pykeepass/kdbx_parsing/kdbx4.py#L31-L62
def compute_transformed(context): """Compute transformed key for opening database""" key_composite = compute_key_composite( password=context._._.password, keyfile=context._._.keyfile ) kdf_parameters = context._.header.value.dynamic_header.kdf_parameters.data.dict if context._._.tr...
[ "def", "compute_transformed", "(", "context", ")", ":", "key_composite", "=", "compute_key_composite", "(", "password", "=", "context", ".", "_", ".", "_", ".", "password", ",", "keyfile", "=", "context", ".", "_", ".", "_", ".", "keyfile", ")", "kdf_param...
Compute transformed key for opening database
[ "Compute", "transformed", "key", "for", "opening", "database" ]
python
train
36.34375
ccubed/PyMoe
Pymoe/VNDB/connection.py
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/connection.py#L70-L88
def send_command(self, command, args=None): """ Send a command to VNDB and then get the result. :param command: What command are we sending :param args: What are the json args for this command :return: Servers Response :rtype: Dictionary (See D11 docs on VNDB) ""...
[ "def", "send_command", "(", "self", ",", "command", ",", "args", "=", "None", ")", ":", "if", "args", ":", "if", "isinstance", "(", "args", ",", "str", ")", ":", "final_command", "=", "command", "+", "' '", "+", "args", "+", "'\\x04'", "else", ":", ...
Send a command to VNDB and then get the result. :param command: What command are we sending :param args: What are the json args for this command :return: Servers Response :rtype: Dictionary (See D11 docs on VNDB)
[ "Send", "a", "command", "to", "VNDB", "and", "then", "get", "the", "result", "." ]
python
train
39.894737
pyvisa/pyvisa
pyvisa/highlevel.py
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/highlevel.py#L1691-L1739
def open_resource(self, resource_name, access_mode=constants.AccessModes.no_lock, open_timeout=constants.VI_TMO_IMMEDIATE, resource_pyclass=None, **kwargs): """Return an instrument for the resource name. :param reso...
[ "def", "open_resource", "(", "self", ",", "resource_name", ",", "access_mode", "=", "constants", ".", "AccessModes", ".", "no_lock", ",", "open_timeout", "=", "constants", ".", "VI_TMO_IMMEDIATE", ",", "resource_pyclass", "=", "None", ",", "*", "*", "kwargs", ...
Return an instrument for the resource name. :param resource_name: name or alias of the resource to open. :param access_mode: access mode. :type access_mode: :class:`pyvisa.constants.AccessModes` :param open_timeout: time out to open. :param resource_pyclass: resource python clas...
[ "Return", "an", "instrument", "for", "the", "resource", "name", "." ]
python
train
39.877551
ejeschke/ginga
ginga/cmap.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/cmap.py#L13305-L13327
def add_matplotlib_cmaps(fail_on_import_error=True): """Add all matplotlib colormaps.""" try: from matplotlib import cm as _cm from matplotlib.cbook import mplDeprecation except ImportError: if fail_on_import_error: raise # silently fail return for na...
[ "def", "add_matplotlib_cmaps", "(", "fail_on_import_error", "=", "True", ")", ":", "try", ":", "from", "matplotlib", "import", "cm", "as", "_cm", "from", "matplotlib", ".", "cbook", "import", "mplDeprecation", "except", "ImportError", ":", "if", "fail_on_import_er...
Add all matplotlib colormaps.
[ "Add", "all", "matplotlib", "colormaps", "." ]
python
train
33.608696
fudge-py/fudge
fudge/__init__.py
https://github.com/fudge-py/fudge/blob/b283fbc1a41900f3f5845b10b8c2ef9136a67ebc/fudge/__init__.py#L1141-L1176
def times_called(self, n): """Set the number of times an object can be called. When working with provided calls, you'll only see an error if the expected call count is exceeded :: >>> auth = Fake('auth').provides('login').times_called(1) >>> auth.login() >>>...
[ "def", "times_called", "(", "self", ",", "n", ")", ":", "if", "self", ".", "_last_declared_call_name", ":", "actual_last_call", "=", "self", ".", "_declared_calls", "[", "self", ".", "_last_declared_call_name", "]", "if", "isinstance", "(", "actual_last_call", "...
Set the number of times an object can be called. When working with provided calls, you'll only see an error if the expected call count is exceeded :: >>> auth = Fake('auth').provides('login').times_called(1) >>> auth.login() >>> auth.login() Traceback (m...
[ "Set", "the", "number", "of", "times", "an", "object", "can", "be", "called", "." ]
python
train
38.444444
AnthonyBloomer/daftlistings
daftlistings/listing.py
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L541-L559
def city_center_distance(self): """ This method gets the distance to city center, in km. :return: """ try: infos = self._ad_page_content.find_all( 'div', {"class": "map_info_box"}) for info in infos: if 'Distance to City Cen...
[ "def", "city_center_distance", "(", "self", ")", ":", "try", ":", "infos", "=", "self", ".", "_ad_page_content", ".", "find_all", "(", "'div'", ",", "{", "\"class\"", ":", "\"map_info_box\"", "}", ")", "for", "info", "in", "infos", ":", "if", "'Distance to...
This method gets the distance to city center, in km. :return:
[ "This", "method", "gets", "the", "distance", "to", "city", "center", "in", "km", ".", ":", "return", ":" ]
python
train
34.368421
intake/intake
intake/catalog/default.py
https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/default.py#L79-L99
def load_combo_catalog(): """Load a union of the user and global catalogs for convenience""" user_dir = user_data_dir() global_dir = global_data_dir() desc = 'Generated from data packages found on your intake search path' cat_dirs = [] if os.path.isdir(user_dir): cat_dirs.append(user_dir...
[ "def", "load_combo_catalog", "(", ")", ":", "user_dir", "=", "user_data_dir", "(", ")", "global_dir", "=", "global_data_dir", "(", ")", "desc", "=", "'Generated from data packages found on your intake search path'", "cat_dirs", "=", "[", "]", "if", "os", ".", "path"...
Load a union of the user and global catalogs for convenience
[ "Load", "a", "union", "of", "the", "user", "and", "global", "catalogs", "for", "convenience" ]
python
train
40.904762
quantumlib/Cirq
cirq/schedules/schedule.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L75-L120
def query( self, *, # Forces keyword args. time: Timestamp, duration: Union[Duration, timedelta] = Duration(), qubits: Iterable[Qid] = None, include_query_end_time=False, include_op_end_times=False) -> List[ScheduledOperation]: ...
[ "def", "query", "(", "self", ",", "*", ",", "# Forces keyword args.", "time", ":", "Timestamp", ",", "duration", ":", "Union", "[", "Duration", ",", "timedelta", "]", "=", "Duration", "(", ")", ",", "qubits", ":", "Iterable", "[", "Qid", "]", "=", "Non...
Finds operations by time and qubit. Args: time: Operations must end after this time to be returned. duration: Operations must start by time+duration to be returned. qubits: If specified, only operations touching one of the included qubits will...
[ "Finds", "operations", "by", "time", "and", "qubit", "." ]
python
train
41.978261
bcbio/bcbio-nextgen
bcbio/distributed/objectstore.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/objectstore.py#L194-L202
def _download_chunk(self, chunk_offset, chunk_size): """Reads or downloads the received blob from the system.""" range_id = 'bytes={0}-{1}'.format( chunk_offset, chunk_offset + chunk_size - 1) return self._blob_service.get_blob( container_name=self._container_name, ...
[ "def", "_download_chunk", "(", "self", ",", "chunk_offset", ",", "chunk_size", ")", ":", "range_id", "=", "'bytes={0}-{1}'", ".", "format", "(", "chunk_offset", ",", "chunk_offset", "+", "chunk_size", "-", "1", ")", "return", "self", ".", "_blob_service", ".",...
Reads or downloads the received blob from the system.
[ "Reads", "or", "downloads", "the", "received", "blob", "from", "the", "system", "." ]
python
train
42
clemfromspace/scrapy-cloudflare-middleware
scrapy_cloudflare_middleware/middlewares.py
https://github.com/clemfromspace/scrapy-cloudflare-middleware/blob/03ccea9164418dabe8180053165b0da0bffa0741/scrapy_cloudflare_middleware/middlewares.py#L22-L48
def process_response(self, request, response, spider): """Handle the a Scrapy response""" if not self.is_cloudflare_challenge(response): return response logger = logging.getLogger('cloudflaremiddleware') logger.debug( 'Cloudflare protection detected on %s, tryi...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ",", "spider", ")", ":", "if", "not", "self", ".", "is_cloudflare_challenge", "(", "response", ")", ":", "return", "response", "logger", "=", "logging", ".", "getLogger", "(", "'cloudfl...
Handle the a Scrapy response
[ "Handle", "the", "a", "Scrapy", "response" ]
python
train
27.222222
CivicSpleen/ckcache
ckcache/filesystem.py
https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/filesystem.py#L552-L583
def verify(self): '''Check that the database accurately describes the state of the repository''' c = self.database.cursor() non_exist = set() no_db_entry = set(os.listdir(self.cache_dir)) try: no_db_entry.remove('file_database.db') no_db_entry.remove('fi...
[ "def", "verify", "(", "self", ")", ":", "c", "=", "self", ".", "database", ".", "cursor", "(", ")", "non_exist", "=", "set", "(", ")", "no_db_entry", "=", "set", "(", "os", ".", "listdir", "(", "self", ".", "cache_dir", ")", ")", "try", ":", "no_...
Check that the database accurately describes the state of the repository
[ "Check", "that", "the", "database", "accurately", "describes", "the", "state", "of", "the", "repository" ]
python
train
32.34375
zetaops/zengine
zengine/messaging/views.py
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L192-L224
def channel_history(current): """ Get old messages for a channel. 20 messages per request .. code-block:: python # request: { 'view':'_zops_channel_history, 'channel_key': key, 'timestamp': datetime, # timestamp data of o...
[ "def", "channel_history", "(", "current", ")", ":", "current", ".", "output", "=", "{", "'status'", ":", "'OK'", ",", "'code'", ":", "201", ",", "'messages'", ":", "[", "]", "}", "for", "msg", "in", "list", "(", "Message", ".", "objects", ".", "filte...
Get old messages for a channel. 20 messages per request .. code-block:: python # request: { 'view':'_zops_channel_history, 'channel_key': key, 'timestamp': datetime, # timestamp data of oldest shown message } ...
[ "Get", "old", "messages", "for", "a", "channel", ".", "20", "messages", "per", "request" ]
python
train
31.636364
python-rope/rope
rope/base/resourceobserver.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/base/resourceobserver.py#L32-L35
def resource_moved(self, resource, new_resource): """It is called when a resource is moved""" if self.moved is not None: self.moved(resource, new_resource)
[ "def", "resource_moved", "(", "self", ",", "resource", ",", "new_resource", ")", ":", "if", "self", ".", "moved", "is", "not", "None", ":", "self", ".", "moved", "(", "resource", ",", "new_resource", ")" ]
It is called when a resource is moved
[ "It", "is", "called", "when", "a", "resource", "is", "moved" ]
python
train
45
mfcloud/python-zvm-sdk
smtLayer/generalUtils.py
https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/smtLayer/generalUtils.py#L137-L163
def cvtToMag(rh, size): """ Convert a size value to a number with a magnitude appended. Input: Request Handle Size bytes Output: Converted value with a magnitude """ rh.printSysLog("Enter generalUtils.cvtToMag") mSize = '' size = size / (1024 * 1024) if size...
[ "def", "cvtToMag", "(", "rh", ",", "size", ")", ":", "rh", ".", "printSysLog", "(", "\"Enter generalUtils.cvtToMag\"", ")", "mSize", "=", "''", "size", "=", "size", "/", "(", "1024", "*", "1024", ")", "if", "size", ">", "(", "1024", "*", "5", ")", ...
Convert a size value to a number with a magnitude appended. Input: Request Handle Size bytes Output: Converted value with a magnitude
[ "Convert", "a", "size", "value", "to", "a", "number", "with", "a", "magnitude", "appended", "." ]
python
train
22.62963
saltstack/salt
salt/roster/sshconfig.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/roster/sshconfig.py#L128-L138
def ret_glob_minions(self): ''' Return minions that match via glob ''' minions = {} for minion in self.raw: if fnmatch.fnmatch(minion, self.tgt): data = self.get_data(minion) if data: minions[minion] = data r...
[ "def", "ret_glob_minions", "(", "self", ")", ":", "minions", "=", "{", "}", "for", "minion", "in", "self", ".", "raw", ":", "if", "fnmatch", ".", "fnmatch", "(", "minion", ",", "self", ".", "tgt", ")", ":", "data", "=", "self", ".", "get_data", "("...
Return minions that match via glob
[ "Return", "minions", "that", "match", "via", "glob" ]
python
train
29.363636
Esri/ArcREST
src/arcrest/manageportal/administration.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageportal/administration.py#L1734-L1744
def importSite(self, location): """ This operation imports the portal site configuration to a location you specify. """ params = { "location" : location, "f" : "json" } url = self._url + "/importSite" return self._post(url=url, para...
[ "def", "importSite", "(", "self", ",", "location", ")", ":", "params", "=", "{", "\"location\"", ":", "location", ",", "\"f\"", ":", "\"json\"", "}", "url", "=", "self", ".", "_url", "+", "\"/importSite\"", "return", "self", ".", "_post", "(", "url", "...
This operation imports the portal site configuration to a location you specify.
[ "This", "operation", "imports", "the", "portal", "site", "configuration", "to", "a", "location", "you", "specify", "." ]
python
train
29.454545
python-gitlab/python-gitlab
gitlab/v4/objects.py
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L1447-L1472
def create(self, data, **kwargs): """Create a new object. Args: data (dict): Parameters to send to the server to create the resource **kwargs: Extra options to send to the server (e.g. sudo or 'ref_name', 'stage', 'name', 'all') ...
[ "def", "create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "# project_id and commit_id are in the data dict when using the CLI, but", "# they are missing when using only the API", "# See #511", "base_path", "=", "'/projects/%(project_id)s/statuses/%(commit_id)s'"...
Create a new object. Args: data (dict): Parameters to send to the server to create the resource **kwargs: Extra options to send to the server (e.g. sudo or 'ref_name', 'stage', 'name', 'all') Raises: GitlabAuthenticatio...
[ "Create", "a", "new", "object", "." ]
python
train
40.538462
riga/law
law/logger.py
https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/logger.py#L22-L45
def setup_logging(): """ Sets up the internal logging mechanism, i.e., it creates the :py:attr:`console_handler`, sets its formatting, and mounts on on the main ``"law"`` logger. It also sets the levels of all loggers that are given in the law config. """ global console_handler # make sure ...
[ "def", "setup_logging", "(", ")", ":", "global", "console_handler", "# make sure logging is setup only once", "if", "console_handler", ":", "return", "# set the handler of the law root logger", "console_handler", "=", "logging", ".", "StreamHandler", "(", ")", "console_handle...
Sets up the internal logging mechanism, i.e., it creates the :py:attr:`console_handler`, sets its formatting, and mounts on on the main ``"law"`` logger. It also sets the levels of all loggers that are given in the law config.
[ "Sets", "up", "the", "internal", "logging", "mechanism", "i", ".", "e", ".", "it", "creates", "the", ":", "py", ":", "attr", ":", "console_handler", "sets", "its", "formatting", "and", "mounts", "on", "on", "the", "main", "law", "logger", ".", "It", "a...
python
train
37.208333
mikedh/trimesh
trimesh/transformations.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/transformations.py#L2033-L2052
def spherical_matrix(theta, phi, axes='sxyz'): """ Give a spherical coordinate vector, find the rotation that will transform a [0,0,1] vector to those coordinates Parameters ----------- theta: float, rotation angle in radians phi: float, rotation angle in radians Returns --------...
[ "def", "spherical_matrix", "(", "theta", ",", "phi", ",", "axes", "=", "'sxyz'", ")", ":", "result", "=", "euler_matrix", "(", "0.0", ",", "phi", ",", "theta", ",", "axes", "=", "axes", ")", "return", "result" ]
Give a spherical coordinate vector, find the rotation that will transform a [0,0,1] vector to those coordinates Parameters ----------- theta: float, rotation angle in radians phi: float, rotation angle in radians Returns ---------- matrix: (4,4) rotation matrix where the following wi...
[ "Give", "a", "spherical", "coordinate", "vector", "find", "the", "rotation", "that", "will", "transform", "a", "[", "0", "0", "1", "]", "vector", "to", "those", "coordinates" ]
python
train
29.25
fhamborg/news-please
newsplease/pipeline/extractor/cleaner.py
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/cleaner.py#L22-L33
def delete_tags(self, arg): """Removes html-tags from extracted data. :param arg: A string, the string which shall be cleaned :return: A string, the cleaned string """ if len(arg) > 0: raw = html.fromstring(arg) return raw.text_content().strip() ...
[ "def", "delete_tags", "(", "self", ",", "arg", ")", ":", "if", "len", "(", "arg", ")", ">", "0", ":", "raw", "=", "html", ".", "fromstring", "(", "arg", ")", "return", "raw", ".", "text_content", "(", ")", ".", "strip", "(", ")", "return", "arg" ...
Removes html-tags from extracted data. :param arg: A string, the string which shall be cleaned :return: A string, the cleaned string
[ "Removes", "html", "-", "tags", "from", "extracted", "data", "." ]
python
train
26.666667
Fizzadar/pyinfra
pyinfra/local.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/local.py#L81-L134
def shell(commands, splitlines=False, ignore_errors=False): ''' Subprocess based implementation of pyinfra/api/ssh.py's ``run_shell_command``. Args: commands (string, list): command or list of commands to execute spltlines (bool): optionally have the output split by lines ignore_err...
[ "def", "shell", "(", "commands", ",", "splitlines", "=", "False", ",", "ignore_errors", "=", "False", ")", ":", "if", "isinstance", "(", "commands", ",", "six", ".", "string_types", ")", ":", "commands", "=", "[", "commands", "]", "all_stdout", "=", "[",...
Subprocess based implementation of pyinfra/api/ssh.py's ``run_shell_command``. Args: commands (string, list): command or list of commands to execute spltlines (bool): optionally have the output split by lines ignore_errors (bool): ignore errors when executing these commands
[ "Subprocess", "based", "implementation", "of", "pyinfra", "/", "api", "/", "ssh", ".", "py", "s", "run_shell_command", "." ]
python
train
27.388889
nvdv/vprof
vprof/runner.py
https://github.com/nvdv/vprof/blob/4c3ff78f8920ab10cb9c00b14143452aa09ff6bb/vprof/runner.py#L45-L74
def run_profilers(run_object, prof_config, verbose=False): """Runs profilers on run_object. Args: run_object: An object (string or tuple) for profiling. prof_config: A string with profilers configuration. verbose: True if info about running profilers should be shown. Returns: ...
[ "def", "run_profilers", "(", "run_object", ",", "prof_config", ",", "verbose", "=", "False", ")", ":", "if", "len", "(", "prof_config", ")", ">", "len", "(", "set", "(", "prof_config", ")", ")", ":", "raise", "AmbiguousConfigurationError", "(", "'Profiler co...
Runs profilers on run_object. Args: run_object: An object (string or tuple) for profiling. prof_config: A string with profilers configuration. verbose: True if info about running profilers should be shown. Returns: An ordered dictionary with collected stats. Raises: ...
[ "Runs", "profilers", "on", "run_object", "." ]
python
test
40.266667
davgeo/clear
clear/renamer.py
https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/renamer.py#L529-L561
def _CreateNewShowDir(self, showName): """ Create new directory name for show. An autogenerated choice, which is the showName input that has been stripped of special characters, is proposed which the user can accept or they can enter a new name to use. If the skipUserInput variable is True the autog...
[ "def", "_CreateNewShowDir", "(", "self", ",", "showName", ")", ":", "stripedDir", "=", "util", ".", "StripSpecialCharacters", "(", "showName", ")", "goodlogging", ".", "Log", ".", "Info", "(", "\"RENAMER\"", ",", "\"Suggested show directory name is: '{0}'\"", ".", ...
Create new directory name for show. An autogenerated choice, which is the showName input that has been stripped of special characters, is proposed which the user can accept or they can enter a new name to use. If the skipUserInput variable is True the autogenerated value is accepted by default. Par...
[ "Create", "new", "directory", "name", "for", "show", ".", "An", "autogenerated", "choice", "which", "is", "the", "showName", "input", "that", "has", "been", "stripped", "of", "special", "characters", "is", "proposed", "which", "the", "user", "can", "accept", ...
python
train
33.878788
DLR-RM/RAFCON
source/rafcon/gui/models/modification_history.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/modification_history.py#L121-L141
def prepare_destruction(self): """Prepares the model for destruction Un-registers itself as observer from the state machine and the root state """ try: self.relieve_model(self.state_machine_model) assert self.__buffered_root_state_model is self.state_machine_mode...
[ "def", "prepare_destruction", "(", "self", ")", ":", "try", ":", "self", ".", "relieve_model", "(", "self", ".", "state_machine_model", ")", "assert", "self", ".", "__buffered_root_state_model", "is", "self", ".", "state_machine_model", ".", "root_state", "self", ...
Prepares the model for destruction Un-registers itself as observer from the state machine and the root state
[ "Prepares", "the", "model", "for", "destruction" ]
python
train
46.428571
shoebot/shoebot
lib/web/url.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/url.py#L181-L223
def open(url, wait=10): """ Returns a connection to a url which you can read(). When the wait amount is exceeded, raises a URLTimeout. When an error occurs, raises a URLError. 404 errors specifically return a HTTP404NotFound. """ # If the url is a URLParser, get any POST parameters. post...
[ "def", "open", "(", "url", ",", "wait", "=", "10", ")", ":", "# If the url is a URLParser, get any POST parameters.", "post", "=", "None", "if", "isinstance", "(", "url", ",", "URLParser", ")", "and", "url", ".", "method", "==", "\"post\"", ":", "post", "=",...
Returns a connection to a url which you can read(). When the wait amount is exceeded, raises a URLTimeout. When an error occurs, raises a URLError. 404 errors specifically return a HTTP404NotFound.
[ "Returns", "a", "connection", "to", "a", "url", "which", "you", "can", "read", "()", "." ]
python
valid
33.651163
saltstack/salt
salt/states/keystone_endpoint.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_endpoint.py#L80-L143
def present(name, service_name, auth=None, **kwargs): ''' Ensure an endpoint exists and is up-to-date name Interface name url URL of the endpoint service_name Service name or ID region The region name to assign the endpoint enabled Boolean to cont...
[ "def", "present", "(", "name", ",", "service_name", ",", "auth", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "...
Ensure an endpoint exists and is up-to-date name Interface name url URL of the endpoint service_name Service name or ID region The region name to assign the endpoint enabled Boolean to control if endpoint is enabled
[ "Ensure", "an", "endpoint", "exists", "and", "is", "up", "-", "to", "-", "date" ]
python
train
27.328125
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L134-L161
def get_trial_info(current_trial): """Get job information for current trial.""" if current_trial.end_time and ("_" in current_trial.end_time): # end time is parsed from result.json and the format # is like: yyyy-mm-dd_hh-MM-ss, which will be converted # to yyyy-mm-dd hh:MM:ss here ...
[ "def", "get_trial_info", "(", "current_trial", ")", ":", "if", "current_trial", ".", "end_time", "and", "(", "\"_\"", "in", "current_trial", ".", "end_time", ")", ":", "# end time is parsed from result.json and the format", "# is like: yyyy-mm-dd_hh-MM-ss, which will be conve...
Get job information for current trial.
[ "Get", "job", "information", "for", "current", "trial", "." ]
python
train
35.535714
potash/drain
drain/metrics.py
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/metrics.py#L29-L37
def _argtop(y_score, k=None): """ Returns the indexes of the top k scores (not necessarily sorted) """ # avoid sorting when just want the top all if k is None: return slice(0, len(y_score)) else: return _argsort(y_score, k)
[ "def", "_argtop", "(", "y_score", ",", "k", "=", "None", ")", ":", "# avoid sorting when just want the top all", "if", "k", "is", "None", ":", "return", "slice", "(", "0", ",", "len", "(", "y_score", ")", ")", "else", ":", "return", "_argsort", "(", "y_s...
Returns the indexes of the top k scores (not necessarily sorted)
[ "Returns", "the", "indexes", "of", "the", "top", "k", "scores", "(", "not", "necessarily", "sorted", ")" ]
python
train
28.333333
saltstack/salt
salt/cloud/clouds/parallels.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/parallels.py#L184-L270
def create_node(vm_): ''' Build and submit the XML to create a node ''' # Start the tree content = ET.Element('ve') # Name of the instance name = ET.SubElement(content, 'name') name.text = vm_['name'] # Description, defaults to name desc = ET.SubElement(content, 'description') ...
[ "def", "create_node", "(", "vm_", ")", ":", "# Start the tree", "content", "=", "ET", ".", "Element", "(", "'ve'", ")", "# Name of the instance", "name", "=", "ET", ".", "SubElement", "(", "content", ",", "'name'", ")", "name", ".", "text", "=", "vm_", "...
Build and submit the XML to create a node
[ "Build", "and", "submit", "the", "XML", "to", "create", "a", "node" ]
python
train
33.321839
scanny/python-pptx
pptx/parts/slide.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/parts/slide.py#L34-L44
def get_or_add_image_part(self, image_file): """ Return an ``(image_part, rId)`` 2-tuple corresponding to an |ImagePart| object containing the image in *image_file*, and related to this slide with the key *rId*. If either the image part or relationship already exists, they are re...
[ "def", "get_or_add_image_part", "(", "self", ",", "image_file", ")", ":", "image_part", "=", "self", ".", "_package", ".", "get_or_add_image_part", "(", "image_file", ")", "rId", "=", "self", ".", "relate_to", "(", "image_part", ",", "RT", ".", "IMAGE", ")",...
Return an ``(image_part, rId)`` 2-tuple corresponding to an |ImagePart| object containing the image in *image_file*, and related to this slide with the key *rId*. If either the image part or relationship already exists, they are reused, otherwise they are newly created.
[ "Return", "an", "(", "image_part", "rId", ")", "2", "-", "tuple", "corresponding", "to", "an", "|ImagePart|", "object", "containing", "the", "image", "in", "*", "image_file", "*", "and", "related", "to", "this", "slide", "with", "the", "key", "*", "rId", ...
python
train
47.272727
ellmetha/django-machina
machina/apps/forum_conversation/abstract_models.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/abstract_models.py#L147-L168
def save(self, *args, **kwargs): """ Saves the topic instance. """ # It is vital to track the changes of the forum associated with a topic in order to # maintain counters up-to-date. old_instance = None if self.pk: old_instance = self.__class__._default_manager.get(pk...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# It is vital to track the changes of the forum associated with a topic in order to", "# maintain counters up-to-date.", "old_instance", "=", "None", "if", "self", ".", "pk", ":", "old_ins...
Saves the topic instance.
[ "Saves", "the", "topic", "instance", "." ]
python
train
41.363636
CalebBell/ht
ht/boiling_flow.py
https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/boiling_flow.py#L38-L113
def Lazarek_Black(m, D, mul, kl, Hvap, q=None, Te=None): r'''Calculates heat transfer coefficient for film boiling of saturated fluid in vertical tubes for either upward or downward flow. Correlation is as shown in [1]_, and also reviewed in [2]_ and [3]_. Either the heat flux or excess temperature...
[ "def", "Lazarek_Black", "(", "m", ",", "D", ",", "mul", ",", "kl", ",", "Hvap", ",", "q", "=", "None", ",", "Te", "=", "None", ")", ":", "G", "=", "m", "/", "(", "pi", "/", "4", "*", "D", "**", "2", ")", "Relo", "=", "G", "*", "D", "/",...
r'''Calculates heat transfer coefficient for film boiling of saturated fluid in vertical tubes for either upward or downward flow. Correlation is as shown in [1]_, and also reviewed in [2]_ and [3]_. Either the heat flux or excess temperature is required for the calculation of heat transfer coeffic...
[ "r", "Calculates", "heat", "transfer", "coefficient", "for", "film", "boiling", "of", "saturated", "fluid", "in", "vertical", "tubes", "for", "either", "upward", "or", "downward", "flow", ".", "Correlation", "is", "as", "shown", "in", "[", "1", "]", "_", "...
python
train
36.026316
DarkEnergySurvey/ugali
ugali/utils/projector.py
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/projector.py#L202-L213
def gnomonicImageToSphere(x, y): """ Inverse gnomonic projection (deg). """ # Convert angle to [-180, 180] interval x = x - 360.*(x>180) x = np.asarray(x) y = np.asarray(y) lon = np.degrees(np.arctan2(y, x)) r_theta = np.sqrt(x**2 + y**2) lat = np.degrees(np.arctan(180. / (np.pi ...
[ "def", "gnomonicImageToSphere", "(", "x", ",", "y", ")", ":", "# Convert angle to [-180, 180] interval", "x", "=", "x", "-", "360.", "*", "(", "x", ">", "180", ")", "x", "=", "np", ".", "asarray", "(", "x", ")", "y", "=", "np", ".", "asarray", "(", ...
Inverse gnomonic projection (deg).
[ "Inverse", "gnomonic", "projection", "(", "deg", ")", "." ]
python
train
28.416667
bitcraze/crazyflie-lib-python
cflib/crazyflie/toc.py
https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/crazyflie/toc.py#L82-L91
def get_element_id(self, complete_name): """Get the TocElement element id-number of the element with the supplied name.""" [group, name] = complete_name.split('.') element = self.get_element(group, name) if element: return element.ident else: logge...
[ "def", "get_element_id", "(", "self", ",", "complete_name", ")", ":", "[", "group", ",", "name", "]", "=", "complete_name", ".", "split", "(", "'.'", ")", "element", "=", "self", ".", "get_element", "(", "group", ",", "name", ")", "if", "element", ":",...
Get the TocElement element id-number of the element with the supplied name.
[ "Get", "the", "TocElement", "element", "id", "-", "number", "of", "the", "element", "with", "the", "supplied", "name", "." ]
python
train
39.1
googleapis/google-cloud-python
datacatalog/google/cloud/datacatalog_v1beta1/gapic/data_catalog_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datacatalog/google/cloud/datacatalog_v1beta1/gapic/data_catalog_client.py#L195-L272
def lookup_entry( self, linked_resource=None, sql_resource=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Get an entry by target resource name. This method allows clients to u...
[ "def", "lookup_entry", "(", "self", ",", "linked_resource", "=", "None", ",", "sql_resource", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", ...
Get an entry by target resource name. This method allows clients to use the resource name from the source Google Cloud Platform service to get the Cloud Data Catalog Entry. Example: >>> from google.cloud import datacatalog_v1beta1 >>> >>> client = datacatalog...
[ "Get", "an", "entry", "by", "target", "resource", "name", ".", "This", "method", "allows", "clients", "to", "use", "the", "resource", "name", "from", "the", "source", "Google", "Cloud", "Platform", "service", "to", "get", "the", "Cloud", "Data", "Catalog", ...
python
train
43.871795
KenjiTakahashi/td
td/model.py
https://github.com/KenjiTakahashi/td/blob/7311eabc63efe6fe6600687c3026f0837454c2e4/td/model.py#L104-L127
def save(func): """@decorator: Saves data after executing :func:. Also performs modifications set as permanent options. """ def aux(self, *args, **kwargs): out = func(self, *args, **kwargs) path = (hasattr(self, 'path') and self.path or os.path.join(os.getcwd(), '.td'))...
[ "def", "save", "(", "func", ")", ":", "def", "aux", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "path", "=", "(", "hasattr", "(", "self", ...
@decorator: Saves data after executing :func:. Also performs modifications set as permanent options.
[ "@decorator", ":", "Saves", "data", "after", "executing", ":", "func", ":", "." ]
python
train
33.375
polysquare/polysquare-generic-file-linter
polysquarelinter/spelling.py
https://github.com/polysquare/polysquare-generic-file-linter/blob/cfc88771acd3d5551c28fa5d917bb0aeb584c4cc/polysquarelinter/spelling.py#L395-L429
def from_text(self, line, line_index, column, is_escaped): """Return the new state of the comment parser.""" begin = self._begin end = self._end single = self._single single_len = len(single) start_len = len(begin) if _token_at_col_in_line(line, column, single, ...
[ "def", "from_text", "(", "self", ",", "line", ",", "line_index", ",", "column", ",", "is_escaped", ")", ":", "begin", "=", "self", ".", "_begin", "end", "=", "self", ".", "_end", "single", "=", "self", ".", "_single", "single_len", "=", "len", "(", "...
Return the new state of the comment parser.
[ "Return", "the", "new", "state", "of", "the", "comment", "parser", "." ]
python
train
40.142857
MisterWil/abodepy
abodepy/__init__.py
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L371-L383
def _area_settings(area, setting, value, validate_value): """Will validate area settings and values, returns data packet.""" if validate_value: # Exit delay has some specific limitations apparently if (setting == CONST.SETTING_EXIT_DELAY_AWAY and value not in ...
[ "def", "_area_settings", "(", "area", ",", "setting", ",", "value", ",", "validate_value", ")", ":", "if", "validate_value", ":", "# Exit delay has some specific limitations apparently", "if", "(", "setting", "==", "CONST", ".", "SETTING_EXIT_DELAY_AWAY", "and", "valu...
Will validate area settings and values, returns data packet.
[ "Will", "validate", "area", "settings", "and", "values", "returns", "data", "packet", "." ]
python
train
55.769231
google/pyringe
pyringe/payload/libpython.py
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L459-L479
def proxyval(self, visited): ''' Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors ''' # Guard against infinite loops: if self.as_address() in visited: ...
[ "def", "proxyval", "(", "self", ",", "visited", ")", ":", "# Guard against infinite loops:", "if", "self", ".", "as_address", "(", ")", "in", "visited", ":", "return", "ProxyAlreadyVisited", "(", "'<...>'", ")", "visited", ".", "add", "(", "self", ".", "as_a...
Support for new-style classes. Currently we just locate the dictionary using a transliteration to python of _PyObject_GetDictPtr, ignoring descriptors
[ "Support", "for", "new", "-", "style", "classes", "." ]
python
train
32.52381
tanghaibao/goatools
goatools/grouper/sorter.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/sorter.py#L94-L146
def get_desc2nts_fnc(self, hdrgo_prt=True, section_prt=None, top_n=None, use_sections=True): """Return grouped, sorted namedtuples in either format: flat, sections.""" # RETURN: flat list of namedtuples nts_flat = self.get_nts_flat(hdrgo_prt, use_sections) if nts...
[ "def", "get_desc2nts_fnc", "(", "self", ",", "hdrgo_prt", "=", "True", ",", "section_prt", "=", "None", ",", "top_n", "=", "None", ",", "use_sections", "=", "True", ")", ":", "# RETURN: flat list of namedtuples", "nts_flat", "=", "self", ".", "get_nts_flat", "...
Return grouped, sorted namedtuples in either format: flat, sections.
[ "Return", "grouped", "sorted", "namedtuples", "in", "either", "format", ":", "flat", "sections", "." ]
python
train
59.283019
mitsei/dlkit
dlkit/records/assessment/fbw/assessment_bank_records.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/records/assessment/fbw/assessment_bank_records.py#L48-L63
def _init_metadata(self): """stub""" self._objective_bank_id_metadata = { 'element_id': Id(self.my_osid_object_form._authority, self.my_osid_object_form._namespace, 'objective_bank_id'), 'element_label': 'Objective Bank Id...
[ "def", "_init_metadata", "(", "self", ")", ":", "self", ".", "_objective_bank_id_metadata", "=", "{", "'element_id'", ":", "Id", "(", "self", ".", "my_osid_object_form", ".", "_authority", ",", "self", ".", "my_osid_object_form", ".", "_namespace", ",", "'object...
stub
[ "stub" ]
python
train
36.9375
woolfson-group/isambard
isambard/ampal/pseudo_atoms.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pseudo_atoms.py#L259-L268
def from_coordinates(cls, coordinates): """Creates a `Primitive` from a list of coordinates.""" prim = cls() for coord in coordinates: pm = PseudoMonomer(ampal_parent=prim) pa = PseudoAtom(coord, ampal_parent=pm) pm.atoms = OrderedDict([('CA', pa)]) ...
[ "def", "from_coordinates", "(", "cls", ",", "coordinates", ")", ":", "prim", "=", "cls", "(", ")", "for", "coord", "in", "coordinates", ":", "pm", "=", "PseudoMonomer", "(", "ampal_parent", "=", "prim", ")", "pa", "=", "PseudoAtom", "(", "coord", ",", ...
Creates a `Primitive` from a list of coordinates.
[ "Creates", "a", "Primitive", "from", "a", "list", "of", "coordinates", "." ]
python
train
37.5
google/grr
grr/server/grr_response_server/aff4_objects/filestore.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L418-L444
def ListHashes(age=aff4.NEWEST_TIME): """Yields all the hashes in the file store. Args: age: AFF4 age specification. Only get hits corresponding to the given age spec. Should be aff4.NEWEST_TIME or a time range given as a tuple (start, end) in microseconds since Jan 1st, 1970. If just a m...
[ "def", "ListHashes", "(", "age", "=", "aff4", ".", "NEWEST_TIME", ")", ":", "if", "age", "==", "aff4", ".", "ALL_TIMES", ":", "raise", "ValueError", "(", "\"age==aff4.ALL_TIMES is not allowed.\"", ")", "urns", "=", "[", "]", "for", "fingerprint_type", ",", "...
Yields all the hashes in the file store. Args: age: AFF4 age specification. Only get hits corresponding to the given age spec. Should be aff4.NEWEST_TIME or a time range given as a tuple (start, end) in microseconds since Jan 1st, 1970. If just a microseconds value is given it's treat...
[ "Yields", "all", "the", "hashes", "in", "the", "file", "store", "." ]
python
train
38.592593
noirbizarre/django-eztables
eztables/views.py
https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L191-L202
def get_row(self, row): '''Format a single row (if necessary)''' if isinstance(self.fields, dict): return dict([ (key, text_type(value).format(**row) if RE_FORMATTED.match(value) else row[value]) for key, value in self.fields.items() ]) el...
[ "def", "get_row", "(", "self", ",", "row", ")", ":", "if", "isinstance", "(", "self", ".", "fields", ",", "dict", ")", ":", "return", "dict", "(", "[", "(", "key", ",", "text_type", "(", "value", ")", ".", "format", "(", "*", "*", "row", ")", "...
Format a single row (if necessary)
[ "Format", "a", "single", "row", "(", "if", "necessary", ")" ]
python
train
39.5
Tanganelli/CoAPthon3
coapthon/layers/blocklayer.py
https://github.com/Tanganelli/CoAPthon3/blob/985763bfe2eb9e00f49ec100c5b8877c2ed7d531/coapthon/layers/blocklayer.py#L293-L308
def error(transaction, code): # pragma: no cover """ Notifies generic error on blockwise exchange. :type transaction: Transaction :param transaction: the transaction that owns the response :rtype : Transaction :return: the edited transaction """ transact...
[ "def", "error", "(", "transaction", ",", "code", ")", ":", "# pragma: no cover", "transaction", ".", "block_transfer", "=", "True", "transaction", ".", "response", "=", "Response", "(", ")", "transaction", ".", "response", ".", "destination", "=", "transaction",...
Notifies generic error on blockwise exchange. :type transaction: Transaction :param transaction: the transaction that owns the response :rtype : Transaction :return: the edited transaction
[ "Notifies", "generic", "error", "on", "blockwise", "exchange", "." ]
python
train
39.375
impact27/registrator
registrator/image.py
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/image.py#L634-L662
def shift_image(im, shift, borderValue=0): """shift the image Parameters ---------- im: 2d array The image shift: 2 numbers (y,x) the shift in y and x direction borderValue: number, default 0 The value for the pixels outside the border (default 0) Returns ------...
[ "def", "shift_image", "(", "im", ",", "shift", ",", "borderValue", "=", "0", ")", ":", "im", "=", "np", ".", "asarray", "(", "im", ",", "dtype", "=", "np", ".", "float32", ")", "rows", ",", "cols", "=", "im", ".", "shape", "M", "=", "np", ".", ...
shift the image Parameters ---------- im: 2d array The image shift: 2 numbers (y,x) the shift in y and x direction borderValue: number, default 0 The value for the pixels outside the border (default 0) Returns ------- im: 2d array The shifted image ...
[ "shift", "the", "image" ]
python
train
28.344828
pesaply/sarafu
profile.py
https://github.com/pesaply/sarafu/blob/8c1296d48427a6cf17ffc5600d100b49acc9c5b7/profile.py#L399-L404
def delete(self): """Delete the customer payment profile remotely and locally""" response = delete_payment_profile(self.customer_profile.profile_id, self.payment_profile_id) response.raise_if_error() return super(CustomerPaymentProfile, self).del...
[ "def", "delete", "(", "self", ")", ":", "response", "=", "delete_payment_profile", "(", "self", ".", "customer_profile", ".", "profile_id", ",", "self", ".", "payment_profile_id", ")", "response", ".", "raise_if_error", "(", ")", "return", "super", "(", "Custo...
Delete the customer payment profile remotely and locally
[ "Delete", "the", "customer", "payment", "profile", "remotely", "and", "locally" ]
python
train
53.333333
toumorokoshi/sprinter
sprinter/core/featureconfig.py
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/core/featureconfig.py#L101-L106
def write_to_manifest(self): """ Overwrites the section of the manifest with the featureconfig's value """ self.manifest.remove_section(self.feature_name) self.manifest.add_section(self.feature_name) for k, v in self.raw_dict.items(): self.manifest.set(self.feature_name, k, v...
[ "def", "write_to_manifest", "(", "self", ")", ":", "self", ".", "manifest", ".", "remove_section", "(", "self", ".", "feature_name", ")", "self", ".", "manifest", ".", "add_section", "(", "self", ".", "feature_name", ")", "for", "k", ",", "v", "in", "sel...
Overwrites the section of the manifest with the featureconfig's value
[ "Overwrites", "the", "section", "of", "the", "manifest", "with", "the", "featureconfig", "s", "value" ]
python
train
52.666667
CellProfiler/centrosome
centrosome/otsu.py
https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/otsu.py#L205-L217
def entropy_score(var,bins, w=None, decimate=True): '''Compute entropy scores, given a variance and # of bins ''' if w is None: n = len(var) w = np.arange(0,n,n//bins) / float(n) if decimate: n = len(var) var = var[0:n:n//bins] score = w * np.log(var * w * np.sqr...
[ "def", "entropy_score", "(", "var", ",", "bins", ",", "w", "=", "None", ",", "decimate", "=", "True", ")", ":", "if", "w", "is", "None", ":", "n", "=", "len", "(", "var", ")", "w", "=", "np", ".", "arange", "(", "0", ",", "n", ",", "n", "//...
Compute entropy scores, given a variance and # of bins
[ "Compute", "entropy", "scores", "given", "a", "variance", "and", "#", "of", "bins" ]
python
train
29.230769
apache/incubator-mxnet
python/mxnet/ndarray/utils.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/utils.py#L222-L273
def save(fname, data): """Saves a list of arrays or a dict of str->array to file. Examples of filenames: - ``/path/to/file`` - ``s3://my-bucket/path/to/file`` (if compiled with AWS S3 supports) - ``hdfs://path/to/file`` (if compiled with HDFS supports) Parameters ---------- fname : st...
[ "def", "save", "(", "fname", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "NDArray", ")", ":", "data", "=", "[", "data", "]", "handles", "=", "c_array", "(", "NDArrayHandle", ",", "[", "]", ")", "if", "isinstance", "(", "data", ",",...
Saves a list of arrays or a dict of str->array to file. Examples of filenames: - ``/path/to/file`` - ``s3://my-bucket/path/to/file`` (if compiled with AWS S3 supports) - ``hdfs://path/to/file`` (if compiled with HDFS supports) Parameters ---------- fname : str The filename. da...
[ "Saves", "a", "list", "of", "arrays", "or", "a", "dict", "of", "str", "-", ">", "array", "to", "file", "." ]
python
train
36.980769
ggravlingen/pytradfri
pytradfri/gateway.py
https://github.com/ggravlingen/pytradfri/blob/63750fa8fb27158c013d24865cdaa7fb82b3ab53/pytradfri/gateway.py#L47-L56
def get_devices(self): """ Return the devices linked to the gateway. Returns a Command. """ def process_result(result): return [self.get_device(dev) for dev in result] return Command('get', [ROOT_DEVICES], process_result=process_result)
[ "def", "get_devices", "(", "self", ")", ":", "def", "process_result", "(", "result", ")", ":", "return", "[", "self", ".", "get_device", "(", "dev", ")", "for", "dev", "in", "result", "]", "return", "Command", "(", "'get'", ",", "[", "ROOT_DEVICES", "]...
Return the devices linked to the gateway. Returns a Command.
[ "Return", "the", "devices", "linked", "to", "the", "gateway", "." ]
python
train
28.9
CyberReboot/vent
vent/menus/main.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/main.py#L83-L160
def perform_action(self, action): """ Perform actions in the api from the CLI """ form = ToolForm s_action = form_action = action.split('_')[0] form_name = s_action.title() + ' tools' cores = False a_type = 'containers' forms = [action.upper() + 'TOOLS'] f...
[ "def", "perform_action", "(", "self", ",", "action", ")", ":", "form", "=", "ToolForm", "s_action", "=", "form_action", "=", "action", ".", "split", "(", "'_'", ")", "[", "0", "]", "form_name", "=", "s_action", ".", "title", "(", ")", "+", "' tools'", ...
Perform actions in the api from the CLI
[ "Perform", "actions", "in", "the", "api", "from", "the", "CLI" ]
python
train
41.115385
tbielawa/bitmath
bitmath/__init__.py
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1174-L1198
def best_prefix(bytes, system=NIST): """Return a bitmath instance representing the best human-readable representation of the number of bytes given by ``bytes``. In addition to a numeric type, the ``bytes`` parameter may also be a bitmath type. Optionally select a preferred unit system by specifying the ``system`` ...
[ "def", "best_prefix", "(", "bytes", ",", "system", "=", "NIST", ")", ":", "if", "isinstance", "(", "bytes", ",", "Bitmath", ")", ":", "value", "=", "bytes", ".", "bytes", "else", ":", "value", "=", "bytes", "return", "Byte", "(", "value", ")", ".", ...
Return a bitmath instance representing the best human-readable representation of the number of bytes given by ``bytes``. In addition to a numeric type, the ``bytes`` parameter may also be a bitmath type. Optionally select a preferred unit system by specifying the ``system`` keyword. Choices for ``system`` are ``bitmat...
[ "Return", "a", "bitmath", "instance", "representing", "the", "best", "human", "-", "readable", "representation", "of", "the", "number", "of", "bytes", "given", "by", "bytes", ".", "In", "addition", "to", "a", "numeric", "type", "the", "bytes", "parameter", "...
python
train
29.04
google/openhtf
openhtf/plugs/usb/fastboot_protocol.py
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/fastboot_protocol.py#L244-L274
def download(self, source_file, source_len=0, info_cb=DEFAULT_MESSAGE_CALLBACK, progress_callback=None): """Downloads a file to the device. Args: source_file: A filename or file-like object to download to the device. source_len: Optional length of source_file. If source_file is a fil...
[ "def", "download", "(", "self", ",", "source_file", ",", "source_len", "=", "0", ",", "info_cb", "=", "DEFAULT_MESSAGE_CALLBACK", ",", "progress_callback", "=", "None", ")", ":", "if", "isinstance", "(", "source_file", ",", "six", ".", "string_types", ")", "...
Downloads a file to the device. Args: source_file: A filename or file-like object to download to the device. source_len: Optional length of source_file. If source_file is a file-like object and source_len is not provided, source_file is read into memory. info_cb: Optional call...
[ "Downloads", "a", "file", "to", "the", "device", "." ]
python
train
40.322581
projectshift/shift-boiler
boiler/user/views_social.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/views_social.py#L106-L176
def dispatch_request(self): """ Handle redirect back from provider """ if current_user.is_authenticated: return redirect(self.next) # clear previous! if 'social_data' in session: del session['social_data'] res = self.app.authorized_response() if ...
[ "def", "dispatch_request", "(", "self", ")", ":", "if", "current_user", ".", "is_authenticated", ":", "return", "redirect", "(", "self", ".", "next", ")", "# clear previous!", "if", "'social_data'", "in", "session", ":", "del", "session", "[", "'social_data'", ...
Handle redirect back from provider
[ "Handle", "redirect", "back", "from", "provider" ]
python
train
35.380282
aouyar/PyMunin
pysysinfo/system.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/system.py#L60-L76
def getLoadAvg(self): """Return system Load Average. @return: List of 1 min, 5 min and 15 min Load Average figures. """ try: fp = open(loadavgFile, 'r') line = fp.readline() fp.close() except: raise IOError('Failed...
[ "def", "getLoadAvg", "(", "self", ")", ":", "try", ":", "fp", "=", "open", "(", "loadavgFile", ",", "'r'", ")", "line", "=", "fp", ".", "readline", "(", ")", "fp", ".", "close", "(", ")", "except", ":", "raise", "IOError", "(", "'Failed reading stats...
Return system Load Average. @return: List of 1 min, 5 min and 15 min Load Average figures.
[ "Return", "system", "Load", "Average", "." ]
python
train
28.823529
nickjj/flask-webpack
flask_webpack/__init__.py
https://github.com/nickjj/flask-webpack/blob/241617c6ce0fd9ec11f507204958ddd0ec467634/flask_webpack/__init__.py#L114-L129
def asset_url_for(self, asset): """ Lookup the hashed asset path of a file name unless it starts with something that resembles a web address, then take it as is. :param asset: A logical path to an asset :type asset: str :return: Asset path or None if not found ""...
[ "def", "asset_url_for", "(", "self", ",", "asset", ")", ":", "if", "'//'", "in", "asset", ":", "return", "asset", "if", "asset", "not", "in", "self", ".", "assets", ":", "return", "None", "return", "'{0}{1}'", ".", "format", "(", "self", ".", "assets_u...
Lookup the hashed asset path of a file name unless it starts with something that resembles a web address, then take it as is. :param asset: A logical path to an asset :type asset: str :return: Asset path or None if not found
[ "Lookup", "the", "hashed", "asset", "path", "of", "a", "file", "name", "unless", "it", "starts", "with", "something", "that", "resembles", "a", "web", "address", "then", "take", "it", "as", "is", "." ]
python
train
30.5
BeyondTheClouds/enoslib
enoslib/infra/enos_g5k/provider.py
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/provider.py#L54-L77
def init(self, force_deploy=False, client=None): """Reserve and deploys the nodes according to the resources section In comparison to the vagrant provider, networks must be characterized as in the networks key. Args: force_deploy (bool): True iff the environment must be red...
[ "def", "init", "(", "self", ",", "force_deploy", "=", "False", ",", "client", "=", "None", ")", ":", "_force_deploy", "=", "self", ".", "provider_conf", ".", "force_deploy", "self", ".", "provider_conf", ".", "force_deploy", "=", "_force_deploy", "or", "forc...
Reserve and deploys the nodes according to the resources section In comparison to the vagrant provider, networks must be characterized as in the networks key. Args: force_deploy (bool): True iff the environment must be redeployed Raises: MissingNetworkError: If ...
[ "Reserve", "and", "deploys", "the", "nodes", "according", "to", "the", "resources", "section" ]
python
train
39
thiderman/doge
doge/core.py
https://github.com/thiderman/doge/blob/cea077d4f72929f9dcf44d0d16a7d1a6ee0e3e3f/doge/core.py#L75-L106
def setup_seasonal(self): """ Check if there's some seasonal holiday going on, setup appropriate Shibe picture and load holiday words. Note: if there are two or more holidays defined for a certain date, the first one takes precedence. """ # If we've specified a...
[ "def", "setup_seasonal", "(", "self", ")", ":", "# If we've specified a season, just run that one", "if", "self", ".", "ns", ".", "season", ":", "return", "self", ".", "load_season", "(", "self", ".", "ns", ".", "season", ")", "# If we've specified another doge or n...
Check if there's some seasonal holiday going on, setup appropriate Shibe picture and load holiday words. Note: if there are two or more holidays defined for a certain date, the first one takes precedence.
[ "Check", "if", "there", "s", "some", "seasonal", "holiday", "going", "on", "setup", "appropriate", "Shibe", "picture", "and", "load", "holiday", "words", "." ]
python
train
34.53125
idlesign/django-sitemessage
sitemessage/views.py
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/views.py#L47-L60
def unsubscribe(request, message_id, dispatch_id, hashed, redirect_to=None): """Handles unsubscribe request. :param Request request: :param int message_id: :param int dispatch_id: :param str hashed: :param str redirect_to: :return: """ return _generic_view( 'handle_unsubscri...
[ "def", "unsubscribe", "(", "request", ",", "message_id", ",", "dispatch_id", ",", "hashed", ",", "redirect_to", "=", "None", ")", ":", "return", "_generic_view", "(", "'handle_unsubscribe_request'", ",", "sig_unsubscribe_failed", ",", "request", ",", "message_id", ...
Handles unsubscribe request. :param Request request: :param int message_id: :param int dispatch_id: :param str hashed: :param str redirect_to: :return:
[ "Handles", "unsubscribe", "request", "." ]
python
train
30.214286
agsimeonov/cbexchange
cbexchange/market.py
https://github.com/agsimeonov/cbexchange/blob/e3762f77583f89cf7b4f501ab3c7675fc7d30ab3/cbexchange/market.py#L82-L98
def _request(self, method, *relative_path_parts, **kwargs): """Sends an HTTP request to the REST API and receives the requested data. Additionally sets up pagination cursors. :param str method: HTTP method name :param relative_path_parts: the relative paths for the request URI :param kwargs: argume...
[ "def", "_request", "(", "self", ",", "method", ",", "*", "relative_path_parts", ",", "*", "*", "kwargs", ")", ":", "uri", "=", "self", ".", "_create_api_uri", "(", "*", "relative_path_parts", ")", "response", "=", "get", "(", "uri", ",", "params", "=", ...
Sends an HTTP request to the REST API and receives the requested data. Additionally sets up pagination cursors. :param str method: HTTP method name :param relative_path_parts: the relative paths for the request URI :param kwargs: argument keywords :returns: requested data :raises APIError: for ...
[ "Sends", "an", "HTTP", "request", "to", "the", "REST", "API", "and", "receives", "the", "requested", "data", ".", "Additionally", "sets", "up", "pagination", "cursors", "." ]
python
valid
42.058824
RJT1990/pyflux
pyflux/garch/segarchm.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/garch/segarchm.py#L508-L530
def add_leverage(self): """ Adds leverage term to the model Returns ---------- None (changes instance attributes) """ if self.leverage is True: pass else: self.leverage = True self.z_no += 1 self.laten...
[ "def", "add_leverage", "(", "self", ")", ":", "if", "self", ".", "leverage", "is", "True", ":", "pass", "else", ":", "self", ".", "leverage", "=", "True", "self", ".", "z_no", "+=", "1", "self", ".", "latent_variables", ".", "z_list", ".", "pop", "("...
Adds leverage term to the model Returns ---------- None (changes instance attributes)
[ "Adds", "leverage", "term", "to", "the", "model" ]
python
train
44.304348
moremoban/moban
moban/main.py
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/main.py#L179-L209
def handle_command_line(options): """ act upon command options """ options = merge(options, constants.DEFAULT_OPTIONS) engine = plugins.ENGINES.get_engine( options[constants.LABEL_TEMPLATE_TYPE], options[constants.LABEL_TMPL_DIRS], options[constants.LABEL_CONFIG_DIR], ) ...
[ "def", "handle_command_line", "(", "options", ")", ":", "options", "=", "merge", "(", "options", ",", "constants", ".", "DEFAULT_OPTIONS", ")", "engine", "=", "plugins", ".", "ENGINES", ".", "get_engine", "(", "options", "[", "constants", ".", "LABEL_TEMPLATE_...
act upon command options
[ "act", "upon", "command", "options" ]
python
train
34.258065
Esri/ArcREST
src/arcresthelper/featureservicetools.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/featureservicetools.py#L399-L461
def GetLayerFromFeatureService(self, fs, layerName="", returnURLOnly=False): """Obtains a layer from a feature service by feature service reference. Args: fs (FeatureService): The feature service from which to obtain the layer. layerName (str): The name of the layer. Defaults to...
[ "def", "GetLayerFromFeatureService", "(", "self", ",", "fs", ",", "layerName", "=", "\"\"", ",", "returnURLOnly", "=", "False", ")", ":", "layers", "=", "None", "table", "=", "None", "layer", "=", "None", "sublayer", "=", "None", "try", ":", "layers", "=...
Obtains a layer from a feature service by feature service reference. Args: fs (FeatureService): The feature service from which to obtain the layer. layerName (str): The name of the layer. Defaults to ``""``. returnURLOnly (bool): A boolean value to return the URL of the laye...
[ "Obtains", "a", "layer", "from", "a", "feature", "service", "by", "feature", "service", "reference", "." ]
python
train
38.634921
timothyb0912/pylogit
pylogit/bootstrap_mle.py
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/bootstrap_mle.py#L103-L133
def get_model_creation_kwargs(model_obj): """ Get a dictionary of the keyword arguments needed to create the passed model object using `pylogit.create_choice_model`. Parameters ---------- model_obj : An MNDC_Model instance. Returns ------- model_kwargs : dict. Contains the ...
[ "def", "get_model_creation_kwargs", "(", "model_obj", ")", ":", "# Extract the model abbreviation for this model", "model_abbrev", "=", "get_model_abbrev", "(", "model_obj", ")", "# Create a dictionary to store the keyword arguments needed to Initialize", "# the new model object.d", "m...
Get a dictionary of the keyword arguments needed to create the passed model object using `pylogit.create_choice_model`. Parameters ---------- model_obj : An MNDC_Model instance. Returns ------- model_kwargs : dict. Contains the keyword arguments and the required values that are nee...
[ "Get", "a", "dictionary", "of", "the", "keyword", "arguments", "needed", "to", "create", "the", "passed", "model", "object", "using", "pylogit", ".", "create_choice_model", "." ]
python
train
37.83871
jazzband/django-axes
axes/attempts.py
https://github.com/jazzband/django-axes/blob/3e215a174030e43e7ab8c2a79c395eb0eeddc667/axes/attempts.py#L61-L73
def clean_expired_user_attempts(attempt_time: datetime = None) -> int: """ Clean expired user attempts from the database. """ if settings.AXES_COOLOFF_TIME is None: log.debug('AXES: Skipping clean for expired access attempts because no AXES_COOLOFF_TIME is configured') return 0 thr...
[ "def", "clean_expired_user_attempts", "(", "attempt_time", ":", "datetime", "=", "None", ")", "->", "int", ":", "if", "settings", ".", "AXES_COOLOFF_TIME", "is", "None", ":", "log", ".", "debug", "(", "'AXES: Skipping clean for expired access attempts because no AXES_CO...
Clean expired user attempts from the database.
[ "Clean", "expired", "user", "attempts", "from", "the", "database", "." ]
python
train
43.615385
ozgurgunes/django-manifest
manifest/accounts/forms.py
https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/forms.py#L48-L65
def clean_username(self): """ Validate that the username is unique and not listed in ``defaults.ACCOUNTS_FORBIDDEN_USERNAMES`` list. """ try: user = get_user_model().objects.get(username=self.cleaned_data["username"]) except get_user_model().DoesNot...
[ "def", "clean_username", "(", "self", ")", ":", "try", ":", "user", "=", "get_user_model", "(", ")", ".", "objects", ".", "get", "(", "username", "=", "self", ".", "cleaned_data", "[", "\"username\"", "]", ")", "except", "get_user_model", "(", ")", ".", ...
Validate that the username is unique and not listed in ``defaults.ACCOUNTS_FORBIDDEN_USERNAMES`` list.
[ "Validate", "that", "the", "username", "is", "unique", "and", "not", "listed", "in", "defaults", ".", "ACCOUNTS_FORBIDDEN_USERNAMES", "list", "." ]
python
train
37.888889
Esri/ArcREST
src/arcresthelper/common.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/common.py#L263-L306
def local_time_to_online(dt=None): """Converts datetime object to a UTC timestamp for AGOL. Args: dt (datetime): The :py:class:`datetime.datetime` object to convert. Defaults to ``None``, i.e., :py:func:`datetime.datetime.now`. Returns: float: A UTC timestamp as understood by AGOL (time in...
[ "def", "local_time_to_online", "(", "dt", "=", "None", ")", ":", "is_dst", "=", "None", "utc_offset", "=", "None", "try", ":", "if", "dt", "is", "None", ":", "dt", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "is_dst", "=", "time", ".", ...
Converts datetime object to a UTC timestamp for AGOL. Args: dt (datetime): The :py:class:`datetime.datetime` object to convert. Defaults to ``None``, i.e., :py:func:`datetime.datetime.now`. Returns: float: A UTC timestamp as understood by AGOL (time in ms since Unix epoch * 1000) Examples...
[ "Converts", "datetime", "object", "to", "a", "UTC", "timestamp", "for", "AGOL", "." ]
python
train
32.159091
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L1385-L1393
def psetex(self, name, time_ms, value): """ Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object """ if isinstance(time_ms, datetime.timedelta): time_ms =...
[ "def", "psetex", "(", "self", ",", "name", ",", "time_ms", ",", "value", ")", ":", "if", "isinstance", "(", "time_ms", ",", "datetime", ".", "timedelta", ")", ":", "time_ms", "=", "int", "(", "time_ms", ".", "total_seconds", "(", ")", "*", "1000", ")...
Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object
[ "Set", "the", "value", "of", "key", "name", "to", "value", "that", "expires", "in", "time_ms", "milliseconds", ".", "time_ms", "can", "be", "represented", "by", "an", "integer", "or", "a", "Python", "timedelta", "object" ]
python
train
46.222222
klen/graphite-beacon
graphite_beacon/alerts.py
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/alerts.py#L94-L142
def configure(self, name=None, rules=None, query=None, **options): """Configure the alert.""" self.name = name if not name: raise AssertionError("Alert's name should be defined and not empty.") if not rules: raise AssertionError("%s: Alert's rules is invalid" % n...
[ "def", "configure", "(", "self", ",", "name", "=", "None", ",", "rules", "=", "None", ",", "query", "=", "None", ",", "*", "*", "options", ")", ":", "self", ".", "name", "=", "name", "if", "not", "name", ":", "raise", "AssertionError", "(", "\"Aler...
Configure the alert.
[ "Configure", "the", "alert", "." ]
python
train
44.387755
openstack/proliantutils
proliantutils/ilo/ris.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/ilo/ris.py#L735-L750
def set_secure_boot_mode(self, secure_boot_enable): """Enable/Disable secure boot on the server. :param secure_boot_enable: True, if secure boot needs to be enabled for next boot, else False. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, i...
[ "def", "set_secure_boot_mode", "(", "self", ",", "secure_boot_enable", ")", ":", "if", "self", ".", "_is_boot_mode_uefi", "(", ")", ":", "self", ".", "_change_secure_boot_settings", "(", "'SecureBootEnable'", ",", "secure_boot_enable", ")", "else", ":", "msg", "="...
Enable/Disable secure boot on the server. :param secure_boot_enable: True, if secure boot needs to be enabled for next boot, else False. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
[ "Enable", "/", "Disable", "secure", "boot", "on", "the", "server", "." ]
python
train
47.3125
TUNE-Archive/freight_forwarder
freight_forwarder/image.py
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/image.py#L322-L378
def build(client, repository_tag, docker_file, tag=None, use_cache=False): """ Build a docker image """ if not isinstance(client, docker.Client): raise TypeError("client needs to be of type docker.Client.") if not isinstance(docker_file, six.string_types) or not os.p...
[ "def", "build", "(", "client", ",", "repository_tag", ",", "docker_file", ",", "tag", "=", "None", ",", "use_cache", "=", "False", ")", ":", "if", "not", "isinstance", "(", "client", ",", "docker", ".", "Client", ")", ":", "raise", "TypeError", "(", "\...
Build a docker image
[ "Build", "a", "docker", "image" ]
python
train
36.403509
intel-analytics/BigDL
pyspark/bigdl/util/common.py
https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L630-L635
def callJavaFunc(func, *args): """ Call Java Function """ gateway = _get_gateway() args = [_py2java(gateway, a) for a in args] result = func(*args) return _java2py(gateway, result)
[ "def", "callJavaFunc", "(", "func", ",", "*", "args", ")", ":", "gateway", "=", "_get_gateway", "(", ")", "args", "=", "[", "_py2java", "(", "gateway", ",", "a", ")", "for", "a", "in", "args", "]", "result", "=", "func", "(", "*", "args", ")", "r...
Call Java Function
[ "Call", "Java", "Function" ]
python
test
32.5
etcher-be/emiz
emiz/avwx/core.py
https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/core.py#L238-L280
def extra_space_exists(str1: str, str2: str) -> bool: # noqa """ Return True if a space shouldn't exist between two items """ ls1, ls2 = len(str1), len(str2) if str1.isdigit(): # 10 SM if str2 in ['SM', '0SM']: return True # 12 /10 if ls2 > 2 and str2[0] ...
[ "def", "extra_space_exists", "(", "str1", ":", "str", ",", "str2", ":", "str", ")", "->", "bool", ":", "# noqa", "ls1", ",", "ls2", "=", "len", "(", "str1", ")", ",", "len", "(", "str2", ")", "if", "str1", ".", "isdigit", "(", ")", ":", "# 10 SM"...
Return True if a space shouldn't exist between two items
[ "Return", "True", "if", "a", "space", "shouldn", "t", "exist", "between", "two", "items" ]
python
train
34.27907
googleapis/google-cloud-python
storage/google/cloud/storage/acl.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/acl.py#L314-L338
def entity(self, entity_type, identifier=None): """Factory method for creating an Entity. If an entity with the same type and identifier already exists, this will return a reference to that entity. If not, it will create a new one and add it to the list of known entities for th...
[ "def", "entity", "(", "self", ",", "entity_type", ",", "identifier", "=", "None", ")", ":", "entity", "=", "_ACLEntity", "(", "entity_type", "=", "entity_type", ",", "identifier", "=", "identifier", ")", "if", "self", ".", "has_entity", "(", "entity", ")",...
Factory method for creating an Entity. If an entity with the same type and identifier already exists, this will return a reference to that entity. If not, it will create a new one and add it to the list of known entities for this ACL. :type entity_type: str :param enti...
[ "Factory", "method", "for", "creating", "an", "Entity", "." ]
python
train
39.12
jaraco/jaraco.mongodb
jaraco/mongodb/oplog.py
https://github.com/jaraco/jaraco.mongodb/blob/280f17894941f4babf2e97db033dbb1fd2b9f705/jaraco/mongodb/oplog.py#L472-L486
def since(self, ts): """ Query the oplog for items since ts and then return """ spec = {'ts': {'$gt': ts}} cursor = self.query(spec) while True: # todo: trap InvalidDocument errors: # except bson.errors.InvalidDocument as e: # logging....
[ "def", "since", "(", "self", ",", "ts", ")", ":", "spec", "=", "{", "'ts'", ":", "{", "'$gt'", ":", "ts", "}", "}", "cursor", "=", "self", ".", "query", "(", "spec", ")", "while", "True", ":", "# todo: trap InvalidDocument errors:", "# except bson.errors...
Query the oplog for items since ts and then return
[ "Query", "the", "oplog", "for", "items", "since", "ts", "and", "then", "return" ]
python
train
30.466667
cimm-kzn/CGRtools
CGRtools/containers/query.py
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/query.py#L31-L41
def _matcher(self, other): """ QueryContainer < MoleculeContainer QueryContainer < QueryContainer[more general] QueryContainer < QueryCGRContainer[more general] """ if isinstance(other, MoleculeContainer): return GraphMatcher(other, self, lambda x, y: y == x, ...
[ "def", "_matcher", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "MoleculeContainer", ")", ":", "return", "GraphMatcher", "(", "other", ",", "self", ",", "lambda", "x", ",", "y", ":", "y", "==", "x", ",", "lambda", "x", ...
QueryContainer < MoleculeContainer QueryContainer < QueryContainer[more general] QueryContainer < QueryCGRContainer[more general]
[ "QueryContainer", "<", "MoleculeContainer", "QueryContainer", "<", "QueryContainer", "[", "more", "general", "]", "QueryContainer", "<", "QueryCGRContainer", "[", "more", "general", "]" ]
python
train
52.181818
lucuma/Clay
clay/manage.py
https://github.com/lucuma/Clay/blob/620d37086b712bdc4d13930ced43a5b7c9a5f46d/clay/manage.py#L24-L40
def new(path='.', template=None): """Creates a new project """ path = abspath(path.rstrip(sep)) template = template or DEFAULT_TEMPLATE_URL render_skeleton( template, path, include_this=['.gitignore'], filter_this=[ '~*', '*.py[co]', '__pycache__', '__...
[ "def", "new", "(", "path", "=", "'.'", ",", "template", "=", "None", ")", ":", "path", "=", "abspath", "(", "path", ".", "rstrip", "(", "sep", ")", ")", "template", "=", "template", "or", "DEFAULT_TEMPLATE_URL", "render_skeleton", "(", "template", ",", ...
Creates a new project
[ "Creates", "a", "new", "project" ]
python
train
26.529412