repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
ownport/scrapy-dblite
dblite/__init__.py
https://github.com/ownport/scrapy-dblite/blob/6de5021caa31d439478d9808738b046d1db699c9/dblite/__init__.py#L318-L330
def delete(self, criteria=None, _all=False): ''' delete dictionary(ies) in sqlite database _all = True - delete all items ''' if isinstance(criteria, self._item_class): criteria = {'_id': criteria['_id']} if criteria is None and not _all: raise RuntimeEr...
[ "def", "delete", "(", "self", ",", "criteria", "=", "None", ",", "_all", "=", "False", ")", ":", "if", "isinstance", "(", "criteria", ",", "self", ".", "_item_class", ")", ":", "criteria", "=", "{", "'_id'", ":", "criteria", "[", "'_id'", "]", "}", ...
delete dictionary(ies) in sqlite database _all = True - delete all items
[ "delete", "dictionary", "(", "ies", ")", "in", "sqlite", "database" ]
python
train
pygeobuf/pygeobuf
geobuf/scripts/cli.py
https://github.com/pygeobuf/pygeobuf/blob/c9e055ab47532781626cfe2c931a8444820acf05/geobuf/scripts/cli.py#L46-L61
def encode(precision, with_z): """Given GeoJSON on stdin, writes a geobuf file to stdout.""" logger = logging.getLogger('geobuf') stdin = click.get_text_stream('stdin') sink = click.get_binary_stream('stdout') try: data = json.load(stdin) pbf = geobuf.encode( data, ...
[ "def", "encode", "(", "precision", ",", "with_z", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'geobuf'", ")", "stdin", "=", "click", ".", "get_text_stream", "(", "'stdin'", ")", "sink", "=", "click", ".", "get_binary_stream", "(", "'stdout'...
Given GeoJSON on stdin, writes a geobuf file to stdout.
[ "Given", "GeoJSON", "on", "stdin", "writes", "a", "geobuf", "file", "to", "stdout", "." ]
python
train
saltstack/salt
salt/cloud/clouds/linode.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/linode.py#L1318-L1360
def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f show_pricing my-linode-config profile=my-linode-profile '...
[ "def", "show_pricing", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudException", "(", "'The show_instance action must be called with -f or --function.'", ")", "profile", "=", "__opts__", "["...
Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f show_pricing my-linode-config profile=my-linode-profile
[ "Show", "pricing", "for", "a", "particular", "profile", ".", "This", "is", "only", "an", "estimate", "based", "on", "unofficial", "pricing", "sources", "." ]
python
train
eleme/meepo
meepo/utils.py
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/utils.py#L57-L64
def cast_str(s, encoding='utf8', errors='strict'): """cast bytes or str to str""" if isinstance(s, bytes): return s.decode(encoding, errors) elif isinstance(s, str): return s else: raise TypeError("Expected unicode or bytes, got %r" % s)
[ "def", "cast_str", "(", "s", ",", "encoding", "=", "'utf8'", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "return", "s", ".", "decode", "(", "encoding", ",", "errors", ")", "elif", "isinstance", "(",...
cast bytes or str to str
[ "cast", "bytes", "or", "str", "to", "str" ]
python
train
bukun/TorCMS
torcms/core/tools.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/core/tools.py#L251-L288
def gen_pager_purecss(cat_slug, page_num, current): ''' Generate pager of purecss. ''' if page_num == 1: return '' pager_shouye = '''<li class="pure-menu-item {0}"> <a class="pure-menu-link" href="{1}">&lt;&lt; 首页</a></li>'''.format( 'hidden' if current <= 1 else '', cat_slug ...
[ "def", "gen_pager_purecss", "(", "cat_slug", ",", "page_num", ",", "current", ")", ":", "if", "page_num", "==", "1", ":", "return", "''", "pager_shouye", "=", "'''<li class=\"pure-menu-item {0}\">\n <a class=\"pure-menu-link\" href=\"{1}\">&lt;&lt; 首页</a></li>'''.for", "m"...
Generate pager of purecss.
[ "Generate", "pager", "of", "purecss", "." ]
python
train
DataDog/integrations-core
kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubernetes_state/datadog_checks/kubernetes_state/kubernetes_state.py#L666-L679
def count_objects_by_tags(self, metric, scraper_config): """ Count objects by whitelisted tags and submit counts as gauges. """ config = self.object_count_params[metric.name] metric_name = "{}.{}".format(scraper_config['namespace'], config['metric_name']) object_counter = Counter() ...
[ "def", "count_objects_by_tags", "(", "self", ",", "metric", ",", "scraper_config", ")", ":", "config", "=", "self", ".", "object_count_params", "[", "metric", ".", "name", "]", "metric_name", "=", "\"{}.{}\"", ".", "format", "(", "scraper_config", "[", "'names...
Count objects by whitelisted tags and submit counts as gauges.
[ "Count", "objects", "by", "whitelisted", "tags", "and", "submit", "counts", "as", "gauges", "." ]
python
train
pearu/pyvtk
pyvtk/common.py
https://github.com/pearu/pyvtk/blob/b004ec3c03299a2d75338a4be93dd29f076b70ab/pyvtk/common.py#L208-L233
def get_3_3_tuple(self,obj,default=None): """Return tuple of 3-tuples """ if is_sequence2(obj): ret = [] for i in range(3): if i<len(obj): ret.append(self.get_3_tuple(obj[i],default)) else: ret.append...
[ "def", "get_3_3_tuple", "(", "self", ",", "obj", ",", "default", "=", "None", ")", ":", "if", "is_sequence2", "(", "obj", ")", ":", "ret", "=", "[", "]", "for", "i", "in", "range", "(", "3", ")", ":", "if", "i", "<", "len", "(", "obj", ")", "...
Return tuple of 3-tuples
[ "Return", "tuple", "of", "3", "-", "tuples" ]
python
train
has2k1/mizani
mizani/bounds.py
https://github.com/has2k1/mizani/blob/312d0550ee0136fd1b0384829b33f3b2065f47c8/mizani/bounds.py#L39-L70
def rescale(x, to=(0, 1), _from=None): """ Rescale numeric vector to have specified minimum and maximum. Parameters ---------- x : array_like | numeric 1D vector of values to manipulate. to : tuple output range (numeric vector of length two) _from : tuple input range...
[ "def", "rescale", "(", "x", ",", "to", "=", "(", "0", ",", "1", ")", ",", "_from", "=", "None", ")", ":", "if", "_from", "is", "None", ":", "_from", "=", "np", ".", "min", "(", "x", ")", ",", "np", ".", "max", "(", "x", ")", "return", "np...
Rescale numeric vector to have specified minimum and maximum. Parameters ---------- x : array_like | numeric 1D vector of values to manipulate. to : tuple output range (numeric vector of length two) _from : tuple input range (numeric vector of length two). If not giv...
[ "Rescale", "numeric", "vector", "to", "have", "specified", "minimum", "and", "maximum", "." ]
python
valid
bcbio/bcbio-nextgen
bcbio/pipeline/qcsummary.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/qcsummary.py#L38-L58
def generate_parallel(samples, run_parallel): """Provide parallel preparation of summary information for alignment and variant calling. """ to_analyze, extras = _split_samples_by_qc(samples) qced = run_parallel("pipeline_summary", to_analyze) samples = _combine_qc_samples(qced) + extras qsign_in...
[ "def", "generate_parallel", "(", "samples", ",", "run_parallel", ")", ":", "to_analyze", ",", "extras", "=", "_split_samples_by_qc", "(", "samples", ")", "qced", "=", "run_parallel", "(", "\"pipeline_summary\"", ",", "to_analyze", ")", "samples", "=", "_combine_qc...
Provide parallel preparation of summary information for alignment and variant calling.
[ "Provide", "parallel", "preparation", "of", "summary", "information", "for", "alignment", "and", "variant", "calling", "." ]
python
train
bronto/javasphinx
javasphinx/compiler.py
https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L95-L106
def __output_see(self, see): """ Convert the argument to a @see tag to rest """ if see.startswith('<a href'): # HTML link -- <a href="...">...</a> return self.__html_to_rst(see) elif '"' in see: # Plain text return see else: # ...
[ "def", "__output_see", "(", "self", ",", "see", ")", ":", "if", "see", ".", "startswith", "(", "'<a href'", ")", ":", "# HTML link -- <a href=\"...\">...</a>", "return", "self", ".", "__html_to_rst", "(", "see", ")", "elif", "'\"'", "in", "see", ":", "# Plai...
Convert the argument to a @see tag to rest
[ "Convert", "the", "argument", "to", "a" ]
python
train
robehickman/simple-http-file-sync
shttpfs/crypto.py
https://github.com/robehickman/simple-http-file-sync/blob/fa29b3ee58e9504e1d3ddfc0c14047284bf9921d/shttpfs/crypto.py#L4-L10
def prompt_for_new_password(): """ Prompt the user to enter a new password, with confirmation """ while True: passw = getpass.getpass() passw2 = getpass.getpass() if passw == passw2: return passw print 'Passwords do not match'
[ "def", "prompt_for_new_password", "(", ")", ":", "while", "True", ":", "passw", "=", "getpass", ".", "getpass", "(", ")", "passw2", "=", "getpass", ".", "getpass", "(", ")", "if", "passw", "==", "passw2", ":", "return", "passw", "print", "'Passwords do not...
Prompt the user to enter a new password, with confirmation
[ "Prompt", "the", "user", "to", "enter", "a", "new", "password", "with", "confirmation" ]
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/interval.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/interval.py#L925-L974
def subset(self, interval: Interval, flexibility: int = 2) -> "IntervalList": """ Returns an IntervalList that's a subset of this one, only containing intervals that meet the "interval" parameter criterion. What "meet" means is defined by the ``flexibility`` parameter. ...
[ "def", "subset", "(", "self", ",", "interval", ":", "Interval", ",", "flexibility", ":", "int", "=", "2", ")", "->", "\"IntervalList\"", ":", "if", "flexibility", "not", "in", "[", "0", ",", "1", ",", "2", "]", ":", "raise", "ValueError", "(", "\"sub...
Returns an IntervalList that's a subset of this one, only containing intervals that meet the "interval" parameter criterion. What "meet" means is defined by the ``flexibility`` parameter. ``flexibility == 0``: permits only wholly contained intervals: .. code-block:: none i...
[ "Returns", "an", "IntervalList", "that", "s", "a", "subset", "of", "this", "one", "only", "containing", "intervals", "that", "meet", "the", "interval", "parameter", "criterion", ".", "What", "meet", "means", "is", "defined", "by", "the", "flexibility", "parame...
python
train
rodluger/everest
everest/missions/k2/k2.py
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/k2.py#L1847-L1867
def GetTargetCBVs(model): ''' Returns the design matrix of CBVs for the given target. :param model: An instance of the :py:obj:`everest` model for the target ''' # Get the info season = model.season name = model.name # We use the LC light curves as CBVs; there aren't # enough SC ...
[ "def", "GetTargetCBVs", "(", "model", ")", ":", "# Get the info", "season", "=", "model", ".", "season", "name", "=", "model", ".", "name", "# We use the LC light curves as CBVs; there aren't", "# enough SC light curves to get a good set", "if", "name", ".", "endswith", ...
Returns the design matrix of CBVs for the given target. :param model: An instance of the :py:obj:`everest` model for the target
[ "Returns", "the", "design", "matrix", "of", "CBVs", "for", "the", "given", "target", "." ]
python
train
saltstack/salt
salt/modules/file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L3650-L3672
def readdir(path): ''' .. versionadded:: 2014.1.0 Return a list containing the contents of a directory CLI Example: .. code-block:: bash salt '*' file.readdir /path/to/dir/ ''' path = os.path.expanduser(path) if not os.path.isabs(path): raise SaltInvocationError('Dir...
[ "def", "readdir", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "raise", "SaltInvocationError", "(", "'Dir path must be absolute.'", ")", ...
.. versionadded:: 2014.1.0 Return a list containing the contents of a directory CLI Example: .. code-block:: bash salt '*' file.readdir /path/to/dir/
[ "..", "versionadded", "::", "2014", ".", "1", ".", "0" ]
python
train
cwacek/python-jsonschema-objects
python_jsonschema_objects/classbuilder.py
https://github.com/cwacek/python-jsonschema-objects/blob/54c82bfaec9c099c472663742abfc7de373a5e49/python_jsonschema_objects/classbuilder.py#L557-L736
def _build_object(self, nm, clsdata, parents,**kw): logger.debug(util.lazy_format("Building object {0}", nm)) # To support circular references, we tag objects that we're # currently building as "under construction" self.under_construction.add(nm) props = {} defaults = s...
[ "def", "_build_object", "(", "self", ",", "nm", ",", "clsdata", ",", "parents", ",", "*", "*", "kw", ")", ":", "logger", ".", "debug", "(", "util", ".", "lazy_format", "(", "\"Building object {0}\"", ",", "nm", ")", ")", "# To support circular references, we...
If this object itself has a 'oneOf' designation, then make the validation 'type' the list of potential objects.
[ "If", "this", "object", "itself", "has", "a", "oneOf", "designation", "then", "make", "the", "validation", "type", "the", "list", "of", "potential", "objects", "." ]
python
train
BernardFW/bernard
src/bernard/utils.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/utils.py#L234-L259
def dict_is_subset(subset: Any, full_set: Any) -> bool: """ Checks that all keys present in `subset` are present and have the same value in `full_set`. If a key is in `full_set` but not in `subset` then True will be returned anyways. """ if not isinstance(subset, full_set.__class__): re...
[ "def", "dict_is_subset", "(", "subset", ":", "Any", ",", "full_set", ":", "Any", ")", "->", "bool", ":", "if", "not", "isinstance", "(", "subset", ",", "full_set", ".", "__class__", ")", ":", "return", "False", "elif", "isinstance", "(", "subset", ",", ...
Checks that all keys present in `subset` are present and have the same value in `full_set`. If a key is in `full_set` but not in `subset` then True will be returned anyways.
[ "Checks", "that", "all", "keys", "present", "in", "subset", "are", "present", "and", "have", "the", "same", "value", "in", "full_set", ".", "If", "a", "key", "is", "in", "full_set", "but", "not", "in", "subset", "then", "True", "will", "be", "returned", ...
python
train
bslatkin/dpxdt
dpxdt/client/pdiff_worker.py
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/client/pdiff_worker.py#L226-L240
def register(coordinator): """Registers this module as a worker with the given coordinator.""" utils.verify_binary('pdiff_compare_binary', ['-version']) utils.verify_binary('pdiff_composite_binary', ['-version']) assert FLAGS.pdiff_threads > 0 assert FLAGS.queue_server_prefix item = queue_work...
[ "def", "register", "(", "coordinator", ")", ":", "utils", ".", "verify_binary", "(", "'pdiff_compare_binary'", ",", "[", "'-version'", "]", ")", "utils", ".", "verify_binary", "(", "'pdiff_composite_binary'", ",", "[", "'-version'", "]", ")", "assert", "FLAGS", ...
Registers this module as a worker with the given coordinator.
[ "Registers", "this", "module", "as", "a", "worker", "with", "the", "given", "coordinator", "." ]
python
train
awslabs/sockeye
sockeye/evaluate.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/evaluate.py#L94-L103
def raw_corpus_length_ratio(hypotheses: Iterable[str], references: Iterable[str]) -> float: """ Simple wrapper around length ratio implementation. :param hypotheses: Hypotheses stream. :param references: Reference stream. :return: Length ratio score as float. """ ratios = [len(h.split())/le...
[ "def", "raw_corpus_length_ratio", "(", "hypotheses", ":", "Iterable", "[", "str", "]", ",", "references", ":", "Iterable", "[", "str", "]", ")", "->", "float", ":", "ratios", "=", "[", "len", "(", "h", ".", "split", "(", ")", ")", "/", "len", "(", ...
Simple wrapper around length ratio implementation. :param hypotheses: Hypotheses stream. :param references: Reference stream. :return: Length ratio score as float.
[ "Simple", "wrapper", "around", "length", "ratio", "implementation", "." ]
python
train
modin-project/modin
modin/pandas/general.py
https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/pandas/general.py#L13-L25
def isna(obj): """ Detect missing values for an array-like object. Args: obj: Object to check for null or missing values. Returns: bool or array-like of bool """ if isinstance(obj, BasePandasDataset): return obj.isna() else: return pandas.isna(obj)
[ "def", "isna", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "BasePandasDataset", ")", ":", "return", "obj", ".", "isna", "(", ")", "else", ":", "return", "pandas", ".", "isna", "(", "obj", ")" ]
Detect missing values for an array-like object. Args: obj: Object to check for null or missing values. Returns: bool or array-like of bool
[ "Detect", "missing", "values", "for", "an", "array", "-", "like", "object", ".", "Args", ":", "obj", ":", "Object", "to", "check", "for", "null", "or", "missing", "values", "." ]
python
train
postlund/pyatv
pyatv/mrp/srp.py
https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/srp.py#L145-L153
def step1(self, pin): """First pairing step.""" context = SRPContext( 'Pair-Setup', str(pin), prime=constants.PRIME_3072, generator=constants.PRIME_3072_GEN, hash_func=hashlib.sha512) self._session = SRPClientSession( context, binascii....
[ "def", "step1", "(", "self", ",", "pin", ")", ":", "context", "=", "SRPContext", "(", "'Pair-Setup'", ",", "str", "(", "pin", ")", ",", "prime", "=", "constants", ".", "PRIME_3072", ",", "generator", "=", "constants", ".", "PRIME_3072_GEN", ",", "hash_fu...
First pairing step.
[ "First", "pairing", "step", "." ]
python
train
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_node_expression_parser.py#L64-L67
def visitNodeConstraintValueSet(self, ctx: ShExDocParser.NodeConstraintValueSetContext): """ nodeConstraint: valueSet xsFacet* #nodeConstraintValueSet """ self.nodeconstraint.values = [] self.visitChildren(ctx)
[ "def", "visitNodeConstraintValueSet", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "NodeConstraintValueSetContext", ")", ":", "self", ".", "nodeconstraint", ".", "values", "=", "[", "]", "self", ".", "visitChildren", "(", "ctx", ")" ]
nodeConstraint: valueSet xsFacet* #nodeConstraintValueSet
[ "nodeConstraint", ":", "valueSet", "xsFacet", "*", "#nodeConstraintValueSet" ]
python
train
qualisys/qualisys_python_sdk
qtm/packet.py
https://github.com/qualisys/qualisys_python_sdk/blob/127d7eeebc2b38b5cafdfa5d1d0198437fedd274/qtm/packet.py#L484-L490
def get_3d_markers_residual( self, component_info=None, data=None, component_position=None ): """Get 3D markers with residual.""" return self._get_3d_markers( RT3DMarkerPositionResidual, component_info, data, component_position )
[ "def", "get_3d_markers_residual", "(", "self", ",", "component_info", "=", "None", ",", "data", "=", "None", ",", "component_position", "=", "None", ")", ":", "return", "self", ".", "_get_3d_markers", "(", "RT3DMarkerPositionResidual", ",", "component_info", ",", ...
Get 3D markers with residual.
[ "Get", "3D", "markers", "with", "residual", "." ]
python
valid
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L31-L46
def triangles_keep_cortex(triangles, cortex): """ Remove triangles with nodes not contained in the cortex label array """ # for or each face/triangle keep only those that only contain nodes within the list of cortex nodes input_shape = triangles.shape triangle_is_in_cortex = np.all(np.reshape(n...
[ "def", "triangles_keep_cortex", "(", "triangles", ",", "cortex", ")", ":", "# for or each face/triangle keep only those that only contain nodes within the list of cortex nodes", "input_shape", "=", "triangles", ".", "shape", "triangle_is_in_cortex", "=", "np", ".", "all", "(", ...
Remove triangles with nodes not contained in the cortex label array
[ "Remove", "triangles", "with", "nodes", "not", "contained", "in", "the", "cortex", "label", "array" ]
python
train
NuGrid/NuGridPy
nugridpy/h5T.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/h5T.py#L543-L980
def get(self, cycle_list, dataitem=None, isotope=None, sparse=1): ''' Get Data from HDF5 files. There are three ways to call this function 1. get(dataitem) Fetches the datatiem for all cycles. If dataitem is a header attribute or list of attributes then the dat...
[ "def", "get", "(", "self", ",", "cycle_list", ",", "dataitem", "=", "None", ",", "isotope", "=", "None", ",", "sparse", "=", "1", ")", ":", "# Check out the inputs", "t1", "=", "time", ".", "time", "(", ")", "isotopes_of_interest", "=", "[", "]", "n...
Get Data from HDF5 files. There are three ways to call this function 1. get(dataitem) Fetches the datatiem for all cycles. If dataitem is a header attribute or list of attributes then the data is retured. If detaitem an individulal or list of column attributes, ...
[ "Get", "Data", "from", "HDF5", "files", "." ]
python
train
fr33jc/bang
bang/providers/aws.py
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/aws.py#L30-L42
def server_to_dict(server): """ Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects. """ return { A.server.ID: server.id, A.server.PUBLIC_IPS: [server.pu...
[ "def", "server_to_dict", "(", "server", ")", ":", "return", "{", "A", ".", "server", ".", "ID", ":", "server", ".", "id", ",", "A", ".", "server", ".", "PUBLIC_IPS", ":", "[", "server", ".", "public_dns_name", "]", ",", "A", ".", "server", ".", "PR...
Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects.
[ "Returns", "the", ":", "class", ":", "dict", "representation", "of", "a", "server", "object", "." ]
python
train
dtmilano/AndroidViewClient
src/com/dtmilano/android/viewclient.py
https://github.com/dtmilano/AndroidViewClient/blob/7e6e83fde63af99e5e4ab959712ecf94f9881aa2/src/com/dtmilano/android/viewclient.py#L3188-L3212
def traverse(self, root="ROOT", indent="", transform=None, stream=sys.stdout): ''' Traverses the C{View} tree and prints its nodes. The nodes are printed converting them to string but other transformations can be specified by providing a method name as the C{transform} parameter. ...
[ "def", "traverse", "(", "self", ",", "root", "=", "\"ROOT\"", ",", "indent", "=", "\"\"", ",", "transform", "=", "None", ",", "stream", "=", "sys", ".", "stdout", ")", ":", "if", "transform", "is", "None", ":", "# this cannot be a default value, otherwise", ...
Traverses the C{View} tree and prints its nodes. The nodes are printed converting them to string but other transformations can be specified by providing a method name as the C{transform} parameter. @type root: L{View} @param root: the root node from where the traverse starts @t...
[ "Traverses", "the", "C", "{", "View", "}", "tree", "and", "prints", "its", "nodes", "." ]
python
train
MKLab-ITI/reveal-graph-embedding
reveal_graph_embedding/embedding/common.py
https://github.com/MKLab-ITI/reveal-graph-embedding/blob/eda862687aa5a64b79c6b12de1b4dca6ce986dc8/reveal_graph_embedding/embedding/common.py#L49-L67
def normalize_columns(features): """ This performs column normalization of community embedding features. Input: - X in R^(nxC_n): The community indicator matrix. Output: - X_norm in R^(nxC_n): The tf-idf + row normalized community indicator matrix. """ # Calculate inverse document frequency. ...
[ "def", "normalize_columns", "(", "features", ")", ":", "# Calculate inverse document frequency.", "features", "=", "features", ".", "tocsc", "(", ")", "for", "j", "in", "range", "(", "features", ".", "shape", "[", "1", "]", ")", ":", "document_frequency", "=",...
This performs column normalization of community embedding features. Input: - X in R^(nxC_n): The community indicator matrix. Output: - X_norm in R^(nxC_n): The tf-idf + row normalized community indicator matrix.
[ "This", "performs", "column", "normalization", "of", "community", "embedding", "features", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/message_factory.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/message_factory.py#L57-L87
def GetPrototype(self, descriptor): """Builds a proto2 message class based on the passed in descriptor. Passing a descriptor with a fully qualified name matching a previous invocation will cause the same class to be returned. Args: descriptor: The descriptor to build from. Returns: A ...
[ "def", "GetPrototype", "(", "self", ",", "descriptor", ")", ":", "if", "descriptor", ".", "full_name", "not", "in", "self", ".", "_classes", ":", "descriptor_name", "=", "descriptor", ".", "name", "if", "str", "is", "bytes", ":", "# PY2", "descriptor_name", ...
Builds a proto2 message class based on the passed in descriptor. Passing a descriptor with a fully qualified name matching a previous invocation will cause the same class to be returned. Args: descriptor: The descriptor to build from. Returns: A class describing the passed in descriptor.
[ "Builds", "a", "proto2", "message", "class", "based", "on", "the", "passed", "in", "descriptor", "." ]
python
train
ensime/ensime-vim
ensime_shared/editor.py
https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/editor.py#L298-L303
def get_error_at(self, cursor): """Return error at position `cursor`.""" for error in self._errors: if error.includes(self._vim.eval("expand('%:p')"), cursor): return error return None
[ "def", "get_error_at", "(", "self", ",", "cursor", ")", ":", "for", "error", "in", "self", ".", "_errors", ":", "if", "error", ".", "includes", "(", "self", ".", "_vim", ".", "eval", "(", "\"expand('%:p')\"", ")", ",", "cursor", ")", ":", "return", "...
Return error at position `cursor`.
[ "Return", "error", "at", "position", "cursor", "." ]
python
train
hfaran/slack-export-viewer
slackviewer/reader.py
https://github.com/hfaran/slack-export-viewer/blob/bbe97f5cd9f72a0cc41c7395cef23860b44918f8/slackviewer/reader.py#L89-L111
def compile_mpim_users(self): """ Gets the info for the members within the multiple person instant message Returns a list of all dms with the members that have ever existed :rtype: [object] { name: <name> users: [<user_id>] } """ ...
[ "def", "compile_mpim_users", "(", "self", ")", ":", "mpim_data", "=", "self", ".", "_read_from_json", "(", "\"mpims.json\"", ")", "mpims", "=", "[", "c", "for", "c", "in", "mpim_data", ".", "values", "(", ")", "]", "all_mpim_users", "=", "[", "]", "for",...
Gets the info for the members within the multiple person instant message Returns a list of all dms with the members that have ever existed :rtype: [object] { name: <name> users: [<user_id>] }
[ "Gets", "the", "info", "for", "the", "members", "within", "the", "multiple", "person", "instant", "message" ]
python
train
jazzband/sorl-thumbnail
sorl/thumbnail/engines/base.py
https://github.com/jazzband/sorl-thumbnail/blob/22ccd9781462a820f963f57018ad3dcef85053ed/sorl/thumbnail/engines/base.py#L15-L28
def create(self, image, geometry, options): """ Processing conductor, returns the thumbnail as an image engine instance """ image = self.cropbox(image, geometry, options) image = self.orientation(image, geometry, options) image = self.colorspace(image, geometry, options) ...
[ "def", "create", "(", "self", ",", "image", ",", "geometry", ",", "options", ")", ":", "image", "=", "self", ".", "cropbox", "(", "image", ",", "geometry", ",", "options", ")", "image", "=", "self", ".", "orientation", "(", "image", ",", "geometry", ...
Processing conductor, returns the thumbnail as an image engine instance
[ "Processing", "conductor", "returns", "the", "thumbnail", "as", "an", "image", "engine", "instance" ]
python
train
materialsproject/pymatgen
pymatgen/io/vasp/outputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/outputs.py#L859-L877
def eigenvalue_band_properties(self): """ Band properties from the eigenvalues as a tuple, (band gap, cbm, vbm, is_band_gap_direct). """ vbm = -float("inf") vbm_kpoint = None cbm = float("inf") cbm_kpoint = None for spin, d in self.eigenvalues.item...
[ "def", "eigenvalue_band_properties", "(", "self", ")", ":", "vbm", "=", "-", "float", "(", "\"inf\"", ")", "vbm_kpoint", "=", "None", "cbm", "=", "float", "(", "\"inf\"", ")", "cbm_kpoint", "=", "None", "for", "spin", ",", "d", "in", "self", ".", "eige...
Band properties from the eigenvalues as a tuple, (band gap, cbm, vbm, is_band_gap_direct).
[ "Band", "properties", "from", "the", "eigenvalues", "as", "a", "tuple", "(", "band", "gap", "cbm", "vbm", "is_band_gap_direct", ")", "." ]
python
train
drslump/pyshould
pyshould/expectation.py
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/expectation.py#L51-L57
def clone(self): """ Clone this expression """ from copy import copy clone = copy(self) clone.expr = copy(self.expr) clone.factory = False return clone
[ "def", "clone", "(", "self", ")", ":", "from", "copy", "import", "copy", "clone", "=", "copy", "(", "self", ")", "clone", ".", "expr", "=", "copy", "(", "self", ".", "expr", ")", "clone", ".", "factory", "=", "False", "return", "clone" ]
Clone this expression
[ "Clone", "this", "expression" ]
python
train
lemieuxl/pyGenClean
pyGenClean/Misc/compare_gold_standard.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L436-L474
def read_same_samples_file(filename, out_prefix): """Reads a file containing same samples.""" # The same samples same_samples = [] # Creating the extraction files gold_file = None try: gold_file = open(out_prefix + ".gold_samples2keep", 'w') except IOError: msg = "{}: can't ...
[ "def", "read_same_samples_file", "(", "filename", ",", "out_prefix", ")", ":", "# The same samples", "same_samples", "=", "[", "]", "# Creating the extraction files", "gold_file", "=", "None", "try", ":", "gold_file", "=", "open", "(", "out_prefix", "+", "\".gold_sa...
Reads a file containing same samples.
[ "Reads", "a", "file", "containing", "same", "samples", "." ]
python
train
coursera-dl/coursera-dl
coursera/cookies.py
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L209-L217
def do_we_have_enough_cookies(cj, class_name): """ Check whether we have all the required cookies to authenticate on class.coursera.org. """ domain = 'class.coursera.org' path = "/" + class_name return cj.get('csrf_token', domain=domain, path=path) is not None
[ "def", "do_we_have_enough_cookies", "(", "cj", ",", "class_name", ")", ":", "domain", "=", "'class.coursera.org'", "path", "=", "\"/\"", "+", "class_name", "return", "cj", ".", "get", "(", "'csrf_token'", ",", "domain", "=", "domain", ",", "path", "=", "path...
Check whether we have all the required cookies to authenticate on class.coursera.org.
[ "Check", "whether", "we", "have", "all", "the", "required", "cookies", "to", "authenticate", "on", "class", ".", "coursera", ".", "org", "." ]
python
train
radjkarl/imgProcessor
imgProcessor/camera/NoiseLevelFunction.py
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/NoiseLevelFunction.py#L131-L150
def smooth(x, y, weights): ''' in case the NLF cannot be described by a square root function commit bounded polynomial interpolation ''' # Spline hard to smooth properly, therefore solfed with # bounded polynomal interpolation # ext=3: no extrapolation, but boundary value # ...
[ "def", "smooth", "(", "x", ",", "y", ",", "weights", ")", ":", "# Spline hard to smooth properly, therefore solfed with\r", "# bounded polynomal interpolation\r", "# ext=3: no extrapolation, but boundary value\r", "# return UnivariateSpline(x, y, w=weights,\r", "# ...
in case the NLF cannot be described by a square root function commit bounded polynomial interpolation
[ "in", "case", "the", "NLF", "cannot", "be", "described", "by", "a", "square", "root", "function", "commit", "bounded", "polynomial", "interpolation" ]
python
train
Telefonica/toolium
toolium/utils.py
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/utils.py#L524-L538
def _download_video(self, video_url, video_name): """Download a video from the remote node :param video_url: video url :param video_name: video name """ filename = '{0:0=2d}_{1}'.format(DriverWrappersPool.videos_number, video_name) filename = '{}.mp4'.format(get_valid_fi...
[ "def", "_download_video", "(", "self", ",", "video_url", ",", "video_name", ")", ":", "filename", "=", "'{0:0=2d}_{1}'", ".", "format", "(", "DriverWrappersPool", ".", "videos_number", ",", "video_name", ")", "filename", "=", "'{}.mp4'", ".", "format", "(", "g...
Download a video from the remote node :param video_url: video url :param video_name: video name
[ "Download", "a", "video", "from", "the", "remote", "node" ]
python
train
pypa/pipenv
pipenv/patched/notpip/_internal/configuration.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/configuration.py#L139-L146
def get_value(self, key): # type: (str) -> Any """Get a value from the configuration. """ try: return self._dictionary[key] except KeyError: raise ConfigurationError("No such key - {}".format(key))
[ "def", "get_value", "(", "self", ",", "key", ")", ":", "# type: (str) -> Any", "try", ":", "return", "self", ".", "_dictionary", "[", "key", "]", "except", "KeyError", ":", "raise", "ConfigurationError", "(", "\"No such key - {}\"", ".", "format", "(", "key", ...
Get a value from the configuration.
[ "Get", "a", "value", "from", "the", "configuration", "." ]
python
train
cdgriffith/puremagic
puremagic/main.py
https://github.com/cdgriffith/puremagic/blob/ae2c4c400930b8a19519e787f61dd779db7e415b/puremagic/main.py#L116-L126
def _file_details(filename): """ Grab the start and end of the file""" max_head, max_foot = _max_lengths() with open(filename, "rb") as fin: head = fin.read(max_head) try: fin.seek(-max_foot, os.SEEK_END) except IOError: fin.seek(0) foot = fin.read() ...
[ "def", "_file_details", "(", "filename", ")", ":", "max_head", ",", "max_foot", "=", "_max_lengths", "(", ")", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "fin", ":", "head", "=", "fin", ".", "read", "(", "max_head", ")", "try", ":", "...
Grab the start and end of the file
[ "Grab", "the", "start", "and", "end", "of", "the", "file" ]
python
train
aichaos/rivescript-python
rivescript/rivescript.py
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/rivescript.py#L640-L653
def set_variable(self, name, value): """Set a bot variable. Equivalent to ``! var`` in RiveScript code. :param str name: The name of the variable to set. :param str value: The value of the variable. Set this to ``None`` to delete the variable. """ if value i...
[ "def", "set_variable", "(", "self", ",", "name", ",", "value", ")", ":", "if", "value", "is", "None", ":", "# Unset the variable.", "if", "name", "in", "self", ".", "_var", ":", "del", "self", ".", "_var", "[", "name", "]", "self", ".", "_var", "[", ...
Set a bot variable. Equivalent to ``! var`` in RiveScript code. :param str name: The name of the variable to set. :param str value: The value of the variable. Set this to ``None`` to delete the variable.
[ "Set", "a", "bot", "variable", "." ]
python
train
pantsbuild/pants
src/python/pants/pantsd/service/fs_event_service.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/service/fs_event_service.py#L105-L124
def run(self): """Main service entrypoint. Called via Thread.start() via PantsDaemon.run().""" if not (self._watchman and self._watchman.is_alive()): raise PantsService.ServiceError('watchman is not running, bailing!') # Enable watchman for the build root. self._watchman.watch_project(self._buil...
[ "def", "run", "(", "self", ")", ":", "if", "not", "(", "self", ".", "_watchman", "and", "self", ".", "_watchman", ".", "is_alive", "(", ")", ")", ":", "raise", "PantsService", ".", "ServiceError", "(", "'watchman is not running, bailing!'", ")", "# Enable wa...
Main service entrypoint. Called via Thread.start() via PantsDaemon.run().
[ "Main", "service", "entrypoint", ".", "Called", "via", "Thread", ".", "start", "()", "via", "PantsDaemon", ".", "run", "()", "." ]
python
train
inasafe/inasafe
extras/data_audit.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/data_audit.py#L237-L405
def license_file_is_valid(license_filename, data_filename, dirpath='.', verbose=False): """Check that XML license file for given filename_to_verify is valid. Input: license_filename: XML license file (must be an absolute path name) data_filename: The data filename that...
[ "def", "license_file_is_valid", "(", "license_filename", ",", "data_filename", ",", "dirpath", "=", "'.'", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "print", "'Parsing'", ",", "license_filename", "doc", "=", "xml2object", "(", "license_filena...
Check that XML license file for given filename_to_verify is valid. Input: license_filename: XML license file (must be an absolute path name) data_filename: The data filename that is being audited dir_path: Where the files live verbose: Optional verbosity Check for each datafil...
[ "Check", "that", "XML", "license", "file", "for", "given", "filename_to_verify", "is", "valid", "." ]
python
train
Gandi/gandi.cli
gandi/cli/modules/domain.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/domain.py#L30-L77
def create(cls, fqdn, duration, owner, admin, tech, bill, nameserver, extra_parameter, background): """Create a domain.""" fqdn = fqdn.lower() if not background and not cls.intty(): background = True result = cls.call('domain.available', [fqdn]) while ...
[ "def", "create", "(", "cls", ",", "fqdn", ",", "duration", ",", "owner", ",", "admin", ",", "tech", ",", "bill", ",", "nameserver", ",", "extra_parameter", ",", "background", ")", ":", "fqdn", "=", "fqdn", ".", "lower", "(", ")", "if", "not", "backgr...
Create a domain.
[ "Create", "a", "domain", "." ]
python
train
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L466-L577
def _mof_escaped(strvalue): # Note: This is a raw docstring because it shows many backslashes, and # that avoids having to double them. r""" Return a MOF-escaped string from the input string. Parameters: strvalue (:term:`unicode string`): The string value. Must not be `None`. Special...
[ "def", "_mof_escaped", "(", "strvalue", ")", ":", "# Note: This is a raw docstring because it shows many backslashes, and", "# that avoids having to double them.", "escaped_str", "=", "strvalue", "# Escape backslash (\\)", "escaped_str", "=", "escaped_str", ".", "replace", "(", "...
r""" Return a MOF-escaped string from the input string. Parameters: strvalue (:term:`unicode string`): The string value. Must not be `None`. Special characters must not be backslash-escaped. Details on backslash-escaping: `DSP0004` defines that the character repertoire for MOF string c...
[ "r", "Return", "a", "MOF", "-", "escaped", "string", "from", "the", "input", "string", "." ]
python
train
jenanwise/codequality
codequality/main.py
https://github.com/jenanwise/codequality/blob/8a2bd767fd73091c49a5318fdbfb2b4fff77533d/codequality/main.py#L152-L174
def _resolve_paths(self, *paths): """ Resolve paths into a set of filenames (no directories) to check. External tools will handle directories as arguments differently, so for consistency we just want to pass them filenames. This method will recursively walk all directories and ...
[ "def", "_resolve_paths", "(", "self", ",", "*", "paths", ")", ":", "result", "=", "set", "(", ")", "for", "path", "in", "paths", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "for", "dirpath", ",", "_", ",", "filenames", "in"...
Resolve paths into a set of filenames (no directories) to check. External tools will handle directories as arguments differently, so for consistency we just want to pass them filenames. This method will recursively walk all directories and filter out any paths that match self.options.i...
[ "Resolve", "paths", "into", "a", "set", "of", "filenames", "(", "no", "directories", ")", "to", "check", "." ]
python
train
hotdoc/hotdoc
hotdoc/utils/setup_utils.py
https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/utils/setup_utils.py#L116-L133
def symlink(source, link_name): """ Method to allow creating symlinks on Windows """ if os.path.islink(link_name) and os.readlink(link_name) == source: return os_symlink = getattr(os, "symlink", None) if callable(os_symlink): os_symlink(source, link_name) else: impor...
[ "def", "symlink", "(", "source", ",", "link_name", ")", ":", "if", "os", ".", "path", ".", "islink", "(", "link_name", ")", "and", "os", ".", "readlink", "(", "link_name", ")", "==", "source", ":", "return", "os_symlink", "=", "getattr", "(", "os", "...
Method to allow creating symlinks on Windows
[ "Method", "to", "allow", "creating", "symlinks", "on", "Windows" ]
python
train
rfverbruggen/rachiopy
rachiopy/schedulerule.py
https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/schedulerule.py#L33-L36
def get(self, sched_rule_id): """Retrieve the information for a scheduleRule entity.""" path = '/'.join(['schedulerule', sched_rule_id]) return self.rachio.get(path)
[ "def", "get", "(", "self", ",", "sched_rule_id", ")", ":", "path", "=", "'/'", ".", "join", "(", "[", "'schedulerule'", ",", "sched_rule_id", "]", ")", "return", "self", ".", "rachio", ".", "get", "(", "path", ")" ]
Retrieve the information for a scheduleRule entity.
[ "Retrieve", "the", "information", "for", "a", "scheduleRule", "entity", "." ]
python
train
Spinmob/spinmob
_plotting_mess.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_plotting_mess.py#L441-L524
def realimag_data(xdata, ydata, eydata=None, exdata=None, xscale='linear', rscale='linear', iscale='linear', rlabel='Real', ilabel='Imaginary', figure='gcf', clear=1, draw=True, **kwargs): """ Plots the real and imaginary parts of complex ydata vs xdata. Parameters ---------- xdata Real-val...
[ "def", "realimag_data", "(", "xdata", ",", "ydata", ",", "eydata", "=", "None", ",", "exdata", "=", "None", ",", "xscale", "=", "'linear'", ",", "rscale", "=", "'linear'", ",", "iscale", "=", "'linear'", ",", "rlabel", "=", "'Real'", ",", "ilabel", "="...
Plots the real and imaginary parts of complex ydata vs xdata. Parameters ---------- xdata Real-valued x-axis data ydata Complex-valued y-axis data eydata=None Complex-valued y-error exdata=None Real-valued x-error xscale='line...
[ "Plots", "the", "real", "and", "imaginary", "parts", "of", "complex", "ydata", "vs", "xdata", "." ]
python
train
kolypto/py-smsframework
smsframework/providers/loopback.py
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/loopback.py#L46-L66
def received(self, src, body): """ Simulate an incoming message :type src: str :param src: Message source :type boby: str | unicode :param body: Message body :rtype: IncomingMessage """ # Create the message self._msgid += 1 ...
[ "def", "received", "(", "self", ",", "src", ",", "body", ")", ":", "# Create the message", "self", ".", "_msgid", "+=", "1", "message", "=", "IncomingMessage", "(", "src", ",", "body", ",", "self", ".", "_msgid", ")", "# Log traffic", "self", ".", "_traf...
Simulate an incoming message :type src: str :param src: Message source :type boby: str | unicode :param body: Message body :rtype: IncomingMessage
[ "Simulate", "an", "incoming", "message" ]
python
test
CxAalto/gtfspy
gtfspy/stats.py
https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/stats.py#L48-L64
def get_median_lat_lon_of_stops(gtfs): """ Get median latitude AND longitude of stops Parameters ---------- gtfs: GTFS Returns ------- median_lat : float median_lon : float """ stops = gtfs.get_table("stops") median_lat = numpy.percentile(stops['lat'].values, 50) me...
[ "def", "get_median_lat_lon_of_stops", "(", "gtfs", ")", ":", "stops", "=", "gtfs", ".", "get_table", "(", "\"stops\"", ")", "median_lat", "=", "numpy", ".", "percentile", "(", "stops", "[", "'lat'", "]", ".", "values", ",", "50", ")", "median_lon", "=", ...
Get median latitude AND longitude of stops Parameters ---------- gtfs: GTFS Returns ------- median_lat : float median_lon : float
[ "Get", "median", "latitude", "AND", "longitude", "of", "stops" ]
python
valid
RusticiSoftware/TinCanPython
tincan/remote_lrs.py
https://github.com/RusticiSoftware/TinCanPython/blob/424eedaa6d19221efb1108edb915fc332abbb317/tincan/remote_lrs.py#L738-L779
def retrieve_agent_profile(self, agent, profile_id): """Retrieve agent profile with the specified parameters :param agent: Agent object of the desired agent profile :type agent: :class:`tincan.agent.Agent` :param profile_id: UUID of the desired agent profile :type profile_id: st...
[ "def", "retrieve_agent_profile", "(", "self", ",", "agent", ",", "profile_id", ")", ":", "if", "not", "isinstance", "(", "agent", ",", "Agent", ")", ":", "agent", "=", "Agent", "(", "agent", ")", "request", "=", "HTTPRequest", "(", "method", "=", "\"GET\...
Retrieve agent profile with the specified parameters :param agent: Agent object of the desired agent profile :type agent: :class:`tincan.agent.Agent` :param profile_id: UUID of the desired agent profile :type profile_id: str | unicode :return: LRS Response object with an agent p...
[ "Retrieve", "agent", "profile", "with", "the", "specified", "parameters" ]
python
train
saltstack/salt
salt/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L586-L618
def order_chunks(self, chunks): ''' Sort the chunk list verifying that the chunks follow the order specified in the order options. ''' cap = 1 for chunk in chunks: if 'order' in chunk: if not isinstance(chunk['order'], int): ...
[ "def", "order_chunks", "(", "self", ",", "chunks", ")", ":", "cap", "=", "1", "for", "chunk", "in", "chunks", ":", "if", "'order'", "in", "chunk", ":", "if", "not", "isinstance", "(", "chunk", "[", "'order'", "]", ",", "int", ")", ":", "continue", ...
Sort the chunk list verifying that the chunks follow the order specified in the order options.
[ "Sort", "the", "chunk", "list", "verifying", "that", "the", "chunks", "follow", "the", "order", "specified", "in", "the", "order", "options", "." ]
python
train
wtolson/pysis
pysis/util/file_manipulation.py
https://github.com/wtolson/pysis/blob/7b907c8104bddfbb14c603de4d666c2101e1f999/pysis/util/file_manipulation.py#L11-L26
def write_file_list(filename, file_list=[], glob=None): """Write a list of files to a file. :param filename: the name of the file to write the list to :param file_list: a list of filenames to write to a file :param glob: if glob is specified, it will ignore file_list and instead create a list...
[ "def", "write_file_list", "(", "filename", ",", "file_list", "=", "[", "]", ",", "glob", "=", "None", ")", ":", "if", "glob", ":", "file_list", "=", "iglob", "(", "glob", ")", "with", "open", "(", "filename", ",", "'w'", ")", "as", "f", ":", "for",...
Write a list of files to a file. :param filename: the name of the file to write the list to :param file_list: a list of filenames to write to a file :param glob: if glob is specified, it will ignore file_list and instead create a list of files based on the pattern provide by glob (ex. *.cub)
[ "Write", "a", "list", "of", "files", "to", "a", "file", "." ]
python
train
trentm/cmdln
examples/svn.py
https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/examples/svn.py#L1067-L1086
def do_switch(self, subcmd, opts, *args): """Update the working copy to a different URL. usage: 1. switch URL [PATH] 2. switch --relocate FROM TO [PATH...] 1. Update the working copy to mirror a new URL within the repository. This behaviour is similar...
[ "def", "do_switch", "(", "self", ",", "subcmd", ",", "opts", ",", "*", "args", ")", ":", "print", "\"'svn %s' opts: %s\"", "%", "(", "subcmd", ",", "opts", ")", "print", "\"'svn %s' args: %s\"", "%", "(", "subcmd", ",", "args", ")" ]
Update the working copy to a different URL. usage: 1. switch URL [PATH] 2. switch --relocate FROM TO [PATH...] 1. Update the working copy to mirror a new URL within the repository. This behaviour is similar to 'svn update', and is the way to move a...
[ "Update", "the", "working", "copy", "to", "a", "different", "URL", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_system_monitor.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_system_monitor.py#L25-L36
def system_monitor_fan_threshold_down_threshold(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") system_monitor = ET.SubElement(config, "system-monitor", xmlns="urn:brocade.com:mgmt:brocade-system-monitor") fan = ET.SubElement(system_monitor, "fan") ...
[ "def", "system_monitor_fan_threshold_down_threshold", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "system_monitor", "=", "ET", ".", "SubElement", "(", "config", ",", "\"system-monitor\"", ",", "x...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
hyperledger/indy-plenum
plenum/server/node.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L637-L648
def execute_pool_txns(self, three_pc_batch) -> List: """ Execute a transaction that involves consensus pool management, like adding a node, client or a steward. :param ppTime: PrePrepare request time :param reqs_keys: requests keys to be committed """ committed_t...
[ "def", "execute_pool_txns", "(", "self", ",", "three_pc_batch", ")", "->", "List", ":", "committed_txns", "=", "self", ".", "default_executer", "(", "three_pc_batch", ")", "for", "txn", "in", "committed_txns", ":", "self", ".", "poolManager", ".", "onPoolMembers...
Execute a transaction that involves consensus pool management, like adding a node, client or a steward. :param ppTime: PrePrepare request time :param reqs_keys: requests keys to be committed
[ "Execute", "a", "transaction", "that", "involves", "consensus", "pool", "management", "like", "adding", "a", "node", "client", "or", "a", "steward", "." ]
python
train
apple/turicreate
src/unity/python/turicreate/toolkits/recommender/util.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/recommender/util.py#L927-L988
def get_similar_items(self, items=None, k=10, verbose=False): """ Get the k most similar items for each item in items. Each type of recommender has its own model for the similarity between items. For example, the item_similarity_recommender will return the most similar items acc...
[ "def", "get_similar_items", "(", "self", ",", "items", "=", "None", ",", "k", "=", "10", ",", "verbose", "=", "False", ")", ":", "if", "items", "is", "None", ":", "get_all_items", "=", "True", "items", "=", "_SArray", "(", ")", "else", ":", "get_all_...
Get the k most similar items for each item in items. Each type of recommender has its own model for the similarity between items. For example, the item_similarity_recommender will return the most similar items according to the user-chosen similarity; the factorization_recommender will r...
[ "Get", "the", "k", "most", "similar", "items", "for", "each", "item", "in", "items", "." ]
python
train
jim-easterbrook/pyctools
src/pyctools/core/frame.py
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/frame.py#L324-L342
def get(self, tag, default=None): """Get a metadata value. Each metadata value is referenced by a ``tag`` -- a short string such as ``'xlen'`` or ``'audit'``. In the sidecar file these tag names are prepended with ``'Xmp.pyctools.'``, which corresponds to a custom namespace in t...
[ "def", "get", "(", "self", ",", "tag", ",", "default", "=", "None", ")", ":", "full_tag", "=", "'Xmp.pyctools.'", "+", "tag", "if", "full_tag", "in", "self", ".", "data", ":", "return", "self", ".", "data", "[", "full_tag", "]", "return", "default" ]
Get a metadata value. Each metadata value is referenced by a ``tag`` -- a short string such as ``'xlen'`` or ``'audit'``. In the sidecar file these tag names are prepended with ``'Xmp.pyctools.'``, which corresponds to a custom namespace in the XML file. :param str tag: The tag...
[ "Get", "a", "metadata", "value", "." ]
python
train
ska-sa/spead2
spead2/__init__.py
https://github.com/ska-sa/spead2/blob/cac95fd01d8debaa302d2691bd26da64b7828bc6/spead2/__init__.py#L81-L97
def parse_range_list(ranges): """Split a string like 2,3-5,8,9-11 into a list of integers. This is intended to ease adding command-line options for dealing with affinity. """ if not ranges: return [] parts = ranges.split(',') out = [] for part in parts: fields = part.split('-...
[ "def", "parse_range_list", "(", "ranges", ")", ":", "if", "not", "ranges", ":", "return", "[", "]", "parts", "=", "ranges", ".", "split", "(", "','", ")", "out", "=", "[", "]", "for", "part", "in", "parts", ":", "fields", "=", "part", ".", "split",...
Split a string like 2,3-5,8,9-11 into a list of integers. This is intended to ease adding command-line options for dealing with affinity.
[ "Split", "a", "string", "like", "2", "3", "-", "5", "8", "9", "-", "11", "into", "a", "list", "of", "integers", ".", "This", "is", "intended", "to", "ease", "adding", "command", "-", "line", "options", "for", "dealing", "with", "affinity", "." ]
python
train
softlayer/softlayer-python
SoftLayer/managers/block.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/block.py#L306-L333
def order_modified_volume(self, volume_id, new_size=None, new_iops=None, new_tier_level=None): """Places an order for modifying an existing block volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new ...
[ "def", "order_modified_volume", "(", "self", ",", "volume_id", ",", "new_size", "=", "None", ",", "new_iops", "=", "None", ",", "new_tier_level", "=", "None", ")", ":", "mask_items", "=", "[", "'id'", ",", "'billingItem'", ",", "'storageType[keyName]'", ",", ...
Places an order for modifying an existing block volume. :param volume_id: The ID of the volume to be modified :param new_size: The new size/capacity for the volume :param new_iops: The new IOPS for the volume :param new_tier_level: The new tier level for the volume :return: Retu...
[ "Places", "an", "order", "for", "modifying", "an", "existing", "block", "volume", "." ]
python
train
krukas/Trionyx
trionyx/quickstart/__init__.py
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/quickstart/__init__.py#L47-L66
def create_app(self, apps_path, name): """ Create Trionyx app in given path :param str path: path to create app in. :param str name: name of app :raises FileExistsError: """ app_path = os.path.join(apps_path, name.lower()) shutil.copytree(self.app_path, ...
[ "def", "create_app", "(", "self", ",", "apps_path", ",", "name", ")", ":", "app_path", "=", "os", ".", "path", ".", "join", "(", "apps_path", ",", "name", ".", "lower", "(", ")", ")", "shutil", ".", "copytree", "(", "self", ".", "app_path", ",", "a...
Create Trionyx app in given path :param str path: path to create app in. :param str name: name of app :raises FileExistsError:
[ "Create", "Trionyx", "app", "in", "given", "path" ]
python
train
peopledoc/workalendar
workalendar/core.py
https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L304-L318
def get_first_weekday_after(day, weekday): """Get the first weekday after a given day. If the day is the same weekday, the same day will be returned. >>> # the first monday after Apr 1 2015 >>> Calendar.get_first_weekday_after(date(2015, 4, 1), MON) datetime.date(2015, 4, 6) ...
[ "def", "get_first_weekday_after", "(", "day", ",", "weekday", ")", ":", "day_delta", "=", "(", "weekday", "-", "day", ".", "weekday", "(", ")", ")", "%", "7", "day", "=", "day", "+", "timedelta", "(", "days", "=", "day_delta", ")", "return", "day" ]
Get the first weekday after a given day. If the day is the same weekday, the same day will be returned. >>> # the first monday after Apr 1 2015 >>> Calendar.get_first_weekday_after(date(2015, 4, 1), MON) datetime.date(2015, 4, 6) >>> # the first tuesday after Apr 14 2015 ...
[ "Get", "the", "first", "weekday", "after", "a", "given", "day", ".", "If", "the", "day", "is", "the", "same", "weekday", "the", "same", "day", "will", "be", "returned", "." ]
python
train
Duke-GCB/DukeDSClient
ddsc/core/ignorefile.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/ignorefile.py#L47-L55
def add_filename_pattern(self, dir_name, pattern): """ Adds a Unix shell-style wildcard pattern underneath the specified directory :param dir_name: str: directory that contains the pattern :param pattern: str: Unix shell-style wildcard pattern """ full_pattern = '{}{}{}'....
[ "def", "add_filename_pattern", "(", "self", ",", "dir_name", ",", "pattern", ")", ":", "full_pattern", "=", "'{}{}{}'", ".", "format", "(", "dir_name", ",", "os", ".", "sep", ",", "pattern", ")", "filename_regex", "=", "fnmatch", ".", "translate", "(", "fu...
Adds a Unix shell-style wildcard pattern underneath the specified directory :param dir_name: str: directory that contains the pattern :param pattern: str: Unix shell-style wildcard pattern
[ "Adds", "a", "Unix", "shell", "-", "style", "wildcard", "pattern", "underneath", "the", "specified", "directory", ":", "param", "dir_name", ":", "str", ":", "directory", "that", "contains", "the", "pattern", ":", "param", "pattern", ":", "str", ":", "Unix", ...
python
train
tdryer/hangups
hangups/client.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/client.py#L547-L552
async def get_suggested_entities(self, get_suggested_entities_request): """Return suggested contacts.""" response = hangouts_pb2.GetSuggestedEntitiesResponse() await self._pb_request('contacts/getsuggestedentities', get_suggested_entities_request, response) ...
[ "async", "def", "get_suggested_entities", "(", "self", ",", "get_suggested_entities_request", ")", ":", "response", "=", "hangouts_pb2", ".", "GetSuggestedEntitiesResponse", "(", ")", "await", "self", ".", "_pb_request", "(", "'contacts/getsuggestedentities'", ",", "get...
Return suggested contacts.
[ "Return", "suggested", "contacts", "." ]
python
valid
blue-yonder/tsfresh
tsfresh/utilities/string_manipulation.py
https://github.com/blue-yonder/tsfresh/blob/c72c9c574371cf7dd7d54e00a466792792e5d202/tsfresh/utilities/string_manipulation.py#L47-L71
def convert_to_output_format(param): """ Helper function to convert parameters to a valid string, that can be used in a column name. Does the opposite which is used in the from_columns function. The parameters are sorted by their name and written out in the form <param name>_<param value>__<par...
[ "def", "convert_to_output_format", "(", "param", ")", ":", "def", "add_parenthesis_if_string_value", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "string_types", ")", ":", "return", "'\"'", "+", "str", "(", "x", ")", "+", "'\"'", "else", ":", "...
Helper function to convert parameters to a valid string, that can be used in a column name. Does the opposite which is used in the from_columns function. The parameters are sorted by their name and written out in the form <param name>_<param value>__<param name>_<param value>__ ... If a <param_val...
[ "Helper", "function", "to", "convert", "parameters", "to", "a", "valid", "string", "that", "can", "be", "used", "in", "a", "column", "name", ".", "Does", "the", "opposite", "which", "is", "used", "in", "the", "from_columns", "function", "." ]
python
train
nadirizr/json-logic-py
json_logic/__init__.py
https://github.com/nadirizr/json-logic-py/blob/5fda9125eab4178f8f81c7779291940e31e87bab/json_logic/__init__.py#L59-L63
def less_or_equal(a, b, *args): """Implements the '<=' operator with JS-style type coertion.""" return ( less(a, b) or soft_equals(a, b) ) and (not args or less_or_equal(b, *args))
[ "def", "less_or_equal", "(", "a", ",", "b", ",", "*", "args", ")", ":", "return", "(", "less", "(", "a", ",", "b", ")", "or", "soft_equals", "(", "a", ",", "b", ")", ")", "and", "(", "not", "args", "or", "less_or_equal", "(", "b", ",", "*", "...
Implements the '<=' operator with JS-style type coertion.
[ "Implements", "the", "<", "=", "operator", "with", "JS", "-", "style", "type", "coertion", "." ]
python
valid
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/billing/apis/default_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/billing/apis/default_api.py#L414-L435
def get_service_package_quota_history(self, **kwargs): # noqa: E501 """Service package quota history. # noqa: E501 Get your quota usage history. This API is available for commercial accounts. Aggregator accounts can see own and subtenant quota usage data. History data is ordered in ascending order ba...
[ "def", "get_service_package_quota_history", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", ":", "return", "self", ".", "get_se...
Service package quota history. # noqa: E501 Get your quota usage history. This API is available for commercial accounts. Aggregator accounts can see own and subtenant quota usage data. History data is ordered in ascending order based on the added timestamp. **Example usage:** curl -X GET https://api.us-...
[ "Service", "package", "quota", "history", ".", "#", "noqa", ":", "E501" ]
python
train
mlavin/django-all-access
allaccess/clients.py
https://github.com/mlavin/django-all-access/blob/4b15b6c9dedf8080a7c477e0af1142c609ec5598/allaccess/clients.py#L99-L109
def get_redirect_args(self, request, callback): "Get request parameters for redirect url." callback = force_text(request.build_absolute_uri(callback)) raw_token = self.get_request_token(request, callback) token, secret = self.parse_raw_token(raw_token) if token is not None and se...
[ "def", "get_redirect_args", "(", "self", ",", "request", ",", "callback", ")", ":", "callback", "=", "force_text", "(", "request", ".", "build_absolute_uri", "(", "callback", ")", ")", "raw_token", "=", "self", ".", "get_request_token", "(", "request", ",", ...
Get request parameters for redirect url.
[ "Get", "request", "parameters", "for", "redirect", "url", "." ]
python
train
vtkiorg/vtki
vtki/qt_plotting.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/qt_plotting.py#L472-L501
def update_app_icon(self): """ Update the app icon if the user is not trying to resize the window. """ if os.name == 'nt' or not hasattr(self, '_last_window_size'): # pragma: no cover # DO NOT EVEN ATTEMPT TO UPDATE ICON ON WINDOWS return cur_time = time....
[ "def", "update_app_icon", "(", "self", ")", ":", "if", "os", ".", "name", "==", "'nt'", "or", "not", "hasattr", "(", "self", ",", "'_last_window_size'", ")", ":", "# pragma: no cover", "# DO NOT EVEN ATTEMPT TO UPDATE ICON ON WINDOWS", "return", "cur_time", "=", "...
Update the app icon if the user is not trying to resize the window.
[ "Update", "the", "app", "icon", "if", "the", "user", "is", "not", "trying", "to", "resize", "the", "window", "." ]
python
train
facelessuser/soupsieve
soupsieve/__meta__.py
https://github.com/facelessuser/soupsieve/blob/24859cc3e756ebf46b75547d49c6b4a7bf35ee82/soupsieve/__meta__.py#L157-L186
def parse_version(ver, pre=False): """Parse version into a comparable Version tuple.""" m = RE_VER.match(ver) # Handle major, minor, micro major = int(m.group('major')) minor = int(m.group('minor')) if m.group('minor') else 0 micro = int(m.group('micro')) if m.group('micro') else 0 # Hand...
[ "def", "parse_version", "(", "ver", ",", "pre", "=", "False", ")", ":", "m", "=", "RE_VER", ".", "match", "(", "ver", ")", "# Handle major, minor, micro", "major", "=", "int", "(", "m", ".", "group", "(", "'major'", ")", ")", "minor", "=", "int", "("...
Parse version into a comparable Version tuple.
[ "Parse", "version", "into", "a", "comparable", "Version", "tuple", "." ]
python
train
mbj4668/pyang
pyang/translators/dsdl.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L666-L680
def install_def(self, name, dstmt, def_map, interleave=False): """Install definition `name` into the appropriate dictionary. `dstmt` is the definition statement ('typedef' or 'grouping') that is to be mapped to a RELAX NG named pattern '<define name="`name`">'. `def_map` must be either ...
[ "def", "install_def", "(", "self", ",", "name", ",", "dstmt", ",", "def_map", ",", "interleave", "=", "False", ")", ":", "delem", "=", "SchemaNode", ".", "define", "(", "name", ",", "interleave", "=", "interleave", ")", "delem", ".", "attr", "[", "\"na...
Install definition `name` into the appropriate dictionary. `dstmt` is the definition statement ('typedef' or 'grouping') that is to be mapped to a RELAX NG named pattern '<define name="`name`">'. `def_map` must be either `self.local_defs` or `self.global_defs`. `interleave` determines t...
[ "Install", "definition", "name", "into", "the", "appropriate", "dictionary", "." ]
python
train
studionow/pybrightcove
pybrightcove/config.py
https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/config.py#L40-L46
def has_option(section, name): """ Wrapper around ConfigParser's ``has_option`` method. """ cfg = ConfigParser.SafeConfigParser({"working_dir": "/tmp", "debug": "0"}) cfg.read(CONFIG_LOCATIONS) return cfg.has_option(section, name)
[ "def", "has_option", "(", "section", ",", "name", ")", ":", "cfg", "=", "ConfigParser", ".", "SafeConfigParser", "(", "{", "\"working_dir\"", ":", "\"/tmp\"", ",", "\"debug\"", ":", "\"0\"", "}", ")", "cfg", ".", "read", "(", "CONFIG_LOCATIONS", ")", "retu...
Wrapper around ConfigParser's ``has_option`` method.
[ "Wrapper", "around", "ConfigParser", "s", "has_option", "method", "." ]
python
train
klen/zeta-library
zetalibrary/main.py
https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/main.py#L42-L58
def watch(args): " Watch directory for changes and auto pack sources " assert op.isdir(args.source), "Watch mode allowed only for directories." print 'Zeta-library v. %s watch mode' % VERSION print '================================' print 'Ctrl+C for exit\n' observer = Observer() handler = Z...
[ "def", "watch", "(", "args", ")", ":", "assert", "op", ".", "isdir", "(", "args", ".", "source", ")", ",", "\"Watch mode allowed only for directories.\"", "print", "'Zeta-library v. %s watch mode'", "%", "VERSION", "print", "'================================'", "print",...
Watch directory for changes and auto pack sources
[ "Watch", "directory", "for", "changes", "and", "auto", "pack", "sources" ]
python
train
cloudera/cm_api
python/src/cm_api/endpoints/role_config_groups.py
https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/role_config_groups.py#L210-L219
def update_config(self, config): """ Update the group's configuration. @param config: Dictionary with configuration to update. @return: Dictionary with updated configuration. """ path = self._path() + '/config' resp = self._get_resource_root().put(path, data = config_to_json(config)) re...
[ "def", "update_config", "(", "self", ",", "config", ")", ":", "path", "=", "self", ".", "_path", "(", ")", "+", "'/config'", "resp", "=", "self", ".", "_get_resource_root", "(", ")", ".", "put", "(", "path", ",", "data", "=", "config_to_json", "(", "...
Update the group's configuration. @param config: Dictionary with configuration to update. @return: Dictionary with updated configuration.
[ "Update", "the", "group", "s", "configuration", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/nodes.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/nodes.py#L826-L836
def get_graphviz_dirtree(self, engine="automatic", **kwargs): """ Generate directory graph in the DOT language. The graph show the files and directories in the node workdir. Returns: graphviz.Digraph <https://graphviz.readthedocs.io/en/stable/api.html#digraph> """ if eng...
[ "def", "get_graphviz_dirtree", "(", "self", ",", "engine", "=", "\"automatic\"", ",", "*", "*", "kwargs", ")", ":", "if", "engine", "==", "\"automatic\"", ":", "engine", "=", "\"fdp\"", "return", "Dirviz", "(", "self", ".", "workdir", ")", ".", "get_cluste...
Generate directory graph in the DOT language. The graph show the files and directories in the node workdir. Returns: graphviz.Digraph <https://graphviz.readthedocs.io/en/stable/api.html#digraph>
[ "Generate", "directory", "graph", "in", "the", "DOT", "language", ".", "The", "graph", "show", "the", "files", "and", "directories", "in", "the", "node", "workdir", "." ]
python
train
openeventdata/mordecai
mordecai/utilities.py
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/utilities.py#L218-L231
def structure_results(res): """Format Elasticsearch result as Python dictionary""" out = {'hits': {'hits': []}} keys = [u'admin1_code', u'admin2_code', u'admin3_code', u'admin4_code', u'alternativenames', u'asciiname', u'cc2', u'coordinates', u'country_code2', u'country_code3', u'dem...
[ "def", "structure_results", "(", "res", ")", ":", "out", "=", "{", "'hits'", ":", "{", "'hits'", ":", "[", "]", "}", "}", "keys", "=", "[", "u'admin1_code'", ",", "u'admin2_code'", ",", "u'admin3_code'", ",", "u'admin4_code'", ",", "u'alternativenames'", "...
Format Elasticsearch result as Python dictionary
[ "Format", "Elasticsearch", "result", "as", "Python", "dictionary" ]
python
train
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/dbapi/_helpers.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/dbapi/_helpers.py#L102-L117
def to_query_parameters(parameters): """Converts DB-API parameter values into query parameters. :type parameters: Mapping[str, Any] or Sequence[Any] :param parameters: A dictionary or sequence of query parameter values. :rtype: List[google.cloud.bigquery.query._AbstractQueryParameter] :returns: A ...
[ "def", "to_query_parameters", "(", "parameters", ")", ":", "if", "parameters", "is", "None", ":", "return", "[", "]", "if", "isinstance", "(", "parameters", ",", "collections_abc", ".", "Mapping", ")", ":", "return", "to_query_parameters_dict", "(", "parameters"...
Converts DB-API parameter values into query parameters. :type parameters: Mapping[str, Any] or Sequence[Any] :param parameters: A dictionary or sequence of query parameter values. :rtype: List[google.cloud.bigquery.query._AbstractQueryParameter] :returns: A list of query parameters.
[ "Converts", "DB", "-", "API", "parameter", "values", "into", "query", "parameters", "." ]
python
train
zeaphoo/reston
reston/core/apk.py
https://github.com/zeaphoo/reston/blob/96502487b2259572df55237c9526f92627465088/reston/core/apk.py#L290-L313
def get_app_name(self): """ Return the appname of the APK :rtype: string """ main_activity_name = self.get_main_activity() app_name = self.get_element('activity', 'label', name=main_activity_name) if not app_name: app_name = self.get_element(...
[ "def", "get_app_name", "(", "self", ")", ":", "main_activity_name", "=", "self", ".", "get_main_activity", "(", ")", "app_name", "=", "self", ".", "get_element", "(", "'activity'", ",", "'label'", ",", "name", "=", "main_activity_name", ")", "if", "not", "ap...
Return the appname of the APK :rtype: string
[ "Return", "the", "appname", "of", "the", "APK" ]
python
train
torfsen/service
src/service/__init__.py
https://github.com/torfsen/service/blob/d0dd824fce9237825c1943b30cd14f7b0f5957a6/src/service/__init__.py#L279-L291
def send_signal(self, s): """ Send a signal to the daemon process. The signal must have been enabled using the ``signals`` parameter of :py:meth:`Service.__init__`. Otherwise, a ``ValueError`` is raised. """ self._get_signal_event(s) # Check if signal has been e...
[ "def", "send_signal", "(", "self", ",", "s", ")", ":", "self", ".", "_get_signal_event", "(", "s", ")", "# Check if signal has been enabled", "pid", "=", "self", ".", "get_pid", "(", ")", "if", "not", "pid", ":", "raise", "ValueError", "(", "'Daemon is not r...
Send a signal to the daemon process. The signal must have been enabled using the ``signals`` parameter of :py:meth:`Service.__init__`. Otherwise, a ``ValueError`` is raised.
[ "Send", "a", "signal", "to", "the", "daemon", "process", "." ]
python
train
lextoumbourou/txstripe
txstripe/resource.py
https://github.com/lextoumbourou/txstripe/blob/a69e67f524258026fd1840655a0578311bba3b89/txstripe/resource.py#L374-L377
def invoice_items(self, **params): """Return a deferred.""" params['customer'] = self.id return InvoiceItem.all(self.api_key, **params)
[ "def", "invoice_items", "(", "self", ",", "*", "*", "params", ")", ":", "params", "[", "'customer'", "]", "=", "self", ".", "id", "return", "InvoiceItem", ".", "all", "(", "self", ".", "api_key", ",", "*", "*", "params", ")" ]
Return a deferred.
[ "Return", "a", "deferred", "." ]
python
train
slimkrazy/python-google-places
googleplaces/__init__.py
https://github.com/slimkrazy/python-google-places/blob/d4b7363e1655cdc091a6253379f6d2a95b827881/googleplaces/__init__.py#L741-L756
def get_details(self, language=None): """ Retrieves full information on the place matching the place_id. Stores the response in the `place` property. """ if self._place is None: if language is None: try: language = self._query_inst...
[ "def", "get_details", "(", "self", ",", "language", "=", "None", ")", ":", "if", "self", ".", "_place", "is", "None", ":", "if", "language", "is", "None", ":", "try", ":", "language", "=", "self", ".", "_query_instance", ".", "_request_params", "[", "'...
Retrieves full information on the place matching the place_id. Stores the response in the `place` property.
[ "Retrieves", "full", "information", "on", "the", "place", "matching", "the", "place_id", "." ]
python
train
dask/dask-ml
dask_ml/wrappers.py
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/wrappers.py#L511-L533
def _first_block(dask_object): """Extract the first block / partition from a dask object """ if isinstance(dask_object, da.Array): if dask_object.ndim > 1 and dask_object.numblocks[-1] != 1: raise NotImplementedError( "IID estimators require that the array " ...
[ "def", "_first_block", "(", "dask_object", ")", ":", "if", "isinstance", "(", "dask_object", ",", "da", ".", "Array", ")", ":", "if", "dask_object", ".", "ndim", ">", "1", "and", "dask_object", ".", "numblocks", "[", "-", "1", "]", "!=", "1", ":", "r...
Extract the first block / partition from a dask object
[ "Extract", "the", "first", "block", "/", "partition", "from", "a", "dask", "object" ]
python
train
pantsbuild/pants
src/python/pants/backend/jvm/tasks/coursier_resolve.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/coursier_resolve.py#L104-L185
def resolve(self, targets, compile_classpath, sources, javadoc, executor): """ This is the core function for coursier resolve. Validation strategy: 1. All targets are going through the `invalidated` to get fingerprinted in the target level. No cache is fetched at this stage because it is disabl...
[ "def", "resolve", "(", "self", ",", "targets", ",", "compile_classpath", ",", "sources", ",", "javadoc", ",", "executor", ")", ":", "manager", "=", "JarDependencyManagement", ".", "global_instance", "(", ")", "jar_targets", "=", "manager", ".", "targets_by_artif...
This is the core function for coursier resolve. Validation strategy: 1. All targets are going through the `invalidated` to get fingerprinted in the target level. No cache is fetched at this stage because it is disabled. 2. Once each target is fingerprinted, we combine them into a `VersionedTargetSe...
[ "This", "is", "the", "core", "function", "for", "coursier", "resolve", "." ]
python
train
mrstephenneal/dirutility
dirutility/walk/walk.py
https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/walk.py#L35-L49
def pool_process(func, iterable, process_name='Pool processing', cpus=cpu_count()): """ Apply a function to each element in an iterable and return a result list. :param func: A function that returns a value :param iterable: A list or set of elements to be passed to the func as the singular parameter ...
[ "def", "pool_process", "(", "func", ",", "iterable", ",", "process_name", "=", "'Pool processing'", ",", "cpus", "=", "cpu_count", "(", ")", ")", ":", "with", "Timer", "(", "'\\t{0} ({1}) completed in'", ".", "format", "(", "process_name", ",", "str", "(", "...
Apply a function to each element in an iterable and return a result list. :param func: A function that returns a value :param iterable: A list or set of elements to be passed to the func as the singular parameter :param process_name: Name of the process, for printing purposes only :param cpus: Number o...
[ "Apply", "a", "function", "to", "each", "element", "in", "an", "iterable", "and", "return", "a", "result", "list", "." ]
python
train
Antidote1911/cryptoshop
cryptoshop/_chunk_engine.py
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_chunk_engine.py#L39-L64
def encry_decry_chunk(chunk, key, algo, bool_encry, assoc_data): """ When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False, the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk. :param chunk: ...
[ "def", "encry_decry_chunk", "(", "chunk", ",", "key", ",", "algo", ",", "bool_encry", ",", "assoc_data", ")", ":", "engine", "=", "botan", ".", "cipher", "(", "algo", "=", "algo", ",", "encrypt", "=", "bool_encry", ")", "engine", ".", "set_key", "(", "...
When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False, the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk. :param chunk: a chunk in bytes to encrypt or decrypt. :param key: a 32 bytes key in byt...
[ "When", "bool_encry", "is", "True", "encrypt", "a", "chunk", "of", "the", "file", "with", "the", "key", "and", "a", "randomly", "generated", "nonce", ".", "When", "it", "is", "False", "the", "function", "extract", "the", "nonce", "from", "the", "cipherchun...
python
train
tjcsl/cslbot
cslbot/helpers/handler.py
https://github.com/tjcsl/cslbot/blob/aebe07be47141f61d7c180706bddfb707f19b2b5/cslbot/helpers/handler.py#L376-L398
def do_args(self, modargs, send, nick, target, source, name, msgtype): """Handle the various args that modules need.""" realargs = {} args = { 'nick': nick, 'handler': self, 'db': None, 'config': self.config, 'source': source, ...
[ "def", "do_args", "(", "self", ",", "modargs", ",", "send", ",", "nick", ",", "target", ",", "source", ",", "name", ",", "msgtype", ")", ":", "realargs", "=", "{", "}", "args", "=", "{", "'nick'", ":", "nick", ",", "'handler'", ":", "self", ",", ...
Handle the various args that modules need.
[ "Handle", "the", "various", "args", "that", "modules", "need", "." ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L929-L940
def get_vnetwork_portgroups_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "outpu...
[ "def", "get_vnetwork_portgroups_output_instance_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_vnetwork_portgroups", "=", "ET", ".", "Element", "(", "\"get_vnetwork_portgroups\"", ")", "config...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
sludgedesk/metoffer
metoffer.py
https://github.com/sludgedesk/metoffer/blob/449748d31f913d961d6f0406542bb784e931a95b/metoffer.py#L179-L188
def _query(self, data_category, resource_category, field, request, step, isotime=None): """ Request and return data from DataPoint RESTful API. """ rest_url = "/".join([HOST, data_category, resource_category, field, DATA_TYPE, request]) query_string = "?" + "&".join(["res=" + ste...
[ "def", "_query", "(", "self", ",", "data_category", ",", "resource_category", ",", "field", ",", "request", ",", "step", ",", "isotime", "=", "None", ")", ":", "rest_url", "=", "\"/\"", ".", "join", "(", "[", "HOST", ",", "data_category", ",", "resource_...
Request and return data from DataPoint RESTful API.
[ "Request", "and", "return", "data", "from", "DataPoint", "RESTful", "API", "." ]
python
train
SHDShim/pytheos
pytheos/eqn_hugoniot.py
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L10-L22
def hugoniot_p(rho, rho0, c0, s): """ calculate pressure along a Hugoniot :param rho: density in g/cm^3 :param rho0: density at 1 bar in g/cm^3 :param c0: velocity at 1 bar in km/s :param s: slope of the velocity change :return: pressure in GPa """ eta = 1. - (rho0 / rho) Ph = r...
[ "def", "hugoniot_p", "(", "rho", ",", "rho0", ",", "c0", ",", "s", ")", ":", "eta", "=", "1.", "-", "(", "rho0", "/", "rho", ")", "Ph", "=", "rho0", "*", "c0", "*", "c0", "*", "eta", "/", "np", ".", "power", "(", "(", "1.", "-", "s", "*",...
calculate pressure along a Hugoniot :param rho: density in g/cm^3 :param rho0: density at 1 bar in g/cm^3 :param c0: velocity at 1 bar in km/s :param s: slope of the velocity change :return: pressure in GPa
[ "calculate", "pressure", "along", "a", "Hugoniot" ]
python
train
garnertb/django-classification-banner
django_classification_banner/context_processors.py
https://github.com/garnertb/django-classification-banner/blob/dfe47e510efcce7eb0023e0d756eb2a0906bf9af/django_classification_banner/context_processors.py#L4-L17
def classification(request): """ Adds classification context to views. """ ctx = { 'classification_text': getattr(settings, 'CLASSIFICATION_TEXT', 'UNCLASSIFIED'), 'classification_text_color': getattr(settings, 'CLASSIFICATION_TEXT_COLOR', 'white'), 'classification_background_co...
[ "def", "classification", "(", "request", ")", ":", "ctx", "=", "{", "'classification_text'", ":", "getattr", "(", "settings", ",", "'CLASSIFICATION_TEXT'", ",", "'UNCLASSIFIED'", ")", ",", "'classification_text_color'", ":", "getattr", "(", "settings", ",", "'CLAS...
Adds classification context to views.
[ "Adds", "classification", "context", "to", "views", "." ]
python
train
juju-solutions/charms.reactive
charms/reactive/relations.py
https://github.com/juju-solutions/charms.reactive/blob/e37e781432e77c12b63d2c739bd6cd70d3230c3a/charms/reactive/relations.py#L413-L436
def conversation(self, scope=None): """ Get a single conversation, by scope, that this relation is currently handling. If the scope is not given, the correct scope is inferred by the current hook execution context. If there is no current hook execution context, it is assume tha...
[ "def", "conversation", "(", "self", ",", "scope", "=", "None", ")", ":", "if", "scope", "is", "None", ":", "if", "self", ".", "scope", "is", "scopes", ".", "UNIT", ":", "scope", "=", "hookenv", ".", "remote_unit", "(", ")", "elif", "self", ".", "sc...
Get a single conversation, by scope, that this relation is currently handling. If the scope is not given, the correct scope is inferred by the current hook execution context. If there is no current hook execution context, it is assume that there is only a single global conversation scope for t...
[ "Get", "a", "single", "conversation", "by", "scope", "that", "this", "relation", "is", "currently", "handling", "." ]
python
train
telminov/sw-django-rest-auth
sw_rest_auth/views.py
https://github.com/telminov/sw-django-rest-auth/blob/ba63b6d6c86e4325cac38ae8e2fde1501b47ce0a/sw_rest_auth/views.py#L14-L39
def check_token(request): """ Resource check is token valid. --- request_serializer: serializers.CheckToken type: username: required: true type: string description: token related user responseMessages: - code: 200 message: Token is v...
[ "def", "check_token", "(", "request", ")", ":", "serializer", "=", "serializers", ".", "CheckToken", "(", "data", "=", "request", ".", "data", ")", "serializer", ".", "is_valid", "(", "raise_exception", "=", "True", ")", "token", "=", "serializer", ".", "v...
Resource check is token valid. --- request_serializer: serializers.CheckToken type: username: required: true type: string description: token related user responseMessages: - code: 200 message: Token is valid - code: 400 me...
[ "Resource", "check", "is", "token", "valid", ".", "---", "request_serializer", ":", "serializers", ".", "CheckToken", "type", ":", "username", ":", "required", ":", "true", "type", ":", "string", "description", ":", "token", "related", "user" ]
python
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2136-L2188
def chunk(self, seek=None, lenient=False): """ Read the next PNG chunk from the input file returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's type as a byte string (all PNG chunk types are 4 bytes long). *data* is the chunk's data content, as a byte string. ...
[ "def", "chunk", "(", "self", ",", "seek", "=", "None", ",", "lenient", "=", "False", ")", ":", "self", ".", "validate_signature", "(", ")", "while", "True", ":", "# http://www.w3.org/TR/PNG/#5Chunk-layout", "if", "not", "self", ".", "atchunk", ":", "self", ...
Read the next PNG chunk from the input file returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's type as a byte string (all PNG chunk types are 4 bytes long). *data* is the chunk's data content, as a byte string. If the optional `seek` argument is specified then ...
[ "Read", "the", "next", "PNG", "chunk", "from", "the", "input", "file" ]
python
train
fabaff/python-mystrom
pymystrom/bulb.py
https://github.com/fabaff/python-mystrom/blob/86410f8952104651ef76ad37c84c29740c50551e/pymystrom/bulb.py#L31-L42
def get_status(self): """Get the details from the bulb.""" try: request = requests.get( '{}/{}/'.format(self.resource, URI), timeout=self.timeout) raw_data = request.json() # Doesn't always work !!!!! #self._mac = next(iter(self.raw_data)) ...
[ "def", "get_status", "(", "self", ")", ":", "try", ":", "request", "=", "requests", ".", "get", "(", "'{}/{}/'", ".", "format", "(", "self", ".", "resource", ",", "URI", ")", ",", "timeout", "=", "self", ".", "timeout", ")", "raw_data", "=", "request...
Get the details from the bulb.
[ "Get", "the", "details", "from", "the", "bulb", "." ]
python
train
studionow/pybrightcove
pybrightcove/video.py
https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/video.py#L701-L708
def find_by_text(text, _connection=None, page_size=100, page_number=0, sort_by=enums.DEFAULT_SORT_BY, sort_order=enums.DEFAULT_SORT_ORDER): """ List videos that match the ``text`` in title or description. """ return connection.ItemResultSet('find_videos_by_text', Vide...
[ "def", "find_by_text", "(", "text", ",", "_connection", "=", "None", ",", "page_size", "=", "100", ",", "page_number", "=", "0", ",", "sort_by", "=", "enums", ".", "DEFAULT_SORT_BY", ",", "sort_order", "=", "enums", ".", "DEFAULT_SORT_ORDER", ")", ":", "re...
List videos that match the ``text`` in title or description.
[ "List", "videos", "that", "match", "the", "text", "in", "title", "or", "description", "." ]
python
train
auth0/auth0-python
auth0/v3/management/connections.py
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L101-L115
def update(self, id, body): """Modifies a connection. Args: id: Id of the connection. body (dict): Specifies which fields are to be modified, and to what values. See: https://auth0.com/docs/api/management/v2#!/Connections/patch_connections_by_id ...
[ "def", "update", "(", "self", ",", "id", ",", "body", ")", ":", "return", "self", ".", "client", ".", "patch", "(", "self", ".", "_url", "(", "id", ")", ",", "data", "=", "body", ")" ]
Modifies a connection. Args: id: Id of the connection. body (dict): Specifies which fields are to be modified, and to what values. See: https://auth0.com/docs/api/management/v2#!/Connections/patch_connections_by_id Returns: The modified con...
[ "Modifies", "a", "connection", "." ]
python
train
m32/endesive
endesive/pdf/fpdf/fpdf.py
https://github.com/m32/endesive/blob/973091dc69847fe2df594c80ac9235a8d08460ff/endesive/pdf/fpdf/fpdf.py#L958-L1022
def image(self, name, x=None, y=None, w=0,h=0,type='',link=''): "Put an image on the page" if not name in self.images: #First use of image, get info if(type==''): pos=name.rfind('.') if(not pos): self.error('image file has no ex...
[ "def", "image", "(", "self", ",", "name", ",", "x", "=", "None", ",", "y", "=", "None", ",", "w", "=", "0", ",", "h", "=", "0", ",", "type", "=", "''", ",", "link", "=", "''", ")", ":", "if", "not", "name", "in", "self", ".", "images", ":...
Put an image on the page
[ "Put", "an", "image", "on", "the", "page" ]
python
train
UCL-INGI/INGInious
inginious/backend/backend.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/backend/backend.py#L103-L107
async def handle_client_hello(self, client_addr, _: ClientHello): """ Handle an ClientHello message. Send available containers to the client """ self._logger.info("New client connected %s", client_addr) self._registered_clients.add(client_addr) await self.send_container_update_to_client(...
[ "async", "def", "handle_client_hello", "(", "self", ",", "client_addr", ",", "_", ":", "ClientHello", ")", ":", "self", ".", "_logger", ".", "info", "(", "\"New client connected %s\"", ",", "client_addr", ")", "self", ".", "_registered_clients", ".", "add", "(...
Handle an ClientHello message. Send available containers to the client
[ "Handle", "an", "ClientHello", "message", ".", "Send", "available", "containers", "to", "the", "client" ]
python
train
insomnia-lab/libreant
libreantdb/api.py
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L186-L209
def create_index(self, indexname=None, index_conf=None): ''' Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: confi...
[ "def", "create_index", "(", "self", ",", "indexname", "=", "None", ",", "index_conf", "=", "None", ")", ":", "if", "indexname", "is", "None", ":", "indexname", "=", "self", ".", "index_name", "log", ".", "debug", "(", "\"Creating new index: '{0}'\"", ".", ...
Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: configuration to be used in index creation. If this ...
[ "Create", "the", "index" ]
python
train
saltstack/salt
salt/loader.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/loader.py#L1067-L1076
def cache(opts, serial): ''' Returns the returner modules ''' return LazyLoader( _module_dirs(opts, 'cache', 'cache'), opts, tag='cache', pack={'__opts__': opts, '__context__': {'serial': serial}}, )
[ "def", "cache", "(", "opts", ",", "serial", ")", ":", "return", "LazyLoader", "(", "_module_dirs", "(", "opts", ",", "'cache'", ",", "'cache'", ")", ",", "opts", ",", "tag", "=", "'cache'", ",", "pack", "=", "{", "'__opts__'", ":", "opts", ",", "'__c...
Returns the returner modules
[ "Returns", "the", "returner", "modules" ]
python
train