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
gboeing/osmnx
osmnx/utils.py
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/utils.py#L896-L932
def get_route_edge_attributes(G, route, attribute=None, minimize_key='length', retrieve_default=None): """ Get a list of attribute values for each edge in a path. Parameters ---------- G : networkx multidigraph route : list list of nodes in the path attribute : string the na...
[ "def", "get_route_edge_attributes", "(", "G", ",", "route", ",", "attribute", "=", "None", ",", "minimize_key", "=", "'length'", ",", "retrieve_default", "=", "None", ")", ":", "attribute_values", "=", "[", "]", "for", "u", ",", "v", "in", "zip", "(", "r...
Get a list of attribute values for each edge in a path. Parameters ---------- G : networkx multidigraph route : list list of nodes in the path attribute : string the name of the attribute to get the value of for each edge. If not specified, the complete data dict is returned...
[ "Get", "a", "list", "of", "attribute", "values", "for", "each", "edge", "in", "a", "path", "." ]
python
train
40.027027
junaruga/rpm-py-installer
install.py
https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1809-L1838
def curl_remote_name(cls, file_url): """Download file_url, and save as a file name of the URL. It behaves like "curl -O or --remote-name". It raises HTTPError if the file_url not found. """ tar_gz_file_name = file_url.split('/')[-1] if sys.version_info >= (3, 2): ...
[ "def", "curl_remote_name", "(", "cls", ",", "file_url", ")", ":", "tar_gz_file_name", "=", "file_url", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "2", ")", ":", "from", "urllib", ".", "...
Download file_url, and save as a file name of the URL. It behaves like "curl -O or --remote-name". It raises HTTPError if the file_url not found.
[ "Download", "file_url", "and", "save", "as", "a", "file", "name", "of", "the", "URL", "." ]
python
train
34.566667
androguard/androguard
androguard/core/bytecodes/axml/__init__.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/axml/__init__.py#L2383-L2392
def get_language_and_region(self): """ Returns the combined language+region string or \x00\x00 for the default locale :return: """ if self.locale != 0: _language = self._unpack_language_or_region([self.locale & 0xff, (self.locale & 0xff00) >> 8, ], ord('a')) ...
[ "def", "get_language_and_region", "(", "self", ")", ":", "if", "self", ".", "locale", "!=", "0", ":", "_language", "=", "self", ".", "_unpack_language_or_region", "(", "[", "self", ".", "locale", "&", "0xff", ",", "(", "self", ".", "locale", "&", "0xff00...
Returns the combined language+region string or \x00\x00 for the default locale :return:
[ "Returns", "the", "combined", "language", "+", "region", "string", "or", "\\", "x00", "\\", "x00", "for", "the", "default", "locale", ":", "return", ":" ]
python
train
53.5
shaldengeki/python-mal
myanimelist/character.py
https://github.com/shaldengeki/python-mal/blob/2c3356411a74d88ba13f6b970388040d696f8392/myanimelist/character.py#L292-L301
def load_favorites(self): """Fetches the MAL character favorites page and sets the current character's favorites attributes. :rtype: :class:`.Character` :return: Current character object. """ character = self.session.session.get(u'http://myanimelist.net/character/' + str(self.id) + u'/' + utilitie...
[ "def", "load_favorites", "(", "self", ")", ":", "character", "=", "self", ".", "session", ".", "session", ".", "get", "(", "u'http://myanimelist.net/character/'", "+", "str", "(", "self", ".", "id", ")", "+", "u'/'", "+", "utilities", ".", "urlencode", "("...
Fetches the MAL character favorites page and sets the current character's favorites attributes. :rtype: :class:`.Character` :return: Current character object.
[ "Fetches", "the", "MAL", "character", "favorites", "page", "and", "sets", "the", "current", "character", "s", "favorites", "attributes", "." ]
python
train
44.2
boriel/zxbasic
arch/zx48k/translator.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/translator.py#L297-L303
def check_attr(node, n): """ Check if ATTR has to be normalized after this instruction has been translated to intermediate code. """ if len(node.children) > n: return node.children[n]
[ "def", "check_attr", "(", "node", ",", "n", ")", ":", "if", "len", "(", "node", ".", "children", ")", ">", "n", ":", "return", "node", ".", "children", "[", "n", "]" ]
Check if ATTR has to be normalized after this instruction has been translated to intermediate code.
[ "Check", "if", "ATTR", "has", "to", "be", "normalized", "after", "this", "instruction", "has", "been", "translated", "to", "intermediate", "code", "." ]
python
train
32.714286
monim67/django-bootstrap-datepicker-plus
bootstrap_datepicker_plus/_compatibility.py
https://github.com/monim67/django-bootstrap-datepicker-plus/blob/55819bf12507c98dba91c702e224afd9bae3ef9a/bootstrap_datepicker_plus/_compatibility.py#L81-L93
def get_context(self, name, value, attrs): """Missing method of django.forms.widgets.Widget class.""" context = {} context['widget'] = { 'name': name, 'type': 'text', 'is_hidden': self.is_hidden, 'required': self.is_required, 'value': s...
[ "def", "get_context", "(", "self", ",", "name", ",", "value", ",", "attrs", ")", ":", "context", "=", "{", "}", "context", "[", "'widget'", "]", "=", "{", "'name'", ":", "name", ",", "'type'", ":", "'text'", ",", "'is_hidden'", ":", "self", ".", "i...
Missing method of django.forms.widgets.Widget class.
[ "Missing", "method", "of", "django", ".", "forms", ".", "widgets", ".", "Widget", "class", "." ]
python
train
36
rpcope1/PythonConfluenceAPI
PythonConfluenceAPI/api.py
https://github.com/rpcope1/PythonConfluenceAPI/blob/b7f0ca2a390f964715fdf3a60b5b0c5ef7116d40/PythonConfluenceAPI/api.py#L245-L271
def get_content_macro_by_hash(self, content_id, version, macro_hash, callback=None): """ Returns the body of a macro (in storage format) with the given hash. This resource is primarily used by connect applications that require the body of macro to perform their work. The hash is generat...
[ "def", "get_content_macro_by_hash", "(", "self", ",", "content_id", ",", "version", ",", "macro_hash", ",", "callback", "=", "None", ")", ":", "return", "self", ".", "_service_get_request", "(", "\"rest/api/content/{id}/history/{version}/macro/hash/{hash}\"", "\"\"", "....
Returns the body of a macro (in storage format) with the given hash. This resource is primarily used by connect applications that require the body of macro to perform their work. The hash is generated by connect during render time of the local macro holder and is usually only relevant during th...
[ "Returns", "the", "body", "of", "a", "macro", "(", "in", "storage", "format", ")", "with", "the", "given", "hash", ".", "This", "resource", "is", "primarily", "used", "by", "connect", "applications", "that", "require", "the", "body", "of", "macro", "to", ...
python
train
70.407407
meejah/txtorcon
txtorcon/torconfig.py
https://github.com/meejah/txtorcon/blob/14053b95adf0b4bd9dd9c317bece912a26578a93/txtorcon/torconfig.py#L458-L485
def add_to_tor(self, protocol): ''' Returns a Deferred which fires with 'self' after at least one descriptor has been uploaded. Errback if no descriptor upload succeeds. ''' upload_d = _await_descriptor_upload(protocol, self, progress=None, await_all_uploads=False) ...
[ "def", "add_to_tor", "(", "self", ",", "protocol", ")", ":", "upload_d", "=", "_await_descriptor_upload", "(", "protocol", ",", "self", ",", "progress", "=", "None", ",", "await_all_uploads", "=", "False", ")", "# _add_ephemeral_service takes a TorConfig but we don't ...
Returns a Deferred which fires with 'self' after at least one descriptor has been uploaded. Errback if no descriptor upload succeeds.
[ "Returns", "a", "Deferred", "which", "fires", "with", "self", "after", "at", "least", "one", "descriptor", "has", "been", "uploaded", ".", "Errback", "if", "no", "descriptor", "upload", "succeeds", "." ]
python
train
43.142857
rfosterslo/wagtailplus
wagtailplus/wagtailrelations/signals/handlers.py
https://github.com/rfosterslo/wagtailplus/blob/22cac857175d8a6f77e470751831c14a92ccd768/wagtailplus/wagtailrelations/signals/handlers.py#L50-L59
def delete_entry(sender, instance, **kwargs): """ Deletes Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being deleted. """ from ..models import Entry Entry.objects.get_for_model(instance)[0].delete()
[ "def", "delete_entry", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "models", "import", "Entry", "Entry", ".", "objects", ".", "get_for_model", "(", "instance", ")", "[", "0", "]", ".", "delete", "(", ")" ]
Deletes Entry instance corresponding to specified instance. :param sender: the sending class. :param instance: the instance being deleted.
[ "Deletes", "Entry", "instance", "corresponding", "to", "specified", "instance", "." ]
python
train
29
PmagPy/PmagPy
programs/demag_gui.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L5040-L5073
def write_acceptance_criteria_to_file(self): """ Writes current GUI acceptance criteria to criteria.txt or pmag_criteria.txt depending on data model """ crit_list = list(self.acceptance_criteria.keys()) crit_list.sort() rec = {} rec['pmag_criteria_code'] =...
[ "def", "write_acceptance_criteria_to_file", "(", "self", ")", ":", "crit_list", "=", "list", "(", "self", ".", "acceptance_criteria", ".", "keys", "(", ")", ")", "crit_list", ".", "sort", "(", ")", "rec", "=", "{", "}", "rec", "[", "'pmag_criteria_code'", ...
Writes current GUI acceptance criteria to criteria.txt or pmag_criteria.txt depending on data model
[ "Writes", "current", "GUI", "acceptance", "criteria", "to", "criteria", ".", "txt", "or", "pmag_criteria", ".", "txt", "depending", "on", "data", "model" ]
python
train
50.382353
itsnauman/jumprun
jumprun.py
https://github.com/itsnauman/jumprun/blob/469436720533e9a601226ec1414f294d94d68a53/jumprun.py#L333-L366
def action_rename(self): """ Rename a shortcut """ # get old and new name from args old = self.args['<old>'] new = self.args['<new>'] # select the old shortcut self.db_query(''' SELECT id FROM shortcuts WHERE name=? ''', (old,)) ...
[ "def", "action_rename", "(", "self", ")", ":", "# get old and new name from args", "old", "=", "self", ".", "args", "[", "'<old>'", "]", "new", "=", "self", ".", "args", "[", "'<new>'", "]", "# select the old shortcut", "self", ".", "db_query", "(", "'''\n ...
Rename a shortcut
[ "Rename", "a", "shortcut" ]
python
train
24.852941
gmr/rejected
rejected/consumer.py
https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/consumer.py#L976-L988
def _get_pika_properties(properties_in): """Return a :class:`pika.spec.BasicProperties` object for a :class:`rejected.data.Properties` object. :param dict properties_in: Properties to convert :rtype: :class:`pika.spec.BasicProperties` """ properties = pika.BasicProperti...
[ "def", "_get_pika_properties", "(", "properties_in", ")", ":", "properties", "=", "pika", ".", "BasicProperties", "(", ")", "for", "key", "in", "properties_in", "or", "{", "}", ":", "if", "properties_in", ".", "get", "(", "key", ")", "is", "not", "None", ...
Return a :class:`pika.spec.BasicProperties` object for a :class:`rejected.data.Properties` object. :param dict properties_in: Properties to convert :rtype: :class:`pika.spec.BasicProperties`
[ "Return", "a", ":", "class", ":", "pika", ".", "spec", ".", "BasicProperties", "object", "for", "a", ":", "class", ":", "rejected", ".", "data", ".", "Properties", "object", "." ]
python
train
38
romaryd/python-awesome-decorators
awesomedecorators/timez.py
https://github.com/romaryd/python-awesome-decorators/blob/8c83784149338ab69a25797e1097b214d33a5958/awesomedecorators/timez.py#L36-L58
def timeout(seconds): """ Raises a TimeoutError if a function does not terminate within specified seconds. """ def _timeout_error(signal, frame): raise TimeoutError("Operation did not finish within \ {} seconds".format(seconds)) def timeout_decorator(func): @wraps(func)...
[ "def", "timeout", "(", "seconds", ")", ":", "def", "_timeout_error", "(", "signal", ",", "frame", ")", ":", "raise", "TimeoutError", "(", "\"Operation did not finish within \\\n {} seconds\"", ".", "format", "(", "seconds", ")", ")", "def", "timeout_decorator...
Raises a TimeoutError if a function does not terminate within specified seconds.
[ "Raises", "a", "TimeoutError", "if", "a", "function", "does", "not", "terminate", "within", "specified", "seconds", "." ]
python
train
26.652174
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L142-L170
def define_from_values(cls, xdtu, ydtu, zdtu, xdtu_0, ydtu_0, zdtu_0): """Define class object from from provided values. Parameters ---------- xdtu : float XDTU fits keyword value. ydtu : float YDTU fits keyword value. zdtu : float ZDT...
[ "def", "define_from_values", "(", "cls", ",", "xdtu", ",", "ydtu", ",", "zdtu", ",", "xdtu_0", ",", "ydtu_0", ",", "zdtu_0", ")", ":", "self", "=", "DtuConfiguration", "(", ")", "# define DTU variables", "self", ".", "xdtu", "=", "xdtu", "self", ".", "yd...
Define class object from from provided values. Parameters ---------- xdtu : float XDTU fits keyword value. ydtu : float YDTU fits keyword value. zdtu : float ZDTU fits keyword value. xdtu_0 : float XDTU_0 fits keyword value...
[ "Define", "class", "object", "from", "from", "provided", "values", "." ]
python
train
26.206897
rasguanabana/ytfs
ytfs/ytfs.py
https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L222-L277
def __pathToTuple(self, path): """ Convert directory or file path to its tuple identifier. Parameters ---------- path : str Path to convert. It can look like /, /directory, /directory/ or /directory/filename. Returns ------- tup_id : tuple ...
[ "def", "__pathToTuple", "(", "self", ",", "path", ")", ":", "if", "not", "path", "or", "path", ".", "count", "(", "'/'", ")", ">", "2", ":", "raise", "YTFS", ".", "PathConvertError", "(", "\"Bad path given\"", ")", "# empty or too deep path", "try", ":", ...
Convert directory or file path to its tuple identifier. Parameters ---------- path : str Path to convert. It can look like /, /directory, /directory/ or /directory/filename. Returns ------- tup_id : tuple Two element tuple identifier of directory...
[ "Convert", "directory", "or", "file", "path", "to", "its", "tuple", "identifier", "." ]
python
train
32.285714
openstack/hacking
hacking/checks/imports.py
https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/imports.py#L21-L76
def hacking_import_rules(logical_line, filename, noqa): r"""Check for imports. OpenStack HACKING guide recommends one import per line: Do not import more than one module per line Examples: Okay: from nova.compute import api H301: from nova.compute import api, utils Do not use wildcard im...
[ "def", "hacking_import_rules", "(", "logical_line", ",", "filename", ",", "noqa", ")", ":", "# TODO(jogo): make the following doctests pass:", "# H301: import os, sys", "# TODO(mordred: We need to split this into different checks so that they", "# can be disabled by command line...
r"""Check for imports. OpenStack HACKING guide recommends one import per line: Do not import more than one module per line Examples: Okay: from nova.compute import api H301: from nova.compute import api, utils Do not use wildcard import Do not make relative imports Examples: Ok...
[ "r", "Check", "for", "imports", "." ]
python
train
33.75
numenta/nupic
src/nupic/support/configuration_base.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/configuration_base.py#L359-L371
def findConfigFile(cls, filename): """ Search the configuration path (specified via the NTA_CONF_PATH environment variable) for the given filename. If found, return the complete path to the file. :param filename: (string) name of file to locate """ paths = cls.getConfigPaths() for p in pat...
[ "def", "findConfigFile", "(", "cls", ",", "filename", ")", ":", "paths", "=", "cls", ".", "getConfigPaths", "(", ")", "for", "p", "in", "paths", ":", "testPath", "=", "os", ".", "path", ".", "join", "(", "p", ",", "filename", ")", "if", "os", ".", ...
Search the configuration path (specified via the NTA_CONF_PATH environment variable) for the given filename. If found, return the complete path to the file. :param filename: (string) name of file to locate
[ "Search", "the", "configuration", "path", "(", "specified", "via", "the", "NTA_CONF_PATH", "environment", "variable", ")", "for", "the", "given", "filename", ".", "If", "found", "return", "the", "complete", "path", "to", "the", "file", "." ]
python
valid
33.076923
biocommons/hgvs
hgvs/dataproviders/ncbi.py
https://github.com/biocommons/hgvs/blob/4d16efb475e1802b2531a2f1c373e8819d8e533b/hgvs/dataproviders/ncbi.py#L25-L31
def _stage_from_version(version): """return "prd", "stg", or "dev" for the given version string. A value is always returned""" if version: m = re.match(r"^(?P<xyz>\d+\.\d+\.\d+)(?P<extra>.*)", version) if m: return "stg" if m.group("extra") else "prd" return "dev"
[ "def", "_stage_from_version", "(", "version", ")", ":", "if", "version", ":", "m", "=", "re", ".", "match", "(", "r\"^(?P<xyz>\\d+\\.\\d+\\.\\d+)(?P<extra>.*)\"", ",", "version", ")", "if", "m", ":", "return", "\"stg\"", "if", "m", ".", "group", "(", "\"extr...
return "prd", "stg", or "dev" for the given version string. A value is always returned
[ "return", "prd", "stg", "or", "dev", "for", "the", "given", "version", "string", ".", "A", "value", "is", "always", "returned" ]
python
train
42.714286
tdryer/hangups
hangups/auth.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/auth.py#L405-L434
def _get_session_cookies(session, access_token): """Use the access token to get session cookies. Raises GoogleAuthError if session cookies could not be loaded. Returns dict of cookies. """ headers = {'Authorization': 'Bearer {}'.format(access_token)} try: r = session.get(('https://acc...
[ "def", "_get_session_cookies", "(", "session", ",", "access_token", ")", ":", "headers", "=", "{", "'Authorization'", ":", "'Bearer {}'", ".", "format", "(", "access_token", ")", "}", "try", ":", "r", "=", "session", ".", "get", "(", "(", "'https://accounts....
Use the access token to get session cookies. Raises GoogleAuthError if session cookies could not be loaded. Returns dict of cookies.
[ "Use", "the", "access", "token", "to", "get", "session", "cookies", "." ]
python
valid
37.933333
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/directory.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/directory.py#L4084-L4137
def save(self): """ :return: save this environment on Ariane server (create or update) """ LOGGER.debug("Environment.save") post_payload = {} consolidated_osi_id = [] if self.id is not None: post_payload['environmentID'] = self.id if self.nam...
[ "def", "save", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Environment.save\"", ")", "post_payload", "=", "{", "}", "consolidated_osi_id", "=", "[", "]", "if", "self", ".", "id", "is", "not", "None", ":", "post_payload", "[", "'environmentID'", ...
:return: save this environment on Ariane server (create or update)
[ ":", "return", ":", "save", "this", "environment", "on", "Ariane", "server", "(", "create", "or", "update", ")" ]
python
train
38.611111
readbeyond/aeneas
aeneas/adjustboundaryalgorithm.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/adjustboundaryalgorithm.py#L601-L636
def _apply_rate(self, max_rate, aggressive=False): """ Try to adjust the rate (characters/second) of the fragments of the list, so that it does not exceed the given ``max_rate``. This is done by testing whether some slack can be borrowed from the fragment before ...
[ "def", "_apply_rate", "(", "self", ",", "max_rate", ",", "aggressive", "=", "False", ")", ":", "self", ".", "log", "(", "u\"Called _apply_rate\"", ")", "self", ".", "log", "(", "[", "u\" Aggressive: %s\"", ",", "aggressive", "]", ")", "self", ".", "log", ...
Try to adjust the rate (characters/second) of the fragments of the list, so that it does not exceed the given ``max_rate``. This is done by testing whether some slack can be borrowed from the fragment before the faster current one. If ``aggressive`` is ``True``, ...
[ "Try", "to", "adjust", "the", "rate", "(", "characters", "/", "second", ")", "of", "the", "fragments", "of", "the", "list", "so", "that", "it", "does", "not", "exceed", "the", "given", "max_rate", "." ]
python
train
51.833333
artefactual-labs/mets-reader-writer
metsrw/fsentry.py
https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/fsentry.py#L337-L357
def add_child(self, child): """Add a child FSEntry to this FSEntry. Only FSEntrys with a type of 'directory' can have children. This does not detect cyclic parent/child relationships, but that will cause problems. :param metsrw.fsentry.FSEntry child: FSEntry to add as a child ...
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "if", "self", ".", "type", ".", "lower", "(", ")", "!=", "\"directory\"", ":", "raise", "ValueError", "(", "\"Only directory objects can have children\"", ")", "if", "child", "is", "self", ":", "raise"...
Add a child FSEntry to this FSEntry. Only FSEntrys with a type of 'directory' can have children. This does not detect cyclic parent/child relationships, but that will cause problems. :param metsrw.fsentry.FSEntry child: FSEntry to add as a child :return: The newly added child ...
[ "Add", "a", "child", "FSEntry", "to", "this", "FSEntry", "." ]
python
train
39.047619
aws/aws-xray-sdk-python
aws_xray_sdk/core/models/entity.py
https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/models/entity.py#L192-L208
def apply_status_code(self, status_code): """ When a trace entity is generated under the http context, the status code will affect this entity's fault/error/throttle flags. Flip these flags based on status code. """ self._check_ended() if not status_code: ...
[ "def", "apply_status_code", "(", "self", ",", "status_code", ")", ":", "self", ".", "_check_ended", "(", ")", "if", "not", "status_code", ":", "return", "if", "status_code", ">=", "500", ":", "self", ".", "add_fault_flag", "(", ")", "elif", "status_code", ...
When a trace entity is generated under the http context, the status code will affect this entity's fault/error/throttle flags. Flip these flags based on status code.
[ "When", "a", "trace", "entity", "is", "generated", "under", "the", "http", "context", "the", "status", "code", "will", "affect", "this", "entity", "s", "fault", "/", "error", "/", "throttle", "flags", ".", "Flip", "these", "flags", "based", "on", "status",...
python
train
32.411765
awkman/pywifi
pywifi/iface.py
https://github.com/awkman/pywifi/blob/719baf73d8d32c623dbaf5e9de5d973face152a4/pywifi/iface.py#L41-L46
def scan(self): """Trigger the wifi interface to scan.""" self._logger.info("iface '%s' scans", self.name()) self._wifi_ctrl.scan(self._raw_obj)
[ "def", "scan", "(", "self", ")", ":", "self", ".", "_logger", ".", "info", "(", "\"iface '%s' scans\"", ",", "self", ".", "name", "(", ")", ")", "self", ".", "_wifi_ctrl", ".", "scan", "(", "self", ".", "_raw_obj", ")" ]
Trigger the wifi interface to scan.
[ "Trigger", "the", "wifi", "interface", "to", "scan", "." ]
python
train
27.5
idlesign/uwsgiconf
uwsgiconf/runtime/rpc.py
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/runtime/rpc.py#L7-L36
def register_rpc(name=None): """Decorator. Allows registering a function for RPC. * http://uwsgi.readthedocs.io/en/latest/RPC.html Example: .. code-block:: python @register_rpc() def expose_me(): do() :param str|unicode name: RPC function name to ass...
[ "def", "register_rpc", "(", "name", "=", "None", ")", ":", "def", "wrapper", "(", "func", ")", ":", "func_name", "=", "func", ".", "__name__", "rpc_name", "=", "name", "or", "func_name", "uwsgi", ".", "register_rpc", "(", "rpc_name", ",", "func", ")", ...
Decorator. Allows registering a function for RPC. * http://uwsgi.readthedocs.io/en/latest/RPC.html Example: .. code-block:: python @register_rpc() def expose_me(): do() :param str|unicode name: RPC function name to associate with decorated functi...
[ "Decorator", ".", "Allows", "registering", "a", "function", "for", "RPC", "." ]
python
train
20.966667
pyviz/holoviews
holoviews/plotting/widgets/__init__.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/widgets/__init__.py#L17-L41
def escape_vals(vals, escape_numerics=True): """ Escapes a list of values to a string, converting to unicode for safety. """ # Ints formatted as floats to disambiguate with counter mode ints, floats = "%.1f", "%.10f" escaped = [] for v in vals: if isinstance(v, np.timedelta64): ...
[ "def", "escape_vals", "(", "vals", ",", "escape_numerics", "=", "True", ")", ":", "# Ints formatted as floats to disambiguate with counter mode", "ints", ",", "floats", "=", "\"%.1f\"", ",", "\"%.10f\"", "escaped", "=", "[", "]", "for", "v", "in", "vals", ":", "...
Escapes a list of values to a string, converting to unicode for safety.
[ "Escapes", "a", "list", "of", "values", "to", "a", "string", "converting", "to", "unicode", "for", "safety", "." ]
python
train
29.68
f3at/feat
src/feat/agents/common/dns.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/agents/common/dns.py#L29-L33
def add_mapping(agent, prefix, ip): """Adds a mapping with a contract. It has high latency but gives some kind of guarantee.""" return _broadcast(agent, AddMappingManager, RecordType.record_A, prefix, ip)
[ "def", "add_mapping", "(", "agent", ",", "prefix", ",", "ip", ")", ":", "return", "_broadcast", "(", "agent", ",", "AddMappingManager", ",", "RecordType", ".", "record_A", ",", "prefix", ",", "ip", ")" ]
Adds a mapping with a contract. It has high latency but gives some kind of guarantee.
[ "Adds", "a", "mapping", "with", "a", "contract", ".", "It", "has", "high", "latency", "but", "gives", "some", "kind", "of", "guarantee", "." ]
python
train
46.8
Opentrons/opentrons
api/src/opentrons/protocol_api/execute_v3.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/execute_v3.py#L36-L48
def _set_flow_rate(pipette, params) -> None: """ Set flow rate in uL/mm, to value obtained from command's params. """ flow_rate_param = params['flowRate'] if not (flow_rate_param > 0): raise RuntimeError('Positive flowRate param required') pipette.flow_rate = { 'aspirate': flow...
[ "def", "_set_flow_rate", "(", "pipette", ",", "params", ")", "->", "None", ":", "flow_rate_param", "=", "params", "[", "'flowRate'", "]", "if", "not", "(", "flow_rate_param", ">", "0", ")", ":", "raise", "RuntimeError", "(", "'Positive flowRate param required'",...
Set flow rate in uL/mm, to value obtained from command's params.
[ "Set", "flow", "rate", "in", "uL", "/", "mm", "to", "value", "obtained", "from", "command", "s", "params", "." ]
python
train
27.846154
nickmckay/LiPD-utilities
Python/lipd/dataframes.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/dataframes.py#L183-L237
def get_filtered_dfs(lib, expr): """ Main: Get all data frames that match the given expression :return dict: Filenames and data frames (filtered) """ logger_dataframes.info("enter get_filtered_dfs") dfs = {} tt = None # Process all lipds files or one lipds file? specific_files = _c...
[ "def", "get_filtered_dfs", "(", "lib", ",", "expr", ")", ":", "logger_dataframes", ".", "info", "(", "\"enter get_filtered_dfs\"", ")", "dfs", "=", "{", "}", "tt", "=", "None", "# Process all lipds files or one lipds file?", "specific_files", "=", "_check_expr_filenam...
Main: Get all data frames that match the given expression :return dict: Filenames and data frames (filtered)
[ "Main", ":", "Get", "all", "data", "frames", "that", "match", "the", "given", "expression", ":", "return", "dict", ":", "Filenames", "and", "data", "frames", "(", "filtered", ")" ]
python
train
37.527273
pilliq/scratchpy
scratch/scratch.py
https://github.com/pilliq/scratchpy/blob/a594561c147b1cf6696231c26a0475c7d52b8039/scratch/scratch.py#L47-L59
def _get_type(self, s): """ Converts a string from Scratch to its proper type in Python. Expects a string with its delimiting quotes in place. Returns either a string, int or float. """ # TODO: what if the number is bigger than an int or float? if s.startswith('...
[ "def", "_get_type", "(", "self", ",", "s", ")", ":", "# TODO: what if the number is bigger than an int or float?", "if", "s", ".", "startswith", "(", "'\"'", ")", "and", "s", ".", "endswith", "(", "'\"'", ")", ":", "return", "s", "[", "1", ":", "-", "1", ...
Converts a string from Scratch to its proper type in Python. Expects a string with its delimiting quotes in place. Returns either a string, int or float.
[ "Converts", "a", "string", "from", "Scratch", "to", "its", "proper", "type", "in", "Python", ".", "Expects", "a", "string", "with", "its", "delimiting", "quotes", "in", "place", ".", "Returns", "either", "a", "string", "int", "or", "float", "." ]
python
train
35.538462
gem/oq-engine
openquake/hmtk/seismicity/smoothing/utils.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/smoothing/utils.py#L130-L155
def check_completeness_table(completeness_table, catalogue): ''' Check to ensure completeness table is in the correct format `completeness_table = np.array([[year_, mag_i]]) for i in number of bins` :param np.ndarray completeness_table: Completeness table in format [[year, mag]] :param cat...
[ "def", "check_completeness_table", "(", "completeness_table", ",", "catalogue", ")", ":", "if", "isinstance", "(", "completeness_table", ",", "np", ".", "ndarray", ")", ":", "assert", "np", ".", "shape", "(", "completeness_table", ")", "[", "1", "]", "==", "...
Check to ensure completeness table is in the correct format `completeness_table = np.array([[year_, mag_i]]) for i in number of bins` :param np.ndarray completeness_table: Completeness table in format [[year, mag]] :param catalogue: Instance of openquake.hmtk.seismicity.catalogue.Catalogue...
[ "Check", "to", "ensure", "completeness", "table", "is", "in", "the", "correct", "format", "completeness_table", "=", "np", ".", "array", "(", "[[", "year_", "mag_i", "]]", ")", "for", "i", "in", "number", "of", "bins" ]
python
train
38.038462
briancappello/flask-unchained
flask_unchained/bundles/security/commands/users.py
https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/security/commands/users.py#L188-L199
def remove_role_from_user(user, role): """ Remove a role from a user. """ user = _query_to_user(user) role = _query_to_role(role) if click.confirm(f'Are you sure you want to remove {role!r} from {user!r}?'): user.roles.remove(role) user_manager.save(user, commit=True) cli...
[ "def", "remove_role_from_user", "(", "user", ",", "role", ")", ":", "user", "=", "_query_to_user", "(", "user", ")", "role", "=", "_query_to_role", "(", "role", ")", "if", "click", ".", "confirm", "(", "f'Are you sure you want to remove {role!r} from {user!r}?'", ...
Remove a role from a user.
[ "Remove", "a", "role", "from", "a", "user", "." ]
python
train
33.916667
nickmckay/LiPD-utilities
Python/lipd/timeseries.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/timeseries.py#L298-L313
def _extract_table_root(d, current, pc): """ Extract data from the root level of a paleoData table. :param dict d: paleoData table :param dict current: Current root data :param str pc: paleoData or chronData :return dict current: Current root data """ logger_ts.info("enter extract_table_...
[ "def", "_extract_table_root", "(", "d", ",", "current", ",", "pc", ")", ":", "logger_ts", ".", "info", "(", "\"enter extract_table_root\"", ")", "try", ":", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", "...
Extract data from the root level of a paleoData table. :param dict d: paleoData table :param dict current: Current root data :param str pc: paleoData or chronData :return dict current: Current root data
[ "Extract", "data", "from", "the", "root", "level", "of", "a", "paleoData", "table", ".", ":", "param", "dict", "d", ":", "paleoData", "table", ":", "param", "dict", "current", ":", "Current", "root", "data", ":", "param", "str", "pc", ":", "paleoData", ...
python
train
33.375
mromanello/hucitlib
knowledge_base/surfext/__init__.py
https://github.com/mromanello/hucitlib/blob/6587d1b04eb7e5b48ad7359be845e5d3b444d6fa/knowledge_base/surfext/__init__.py#L201-L215
def set_urn(self,urn): """ Change the CTS URN of the author or adds a new one (if no URN is assigned). """ Type = self.session.get_class(surf.ns.ECRM['E55_Type']) Identifier = self.session.get_class(surf.ns.ECRM['E42_Identifier']) id_uri = "%s/cts_urn"%str(self.subject) ...
[ "def", "set_urn", "(", "self", ",", "urn", ")", ":", "Type", "=", "self", ".", "session", ".", "get_class", "(", "surf", ".", "ns", ".", "ECRM", "[", "'E55_Type'", "]", ")", "Identifier", "=", "self", ".", "session", ".", "get_class", "(", "surf", ...
Change the CTS URN of the author or adds a new one (if no URN is assigned).
[ "Change", "the", "CTS", "URN", "of", "the", "author", "or", "adds", "a", "new", "one", "(", "if", "no", "URN", "is", "assigned", ")", "." ]
python
train
37.066667
saltstack/salt
salt/modules/vsphere.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L8288-L8312
def _create_scsi_devices(scsi_devices): ''' Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SCSI controllers scsi_devices: List of SCSI device properties ''' keys = range(-1000, -1050, -1) scsi_specs = [] if scsi_devices: devs = [scsi['adapter'] fo...
[ "def", "_create_scsi_devices", "(", "scsi_devices", ")", ":", "keys", "=", "range", "(", "-", "1000", ",", "-", "1050", ",", "-", "1", ")", "scsi_specs", "=", "[", "]", "if", "scsi_devices", ":", "devs", "=", "[", "scsi", "[", "'adapter'", "]", "for"...
Returns a list of vim.vm.device.VirtualDeviceSpec objects representing SCSI controllers scsi_devices: List of SCSI device properties
[ "Returns", "a", "list", "of", "vim", ".", "vm", ".", "device", ".", "VirtualDeviceSpec", "objects", "representing", "SCSI", "controllers" ]
python
train
42.44
aio-libs/aiohttp
aiohttp/web_response.py
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L282-L293
def last_modified(self) -> Optional[datetime.datetime]: """The value of Last-Modified HTTP header, or None. This header is represented as a `datetime` object. """ httpdate = self._headers.get(hdrs.LAST_MODIFIED) if httpdate is not None: timetuple = parsedate(httpdate...
[ "def", "last_modified", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "httpdate", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "LAST_MODIFIED", ")", "if", "httpdate", "is", "not", "None", ":", "timetuple",...
The value of Last-Modified HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "Last", "-", "Modified", "HTTP", "header", "or", "None", "." ]
python
train
41.333333
s4int/robotframework-KafkaLibrary
KafkaLibrary/Producer.py
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Producer.py#L27-L44
def send(self, topic, value=None, timeout=60, key=None, partition=None, timestamp_ms=None): """Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. ...
[ "def", "send", "(", "self", ",", "topic", ",", "value", "=", "None", ",", "timeout", "=", "60", ",", "key", "=", "None", ",", "partition", "=", "None", ",", "timestamp_ms", "=", "None", ")", ":", "future", "=", "self", ".", "producer", ".", "send",...
Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. If value is None, key is required and message acts as a `delete`. - ``timeout`` ...
[ "Publish", "a", "message", "to", "a", "topic", "." ]
python
train
71.555556
resonai/ybt
yabt/builders/cpp.py
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L316-L334
def build_cpp(build_context, target, compiler_config, workspace_dir): """Compile and link a C++ binary for `target`.""" rmtree(workspace_dir) binary = join(*split(target.name)) objects = link_cpp_artifacts(build_context, target, workspace_dir, True) buildenv_workspace = build_context.conf.host_to_bu...
[ "def", "build_cpp", "(", "build_context", ",", "target", ",", "compiler_config", ",", "workspace_dir", ")", ":", "rmtree", "(", "workspace_dir", ")", "binary", "=", "join", "(", "*", "split", "(", "target", ".", "name", ")", ")", "objects", "=", "link_cpp_...
Compile and link a C++ binary for `target`.
[ "Compile", "and", "link", "a", "C", "++", "binary", "for", "target", "." ]
python
train
50.105263
jpscaletti/authcode
authcode/wsgi/bottle.py
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/wsgi/bottle.py#L18-L26
def get_full_path(request): """Return the current relative path including the query string. Eg: “/foo/bar/?page=1” """ path = request.fullpath query_string = request.environ.get('QUERY_STRING') if query_string: path += '?' + to_native(query_string) return path
[ "def", "get_full_path", "(", "request", ")", ":", "path", "=", "request", ".", "fullpath", "query_string", "=", "request", ".", "environ", ".", "get", "(", "'QUERY_STRING'", ")", "if", "query_string", ":", "path", "+=", "'?'", "+", "to_native", "(", "query...
Return the current relative path including the query string. Eg: “/foo/bar/?page=1”
[ "Return", "the", "current", "relative", "path", "including", "the", "query", "string", ".", "Eg", ":", "“", "/", "foo", "/", "bar", "/", "?page", "=", "1”" ]
python
train
32
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/mp_tile.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_tile.py#L324-L372
def load_tile_lowres(self, tile): '''load a lower resolution tile from cache to fill in a map while waiting for a higher resolution tile''' if tile.zoom == self.min_zoom: return None # find the equivalent lower res tile (lat,lon) = tile.coord() width2 = TILE...
[ "def", "load_tile_lowres", "(", "self", ",", "tile", ")", ":", "if", "tile", ".", "zoom", "==", "self", ".", "min_zoom", ":", "return", "None", "# find the equivalent lower res tile", "(", "lat", ",", "lon", ")", "=", "tile", ".", "coord", "(", ")", "wid...
load a lower resolution tile from cache to fill in a map while waiting for a higher resolution tile
[ "load", "a", "lower", "resolution", "tile", "from", "cache", "to", "fill", "in", "a", "map", "while", "waiting", "for", "a", "higher", "resolution", "tile" ]
python
train
35.795918
karan/TPB
tpb/tpb.py
https://github.com/karan/TPB/blob/f424a73a10d4bcf4e363d7e7e8cb915a3a057671/tpb/tpb.py#L29-L41
def self_if_parameters(func): """ If any parameter is given, the method's binded object is returned after executing the function. Else the function's result is returned. """ @wraps(func) def wrapper(self, *args, **kwargs): result = func(self, *args, **kwargs) if args or kwargs: ...
[ "def", "self_if_parameters", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs",...
If any parameter is given, the method's binded object is returned after executing the function. Else the function's result is returned.
[ "If", "any", "parameter", "is", "given", "the", "method", "s", "binded", "object", "is", "returned", "after", "executing", "the", "function", ".", "Else", "the", "function", "s", "result", "is", "returned", "." ]
python
train
29.923077
hthiery/python-lacrosse
pylacrosse/lacrosse.py
https://github.com/hthiery/python-lacrosse/blob/d588e68f12b3343e736ff986e5f994777b122fda/pylacrosse/lacrosse.py#L84-L118
def _parse_info(line): """ The output can be: - [LaCrosseITPlusReader.10.1s (RFM12B f:0 r:17241)] - [LaCrosseITPlusReader.10.1s (RFM12B f:0 t:10~3)] """ re_info = re.compile( r'\[(?P<name>\w+).(?P<ver>.*) ' + r'\((?P<rfm1name>\w+) (\w+):(?P<rfm1fre...
[ "def", "_parse_info", "(", "line", ")", ":", "re_info", "=", "re", ".", "compile", "(", "r'\\[(?P<name>\\w+).(?P<ver>.*) '", "+", "r'\\((?P<rfm1name>\\w+) (\\w+):(?P<rfm1freq>\\d+) '", "+", "r'(?P<rfm1mode>.*)\\)\\]'", ")", "info", "=", "{", "'name'", ":", "None", ","...
The output can be: - [LaCrosseITPlusReader.10.1s (RFM12B f:0 r:17241)] - [LaCrosseITPlusReader.10.1s (RFM12B f:0 t:10~3)]
[ "The", "output", "can", "be", ":", "-", "[", "LaCrosseITPlusReader", ".", "10", ".", "1s", "(", "RFM12B", "f", ":", "0", "r", ":", "17241", ")", "]", "-", "[", "LaCrosseITPlusReader", ".", "10", ".", "1s", "(", "RFM12B", "f", ":", "0", "t", ":", ...
python
train
34.342857
RedFantom/ttkwidgets
ttkwidgets/font/chooser.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/font/chooser.py#L102-L105
def _on_change(self): """Callback if any of the values are changed.""" font = self.__generate_font_tuple() self._example_label.configure(font=font)
[ "def", "_on_change", "(", "self", ")", ":", "font", "=", "self", ".", "__generate_font_tuple", "(", ")", "self", ".", "_example_label", ".", "configure", "(", "font", "=", "font", ")" ]
Callback if any of the values are changed.
[ "Callback", "if", "any", "of", "the", "values", "are", "changed", "." ]
python
train
42
Unidata/siphon
siphon/simplewebservice/igra2.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L74-L97
def _get_data(self): """Process the IGRA2 text file for observations at site_id matching time. Return: ------- :class: `pandas.DataFrame` containing the body data. :class: `pandas.DataFrame` containing the header data. """ # Split the list of times into b...
[ "def", "_get_data", "(", "self", ")", ":", "# Split the list of times into begin and end dates. If only", "# one date is supplied, set both begin and end dates equal to that date.", "body", ",", "header", ",", "dates_long", ",", "dates", "=", "self", ".", "_get_data_raw", "(", ...
Process the IGRA2 text file for observations at site_id matching time. Return: ------- :class: `pandas.DataFrame` containing the body data. :class: `pandas.DataFrame` containing the header data.
[ "Process", "the", "IGRA2", "text", "file", "for", "observations", "at", "site_id", "matching", "time", "." ]
python
train
35.5
google/grr
grr/client/grr_response_client/windows/installers.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/windows/installers.py#L56-L104
def StopService(service_name, service_binary_name=None): """Stop a Windows service with the given name. Args: service_name: string The name of the service to be stopped. service_binary_name: string If given, also kill this binary as a best effort fallback solution. """ # QueryServiceStatus retu...
[ "def", "StopService", "(", "service_name", ",", "service_binary_name", "=", "None", ")", ":", "# QueryServiceStatus returns: scvType, svcState, svcControls, err,", "# svcErr, svcCP, svcWH", "try", ":", "status", "=", "win32serviceutil", ".", "QueryServiceStatus", "(", "servic...
Stop a Windows service with the given name. Args: service_name: string The name of the service to be stopped. service_binary_name: string If given, also kill this binary as a best effort fallback solution.
[ "Stop", "a", "Windows", "service", "with", "the", "given", "name", "." ]
python
train
33.734694
mozilla/build-mar
src/mardor/utils.py
https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L233-L244
def path_is_inside(path, dirname): """Return True if path is under dirname.""" path = os.path.abspath(path) dirname = os.path.abspath(dirname) while len(path) >= len(dirname): if path == dirname: return True newpath = os.path.dirname(path) if newpath == path: ...
[ "def", "path_is_inside", "(", "path", ",", "dirname", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "dirname", "=", "os", ".", "path", ".", "abspath", "(", "dirname", ")", "while", "len", "(", "path", ")", ">=", "len",...
Return True if path is under dirname.
[ "Return", "True", "if", "path", "is", "under", "dirname", "." ]
python
train
30.416667
Parsely/birding
src/birding/config.py
https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/config.py#L171-L179
def get_defaults_file(*a, **kw): """Get a file object with YAML data of configuration defaults. Arguments are passed through to :func:`get_defaults_str`. """ fd = StringIO() fd.write(get_defaults_str(*a, **kw)) fd.seek(0) return fd
[ "def", "get_defaults_file", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "fd", "=", "StringIO", "(", ")", "fd", ".", "write", "(", "get_defaults_str", "(", "*", "a", ",", "*", "*", "kw", ")", ")", "fd", ".", "seek", "(", "0", ")", "return", ...
Get a file object with YAML data of configuration defaults. Arguments are passed through to :func:`get_defaults_str`.
[ "Get", "a", "file", "object", "with", "YAML", "data", "of", "configuration", "defaults", "." ]
python
train
28
chaoss/grimoirelab-elk
grimoire_elk/enriched/study_ceres_aoc.py
https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/study_ceres_aoc.py#L214-L226
def areas_of_code(git_enrich, in_conn, out_conn, block_size=100): """Build and index for areas of code from a given Perceval RAW index. :param block_size: size of items block. :param git_enrich: GitEnrich object to deal with SortingHat affiliations. :param in_conn: ESPandasConnector to read from. :...
[ "def", "areas_of_code", "(", "git_enrich", ",", "in_conn", ",", "out_conn", ",", "block_size", "=", "100", ")", ":", "aoc", "=", "AreasOfCode", "(", "in_connector", "=", "in_conn", ",", "out_connector", "=", "out_conn", ",", "block_size", "=", "block_size", ...
Build and index for areas of code from a given Perceval RAW index. :param block_size: size of items block. :param git_enrich: GitEnrich object to deal with SortingHat affiliations. :param in_conn: ESPandasConnector to read from. :param out_conn: ESPandasConnector to write to. :return: number of doc...
[ "Build", "and", "index", "for", "areas", "of", "code", "from", "a", "given", "Perceval", "RAW", "index", "." ]
python
train
47.307692
GoogleCloudPlatform/datastore-ndb-python
ndb/query.py
https://github.com/GoogleCloudPlatform/datastore-ndb-python/blob/cf4cab3f1f69cd04e1a9229871be466b53729f3f/ndb/query.py#L1221-L1239
def fetch_async(self, limit=None, **q_options): """Fetch a list of query results, up to a limit. This is the asynchronous version of Query.fetch(). """ if limit is None: default_options = self._make_options(q_options) if default_options is not None and default_options.limit is not None: ...
[ "def", "fetch_async", "(", "self", ",", "limit", "=", "None", ",", "*", "*", "q_options", ")", ":", "if", "limit", "is", "None", ":", "default_options", "=", "self", ".", "_make_options", "(", "q_options", ")", "if", "default_options", "is", "not", "None...
Fetch a list of query results, up to a limit. This is the asynchronous version of Query.fetch().
[ "Fetch", "a", "list", "of", "query", "results", "up", "to", "a", "limit", "." ]
python
train
36.789474
chibisov/drf-extensions
docs/backdoc.py
https://github.com/chibisov/drf-extensions/blob/1d28a4b28890eab5cd19e93e042f8590c8c2fb8b/docs/backdoc.py#L846-L860
def _prepare_pyshell_blocks(self, text): """Ensure that Python interactive shell sessions are put in code blocks -- even if not properly indented. """ if ">>>" not in text: return text less_than_tab = self.tab_width - 1 _pyshell_block_re = re.compile(r""" ...
[ "def", "_prepare_pyshell_blocks", "(", "self", ",", "text", ")", ":", "if", "\">>>\"", "not", "in", "text", ":", "return", "text", "less_than_tab", "=", "self", ".", "tab_width", "-", "1", "_pyshell_block_re", "=", "re", ".", "compile", "(", "r\"\"\"\n ...
Ensure that Python interactive shell sessions are put in code blocks -- even if not properly indented.
[ "Ensure", "that", "Python", "interactive", "shell", "sessions", "are", "put", "in", "code", "blocks", "--", "even", "if", "not", "properly", "indented", "." ]
python
train
39.8
NJDFan/ctypes-bitfield
bitfield/walk.py
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L240-L251
def _createunbound(kls, **info): """Create a new UnboundNode representing a given class.""" if issubclass(kls, Bitfield): nodetype = UnboundBitfieldNode elif hasattr(kls, '_fields_'): nodetype = UnboundStructureNode elif issubclass(kls, ctypes.Array): nodetype = UnboundArray...
[ "def", "_createunbound", "(", "kls", ",", "*", "*", "info", ")", ":", "if", "issubclass", "(", "kls", ",", "Bitfield", ")", ":", "nodetype", "=", "UnboundBitfieldNode", "elif", "hasattr", "(", "kls", ",", "'_fields_'", ")", ":", "nodetype", "=", "Unbound...
Create a new UnboundNode representing a given class.
[ "Create", "a", "new", "UnboundNode", "representing", "a", "given", "class", "." ]
python
train
33.833333
google/grr
grr/server/grr_response_server/aff4.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4.py#L457-L513
def CreateWithLock(self, urn, aff4_type, token=None, age=NEWEST_TIME, force_new_version=True, blocking=True, blocking_lock_timeout=10, blocking_sleep_in...
[ "def", "CreateWithLock", "(", "self", ",", "urn", ",", "aff4_type", ",", "token", "=", "None", ",", "age", "=", "NEWEST_TIME", ",", "force_new_version", "=", "True", ",", "blocking", "=", "True", ",", "blocking_lock_timeout", "=", "10", ",", "blocking_sleep_...
Creates a new object and locks it. Similar to OpenWithLock below, this creates a locked object. The difference is that when you call CreateWithLock, the object does not yet have to exist in the data store. Args: urn: The object to create. aff4_type: The desired type for this object. ...
[ "Creates", "a", "new", "object", "and", "locks", "it", "." ]
python
train
35.017544
spacetelescope/drizzlepac
drizzlepac/tweakutils.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/tweakutils.py#L201-L270
def radec_hmstodd(ra, dec): """ Function to convert HMS values into decimal degrees. This function relies on the astropy.coordinates package to perform the conversion to decimal degrees. Parameters ---------- ra : list or array List or array of input RA positio...
[ "def", "radec_hmstodd", "(", "ra", ",", "dec", ")", ":", "hmstrans", "=", "string", ".", "maketrans", "(", "string", ".", "ascii_letters", ",", "' '", "*", "len", "(", "string", ".", "ascii_letters", ")", ")", "if", "isinstance", "(", "ra", ",", "list"...
Function to convert HMS values into decimal degrees. This function relies on the astropy.coordinates package to perform the conversion to decimal degrees. Parameters ---------- ra : list or array List or array of input RA positions dec : list or array ...
[ "Function", "to", "convert", "HMS", "values", "into", "decimal", "degrees", "." ]
python
train
28.042857
bwhite/hadoopy
hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/ObjectGraph.py
https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/ObjectGraph.py#L171-L176
def msg(self, level, s, *args): """ Print a debug message with the given level """ if s and level <= self.debug: print "%s%s %s" % (" " * self.indent, s, ' '.join(map(repr, args)))
[ "def", "msg", "(", "self", ",", "level", ",", "s", ",", "*", "args", ")", ":", "if", "s", "and", "level", "<=", "self", ".", "debug", ":", "print", "\"%s%s %s\"", "%", "(", "\" \"", "*", "self", ".", "indent", ",", "s", ",", "' '", ".", "join"...
Print a debug message with the given level
[ "Print", "a", "debug", "message", "with", "the", "given", "level" ]
python
train
36.666667
odlgroup/odl
odl/contrib/datasets/ct/fips.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/contrib/datasets/ct/fips.py#L31-L57
def walnut_data(): """Tomographic X-ray data of a walnut. Notes ----- See the article `Tomographic X-ray data of a walnut`_ for further information. See Also -------- walnut_geometry References ---------- .. _Tomographic X-ray data of a walnut: https://arxiv.org/abs/1502.0...
[ "def", "walnut_data", "(", ")", ":", "# TODO: Store data in some ODL controlled url", "url", "=", "'http://www.fips.fi/dataset/CT_walnut_v1/FullSizeSinograms.mat'", "dct", "=", "get_data", "(", "'walnut.mat'", ",", "subset", "=", "DATA_SUBSET", ",", "url", "=", "url", ")"...
Tomographic X-ray data of a walnut. Notes ----- See the article `Tomographic X-ray data of a walnut`_ for further information. See Also -------- walnut_geometry References ---------- .. _Tomographic X-ray data of a walnut: https://arxiv.org/abs/1502.04064
[ "Tomographic", "X", "-", "ray", "data", "of", "a", "walnut", "." ]
python
train
27.407407
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1513-L1516
def p_parallelblock(self, p): 'parallelblock : FORK block_statements JOIN' p[0] = ParallelBlock(p[2], lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_parallelblock", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "ParallelBlock", "(", "p", "[", "2", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "p", ".", "set_lineno", "(", "0", ",", "p", ".", "lineno...
parallelblock : FORK block_statements JOIN
[ "parallelblock", ":", "FORK", "block_statements", "JOIN" ]
python
train
42.75
saltstack/salt
salt/states/boto_cloudfront.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_cloudfront.py#L837-L955
def distribution_absent(name, region=None, key=None, keyid=None, profile=None, **kwargs): ''' Ensure a distribution with the given Name tag does not exist. Note that CloudFront does not allow directly deleting an enabled Distribution. If such is requested, Salt will attempt to first update the dist...
[ "def", "distribution_absent", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ",", "*", "*", "kwargs", ")", ":", "Name", "=", "kwargs", "[", "'Name'", "]", "if", "'Name'", "i...
Ensure a distribution with the given Name tag does not exist. Note that CloudFront does not allow directly deleting an enabled Distribution. If such is requested, Salt will attempt to first update the distribution's status to Disabled, and once that returns success, to then delete the resource. THIS CA...
[ "Ensure", "a", "distribution", "with", "the", "given", "Name", "tag", "does", "not", "exist", "." ]
python
train
36.10084
saltstack/salt
salt/cloud/clouds/vmware.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vmware.py#L1691-L1707
def list_hosts(kwargs=None, call=None): ''' List all the hosts for this VMware environment CLI Example: .. code-block:: bash salt-cloud -f list_hosts my-vmware-config ''' if call != 'function': raise SaltCloudSystemExit( 'The list_hosts function must be called with...
[ "def", "list_hosts", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_hosts function must be called with '", "'-f or --function.'", ")", "return", "{", "'Hosts'", ...
List all the hosts for this VMware environment CLI Example: .. code-block:: bash salt-cloud -f list_hosts my-vmware-config
[ "List", "all", "the", "hosts", "for", "this", "VMware", "environment" ]
python
train
24.176471
rsheftel/raccoon
raccoon/dataframe.py
https://github.com/rsheftel/raccoon/blob/e5c4b5fb933b51f33aff11e8168c39790e9a7c75/raccoon/dataframe.py#L310-L321
def get_columns(self, index, columns=None, as_dict=False): """ For a single index and list of column names return a DataFrame of the values in that index as either a dict or a DataFrame :param index: single index value :param columns: list of column names :param as_dict:...
[ "def", "get_columns", "(", "self", ",", "index", ",", "columns", "=", "None", ",", "as_dict", "=", "False", ")", ":", "i", "=", "sorted_index", "(", "self", ".", "_index", ",", "index", ")", "if", "self", ".", "_sort", "else", "self", ".", "_index", ...
For a single index and list of column names return a DataFrame of the values in that index as either a dict or a DataFrame :param index: single index value :param columns: list of column names :param as_dict: if True then return the result as a dictionary :return: DataFrame or d...
[ "For", "a", "single", "index", "and", "list", "of", "column", "names", "return", "a", "DataFrame", "of", "the", "values", "in", "that", "index", "as", "either", "a", "dict", "or", "a", "DataFrame" ]
python
train
46
fronzbot/blinkpy
blinkpy/api.py
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L106-L110
def request_homescreen(blink): """Request homescreen info.""" url = "{}/api/v3/accounts/{}/homescreen".format(blink.urls.base_url, blink.account_id) return http_get(blink, url)
[ "def", "request_homescreen", "(", "blink", ")", ":", "url", "=", "\"{}/api/v3/accounts/{}/homescreen\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "blink", ".", "account_id", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request homescreen info.
[ "Request", "homescreen", "info", "." ]
python
train
47.2
ewiger/mlab
src/mlab/awmstools.py
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L1724-L1764
def mkRepr(instance, *argls, **kwargs): r"""Convinience function to implement ``__repr__``. `kwargs` values are ``repr`` ed. Special behavior for ``instance=None``: just the arguments are formatted. Example: >>> class Thing: ... def __init__(self, color, shape, taste=None):...
[ "def", "mkRepr", "(", "instance", ",", "*", "argls", ",", "*", "*", "kwargs", ")", ":", "width", "=", "79", "maxIndent", "=", "15", "minIndent", "=", "2", "args", "=", "(", "map", "(", "repr", ",", "argls", ")", "+", "[", "\"%s=%r\"", "%", "(", ...
r"""Convinience function to implement ``__repr__``. `kwargs` values are ``repr`` ed. Special behavior for ``instance=None``: just the arguments are formatted. Example: >>> class Thing: ... def __init__(self, color, shape, taste=None): ... self.color, self.shape,...
[ "r", "Convinience", "function", "to", "implement", "__repr__", ".", "kwargs", "values", "are", "repr", "ed", ".", "Special", "behavior", "for", "instance", "=", "None", ":", "just", "the", "arguments", "are", "formatted", "." ]
python
train
40.02439
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L118-L130
def destroy(self): """ A reimplemented destructor that cancels the dialog before destroying. """ super(AndroidPopupWindow, self).destroy() window = self.window if window: #: Clear the dismiss listener #: (or we get an error during the ca...
[ "def", "destroy", "(", "self", ")", ":", "super", "(", "AndroidPopupWindow", ",", "self", ")", ".", "destroy", "(", ")", "window", "=", "self", ".", "window", "if", "window", ":", "#: Clear the dismiss listener", "#: (or we get an error during the callback)", "win...
A reimplemented destructor that cancels the dialog before destroying.
[ "A", "reimplemented", "destructor", "that", "cancels", "the", "dialog", "before", "destroying", "." ]
python
train
32.230769
edeposit/edeposit.amqp.antivirus
src/edeposit/amqp/antivirus/wrappers/clamscan.py
https://github.com/edeposit/edeposit.amqp.antivirus/blob/011b38bbe920819fab99a5891b1e70732321a598/src/edeposit/amqp/antivirus/wrappers/clamscan.py#L17-L50
def _parse_result(result): """ Parse ``clamscan`` output into same dictionary structured used by ``pyclamd``. Input example:: /home/bystrousak/Plocha/prace/test/eicar.com: Eicar-Test-Signature FOUND Output dict:: { "/home/bystrousak/Plocha/prace/test/eicar.com": ( ...
[ "def", "_parse_result", "(", "result", ")", ":", "lines", "=", "filter", "(", "lambda", "x", ":", "x", ".", "strip", "(", ")", ",", "result", ".", "splitlines", "(", ")", ")", "# rm blank lines", "if", "not", "lines", ":", "return", "{", "}", "out", ...
Parse ``clamscan`` output into same dictionary structured used by ``pyclamd``. Input example:: /home/bystrousak/Plocha/prace/test/eicar.com: Eicar-Test-Signature FOUND Output dict:: { "/home/bystrousak/Plocha/prace/test/eicar.com": ( "FOUND", "Ei...
[ "Parse", "clamscan", "output", "into", "same", "dictionary", "structured", "used", "by", "pyclamd", "." ]
python
train
22.529412
bitcraze/crazyflie-lib-python
examples/write-eeprom.py
https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/examples/write-eeprom.py#L68-L87
def _connected(self, link_uri): """ This callback is called form the Crazyflie API when a Crazyflie has been connected and the TOCs have been downloaded.""" print('Connected to %s' % link_uri) mems = self._cf.mem.get_mems(MemoryElement.TYPE_I2C) print('Found {} EEPOM(s)'.format(...
[ "def", "_connected", "(", "self", ",", "link_uri", ")", ":", "print", "(", "'Connected to %s'", "%", "link_uri", ")", "mems", "=", "self", ".", "_cf", ".", "mem", ".", "get_mems", "(", "MemoryElement", ".", "TYPE_I2C", ")", "print", "(", "'Found {} EEPOM(s...
This callback is called form the Crazyflie API when a Crazyflie has been connected and the TOCs have been downloaded.
[ "This", "callback", "is", "called", "form", "the", "Crazyflie", "API", "when", "a", "Crazyflie", "has", "been", "connected", "and", "the", "TOCs", "have", "been", "downloaded", "." ]
python
train
38.35
emory-libraries/eulxml
eulxml/xmlmap/mods.py
https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/mods.py#L242-L246
def is_empty(self): '''Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.''' return not bool(self.title or self.subtitle or self.part_number \ or self.part_name or self.non_sort or self.type)
[ "def", "is_empty", "(", "self", ")", ":", "return", "not", "bool", "(", "self", ".", "title", "or", "self", ".", "subtitle", "or", "self", ".", "part_number", "or", "self", ".", "part_name", "or", "self", ".", "non_sort", "or", "self", ".", "type", "...
Returns True if all titleInfo subfields are not set or empty; returns False if any of the fields are not empty.
[ "Returns", "True", "if", "all", "titleInfo", "subfields", "are", "not", "set", "or", "empty", ";", "returns", "False", "if", "any", "of", "the", "fields", "are", "not", "empty", "." ]
python
train
59.2
pmacosta/peng
peng/wave_functions.py
https://github.com/pmacosta/peng/blob/976935377adaa3de26fc5677aceb2cdfbd6f93a7/peng/wave_functions.py#L791-L833
def fftr(wave, npoints=None, indep_min=None, indep_max=None): r""" Return the real part of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less...
[ "def", "fftr", "(", "wave", ",", "npoints", "=", "None", ",", "indep_min", "=", "None", ",", "indep_max", "=", "None", ")", ":", "return", "real", "(", "fft", "(", "wave", ",", "npoints", ",", "indep_min", ",", "indep_max", ")", ")" ]
r""" Return the real part of the Fast Fourier Transform of a waveform. :param wave: Waveform :type wave: :py:class:`peng.eng.Waveform` :param npoints: Number of points to use in the transform. If **npoints** is less than the size of the independent variable vector ...
[ "r", "Return", "the", "real", "part", "of", "the", "Fast", "Fourier", "Transform", "of", "a", "waveform", "." ]
python
test
33.023256
pydron/anycall
anycall/rpc.py
https://github.com/pydron/anycall/blob/43add96660258a14b24aa8e8413dffb1741b72d7/anycall/rpc.py#L178-L194
def open(self): """ Opens the port. :returns: Deferred that callbacks when we are ready to make and receive calls. """ logging.debug("Opening rpc system") d = self._connectionpool.open(self._packet_received) def opened(_): logging.deb...
[ "def", "open", "(", "self", ")", ":", "logging", ".", "debug", "(", "\"Opening rpc system\"", ")", "d", "=", "self", ".", "_connectionpool", ".", "open", "(", "self", ".", "_packet_received", ")", "def", "opened", "(", "_", ")", ":", "logging", ".", "d...
Opens the port. :returns: Deferred that callbacks when we are ready to make and receive calls.
[ "Opens", "the", "port", ".", ":", "returns", ":", "Deferred", "that", "callbacks", "when", "we", "are", "ready", "to", "make", "and", "receive", "calls", "." ]
python
test
31.176471
dropbox/stone
stone/cli_helpers.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/cli_helpers.py#L84-L90
def t_ID(self, token): r'[a-zA-Z_][a-zA-Z0-9_-]*' if token.value in self.KEYWORDS: token.type = self.KEYWORDS[token.value] return token else: return token
[ "def", "t_ID", "(", "self", ",", "token", ")", ":", "if", "token", ".", "value", "in", "self", ".", "KEYWORDS", ":", "token", ".", "type", "=", "self", ".", "KEYWORDS", "[", "token", ".", "value", "]", "return", "token", "else", ":", "return", "tok...
r'[a-zA-Z_][a-zA-Z0-9_-]*
[ "r", "[", "a", "-", "zA", "-", "Z_", "]", "[", "a", "-", "zA", "-", "Z0", "-", "9_", "-", "]", "*" ]
python
train
29.714286
Equitable/trump
trump/orm.py
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/orm.py#L430-L486
def search_tag(self, tag, symbols=True, feeds=False): """ Get a list of Symbols by searching a tag or partial tag. Parameters ---------- tag : str The tag to search. Appending '%' will use SQL's "LIKE" functionality. symbols : bool, optional ...
[ "def", "search_tag", "(", "self", ",", "tag", ",", "symbols", "=", "True", ",", "feeds", "=", "False", ")", ":", "syms", "=", "[", "]", "if", "isinstance", "(", "tag", ",", "(", "str", ",", "unicode", ")", ")", ":", "tags", "=", "[", "tag", "]"...
Get a list of Symbols by searching a tag or partial tag. Parameters ---------- tag : str The tag to search. Appending '%' will use SQL's "LIKE" functionality. symbols : bool, optional Search for Symbol's based on their tags. feeds : ...
[ "Get", "a", "list", "of", "Symbols", "by", "searching", "a", "tag", "or", "partial", "tag", ".", "Parameters", "----------", "tag", ":", "str", "The", "tag", "to", "search", ".", "Appending", "%", "will", "use", "SQL", "s", "LIKE", "functionality", ".", ...
python
train
30.052632
aleju/imgaug
imgaug/augmentables/polys.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/polys.py#L836-L890
def exterior_almost_equals(self, other, max_distance=1e-6, points_per_edge=8): """ Estimate if this and other polygon's exterior are almost identical. The two exteriors can have different numbers of points, but any point randomly sampled on the exterior of one polygon should be close to...
[ "def", "exterior_almost_equals", "(", "self", ",", "other", ",", "max_distance", "=", "1e-6", ",", "points_per_edge", "=", "8", ")", ":", "if", "isinstance", "(", "other", ",", "list", ")", ":", "other", "=", "Polygon", "(", "np", ".", "float32", "(", ...
Estimate if this and other polygon's exterior are almost identical. The two exteriors can have different numbers of points, but any point randomly sampled on the exterior of one polygon should be close to the closest point on the exterior of the other polygon. Note that this method wor...
[ "Estimate", "if", "this", "and", "other", "polygon", "s", "exterior", "are", "almost", "identical", "." ]
python
valid
42.909091
mozilla/rna
rna/models.py
https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/models.py#L158-L167
def to_simple_dict(self): """Return a dict of only the basic data about the release""" return { 'version': self.version, 'product': self.product, 'channel': self.channel, 'is_public': self.is_public, 'slug': self.slug, 'title': unic...
[ "def", "to_simple_dict", "(", "self", ")", ":", "return", "{", "'version'", ":", "self", ".", "version", ",", "'product'", ":", "self", ".", "product", ",", "'channel'", ":", "self", ".", "channel", ",", "'is_public'", ":", "self", ".", "is_public", ",",...
Return a dict of only the basic data about the release
[ "Return", "a", "dict", "of", "only", "the", "basic", "data", "about", "the", "release" ]
python
train
33.1
bmuller/kademlia
kademlia/routing.py
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/routing.py#L140-L146
def lonely_buckets(self): """ Get all of the buckets that haven't been updated in over an hour. """ hrago = time.monotonic() - 3600 return [b for b in self.buckets if b.last_updated < hrago]
[ "def", "lonely_buckets", "(", "self", ")", ":", "hrago", "=", "time", ".", "monotonic", "(", ")", "-", "3600", "return", "[", "b", "for", "b", "in", "self", ".", "buckets", "if", "b", ".", "last_updated", "<", "hrago", "]" ]
Get all of the buckets that haven't been updated in over an hour.
[ "Get", "all", "of", "the", "buckets", "that", "haven", "t", "been", "updated", "in", "over", "an", "hour", "." ]
python
train
33.142857
SoCo/SoCo
soco/core.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1466-L1480
def remove_from_queue(self, index): """Remove a track from the queue by index. The index number is required as an argument, where the first index is 0. Args: index (int): The (0-based) index of the track to remove """ # TODO: what do these parameters actually do? ...
[ "def", "remove_from_queue", "(", "self", ",", "index", ")", ":", "# TODO: what do these parameters actually do?", "updid", "=", "'0'", "objid", "=", "'Q:0/'", "+", "str", "(", "index", "+", "1", ")", "self", ".", "avTransport", ".", "RemoveTrackFromQueue", "(", ...
Remove a track from the queue by index. The index number is required as an argument, where the first index is 0. Args: index (int): The (0-based) index of the track to remove
[ "Remove", "a", "track", "from", "the", "queue", "by", "index", ".", "The", "index", "number", "is", "required", "as", "an", "argument", "where", "the", "first", "index", "is", "0", "." ]
python
train
34.533333
tanghaibao/jcvi
jcvi/assembly/hic.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/hic.py#L662-L682
def get_seqstarts(bamfile, N): """ Go through the SQ headers and pull out all sequences with size greater than the resolution settings, i.e. contains at least a few cells """ import pysam bamfile = pysam.AlignmentFile(bamfile, "rb") seqsize = {} for kv in bamfile.header["SQ"]: if kv[...
[ "def", "get_seqstarts", "(", "bamfile", ",", "N", ")", ":", "import", "pysam", "bamfile", "=", "pysam", ".", "AlignmentFile", "(", "bamfile", ",", "\"rb\"", ")", "seqsize", "=", "{", "}", "for", "kv", "in", "bamfile", ".", "header", "[", "\"SQ\"", "]",...
Go through the SQ headers and pull out all sequences with size greater than the resolution settings, i.e. contains at least a few cells
[ "Go", "through", "the", "SQ", "headers", "and", "pull", "out", "all", "sequences", "with", "size", "greater", "than", "the", "resolution", "settings", "i", ".", "e", ".", "contains", "at", "least", "a", "few", "cells" ]
python
train
33.190476
aleju/imgaug
imgaug/external/poly_point_isect_py2py3.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/external/poly_point_isect_py2py3.py#L1218-L1283
def remove(self, key): """T.remove(key) <==> del T[key], remove item <key> from tree.""" if self._root is None: raise KeyError(str(key)) head = Node() # False tree root node = head node.right = self._root parent = None grand_parent = None foun...
[ "def", "remove", "(", "self", ",", "key", ")", ":", "if", "self", ".", "_root", "is", "None", ":", "raise", "KeyError", "(", "str", "(", "key", ")", ")", "head", "=", "Node", "(", ")", "# False tree root", "node", "=", "head", "node", ".", "right",...
T.remove(key) <==> del T[key], remove item <key> from tree.
[ "T", ".", "remove", "(", "key", ")", "<", "==", ">", "del", "T", "[", "key", "]", "remove", "item", "<key", ">", "from", "tree", "." ]
python
valid
40.227273
konstantint/intervaltree-bio
intervaltree_bio/__init__.py
https://github.com/konstantint/intervaltree-bio/blob/2d0bea6b534f9588c60ae7b6c30584138433c14b/intervaltree_bio/__init__.py#L158-L230
def from_table(fileobj=None, url='http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/knownGene.txt.gz', parser=UCSCTable.KNOWN_GENE, mode='tx', decompress=None): ''' UCSC Genome project provides several tables with gene coordinates (https://genome.ucsc.edu/cgi-bin/hgTables), ...
[ "def", "from_table", "(", "fileobj", "=", "None", ",", "url", "=", "'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/knownGene.txt.gz'", ",", "parser", "=", "UCSCTable", ".", "KNOWN_GENE", ",", "mode", "=", "'tx'", ",", "decompress", "=", "None", ")", ":", ...
UCSC Genome project provides several tables with gene coordinates (https://genome.ucsc.edu/cgi-bin/hgTables), such as knownGene, refGene, ensGene, wgEncodeGencodeBasicV19, etc. Indexing the rows of those tables into a ``GenomeIntervalTree`` is a common task, implemented in this method. The tabl...
[ "UCSC", "Genome", "project", "provides", "several", "tables", "with", "gene", "coordinates", "(", "https", ":", "//", "genome", ".", "ucsc", ".", "edu", "/", "cgi", "-", "bin", "/", "hgTables", ")", "such", "as", "knownGene", "refGene", "ensGene", "wgEncod...
python
train
55.917808
lucasmaystre/choix
choix/ep.py
https://github.com/lucasmaystre/choix/blob/05a57a10bb707338113a9d91601ca528ead7a881/choix/ep.py#L157-L176
def _log_phi(z): """Stable computation of the log of the Normal CDF and its derivative.""" # Adapted from the GPML function `logphi.m`. if z * z < 0.0492: # First case: z close to zero. coef = -z / SQRT2PI val = functools.reduce(lambda acc, c: coef * (c + acc), CS, 0) res = -...
[ "def", "_log_phi", "(", "z", ")", ":", "# Adapted from the GPML function `logphi.m`.", "if", "z", "*", "z", "<", "0.0492", ":", "# First case: z close to zero.", "coef", "=", "-", "z", "/", "SQRT2PI", "val", "=", "functools", ".", "reduce", "(", "lambda", "acc...
Stable computation of the log of the Normal CDF and its derivative.
[ "Stable", "computation", "of", "the", "log", "of", "the", "Normal", "CDF", "and", "its", "derivative", "." ]
python
train
41.2
apache/incubator-heron
heron/instance/src/python/utils/metrics/metrics_helper.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/instance/src/python/utils/metrics/metrics_helper.py#L67-L85
def update_reduced_metric(self, name, value, key=None): """Update the value of ReducedMetric or MultiReducedMetric :type name: str :param name: name of the registered metric to be updated. :param value: specifies a value to be reduced. :type key: str or None :param key: specifies a key for Mult...
[ "def", "update_reduced_metric", "(", "self", ",", "name", ",", "value", ",", "key", "=", "None", ")", ":", "if", "name", "not", "in", "self", ".", "metrics", ":", "Log", ".", "error", "(", "\"In update_reduced_metric(): %s is not registered in the metric\"", ","...
Update the value of ReducedMetric or MultiReducedMetric :type name: str :param name: name of the registered metric to be updated. :param value: specifies a value to be reduced. :type key: str or None :param key: specifies a key for MultiReducedMetric. Needs to be `None` for updating ...
[ "Update", "the", "value", "of", "ReducedMetric", "or", "MultiReducedMetric" ]
python
valid
44.736842
tensorflow/tensor2tensor
tensor2tensor/layers/common_hparams.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_hparams.py#L426-L469
def to_parameter_specs(self, name_prefix=""): """To list of dicts suitable for Cloud ML Engine hyperparameter tuning.""" specs = [] for name, categories, _ in self._categorical_params.values(): spec = { "parameterName": name_prefix + name, "type": "CATEGORICAL", "categori...
[ "def", "to_parameter_specs", "(", "self", ",", "name_prefix", "=", "\"\"", ")", ":", "specs", "=", "[", "]", "for", "name", ",", "categories", ",", "_", "in", "self", ".", "_categorical_params", ".", "values", "(", ")", ":", "spec", "=", "{", "\"parame...
To list of dicts suitable for Cloud ML Engine hyperparameter tuning.
[ "To", "list", "of", "dicts", "suitable", "for", "Cloud", "ML", "Engine", "hyperparameter", "tuning", "." ]
python
train
29.886364
flatangle/flatlib
flatlib/angle.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/angle.py#L70-L74
def strSlist(string): """ Converts angle string to signed list. """ sign = '-' if string[0] == '-' else '+' values = [abs(int(x)) for x in string.split(':')] return _fixSlist(list(sign) + values)
[ "def", "strSlist", "(", "string", ")", ":", "sign", "=", "'-'", "if", "string", "[", "0", "]", "==", "'-'", "else", "'+'", "values", "=", "[", "abs", "(", "int", "(", "x", ")", ")", "for", "x", "in", "string", ".", "split", "(", "':'", ")", "...
Converts angle string to signed list.
[ "Converts", "angle", "string", "to", "signed", "list", "." ]
python
train
41.4
mon/ifstools
ifstools/handlers/lz77.py
https://github.com/mon/ifstools/blob/ccd9c1c3632aa22cdcc4e064f17e07803b1d27ba/ifstools/handlers/lz77.py#L44-L61
def match_window(in_data, offset): '''Find the longest match for the string starting at offset in the preceeding data ''' window_start = max(offset - WINDOW_MASK, 0) for n in range(MAX_LEN, THRESHOLD-1, -1): window_end = min(offset + n, len(in_data)) # we've not got enough data left for...
[ "def", "match_window", "(", "in_data", ",", "offset", ")", ":", "window_start", "=", "max", "(", "offset", "-", "WINDOW_MASK", ",", "0", ")", "for", "n", "in", "range", "(", "MAX_LEN", ",", "THRESHOLD", "-", "1", ",", "-", "1", ")", ":", "window_end"...
Find the longest match for the string starting at offset in the preceeding data
[ "Find", "the", "longest", "match", "for", "the", "string", "starting", "at", "offset", "in", "the", "preceeding", "data" ]
python
train
37.555556
CalebBell/fluids
fluids/fittings.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/fittings.py#L3623-L3687
def K_globe_stop_check_valve_Crane(D1, D2, fd=None, style=0): r'''Returns the loss coefficient for a globe stop check valve as shown in [1]_. If β = 1: .. math:: K = K_1 = K_2 = N\cdot f_d Otherwise: .. math:: K_2 = \frac{K + \left[0.5(1-\beta^2) ...
[ "def", "K_globe_stop_check_valve_Crane", "(", "D1", ",", "D2", ",", "fd", "=", "None", ",", "style", "=", "0", ")", ":", "if", "fd", "is", "None", ":", "fd", "=", "ft_Crane", "(", "D2", ")", "try", ":", "K", "=", "globe_stop_check_valve_Crane_coeffs", ...
r'''Returns the loss coefficient for a globe stop check valve as shown in [1]_. If β = 1: .. math:: K = K_1 = K_2 = N\cdot f_d Otherwise: .. math:: K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4} Style 0 is the stand...
[ "r", "Returns", "the", "loss", "coefficient", "for", "a", "globe", "stop", "check", "valve", "as", "shown", "in", "[", "1", "]", "_", ".", "If", "β", "=", "1", ":", "..", "math", "::", "K", "=", "K_1", "=", "K_2", "=", "N", "\\", "cdot", "f_d",...
python
train
30.569231
dpgaspar/Flask-AppBuilder
flask_appbuilder/security/manager.py
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L113-L120
def _oauth_tokengetter(token=None): """ Default function to return the current user oauth token from session cookie. """ token = session.get("oauth") log.debug("Token Get: {0}".format(token)) return token
[ "def", "_oauth_tokengetter", "(", "token", "=", "None", ")", ":", "token", "=", "session", ".", "get", "(", "\"oauth\"", ")", "log", ".", "debug", "(", "\"Token Get: {0}\"", ".", "format", "(", "token", ")", ")", "return", "token" ]
Default function to return the current user oauth token from session cookie.
[ "Default", "function", "to", "return", "the", "current", "user", "oauth", "token", "from", "session", "cookie", "." ]
python
train
29.125
kennethreitz/records
records.py
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L88-L96
def dataset(self): """A Tablib Dataset containing the row.""" data = tablib.Dataset() data.headers = self.keys() row = _reduce_datetimes(self.values()) data.append(row) return data
[ "def", "dataset", "(", "self", ")", ":", "data", "=", "tablib", ".", "Dataset", "(", ")", "data", ".", "headers", "=", "self", ".", "keys", "(", ")", "row", "=", "_reduce_datetimes", "(", "self", ".", "values", "(", ")", ")", "data", ".", "append",...
A Tablib Dataset containing the row.
[ "A", "Tablib", "Dataset", "containing", "the", "row", "." ]
python
train
24.666667
datascopeanalytics/traces
traces/histogram.py
https://github.com/datascopeanalytics/traces/blob/420611151a05fea88a07bc5200fefffdc37cc95b/traces/histogram.py#L129-L203
def _quantile_function(self, alpha=0.5, smallest_count=None): """Return a function that returns the quantile values for this histogram. """ total = float(self.total()) smallest_observed_count = min(itervalues(self)) if smallest_count is None: smallest_count ...
[ "def", "_quantile_function", "(", "self", ",", "alpha", "=", "0.5", ",", "smallest_count", "=", "None", ")", ":", "total", "=", "float", "(", "self", ".", "total", "(", ")", ")", "smallest_observed_count", "=", "min", "(", "itervalues", "(", "self", ")",...
Return a function that returns the quantile values for this histogram.
[ "Return", "a", "function", "that", "returns", "the", "quantile", "values", "for", "this", "histogram", "." ]
python
train
33.333333
pysal/giddy
giddy/components.py
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/components.py#L53-L103
def check_contiguity(w, neighbors, leaver): """Check if contiguity is maintained if leaver is removed from neighbors Parameters ---------- w : spatial weights object simple contiguity based weights neighbors : list nodes that are to be checked if th...
[ "def", "check_contiguity", "(", "w", ",", "neighbors", ",", "leaver", ")", ":", "ids", "=", "neighbors", "[", ":", "]", "ids", ".", "remove", "(", "leaver", ")", "return", "is_component", "(", "w", ",", "ids", ")" ]
Check if contiguity is maintained if leaver is removed from neighbors Parameters ---------- w : spatial weights object simple contiguity based weights neighbors : list nodes that are to be checked if they form a single \ connec...
[ "Check", "if", "contiguity", "is", "maintained", "if", "leaver", "is", "removed", "from", "neighbors" ]
python
train
27.156863
collectiveacuity/labPack
labpack/databases/sql.py
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L820-L913
def update(self, new_details, old_details=None): ''' a method to upsert changes to a record in the table :param new_details: dictionary with updated record fields :param old_details: [optional] dictionary with original record fields :return: list of dictionaries with u...
[ "def", "update", "(", "self", ",", "new_details", ",", "old_details", "=", "None", ")", ":", "title", "=", "'%s.update'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'new_details'", ":", "new_details", ",", ...
a method to upsert changes to a record in the table :param new_details: dictionary with updated record fields :param old_details: [optional] dictionary with original record fields :return: list of dictionaries with updated field details NOTE: if old_details is empty,...
[ "a", "method", "to", "upsert", "changes", "to", "a", "record", "in", "the", "table", ":", "param", "new_details", ":", "dictionary", "with", "updated", "record", "fields", ":", "param", "old_details", ":", "[", "optional", "]", "dictionary", "with", "origina...
python
train
41.095745
F5Networks/f5-common-python
f5/bigip/mixins.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/mixins.py#L434-L444
def get_device_info(self, bigip): '''Get device information about a specific BigIP device. :param bigip: bigip object --- device to inspect :returns: bigip object ''' coll = bigip.tm.cm.devices.get_collection() device = [device for device in coll if device.selfDevice ==...
[ "def", "get_device_info", "(", "self", ",", "bigip", ")", ":", "coll", "=", "bigip", ".", "tm", ".", "cm", ".", "devices", ".", "get_collection", "(", ")", "device", "=", "[", "device", "for", "device", "in", "coll", "if", "device", ".", "selfDevice", ...
Get device information about a specific BigIP device. :param bigip: bigip object --- device to inspect :returns: bigip object
[ "Get", "device", "information", "about", "a", "specific", "BigIP", "device", "." ]
python
train
34.090909
adobe-apiplatform/umapi-client.py
umapi_client/api.py
https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/api.py#L282-L286
def _fetch_result(self): """ Fetch the queried object. """ self._result = self.conn.query_single(self.object_type, self.url_params, self.query_params)
[ "def", "_fetch_result", "(", "self", ")", ":", "self", ".", "_result", "=", "self", ".", "conn", ".", "query_single", "(", "self", ".", "object_type", ",", "self", ".", "url_params", ",", "self", ".", "query_params", ")" ]
Fetch the queried object.
[ "Fetch", "the", "queried", "object", "." ]
python
train
35.6
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L578-L589
def groupby_task_class(self): """ Returns a dictionary mapping the task class to the list of tasks in the flow """ # Find all Task classes class2tasks = OrderedDict() for task in self.iflat_tasks(): cls = task.__class__ if cls not in class2tasks: c...
[ "def", "groupby_task_class", "(", "self", ")", ":", "# Find all Task classes", "class2tasks", "=", "OrderedDict", "(", ")", "for", "task", "in", "self", ".", "iflat_tasks", "(", ")", ":", "cls", "=", "task", ".", "__class__", "if", "cls", "not", "in", "cla...
Returns a dictionary mapping the task class to the list of tasks in the flow
[ "Returns", "a", "dictionary", "mapping", "the", "task", "class", "to", "the", "list", "of", "tasks", "in", "the", "flow" ]
python
train
33.25
retext-project/retext
ReText/tab.py
https://github.com/retext-project/retext/blob/ad70435341dd89c7a74742df9d1f9af70859a969/ReText/tab.py#L145-L168
def updateActiveMarkupClass(self): ''' Update the active markup class based on the default class and the current filename. If the active markup class changes, the highlighter is rerun on the input text, the markup object of this tab is replaced with one of the new class and the activeMarkupChanged signal is...
[ "def", "updateActiveMarkupClass", "(", "self", ")", ":", "previousMarkupClass", "=", "self", ".", "activeMarkupClass", "self", ".", "activeMarkupClass", "=", "find_markup_class_by_name", "(", "globalSettings", ".", "defaultMarkup", ")", "if", "self", ".", "_fileName",...
Update the active markup class based on the default class and the current filename. If the active markup class changes, the highlighter is rerun on the input text, the markup object of this tab is replaced with one of the new class and the activeMarkupChanged signal is emitted.
[ "Update", "the", "active", "markup", "class", "based", "on", "the", "default", "class", "and", "the", "current", "filename", ".", "If", "the", "active", "markup", "class", "changes", "the", "highlighter", "is", "rerun", "on", "the", "input", "text", "the", ...
python
train
35.625
cytoscape/py2cytoscape
py2cytoscape/cyrest/view.py
https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/view.py#L110-L120
def get_current(self, layout=None, network=None, verbose=False): """ Returns the current view or null if there is none. :param verbose: print more :returns: current view or null if there is none """ PARAMS={} response=api(url=self.__url+"/get_current", PARAMS=PA...
[ "def", "get_current", "(", "self", ",", "layout", "=", "None", ",", "network", "=", "None", ",", "verbose", "=", "False", ")", ":", "PARAMS", "=", "{", "}", "response", "=", "api", "(", "url", "=", "self", ".", "__url", "+", "\"/get_current\"", ",", ...
Returns the current view or null if there is none. :param verbose: print more :returns: current view or null if there is none
[ "Returns", "the", "current", "view", "or", "null", "if", "there", "is", "none", "." ]
python
train
33.727273
snobear/ezmomi
ezmomi/ezmomi.py
https://github.com/snobear/ezmomi/blob/c98e26dc2d32cd5c92134fdcbcb8353540ac0208/ezmomi/ezmomi.py#L109-L142
def connect(self): """Connect to vCenter server""" try: context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) if self.config['no_ssl_verify']: requests.packages.urllib3.disable_warnings() context.verify_mode = ssl.CERT_NONE self.si = Smart...
[ "def", "connect", "(", "self", ")", ":", "try", ":", "context", "=", "ssl", ".", "SSLContext", "(", "ssl", ".", "PROTOCOL_TLSv1_2", ")", "if", "self", ".", "config", "[", "'no_ssl_verify'", "]", ":", "requests", ".", "packages", ".", "urllib3", ".", "d...
Connect to vCenter server
[ "Connect", "to", "vCenter", "server" ]
python
train
36.205882
thombashi/pytablereader
pytablereader/factory/_file.py
https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/factory/_file.py#L141-L158
def _get_extension_loader_mapping(self): """ :return: Mappings of format extension and loader class. :rtype: dict """ loader_table = self._get_common_loader_mapping() loader_table.update( { "htm": HtmlTableFileLoader, "md": Mar...
[ "def", "_get_extension_loader_mapping", "(", "self", ")", ":", "loader_table", "=", "self", ".", "_get_common_loader_mapping", "(", ")", "loader_table", ".", "update", "(", "{", "\"htm\"", ":", "HtmlTableFileLoader", ",", "\"md\"", ":", "MarkdownTableFileLoader", ",...
:return: Mappings of format extension and loader class. :rtype: dict
[ ":", "return", ":", "Mappings", "of", "format", "extension", "and", "loader", "class", ".", ":", "rtype", ":", "dict" ]
python
train
28.5
onecodex/onecodex
onecodex/models/sample.py
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/sample.py#L131-L187
def upload( cls, files, metadata=None, tags=None, project=None, coerce_ascii=False, progressbar=None ): """Uploads a series of files to the One Codex server. Parameters ---------- files : `string` or `tuple` A single path to a file on the system, or a tuple conta...
[ "def", "upload", "(", "cls", ",", "files", ",", "metadata", "=", "None", ",", "tags", "=", "None", ",", "project", "=", "None", ",", "coerce_ascii", "=", "False", ",", "progressbar", "=", "None", ")", ":", "res", "=", "cls", ".", "_resource", "if", ...
Uploads a series of files to the One Codex server. Parameters ---------- files : `string` or `tuple` A single path to a file on the system, or a tuple containing a pairs of paths. Tuple values will be interleaved as paired-end reads and both files should contain the sam...
[ "Uploads", "a", "series", "of", "files", "to", "the", "One", "Codex", "server", "." ]
python
train
38.210526
rameshg87/pyremotevbox
pyremotevbox/ZSI/generate/containers.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/containers.py#L1391-L1489
def _setUpElements(self): """TODO: Remove this method This method ONLY sets up the instance attributes. Dependency instance attribute: mgContent -- expected to be either a complex definition with model group content, a model group, or model group ...
[ "def", "_setUpElements", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"_setUpElements: %s\"", "%", "self", ".", "_item", ".", "getItemTrace", "(", ")", ")", "if", "hasattr", "(", "self", ",", "'_done'", ")", ":", "#return '\\n'.join(s...
TODO: Remove this method This method ONLY sets up the instance attributes. Dependency instance attribute: mgContent -- expected to be either a complex definition with model group content, a model group, or model group content. TODO: should only supp...
[ "TODO", ":", "Remove", "this", "method", "This", "method", "ONLY", "sets", "up", "the", "instance", "attributes", ".", "Dependency", "instance", "attribute", ":", "mgContent", "--", "expected", "to", "be", "either", "a", "complex", "definition", "with", "model...
python
train
37.020202
opendns/pyinvestigate
investigate/investigate.py
https://github.com/opendns/pyinvestigate/blob/a182e73a750f03e906d9b25842d556db8d2fd54f/investigate/investigate.py#L131-L137
def related(self, domain): '''Get the related domains of the given domain. For details, see https://investigate.umbrella.com/docs/api#relatedDomains ''' uri = self._uris["related"].format(domain) return self.get_parse(uri)
[ "def", "related", "(", "self", ",", "domain", ")", ":", "uri", "=", "self", ".", "_uris", "[", "\"related\"", "]", ".", "format", "(", "domain", ")", "return", "self", ".", "get_parse", "(", "uri", ")" ]
Get the related domains of the given domain. For details, see https://investigate.umbrella.com/docs/api#relatedDomains
[ "Get", "the", "related", "domains", "of", "the", "given", "domain", "." ]
python
train
36.714286
FlorianLudwig/rueckenwind
rw/static.py
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/static.py#L25-L37
def get_absolute_path(cls, roots, path): """Returns the absolute location of ``path`` relative to one of the ``roots``. ``roots`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting). """ for root in roots: ...
[ "def", "get_absolute_path", "(", "cls", ",", "roots", ",", "path", ")", ":", "for", "root", "in", "roots", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "root", ",", "path", ")", ")", "if", "abs...
Returns the absolute location of ``path`` relative to one of the ``roots``. ``roots`` is the path configured for this `StaticFileHandler` (in most cases the ``static_path`` `Application` setting).
[ "Returns", "the", "absolute", "location", "of", "path", "relative", "to", "one", "of", "the", "roots", "." ]
python
train
39.615385
apache/airflow
airflow/contrib/hooks/dingding_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/dingding_hook.py#L76-L98
def _build_message(self): """ Build different type of Dingding message As most commonly used type, text message just need post message content rather than a dict like ``{'content': 'message'}`` """ if self.message_type in ['text', 'markdown']: data = { ...
[ "def", "_build_message", "(", "self", ")", ":", "if", "self", ".", "message_type", "in", "[", "'text'", ",", "'markdown'", "]", ":", "data", "=", "{", "'msgtype'", ":", "self", ".", "message_type", ",", "self", ".", "message_type", ":", "{", "'content'",...
Build different type of Dingding message As most commonly used type, text message just need post message content rather than a dict like ``{'content': 'message'}``
[ "Build", "different", "type", "of", "Dingding", "message", "As", "most", "commonly", "used", "type", "text", "message", "just", "need", "post", "message", "content", "rather", "than", "a", "dict", "like", "{", "content", ":", "message", "}" ]
python
test
35.173913
saltstack/salt
salt/modules/pcs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L214-L235
def cluster_node_add(node, extra_args=None): ''' Add a node to the pacemaker cluster via pcs command node node that should be added extra_args list of extra option for the \'pcs cluster node add\' command CLI Example: .. code-block:: bash salt '*' pcs.cluster_node_add...
[ "def", "cluster_node_add", "(", "node", ",", "extra_args", "=", "None", ")", ":", "cmd", "=", "[", "'pcs'", ",", "'cluster'", ",", "'node'", ",", "'add'", "]", "cmd", "+=", "[", "node", "]", "if", "isinstance", "(", "extra_args", ",", "(", "list", ",...
Add a node to the pacemaker cluster via pcs command node node that should be added extra_args list of extra option for the \'pcs cluster node add\' command CLI Example: .. code-block:: bash salt '*' pcs.cluster_node_add node=node2.example.org
[ "Add", "a", "node", "to", "the", "pacemaker", "cluster", "via", "pcs", "command" ]
python
train
25.045455