repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
ubc/ubcpi
ubcpi/serialize.py
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/serialize.py#L310-L348
def serialize_to_xml(root, block): """ Serialize the Peer Instruction XBlock's content to XML. Args: block (PeerInstructionXBlock): The peer instruction block to serialize. root (etree.Element): The XML root node to update. Returns: etree.Element """ root.tag = 'ubcpi'...
[ "def", "serialize_to_xml", "(", "root", ",", "block", ")", ":", "root", ".", "tag", "=", "'ubcpi'", "if", "block", ".", "rationale_size", "is", "not", "None", ":", "if", "block", ".", "rationale_size", ".", "get", "(", "'min'", ")", ":", "root", ".", ...
Serialize the Peer Instruction XBlock's content to XML. Args: block (PeerInstructionXBlock): The peer instruction block to serialize. root (etree.Element): The XML root node to update. Returns: etree.Element
[ "Serialize", "the", "Peer", "Instruction", "XBlock", "s", "content", "to", "XML", "." ]
python
train
33.153846
floydhub/floyd-cli
floyd/client/base.py
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/client/base.py#L30-L72
def request(self, method, url, params=None, data=None, files=None, json=None, timeout=5, headers=None, skip_auth=False): """ Execute the request using requests ...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "data", "=", "None", ",", "files", "=", "None", ",", "json", "=", "None", ",", "timeout", "=", "5", ",", "headers", "=", "None", ",", "skip_auth", "=", "Fa...
Execute the request using requests library
[ "Execute", "the", "request", "using", "requests", "library" ]
python
train
42.930233
tensorflow/tensor2tensor
tensor2tensor/layers/common_attention.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_attention.py#L3609-L3646
def make_2d_block_raster_mask(query_shape, memory_flange): """Creates a mask for 2d block raster scan. The query mask can look to the left, top left, top, and top right, but not to the right. Inside the query, we have the standard raster scan masking. Args: query_shape: A tuple of ints (query_height, que...
[ "def", "make_2d_block_raster_mask", "(", "query_shape", ",", "memory_flange", ")", ":", "# mask inside the query block", "query_triangle", "=", "common_layers", ".", "ones_matrix_band_part", "(", "np", ".", "prod", "(", "query_shape", ")", ",", "np", ".", "prod", "(...
Creates a mask for 2d block raster scan. The query mask can look to the left, top left, top, and top right, but not to the right. Inside the query, we have the standard raster scan masking. Args: query_shape: A tuple of ints (query_height, query_width) memory_flange: A tuple of ints (memory_flang...
[ "Creates", "a", "mask", "for", "2d", "block", "raster", "scan", "." ]
python
train
34.631579
jwodder/javaproperties
javaproperties/xmlprops.py
https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/xmlprops.py#L114-L130
def dumps_xml(props, comment=None, sort_keys=False): """ Convert a series ``props`` of key-value pairs to a text string containing an XML properties document. The document will include a doctype declaration but not an XML declaration. :param props: A mapping or iterable of ``(key, value)`` pairs t...
[ "def", "dumps_xml", "(", "props", ",", "comment", "=", "None", ",", "sort_keys", "=", "False", ")", ":", "return", "''", ".", "join", "(", "s", "+", "'\\n'", "for", "s", "in", "_stream_xml", "(", "props", ",", "comment", ",", "sort_keys", ")", ")" ]
Convert a series ``props`` of key-value pairs to a text string containing an XML properties document. The document will include a doctype declaration but not an XML declaration. :param props: A mapping or iterable of ``(key, value)`` pairs to serialize. All keys and values in ``props`` must be tex...
[ "Convert", "a", "series", "props", "of", "key", "-", "value", "pairs", "to", "a", "text", "string", "containing", "an", "XML", "properties", "document", ".", "The", "document", "will", "include", "a", "doctype", "declaration", "but", "not", "an", "XML", "d...
python
train
50.529412
tradenity/python-sdk
tradenity/resources/state.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/state.py#L443-L463
def get_state_by_id(cls, state_id, **kwargs): """Find State Return single instance of State by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get_state_by_id(state_id, async=True) ...
[ "def", "get_state_by_id", "(", "cls", ",", "state_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_get_state_by_id_with_http_inf...
Find State Return single instance of State by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get_state_by_id(state_id, async=True) >>> result = thread.get() :param async bool...
[ "Find", "State" ]
python
train
39.333333
BreakingBytes/simkit
simkit/core/calculations.py
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/calculations.py#L41-L56
def register(self, new_calc, *args, **kwargs): """ Register calculations and meta data. * ``dependencies`` - list of prerequisite calculations * ``always_calc`` - ``True`` if calculation ignores thresholds * ``frequency`` - frequency of calculation in intervals or units of time ...
[ "def", "register", "(", "self", ",", "new_calc", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "zip", "(", "self", ".", "meta_names", ",", "args", ")", ")", "# dependencies should be a list of other calculations", "if", ...
Register calculations and meta data. * ``dependencies`` - list of prerequisite calculations * ``always_calc`` - ``True`` if calculation ignores thresholds * ``frequency`` - frequency of calculation in intervals or units of time :param new_calc: register new calculation
[ "Register", "calculations", "and", "meta", "data", "." ]
python
train
45.875
Parsely/birding
src/birding/shelf.py
https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/shelf.py#L97-L102
def unpack(self, key, value): """Unpack and return value only if it is fresh.""" value, freshness = value if not self.is_fresh(freshness): raise KeyError('{} (stale)'.format(key)) return value
[ "def", "unpack", "(", "self", ",", "key", ",", "value", ")", ":", "value", ",", "freshness", "=", "value", "if", "not", "self", ".", "is_fresh", "(", "freshness", ")", ":", "raise", "KeyError", "(", "'{} (stale)'", ".", "format", "(", "key", ")", ")"...
Unpack and return value only if it is fresh.
[ "Unpack", "and", "return", "value", "only", "if", "it", "is", "fresh", "." ]
python
train
38.5
chrissimpkins/crypto
lib/crypto/library/hash.py
https://github.com/chrissimpkins/crypto/blob/6b95fa81b26312e46f02557dca0b5f5c898a76fd/lib/crypto/library/hash.py#L10-L14
def generate_hash(filepath): """Public function that reads a local file and generates a SHA256 hash digest for it""" fr = FileReader(filepath) data = fr.read_bin() return _calculate_sha256(data)
[ "def", "generate_hash", "(", "filepath", ")", ":", "fr", "=", "FileReader", "(", "filepath", ")", "data", "=", "fr", ".", "read_bin", "(", ")", "return", "_calculate_sha256", "(", "data", ")" ]
Public function that reads a local file and generates a SHA256 hash digest for it
[ "Public", "function", "that", "reads", "a", "local", "file", "and", "generates", "a", "SHA256", "hash", "digest", "for", "it" ]
python
train
41.2
watson-developer-cloud/python-sdk
ibm_watson/speech_to_text_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/speech_to_text_v1.py#L4941-L4967
def _from_dict(cls, _dict): """Initialize a SpeechRecognitionResult object from a json dictionary.""" args = {} if 'final' in _dict or 'final_results' in _dict: args['final_results'] = _dict.get('final') or _dict.get( 'final_results') else: raise V...
[ "def", "_from_dict", "(", "cls", ",", "_dict", ")", ":", "args", "=", "{", "}", "if", "'final'", "in", "_dict", "or", "'final_results'", "in", "_dict", ":", "args", "[", "'final_results'", "]", "=", "_dict", ".", "get", "(", "'final'", ")", "or", "_d...
Initialize a SpeechRecognitionResult object from a json dictionary.
[ "Initialize", "a", "SpeechRecognitionResult", "object", "from", "a", "json", "dictionary", "." ]
python
train
40.851852
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L135-L146
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ _json = self.to_json() try: return json.dumps(_json, sort_keys=True, cls=JsonEncoder) except: logging.exception("Could not serialize JSON: %r", _json) raise
[ "def", "to_json_str", "(", "self", ")", ":", "_json", "=", "self", ".", "to_json", "(", ")", "try", ":", "return", "json", ".", "dumps", "(", "_json", ",", "sort_keys", "=", "True", ",", "cls", "=", "JsonEncoder", ")", "except", ":", "logging", ".", ...
Convert data to json string representation. Returns: json representation as string.
[ "Convert", "data", "to", "json", "string", "representation", "." ]
python
train
25.666667
tensorflow/lucid
lucid/optvis/objectives.py
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/optvis/objectives.py#L133-L161
def neuron(layer_name, channel_n, x=None, y=None, batch=None): """Visualize a single neuron of a single channel. Defaults to the center neuron. When width and height are even numbers, we choose the neuron in the bottom right of the center 2x2 neurons. Odd width & height: Even width & height: ...
[ "def", "neuron", "(", "layer_name", ",", "channel_n", ",", "x", "=", "None", ",", "y", "=", "None", ",", "batch", "=", "None", ")", ":", "def", "inner", "(", "T", ")", ":", "layer", "=", "T", "(", "layer_name", ")", "shape", "=", "tf", ".", "sh...
Visualize a single neuron of a single channel. Defaults to the center neuron. When width and height are even numbers, we choose the neuron in the bottom right of the center 2x2 neurons. Odd width & height: Even width & height: +---+---+---+ +---+---+---+---+ | | | | ...
[ "Visualize", "a", "single", "neuron", "of", "a", "single", "channel", "." ]
python
train
36.931034
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/setuptools/package_index.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/setuptools/package_index.py#L900-L920
def _encode_auth(auth): """ A function compatible with Python 2.3-3.3 that will encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:...
[ "def", "_encode_auth", "(", "auth", ")", ":", "auth_s", "=", "unquote", "(", "auth", ")", "# convert to bytes", "auth_bytes", "=", "auth_s", ".", "encode", "(", ")", "# use the legacy interface for Python 2.3 support", "encoded_bytes", "=", "base64", ".", "encodestr...
A function compatible with Python 2.3-3.3 that will encode auth from a URL suitable for an HTTP header. >>> str(_encode_auth('username%3Apassword')) 'dXNlcm5hbWU6cGFzc3dvcmQ=' Long auth strings should not cause a newline to be inserted. >>> long_auth = 'username:' + 'password'*10 >>> chr(10) in...
[ "A", "function", "compatible", "with", "Python", "2", ".", "3", "-", "3", ".", "3", "that", "will", "encode", "auth", "from", "a", "URL", "suitable", "for", "an", "HTTP", "header", ".", ">>>", "str", "(", "_encode_auth", "(", "username%3Apassword", "))",...
python
test
34.142857
grundic/yagocd
yagocd/session.py
https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/session.py#L69-L84
def server_version(self): """ Special method for getting server version. Because of different behaviour on different versions of server, we have to pass different headers to the endpoints. This method requests the version from server and caches it in internal variable, s...
[ "def", "server_version", "(", "self", ")", ":", "if", "self", ".", "__server_version", "is", "None", ":", "from", "yagocd", ".", "resources", ".", "info", "import", "InfoManager", "self", ".", "__server_version", "=", "InfoManager", "(", "self", ")", ".", ...
Special method for getting server version. Because of different behaviour on different versions of server, we have to pass different headers to the endpoints. This method requests the version from server and caches it in internal variable, so other resources could use it. :retu...
[ "Special", "method", "for", "getting", "server", "version", "." ]
python
train
37.9375
exhuma/python-cluster
cluster/method/hierarchical.py
https://github.com/exhuma/python-cluster/blob/4c0ac14d9beafcd51f0d849151514083c296402f/cluster/method/hierarchical.py#L120-L189
def cluster(self, matrix=None, level=None, sequence=None): """ Perform hierarchical clustering. :param matrix: The 2D list that is currently under processing. The matrix contains the distances of each item with each other :param level: The current level of clustering ...
[ "def", "cluster", "(", "self", ",", "matrix", "=", "None", ",", "level", "=", "None", ",", "sequence", "=", "None", ")", ":", "logger", ".", "info", "(", "\"Performing cluster()\"", ")", "if", "matrix", "is", "None", ":", "# create level 0, first iteration (...
Perform hierarchical clustering. :param matrix: The 2D list that is currently under processing. The matrix contains the distances of each item with each other :param level: The current level of clustering :param sequence: The sequence number of the clustering
[ "Perform", "hierarchical", "clustering", "." ]
python
train
45.928571
saltstack/salt
salt/modules/keystone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/keystone.py#L661-L686
def tenant_delete(tenant_id=None, name=None, profile=None, **connection_args): ''' Delete a tenant (keystone tenant-delete) CLI Examples: .. code-block:: bash salt '*' keystone.tenant_delete c965f79c4f864eaaa9c3b41904e67082 salt '*' keystone.tenant_delete tenant_id=c965f79c4f864eaaa9c...
[ "def", "tenant_delete", "(", "tenant_id", "=", "None", ",", "name", "=", "None", ",", "profile", "=", "None", ",", "*", "*", "connection_args", ")", ":", "kstone", "=", "auth", "(", "profile", ",", "*", "*", "connection_args", ")", "if", "name", ":", ...
Delete a tenant (keystone tenant-delete) CLI Examples: .. code-block:: bash salt '*' keystone.tenant_delete c965f79c4f864eaaa9c3b41904e67082 salt '*' keystone.tenant_delete tenant_id=c965f79c4f864eaaa9c3b41904e67082 salt '*' keystone.tenant_delete name=demo
[ "Delete", "a", "tenant", "(", "keystone", "tenant", "-", "delete", ")" ]
python
train
32.038462
zhanglab/psamm
psamm/commands/primarypairs.py
https://github.com/zhanglab/psamm/blob/dc427848c4f9d109ca590f0afa024c63b685b3f4/psamm/commands/primarypairs.py#L215-L236
def _parse_weights(weight_args, default_weight=0.6): """Parse list of weight assignments.""" weights_dict = {} r_group_weight = default_weight for weight_arg in weight_args: for weight_assignment in weight_arg.split(','): if '=' not in weight_assignment: raise ValueEr...
[ "def", "_parse_weights", "(", "weight_args", ",", "default_weight", "=", "0.6", ")", ":", "weights_dict", "=", "{", "}", "r_group_weight", "=", "default_weight", "for", "weight_arg", "in", "weight_args", ":", "for", "weight_assignment", "in", "weight_arg", ".", ...
Parse list of weight assignments.
[ "Parse", "list", "of", "weight", "assignments", "." ]
python
train
37.954545
kata198/AdvancedHTMLParser
AdvancedHTMLParser/utils.py
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/utils.py#L24-L41
def stripIEConditionals(contents, addHtmlIfMissing=True): ''' stripIEConditionals - Strips Internet Explorer conditional statements. @param contents <str> - Contents String @param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing....
[ "def", "stripIEConditionals", "(", "contents", ",", "addHtmlIfMissing", "=", "True", ")", ":", "allMatches", "=", "IE_CONDITIONAL_PATTERN", ".", "findall", "(", "contents", ")", "if", "not", "allMatches", ":", "return", "contents", "for", "match", "in", "allMatc...
stripIEConditionals - Strips Internet Explorer conditional statements. @param contents <str> - Contents String @param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing.
[ "stripIEConditionals", "-", "Strips", "Internet", "Explorer", "conditional", "statements", "." ]
python
train
35.222222
pywbem/pywbem
attic/cim_provider2.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/attic/cim_provider2.py#L936-L950
def filter_instance(self, inst, plist): """Remove properties from an instance that aren't in the PropertyList inst -- The pywbem.CIMInstance plist -- The property List, or None. The list items must be all lowercase. """ if plist is not None: for pname ...
[ "def", "filter_instance", "(", "self", ",", "inst", ",", "plist", ")", ":", "if", "plist", "is", "not", "None", ":", "for", "pname", "in", "inst", ".", "properties", ".", "keys", "(", ")", ":", "if", "pname", ".", "lower", "(", ")", "not", "in", ...
Remove properties from an instance that aren't in the PropertyList inst -- The pywbem.CIMInstance plist -- The property List, or None. The list items must be all lowercase.
[ "Remove", "properties", "from", "an", "instance", "that", "aren", "t", "in", "the", "PropertyList" ]
python
train
36.666667
pybel/pybel-tools
src/pybel_tools/summary/provenance.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L43-L55
def _generate_citation_dict(graph: BELGraph) -> Mapping[str, Mapping[Tuple[BaseEntity, BaseEntity], str]]: """Prepare a citation data dictionary from a graph. :return: A dictionary of dictionaries {citation type: {(source, target): citation reference} """ results = defaultdict(lambda: defaultdict(set))...
[ "def", "_generate_citation_dict", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Mapping", "[", "Tuple", "[", "BaseEntity", ",", "BaseEntity", "]", ",", "str", "]", "]", ":", "results", "=", "defaultdict", "(", "lambda", ":", "def...
Prepare a citation data dictionary from a graph. :return: A dictionary of dictionaries {citation type: {(source, target): citation reference}
[ "Prepare", "a", "citation", "data", "dictionary", "from", "a", "graph", "." ]
python
valid
41.230769
assamite/creamas
creamas/ds.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/ds.py#L65-L94
async def run_node(menv, log_folder): """Run :class:`~creamas.mp.MultiEnvironment` until its manager's :meth:`~aiomas.subproc.Manager.stop` is called. :param menv: :class:`~creamas.mp.MultiEnvironment` to wait for. :param str log_folder: Logging folder to be passed down to :meth:`~cream...
[ "async", "def", "run_node", "(", "menv", ",", "log_folder", ")", ":", "try", ":", "await", "menv", ".", "manager", ".", "stop_received", "except", "KeyboardInterrupt", ":", "pass", "finally", ":", "ret", "=", "await", "menv", ".", "destroy", "(", "log_fold...
Run :class:`~creamas.mp.MultiEnvironment` until its manager's :meth:`~aiomas.subproc.Manager.stop` is called. :param menv: :class:`~creamas.mp.MultiEnvironment` to wait for. :param str log_folder: Logging folder to be passed down to :meth:`~creamas.mp.MultiEnvironment.destroy` after :meth:`...
[ "Run", ":", "class", ":", "~creamas", ".", "mp", ".", "MultiEnvironment", "until", "its", "manager", "s", ":", "meth", ":", "~aiomas", ".", "subproc", ".", "Manager", ".", "stop", "is", "called", "." ]
python
train
41.033333
ajdavis/mongo-mockup-db
mockupdb/__init__.py
https://github.com/ajdavis/mongo-mockup-db/blob/ff8a3f793def59e9037397ef60607fbda6949dac/mockupdb/__init__.py#L1086-L1109
def matches(self, *args, **kwargs): """Test if a request matches a :ref:`message spec <message spec>`. Returns ``True`` or ``False``. """ request = make_prototype_request(*args, **kwargs) if self._prototype.opcode not in (None, request.opcode): return False i...
[ "def", "matches", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", "=", "make_prototype_request", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "self", ".", "_prototype", ".", "opcode", "not", "in", "(", "None", ...
Test if a request matches a :ref:`message spec <message spec>`. Returns ``True`` or ``False``.
[ "Test", "if", "a", "request", "matches", "a", ":", "ref", ":", "message", "spec", "<message", "spec", ">", "." ]
python
train
44
appliedsec/pygeoip
pygeoip/__init__.py
https://github.com/appliedsec/pygeoip/blob/2a725df0b727e8b08f217ab84f7b8243c42554f5/pygeoip/__init__.py#L127-L191
def _setup_segments(self): """ Parses the database file to determine what kind of database is being used and setup segment sizes and start points that will be used by the seek*() methods later. """ self._databaseType = const.COUNTRY_EDITION self._recordLength = co...
[ "def", "_setup_segments", "(", "self", ")", ":", "self", ".", "_databaseType", "=", "const", ".", "COUNTRY_EDITION", "self", ".", "_recordLength", "=", "const", ".", "STANDARD_RECORD_LENGTH", "self", ".", "_databaseSegments", "=", "const", ".", "COUNTRY_BEGIN", ...
Parses the database file to determine what kind of database is being used and setup segment sizes and start points that will be used by the seek*() methods later.
[ "Parses", "the", "database", "file", "to", "determine", "what", "kind", "of", "database", "is", "being", "used", "and", "setup", "segment", "sizes", "and", "start", "points", "that", "will", "be", "used", "by", "the", "seek", "*", "()", "methods", "later",...
python
valid
40.984615
datosgobar/pydatajson
pydatajson/core.py
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L692-L769
def generate_harvester_config(self, catalogs=None, harvest='valid', report=None, export_path=None): """Genera un archivo de configuración del harvester a partir de un reporte, o de un conjunto de catálogos y un criterio de cosecha (`harvest`). Args: ...
[ "def", "generate_harvester_config", "(", "self", ",", "catalogs", "=", "None", ",", "harvest", "=", "'valid'", ",", "report", "=", "None", ",", "export_path", "=", "None", ")", ":", "# Si se pasa un único catálogo, genero una lista que lo contenga", "if", "isinstance"...
Genera un archivo de configuración del harvester a partir de un reporte, o de un conjunto de catálogos y un criterio de cosecha (`harvest`). Args: catalogs (str, dict o list): Uno (str o dict) o varios (list de strs y/o dicts) catálogos. harvest (str): Cr...
[ "Genera", "un", "archivo", "de", "configuración", "del", "harvester", "a", "partir", "de", "un", "reporte", "o", "de", "un", "conjunto", "de", "catálogos", "y", "un", "criterio", "de", "cosecha", "(", "harvest", ")", "." ]
python
train
44
KarchinLab/probabilistic2020
prob2020/python/utils.py
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/utils.py#L212-L229
def bed_generator(bed_path): """Iterates through a BED file yielding parsed BED lines. Parameters ---------- bed_path : str path to BED file Yields ------ BedLine(line) : BedLine A BedLine object which has parsed the individual line in a BED file. """ with o...
[ "def", "bed_generator", "(", "bed_path", ")", ":", "with", "open", "(", "bed_path", ")", "as", "handle", ":", "bed_reader", "=", "csv", ".", "reader", "(", "handle", ",", "delimiter", "=", "'\\t'", ")", "for", "line", "in", "bed_reader", ":", "yield", ...
Iterates through a BED file yielding parsed BED lines. Parameters ---------- bed_path : str path to BED file Yields ------ BedLine(line) : BedLine A BedLine object which has parsed the individual line in a BED file.
[ "Iterates", "through", "a", "BED", "file", "yielding", "parsed", "BED", "lines", "." ]
python
train
24.833333
ansible-community/ara
ara/config/webapp.py
https://github.com/ansible-community/ara/blob/15e2d0133c23b6d07438a553bb8149fadff21547/ara/config/webapp.py#L58-L64
def config(self): """ Returns a dictionary for the loaded configuration """ return { key: self.__dict__[key] for key in dir(self) if key.isupper() }
[ "def", "config", "(", "self", ")", ":", "return", "{", "key", ":", "self", ".", "__dict__", "[", "key", "]", "for", "key", "in", "dir", "(", "self", ")", "if", "key", ".", "isupper", "(", ")", "}" ]
Returns a dictionary for the loaded configuration
[ "Returns", "a", "dictionary", "for", "the", "loaded", "configuration" ]
python
train
28.857143
flo-compbio/genometools
genometools/ontology/util.py
https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ontology/util.py#L62-L73
def get_current_ontology_date(): """Get the release date of the current Gene Ontolgo release.""" with closing(requests.get( 'http://geneontology.org/ontology/go-basic.obo', stream=True)) as r: for i, l in enumerate(r.iter_lines(decode_unicode=True)): if i == 1: ...
[ "def", "get_current_ontology_date", "(", ")", ":", "with", "closing", "(", "requests", ".", "get", "(", "'http://geneontology.org/ontology/go-basic.obo'", ",", "stream", "=", "True", ")", ")", "as", "r", ":", "for", "i", ",", "l", "in", "enumerate", "(", "r"...
Get the release date of the current Gene Ontolgo release.
[ "Get", "the", "release", "date", "of", "the", "current", "Gene", "Ontolgo", "release", "." ]
python
train
36.5
talentpair/featurevectormatrix
featurevectormatrix/__init__.py
https://github.com/talentpair/featurevectormatrix/blob/1327026f7e46138947ba55433c11a85bca1adc5d/featurevectormatrix/__init__.py#L250-L259
def keys(self): """ Returns all row keys :raise NotImplementedError: if all rows aren't keyed :return: all row keys """ if len(self._row_name_list) != len(self._rows): raise NotImplementedError("You can't get row keys for a FVM that doesn't have all rows keyed") ...
[ "def", "keys", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_row_name_list", ")", "!=", "len", "(", "self", ".", "_rows", ")", ":", "raise", "NotImplementedError", "(", "\"You can't get row keys for a FVM that doesn't have all rows keyed\"", ")", "return...
Returns all row keys :raise NotImplementedError: if all rows aren't keyed :return: all row keys
[ "Returns", "all", "row", "keys" ]
python
train
33.9
mamins1376/PyBehnevis
pybehnevis/__init__.py
https://github.com/mamins1376/PyBehnevis/blob/8642b4999a62ea8fa76879fbdc320462eb720f6d/pybehnevis/__init__.py#L36-L63
def convert(self, text): """ convert Finglish(or whatever you'd like to call) to Persian. gets and returns string. """ url = self.API_URL encoding = self.ENCODING headers = self.HEADERS data = urlencode({ 'farsi': str(text) }).encode(encoding) request = Request(url=url...
[ "def", "convert", "(", "self", ",", "text", ")", ":", "url", "=", "self", ".", "API_URL", "encoding", "=", "self", ".", "ENCODING", "headers", "=", "self", ".", "HEADERS", "data", "=", "urlencode", "(", "{", "'farsi'", ":", "str", "(", "text", ")", ...
convert Finglish(or whatever you'd like to call) to Persian. gets and returns string.
[ "convert", "Finglish", "(", "or", "whatever", "you", "d", "like", "to", "call", ")", "to", "Persian", ".", "gets", "and", "returns", "string", "." ]
python
train
23.071429
materialsproject/pymatgen
pymatgen/io/abinit/works.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/works.py#L1724-L1778
def from_phononwfkq_work(cls, phononwfkq_work, nscf_vars={}, remove_wfkq=True, with_ddk=True, manager=None): """ Construct a `GKKPWork` from a `PhononWfkqWork` object. The WFQ are the ones used for PhononWfkqWork so in principle have only valence bands """ # Get list of qpoints f...
[ "def", "from_phononwfkq_work", "(", "cls", ",", "phononwfkq_work", ",", "nscf_vars", "=", "{", "}", ",", "remove_wfkq", "=", "True", ",", "with_ddk", "=", "True", ",", "manager", "=", "None", ")", ":", "# Get list of qpoints from the the phonon tasks in this work", ...
Construct a `GKKPWork` from a `PhononWfkqWork` object. The WFQ are the ones used for PhononWfkqWork so in principle have only valence bands
[ "Construct", "a", "GKKPWork", "from", "a", "PhononWfkqWork", "object", ".", "The", "WFQ", "are", "the", "ones", "used", "for", "PhononWfkqWork", "so", "in", "principle", "have", "only", "valence", "bands" ]
python
train
42.763636
Qiskit/qiskit-terra
qiskit/dagcircuit/dagcircuit.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/dagcircuit/dagcircuit.py#L180-L188
def add_qreg(self, qreg): """Add all wires in a quantum register.""" if not isinstance(qreg, QuantumRegister): raise DAGCircuitError("not a QuantumRegister instance.") if qreg.name in self.qregs: raise DAGCircuitError("duplicate register %s" % qreg.name) self.qreg...
[ "def", "add_qreg", "(", "self", ",", "qreg", ")", ":", "if", "not", "isinstance", "(", "qreg", ",", "QuantumRegister", ")", ":", "raise", "DAGCircuitError", "(", "\"not a QuantumRegister instance.\"", ")", "if", "qreg", ".", "name", "in", "self", ".", "qregs...
Add all wires in a quantum register.
[ "Add", "all", "wires", "in", "a", "quantum", "register", "." ]
python
test
44.888889
MillionIntegrals/vel
vel/rl/modules/noise/ou_noise.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/noise/ou_noise.py#L28-L41
def forward(self, actions, batch_info): """ Return model step after applying noise """ while len(self.processes) < actions.shape[0]: len_action_space = self.action_space.shape[-1] self.processes.append( OrnsteinUhlenbeckNoiseProcess( np.zeros(...
[ "def", "forward", "(", "self", ",", "actions", ",", "batch_info", ")", ":", "while", "len", "(", "self", ".", "processes", ")", "<", "actions", ".", "shape", "[", "0", "]", ":", "len_action_space", "=", "self", ".", "action_space", ".", "shape", "[", ...
Return model step after applying noise
[ "Return", "model", "step", "after", "applying", "noise" ]
python
train
42.571429
davidmogar/cucco
cucco/cucco.py
https://github.com/davidmogar/cucco/blob/e2a0ff3342e4a9f25a65c486206a5a2ae1a4dbd4/cucco/cucco.py#L65-L82
def _parse_normalizations(normalizations): """Parse and yield normalizations. Parse normalizations parameter that yield all normalizations and arguments found on it. Args: normalizations: List of normalizations. Yields: A tuple with a parsed normalizati...
[ "def", "_parse_normalizations", "(", "normalizations", ")", ":", "str_type", "=", "str", "if", "sys", ".", "version_info", "[", "0", "]", ">", "2", "else", "(", "str", ",", "unicode", ")", "for", "normalization", "in", "normalizations", ":", "yield", "(", ...
Parse and yield normalizations. Parse normalizations parameter that yield all normalizations and arguments found on it. Args: normalizations: List of normalizations. Yields: A tuple with a parsed normalization. The first item will contain the normal...
[ "Parse", "and", "yield", "normalizations", "." ]
python
train
38.222222
SecurityInnovation/PGPy
pgpy/packet/types.py
https://github.com/SecurityInnovation/PGPy/blob/f1c3d68e32c334f5aa14c34580925e97f17f4fde/pgpy/packet/types.py#L66-L115
def parse(self, packet): """ There are two formats for headers old style --------- Old style headers can be 1, 2, 3, or 6 octets long and are composed of a Tag and a Length. If the header length is 1 octet (length_type == 3), then there is no Length field. new ...
[ "def", "parse", "(", "self", ",", "packet", ")", ":", "self", ".", "_lenfmt", "=", "(", "(", "packet", "[", "0", "]", "&", "0x40", ")", ">>", "6", ")", "self", ".", "tag", "=", "packet", "[", "0", "]", "if", "self", ".", "_lenfmt", "==", "0",...
There are two formats for headers old style --------- Old style headers can be 1, 2, 3, or 6 octets long and are composed of a Tag and a Length. If the header length is 1 octet (length_type == 3), then there is no Length field. new style --------- New style he...
[ "There", "are", "two", "formats", "for", "headers" ]
python
train
43.7
Rapptz/discord.py
discord/message.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/message.py#L699-L728
async def add_reaction(self, emoji): """|coro| Add a reaction to the message. The emoji may be a unicode emoji or a custom guild :class:`Emoji`. You must have the :attr:`~Permissions.read_message_history` permission to use this. If nobody else has reacted to the message using ...
[ "async", "def", "add_reaction", "(", "self", ",", "emoji", ")", ":", "emoji", "=", "self", ".", "_emoji_reaction", "(", "emoji", ")", "await", "self", ".", "_state", ".", "http", ".", "add_reaction", "(", "self", ".", "channel", ".", "id", ",", "self",...
|coro| Add a reaction to the message. The emoji may be a unicode emoji or a custom guild :class:`Emoji`. You must have the :attr:`~Permissions.read_message_history` permission to use this. If nobody else has reacted to the message using this emoji, the :attr:`~Permissions.add_...
[ "|coro|" ]
python
train
33.433333
pymacaron/pymacaron-core
pymacaron_core/exceptions.py
https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/exceptions.py#L25-L33
def add_error_handlers(app): """Add custom error handlers for PyMacaronCoreExceptions to the app""" def handle_validation_error(error): response = jsonify({'message': str(error)}) response.status_code = error.status_code return response app.errorhandler(ValidationError)(handle_vali...
[ "def", "add_error_handlers", "(", "app", ")", ":", "def", "handle_validation_error", "(", "error", ")", ":", "response", "=", "jsonify", "(", "{", "'message'", ":", "str", "(", "error", ")", "}", ")", "response", ".", "status_code", "=", "error", ".", "s...
Add custom error handlers for PyMacaronCoreExceptions to the app
[ "Add", "custom", "error", "handlers", "for", "PyMacaronCoreExceptions", "to", "the", "app" ]
python
train
36.111111
chrizzFTD/naming
naming/base.py
https://github.com/chrizzFTD/naming/blob/ed0efbd2a3718f977c01cc15b33aeb1aa4fb299c/naming/base.py#L6-L11
def _dct_from_mro(cls: type, attr_name: str) -> dict: """"Get a merged dictionary from `cls` bases attribute `attr_name`. MRO defines importance (closest = strongest).""" d = {} for c in reversed(cls.mro()): d.update(getattr(c, attr_name, {})) return d
[ "def", "_dct_from_mro", "(", "cls", ":", "type", ",", "attr_name", ":", "str", ")", "->", "dict", ":", "d", "=", "{", "}", "for", "c", "in", "reversed", "(", "cls", ".", "mro", "(", ")", ")", ":", "d", ".", "update", "(", "getattr", "(", "c", ...
Get a merged dictionary from `cls` bases attribute `attr_name`. MRO defines importance (closest = strongest).
[ "Get", "a", "merged", "dictionary", "from", "cls", "bases", "attribute", "attr_name", ".", "MRO", "defines", "importance", "(", "closest", "=", "strongest", ")", "." ]
python
train
45.166667
jart/fabulous
fabulous/term.py
https://github.com/jart/fabulous/blob/19903cf0a980b82f5928c3bec1f28b6bdd3785bd/fabulous/term.py#L758-L768
def _get_title(self): """According to http://support.microsoft.com/kb/124103 the buffer size is 1024 Does not support unicode, only ANSI""" #TODO: unicode support strbuffer = self.ctypes.create_string_buffer(1024) size = self.ctypes.c_short(1024) #unicode...
[ "def", "_get_title", "(", "self", ")", ":", "#TODO: unicode support", "strbuffer", "=", "self", ".", "ctypes", ".", "create_string_buffer", "(", "1024", ")", "size", "=", "self", ".", "ctypes", ".", "c_short", "(", "1024", ")", "#unicode versions are (Get|Set)Co...
According to http://support.microsoft.com/kb/124103 the buffer size is 1024 Does not support unicode, only ANSI
[ "According", "to", "http", ":", "//", "support", ".", "microsoft", ".", "com", "/", "kb", "/", "124103", "the", "buffer", "size", "is", "1024", "Does", "not", "support", "unicode", "only", "ANSI" ]
python
train
40.545455
QUANTAXIS/QUANTAXIS
QUANTAXIS/QAIndicator/indicators.py
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QAIndicator/indicators.py#L95-L118
def QA_indicator_DMI(DataFrame, M1=14, M2=6): """ 趋向指标 DMI """ HIGH = DataFrame.high LOW = DataFrame.low CLOSE = DataFrame.close OPEN = DataFrame.open TR = SUM(MAX(MAX(HIGH-LOW, ABS(HIGH-REF(CLOSE, 1))), ABS(LOW-REF(CLOSE, 1))), M1) HD = HIGH-REF(HIGH, 1) LD = R...
[ "def", "QA_indicator_DMI", "(", "DataFrame", ",", "M1", "=", "14", ",", "M2", "=", "6", ")", ":", "HIGH", "=", "DataFrame", ".", "high", "LOW", "=", "DataFrame", ".", "low", "CLOSE", "=", "DataFrame", ".", "close", "OPEN", "=", "DataFrame", ".", "ope...
趋向指标 DMI
[ "趋向指标", "DMI" ]
python
train
25.541667
saltstack/salt
salt/modules/marathon.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/marathon.py#L55-L70
def apps(): ''' Return a list of the currently installed app ids. CLI Example: .. code-block:: bash salt marathon-minion-id marathon.apps ''' response = salt.utils.http.query( "{0}/v2/apps".format(_base_url()), decode_type='json', decode=True, ) return ...
[ "def", "apps", "(", ")", ":", "response", "=", "salt", ".", "utils", ".", "http", ".", "query", "(", "\"{0}/v2/apps\"", ".", "format", "(", "_base_url", "(", ")", ")", ",", "decode_type", "=", "'json'", ",", "decode", "=", "True", ",", ")", "return",...
Return a list of the currently installed app ids. CLI Example: .. code-block:: bash salt marathon-minion-id marathon.apps
[ "Return", "a", "list", "of", "the", "currently", "installed", "app", "ids", "." ]
python
train
22.625
da4089/simplefix
simplefix/message.py
https://github.com/da4089/simplefix/blob/10f7f165a99a03467110bee69cc7c083c3531c68/simplefix/message.py#L290-L334
def append_tz_timestamp(self, tag, timestamp=None, precision=3, header=False): """Append a field with a TZTimestamp value, derived from local time. :param tag: Integer or string FIX tag number. :param timestamp: Time value, see below. :param precision: Number...
[ "def", "append_tz_timestamp", "(", "self", ",", "tag", ",", "timestamp", "=", "None", ",", "precision", "=", "3", ",", "header", "=", "False", ")", ":", "# Get float offset from Unix epoch.", "if", "timestamp", "is", "None", ":", "now", "=", "time", ".", "...
Append a field with a TZTimestamp value, derived from local time. :param tag: Integer or string FIX tag number. :param timestamp: Time value, see below. :param precision: Number of decimal places: 0, 3 (ms) or 6 (us). :param header: Append to FIX header if True; default to body. ...
[ "Append", "a", "field", "with", "a", "TZTimestamp", "value", "derived", "from", "local", "time", "." ]
python
train
42.533333
krischer/pyflex
doc/convert.py
https://github.com/krischer/pyflex/blob/e1a988793ba79cc3b31051ba3df5b3a23bc769c4/doc/convert.py#L12-L28
def clean_for_doc(nb): """ Cleans the notebook to be suitable for inclusion in the docs. """ new_cells = [] for cell in nb.worksheets[0].cells: # Remove the pylab inline line. if "input" in cell and cell["input"].strip() == "%pylab inline": continue # Remove outpu...
[ "def", "clean_for_doc", "(", "nb", ")", ":", "new_cells", "=", "[", "]", "for", "cell", "in", "nb", ".", "worksheets", "[", "0", "]", ".", "cells", ":", "# Remove the pylab inline line.", "if", "\"input\"", "in", "cell", "and", "cell", "[", "\"input\"", ...
Cleans the notebook to be suitable for inclusion in the docs.
[ "Cleans", "the", "notebook", "to", "be", "suitable", "for", "inclusion", "in", "the", "docs", "." ]
python
train
38
abe-winter/pg13-py
pg13/diff.py
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L84-L94
def subslice(inner,outer,section): 'helper for rediff\ outer is a slice (2-tuple, not an official python slice) in global coordinates\ inner is a slice (2-tuple) on that slice\ returns the result of sub-slicing outer by inner' # todo: think about constraints here. inner and outer ordered, inner[1] less t...
[ "def", "subslice", "(", "inner", ",", "outer", ",", "section", ")", ":", "# todo: think about constraints here. inner and outer ordered, inner[1] less than outer[1]-outer[0]\r", "# todo: this would make more sense as a member of a Slice class\r", "if", "section", "==", "'head'", ":",...
helper for rediff\ outer is a slice (2-tuple, not an official python slice) in global coordinates\ inner is a slice (2-tuple) on that slice\ returns the result of sub-slicing outer by inner
[ "helper", "for", "rediff", "\\", "outer", "is", "a", "slice", "(", "2", "-", "tuple", "not", "an", "official", "python", "slice", ")", "in", "global", "coordinates", "\\", "inner", "is", "a", "slice", "(", "2", "-", "tuple", ")", "on", "that", "slice...
python
train
60.545455
daler/gffutils
gffutils/helpers.py
https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/helpers.py#L263-L268
def _unjsonify(x, isattributes=False): """Convert JSON string to an ordered defaultdict.""" if isattributes: obj = json.loads(x) return dict_class(obj) return json.loads(x)
[ "def", "_unjsonify", "(", "x", ",", "isattributes", "=", "False", ")", ":", "if", "isattributes", ":", "obj", "=", "json", ".", "loads", "(", "x", ")", "return", "dict_class", "(", "obj", ")", "return", "json", ".", "loads", "(", "x", ")" ]
Convert JSON string to an ordered defaultdict.
[ "Convert", "JSON", "string", "to", "an", "ordered", "defaultdict", "." ]
python
train
32.5
PythonCharmers/python-future
src/future/backports/http/server.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/http/server.py#L543-L552
def date_time_string(self, timestamp=None): """Return the current date and time formatted for a message header.""" if timestamp is None: timestamp = time.time() year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp) s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( ...
[ "def", "date_time_string", "(", "self", ",", "timestamp", "=", "None", ")", ":", "if", "timestamp", "is", "None", ":", "timestamp", "=", "time", ".", "time", "(", ")", "year", ",", "month", ",", "day", ",", "hh", ",", "mm", ",", "ss", ",", "wd", ...
Return the current date and time formatted for a message header.
[ "Return", "the", "current", "date", "and", "time", "formatted", "for", "a", "message", "header", "." ]
python
train
43.8
allianceauth/allianceauth
allianceauth/authentication/admin.py
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/authentication/admin.py#L15-L27
def make_service_hooks_update_groups_action(service): """ Make a admin action for the given service :param service: services.hooks.ServicesHook :return: fn to update services groups for the selected users """ def update_service_groups(modeladmin, request, queryset): for user in queryset:...
[ "def", "make_service_hooks_update_groups_action", "(", "service", ")", ":", "def", "update_service_groups", "(", "modeladmin", ",", "request", ",", "queryset", ")", ":", "for", "user", "in", "queryset", ":", "# queryset filtering doesn't work here?", "service", ".", "...
Make a admin action for the given service :param service: services.hooks.ServicesHook :return: fn to update services groups for the selected users
[ "Make", "a", "admin", "action", "for", "the", "given", "service", ":", "param", "service", ":", "services", ".", "hooks", ".", "ServicesHook", ":", "return", ":", "fn", "to", "update", "services", "groups", "for", "the", "selected", "users" ]
python
train
47.769231
erikrose/peep
peep.py
https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L217-L226
def hash_of_file(path): """Return the hash of a downloaded file.""" with open(path, 'rb') as archive: sha = sha256() while True: data = archive.read(2 ** 20) if not data: break sha.update(data) return encoded_hash(sha)
[ "def", "hash_of_file", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "archive", ":", "sha", "=", "sha256", "(", ")", "while", "True", ":", "data", "=", "archive", ".", "read", "(", "2", "**", "20", ")", "if", "not", ...
Return the hash of a downloaded file.
[ "Return", "the", "hash", "of", "a", "downloaded", "file", "." ]
python
train
28.9
saltstack/salt
salt/modules/splunk_search.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/splunk_search.py#L201-L300
def list_all(prefix=None, app=None, owner=None, description_contains=None, name_not_contains=None, profile="splunk"): ''' Get all splunk search details. Produces results that can be used to create an sls file. if app or owner are specified, results will be limited to matching saved sea...
[ "def", "list_all", "(", "prefix", "=", "None", ",", "app", "=", "None", ",", "owner", "=", "None", ",", "description_contains", "=", "None", ",", "name_not_contains", "=", "None", ",", "profile", "=", "\"splunk\"", ")", ":", "client", "=", "_get_splunk", ...
Get all splunk search details. Produces results that can be used to create an sls file. if app or owner are specified, results will be limited to matching saved searches. if description_contains is specified, results will be limited to those where "description_contains in description" is true if n...
[ "Get", "all", "splunk", "search", "details", ".", "Produces", "results", "that", "can", "be", "used", "to", "create", "an", "sls", "file", "." ]
python
train
40.77
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/encoder.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/encoder.py#L682-L703
def StringEncoder(field_number, is_repeated, is_packed): """Returns an encoder for a string field.""" tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED) local_EncodeVarint = _EncodeVarint local_len = len assert not is_packed if is_repeated: def EncodeRepeatedField(write, value): ...
[ "def", "StringEncoder", "(", "field_number", ",", "is_repeated", ",", "is_packed", ")", ":", "tag", "=", "TagBytes", "(", "field_number", ",", "wire_format", ".", "WIRETYPE_LENGTH_DELIMITED", ")", "local_EncodeVarint", "=", "_EncodeVarint", "local_len", "=", "len", ...
Returns an encoder for a string field.
[ "Returns", "an", "encoder", "for", "a", "string", "field", "." ]
python
train
31.363636
ucsb-cs/submit
submit/models.py
https://github.com/ucsb-cs/submit/blob/92810c81255a4fc6bbebac1ac8aae856fd576ffe/submit/models.py#L625-L627
def can_view(self, user): """Return whether or not `user` can view the submission.""" return user in self.group.users or self.project.can_view(user)
[ "def", "can_view", "(", "self", ",", "user", ")", ":", "return", "user", "in", "self", ".", "group", ".", "users", "or", "self", ".", "project", ".", "can_view", "(", "user", ")" ]
Return whether or not `user` can view the submission.
[ "Return", "whether", "or", "not", "user", "can", "view", "the", "submission", "." ]
python
train
54
inveniosoftware/invenio-files-rest
invenio_files_rest/models.py
https://github.com/inveniosoftware/invenio-files-rest/blob/59a950da61cc8d5882a03c6fde6db2e2ed10befd/invenio_files_rest/models.py#L761-L766
def clear_last_check(self): """Clear the checksum of the file.""" with db.session.begin_nested(): self.last_check = None self.last_check_at = datetime.utcnow() return self
[ "def", "clear_last_check", "(", "self", ")", ":", "with", "db", ".", "session", ".", "begin_nested", "(", ")", ":", "self", ".", "last_check", "=", "None", "self", ".", "last_check_at", "=", "datetime", ".", "utcnow", "(", ")", "return", "self" ]
Clear the checksum of the file.
[ "Clear", "the", "checksum", "of", "the", "file", "." ]
python
train
35.666667
woolfson-group/isambard
isambard/ampal/base_ampal.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/base_ampal.py#L853-L863
def unique_id(self): """Creates a unique ID for the `Atom` based on its parents. Returns ------- unique_id : (str, str, str) (polymer.id, residue.id, atom.id) """ chain = self.ampal_parent.ampal_parent.id residue = self.ampal_parent.id return ...
[ "def", "unique_id", "(", "self", ")", ":", "chain", "=", "self", ".", "ampal_parent", ".", "ampal_parent", ".", "id", "residue", "=", "self", ".", "ampal_parent", ".", "id", "return", "chain", ",", "residue", ",", "self", ".", "id" ]
Creates a unique ID for the `Atom` based on its parents. Returns ------- unique_id : (str, str, str) (polymer.id, residue.id, atom.id)
[ "Creates", "a", "unique", "ID", "for", "the", "Atom", "based", "on", "its", "parents", "." ]
python
train
30.272727
mjirik/imtools
imtools/show_segmentation.py
https://github.com/mjirik/imtools/blob/eb29fa59df0e0684d8334eb3bc5ef36ea46d1d3a/imtools/show_segmentation.py#L386-L439
def create_pvsm_file(vtk_files, pvsm_filename, relative_paths=True): """ Create paraview status file (.pvsm) based on input vtk files. :param vtk_files: :param pvsm_filename: :param relative_paths: :return: """ from xml.etree.ElementTree import Element, SubElement, Comment import os....
[ "def", "create_pvsm_file", "(", "vtk_files", ",", "pvsm_filename", ",", "relative_paths", "=", "True", ")", ":", "from", "xml", ".", "etree", ".", "ElementTree", "import", "Element", ",", "SubElement", ",", "Comment", "import", "os", ".", "path", "as", "op",...
Create paraview status file (.pvsm) based on input vtk files. :param vtk_files: :param pvsm_filename: :param relative_paths: :return:
[ "Create", "paraview", "status", "file", "(", ".", "pvsm", ")", "based", "on", "input", "vtk", "files", ".", ":", "param", "vtk_files", ":", ":", "param", "pvsm_filename", ":", ":", "param", "relative_paths", ":", ":", "return", ":" ]
python
train
36.351852
cuzzo/iw_parse
iw_parse.py
https://github.com/cuzzo/iw_parse/blob/84c287dc6cfceb04ccbc0a8995f8a87323356ee5/iw_parse.py#L45-L63
def get_signal_level(cell): """ Gets the signal level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The signal level of the network. """ signal = matching_line(cell, "Signal level=") if signal is None: return "" signal = sig...
[ "def", "get_signal_level", "(", "cell", ")", ":", "signal", "=", "matching_line", "(", "cell", ",", "\"Signal level=\"", ")", "if", "signal", "is", "None", ":", "return", "\"\"", "signal", "=", "signal", ".", "split", "(", "\"=\"", ")", "[", "1", "]", ...
Gets the signal level of a network / cell. @param string cell A network / cell from iwlist scan. @return string The signal level of the network.
[ "Gets", "the", "signal", "level", "of", "a", "network", "/", "cell", ".", "@param", "string", "cell", "A", "network", "/", "cell", "from", "iwlist", "scan", "." ]
python
train
27.526316
saltstack/salt
salt/modules/saltutil.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/saltutil.py#L1425-L1444
def regen_keys(): ''' Used to regenerate the minion keys. CLI Example: .. code-block:: bash salt '*' saltutil.regen_keys ''' for fn_ in os.listdir(__opts__['pki_dir']): path = os.path.join(__opts__['pki_dir'], fn_) try: os.remove(path) except os.err...
[ "def", "regen_keys", "(", ")", ":", "for", "fn_", "in", "os", ".", "listdir", "(", "__opts__", "[", "'pki_dir'", "]", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "__opts__", "[", "'pki_dir'", "]", ",", "fn_", ")", "try", ":", "os"...
Used to regenerate the minion keys. CLI Example: .. code-block:: bash salt '*' saltutil.regen_keys
[ "Used", "to", "regenerate", "the", "minion", "keys", "." ]
python
train
26.1
ggravlingen/pytradfri
pytradfri/api/aiocoap_api.py
https://github.com/ggravlingen/pytradfri/blob/63750fa8fb27158c013d24865cdaa7fb82b3ab53/pytradfri/api/aiocoap_api.py#L90-L109
async def _get_response(self, msg): """Perform the request, get the response.""" try: protocol = await self._get_protocol() pr = protocol.request(msg) r = await pr.response return pr, r except ConstructionRenderableError as e: raise Cli...
[ "async", "def", "_get_response", "(", "self", ",", "msg", ")", ":", "try", ":", "protocol", "=", "await", "self", ".", "_get_protocol", "(", ")", "pr", "=", "protocol", ".", "request", "(", "msg", ")", "r", "=", "await", "pr", ".", "response", "retur...
Perform the request, get the response.
[ "Perform", "the", "request", "get", "the", "response", "." ]
python
train
43.45
dnanexus/dx-toolkit
src/python/dxpy/api.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L251-L257
def applet_describe(object_id, input_params={}, always_retry=True, **kwargs): """ Invokes the /applet-xxxx/describe API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Applets-and-Entry-Points#API-method%3A-%2Fapplet-xxxx%2Fdescribe """ return DXHTTPRequest('/%s/descr...
[ "def", "applet_describe", "(", "object_id", ",", "input_params", "=", "{", "}", ",", "always_retry", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "DXHTTPRequest", "(", "'/%s/describe'", "%", "object_id", ",", "input_params", ",", "always_retry", ...
Invokes the /applet-xxxx/describe API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Applets-and-Entry-Points#API-method%3A-%2Fapplet-xxxx%2Fdescribe
[ "Invokes", "the", "/", "applet", "-", "xxxx", "/", "describe", "API", "method", "." ]
python
train
54.571429
twilio/twilio-python
twilio/base/page.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/base/page.py#L81-L90
def previous_page_url(self): """ :return str: Returns a link to the previous_page_url or None if doesn't exist. """ if 'meta' in self._payload and 'previous_page_url' in self._payload['meta']: return self._payload['meta']['previous_page_url'] elif 'previous_page_uri' ...
[ "def", "previous_page_url", "(", "self", ")", ":", "if", "'meta'", "in", "self", ".", "_payload", "and", "'previous_page_url'", "in", "self", ".", "_payload", "[", "'meta'", "]", ":", "return", "self", ".", "_payload", "[", "'meta'", "]", "[", "'previous_p...
:return str: Returns a link to the previous_page_url or None if doesn't exist.
[ ":", "return", "str", ":", "Returns", "a", "link", "to", "the", "previous_page_url", "or", "None", "if", "doesn", "t", "exist", "." ]
python
train
47.7
trec-kba/streamcorpus-pipeline
streamcorpus_pipeline/_spinn3r_feed_storage.py
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L301-L332
def _make_content_item(node, mime_type=None, alternate_data=None): """Create a ContentItem from a node in the spinn3r data tree. The ContentItem is created with raw data set to ``node.data``, decompressed if the node's encoding is 'zlib', and UTF-8 normalized, with a MIME type from ``node.mime_type``. ...
[ "def", "_make_content_item", "(", "node", ",", "mime_type", "=", "None", ",", "alternate_data", "=", "None", ")", ":", "raw", "=", "node", ".", "data", "if", "getattr", "(", "node", ",", "'encoding'", ",", "None", ")", "==", "'zlib'", ":", "try", ":", ...
Create a ContentItem from a node in the spinn3r data tree. The ContentItem is created with raw data set to ``node.data``, decompressed if the node's encoding is 'zlib', and UTF-8 normalized, with a MIME type from ``node.mime_type``. ``node`` the actual node from the spinn3r protobuf data ``m...
[ "Create", "a", "ContentItem", "from", "a", "node", "in", "the", "spinn3r", "data", "tree", "." ]
python
test
36.25
iotaledger/iota.lib.py
iota/adapter/sandbox.py
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/adapter/sandbox.py#L191-L205
def get_jobs_url(self, job_id): # type: (Text) -> Text """ Returns the URL to check job status. :param job_id: The ID of the job to check. """ return compat.urllib_parse.urlunsplit(( self.uri.scheme, self.uri.netloc, self.u...
[ "def", "get_jobs_url", "(", "self", ",", "job_id", ")", ":", "# type: (Text) -> Text", "return", "compat", ".", "urllib_parse", ".", "urlunsplit", "(", "(", "self", ".", "uri", ".", "scheme", ",", "self", ".", "uri", ".", "netloc", ",", "self", ".", "uri...
Returns the URL to check job status. :param job_id: The ID of the job to check.
[ "Returns", "the", "URL", "to", "check", "job", "status", "." ]
python
test
27.733333
Clinical-Genomics/scout
scout/server/blueprints/cases/views.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/server/blueprints/cases/views.py#L511-L551
def phenotypes_actions(institute_id, case_name): """Perform actions on multiple phenotypes.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) case_url = url_for('.case', institute_id=institute_id, case_name=case_name) action = request.form['action'] hpo_ids = request.fo...
[ "def", "phenotypes_actions", "(", "institute_id", ",", "case_name", ")", ":", "institute_obj", ",", "case_obj", "=", "institute_and_case", "(", "store", ",", "institute_id", ",", "case_name", ")", "case_url", "=", "url_for", "(", "'.case'", ",", "institute_id", ...
Perform actions on multiple phenotypes.
[ "Perform", "actions", "on", "multiple", "phenotypes", "." ]
python
test
47.878049
sv0/django-markdown-app
django_markdown/templatetags/django_markdown.py
https://github.com/sv0/django-markdown-app/blob/973968c68d79cbe35304e9d6da876ad33f427d2d/django_markdown/templatetags/django_markdown.py#L96-L110
def markdown_media_css(): """ Add css requirements to HTML. :returns: Editor template context. """ return dict( CSS_SET=posixpath.join( settings.MARKDOWN_SET_PATH, settings.MARKDOWN_SET_NAME, 'style.css' ), CSS_SKIN=posixpath.join( 'django_markdown', 'sk...
[ "def", "markdown_media_css", "(", ")", ":", "return", "dict", "(", "CSS_SET", "=", "posixpath", ".", "join", "(", "settings", ".", "MARKDOWN_SET_PATH", ",", "settings", ".", "MARKDOWN_SET_NAME", ",", "'style.css'", ")", ",", "CSS_SKIN", "=", "posixpath", ".", ...
Add css requirements to HTML. :returns: Editor template context.
[ "Add", "css", "requirements", "to", "HTML", "." ]
python
train
25.466667
chaoss/grimoirelab-perceval
perceval/backends/core/confluence.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/confluence.py#L221-L224
def _init_client(self, from_archive=False): """Init client""" return ConfluenceClient(self.url, archive=self.archive, from_archive=from_archive)
[ "def", "_init_client", "(", "self", ",", "from_archive", "=", "False", ")", ":", "return", "ConfluenceClient", "(", "self", ".", "url", ",", "archive", "=", "self", ".", "archive", ",", "from_archive", "=", "from_archive", ")" ]
Init client
[ "Init", "client" ]
python
test
39.5
Spinmob/spinmob
egg/_temporary_fixes.py
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L251-L259
def value(self): """ Return the value of this SpinBox. """ if self.opts['int']: return int(self.val) else: return float(self.val)
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "opts", "[", "'int'", "]", ":", "return", "int", "(", "self", ".", "val", ")", "else", ":", "return", "float", "(", "self", ".", "val", ")" ]
Return the value of this SpinBox.
[ "Return", "the", "value", "of", "this", "SpinBox", "." ]
python
train
21.555556
JonathanRaiman/pytreebank
pytreebank/parse.py
https://github.com/JonathanRaiman/pytreebank/blob/7b4c671d3dff661cc3677e54db817e50c5a1c666/pytreebank/parse.py#L112-L124
def labels(self): """ Construct a dictionary of string -> labels Returns: -------- OrderedDict<str, int> : string label pairs. """ labelings = OrderedDict() for tree in self: for label, line in tree.to_labeled_lines(): labe...
[ "def", "labels", "(", "self", ")", ":", "labelings", "=", "OrderedDict", "(", ")", "for", "tree", "in", "self", ":", "for", "label", ",", "line", "in", "tree", ".", "to_labeled_lines", "(", ")", ":", "labelings", "[", "line", "]", "=", "label", "retu...
Construct a dictionary of string -> labels Returns: -------- OrderedDict<str, int> : string label pairs.
[ "Construct", "a", "dictionary", "of", "string", "-", ">", "labels" ]
python
train
27.076923
sffjunkie/astral
src/astral.py
https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1390-L1412
def moon_phase(self, date=None, rtype=int): """Calculates the moon phase for a specific date. :param date: The date to calculate the phase for. If ommitted the current date is used. :type date: :class:`datetime.date` :returns: A number designating the p...
[ "def", "moon_phase", "(", "self", ",", "date", "=", "None", ",", "rtype", "=", "int", ")", ":", "if", "self", ".", "astral", "is", "None", ":", "self", ".", "astral", "=", "Astral", "(", ")", "if", "date", "is", "None", ":", "date", "=", "datetim...
Calculates the moon phase for a specific date. :param date: The date to calculate the phase for. If ommitted the current date is used. :type date: :class:`datetime.date` :returns: A number designating the phase | 0 = New moon |...
[ "Calculates", "the", "moon", "phase", "for", "a", "specific", "date", "." ]
python
train
27.826087
jborean93/ntlm-auth
ntlm_auth/compute_hash.py
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_hash.py#L12-L45
def _lmowfv1(password): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as LMOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authen...
[ "def", "_lmowfv1", "(", "password", ")", ":", "# if the password is a hash, return the LM hash", "if", "re", ".", "match", "(", "r'^[a-fA-F\\d]{32}:[a-fA-F\\d]{32}$'", ",", "password", ")", ":", "lm_hash", "=", "binascii", ".", "unhexlify", "(", "password", ".", "sp...
[MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as LMOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authenticate with :return res: A Lan M...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
python
train
31.352941
openvax/pyensembl
pyensembl/ensembl_release.py
https://github.com/openvax/pyensembl/blob/4b995fb72e848206d6fbf11950cf30964cd9b3aa/pyensembl/ensembl_release.py#L38-L45
def normalize_init_values(cls, release, species, server): """ Normalizes the arguments which uniquely specify an EnsemblRelease genome. """ release = check_release_number(release) species = check_species_object(species) return (release, species, server)
[ "def", "normalize_init_values", "(", "cls", ",", "release", ",", "species", ",", "server", ")", ":", "release", "=", "check_release_number", "(", "release", ")", "species", "=", "check_species_object", "(", "species", ")", "return", "(", "release", ",", "speci...
Normalizes the arguments which uniquely specify an EnsemblRelease genome.
[ "Normalizes", "the", "arguments", "which", "uniquely", "specify", "an", "EnsemblRelease", "genome", "." ]
python
train
37.75
RudolfCardinal/pythonlib
cardinal_pythonlib/sqlalchemy/orm_inspect.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/orm_inspect.py#L240-L288
def copy_sqla_object(obj: object, omit_fk: bool = True, omit_pk: bool = True, omit_attrs: List[str] = None, debug: bool = False) -> object: """ Given an SQLAlchemy object, creates a new object (FOR WHICH THE OBJECT MUST SUPP...
[ "def", "copy_sqla_object", "(", "obj", ":", "object", ",", "omit_fk", ":", "bool", "=", "True", ",", "omit_pk", ":", "bool", "=", "True", ",", "omit_attrs", ":", "List", "[", "str", "]", "=", "None", ",", "debug", ":", "bool", "=", "False", ")", "-...
Given an SQLAlchemy object, creates a new object (FOR WHICH THE OBJECT MUST SUPPORT CREATION USING ``__init__()`` WITH NO PARAMETERS), and copies across all attributes, omitting PKs (by default), FKs (by default), and relationship attributes (always omitted). Args: obj: the object to copy ...
[ "Given", "an", "SQLAlchemy", "object", "creates", "a", "new", "object", "(", "FOR", "WHICH", "THE", "OBJECT", "MUST", "SUPPORT", "CREATION", "USING", "__init__", "()", "WITH", "NO", "PARAMETERS", ")", "and", "copies", "across", "all", "attributes", "omitting",...
python
train
36.183673
juiceinc/recipe
recipe/core.py
https://github.com/juiceinc/recipe/blob/2e60c2242aeaea3029a2274b31bc3a937761e568/recipe/core.py#L276-L305
def filters(self, *filters): """ Add a list of Filter ingredients to the query. These can either be Filter objects or strings representing filters on the service's shelf. ``.filters()`` are additive, calling .filters() more than once will add to the list of filters being used by ...
[ "def", "filters", "(", "self", ",", "*", "filters", ")", ":", "def", "filter_constructor", "(", "f", ",", "shelf", "=", "None", ")", ":", "if", "isinstance", "(", "f", ",", "BinaryExpression", ")", ":", "return", "Filter", "(", "f", ")", "else", ":",...
Add a list of Filter ingredients to the query. These can either be Filter objects or strings representing filters on the service's shelf. ``.filters()`` are additive, calling .filters() more than once will add to the list of filters being used by the recipe. The Filter expression will b...
[ "Add", "a", "list", "of", "Filter", "ingredients", "to", "the", "query", ".", "These", "can", "either", "be", "Filter", "objects", "or", "strings", "representing", "filters", "on", "the", "service", "s", "shelf", ".", ".", "filters", "()", "are", "additive...
python
train
33.266667
keenlabs/KeenClient-Python
keen/saved_queries.py
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/saved_queries.py#L48-L58
def results(self, query_name): """ Gets a single saved query with a 'result' object for a project from the Keen IO API given a query name. Read or Master key must be set. """ url = "{0}/{1}/result".format(self.saved_query_url, query_name) response = self._get_jso...
[ "def", "results", "(", "self", ",", "query_name", ")", ":", "url", "=", "\"{0}/{1}/result\"", ".", "format", "(", "self", ".", "saved_query_url", ",", "query_name", ")", "response", "=", "self", ".", "_get_json", "(", "HTTPMethods", ".", "GET", ",", "url",...
Gets a single saved query with a 'result' object for a project from the Keen IO API given a query name. Read or Master key must be set.
[ "Gets", "a", "single", "saved", "query", "with", "a", "result", "object", "for", "a", "project", "from", "the", "Keen", "IO", "API", "given", "a", "query", "name", ".", "Read", "or", "Master", "key", "must", "be", "set", "." ]
python
train
34.545455
google/grr
grr/server/grr_response_server/aff4_objects/filestore.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/aff4_objects/filestore.py#L282-L336
def _HashFile(self, fd): """Look for the required hashes in the file.""" hashes = data_store_utils.GetFileHashEntry(fd) if hashes: found_all = True for fingerprint_type, hash_types in iteritems(self.HASH_TYPES): for hash_type in hash_types: if fingerprint_type == "pecoff": ...
[ "def", "_HashFile", "(", "self", ",", "fd", ")", ":", "hashes", "=", "data_store_utils", ".", "GetFileHashEntry", "(", "fd", ")", "if", "hashes", ":", "found_all", "=", "True", "for", "fingerprint_type", ",", "hash_types", "in", "iteritems", "(", "self", "...
Look for the required hashes in the file.
[ "Look", "for", "the", "required", "hashes", "in", "the", "file", "." ]
python
train
32.436364
seanpar203/event-bus
event_bus/bus.py
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L73-L92
def on(self, event: str) -> Callable: """ Decorator for subscribing a function to a specific event. :param event: Name of the event to subscribe to. :type event: str :return: The outer function. :rtype: Callable """ def outer(func): self.add_event(f...
[ "def", "on", "(", "self", ",", "event", ":", "str", ")", "->", "Callable", ":", "def", "outer", "(", "func", ")", ":", "self", ".", "add_event", "(", "func", ",", "event", ")", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ...
Decorator for subscribing a function to a specific event. :param event: Name of the event to subscribe to. :type event: str :return: The outer function. :rtype: Callable
[ "Decorator", "for", "subscribing", "a", "function", "to", "a", "specific", "event", "." ]
python
train
23.75
project-rig/rig
rig/routing_table/utils.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/utils.py#L108-L198
def table_is_subset_of(entries_a, entries_b): """Check that every key matched by every entry in one table results in the same route when checked against the other table. For example, the table:: >>> from rig.routing_table import Routes >>> table = [ ... RoutingTableEntry({Route...
[ "def", "table_is_subset_of", "(", "entries_a", ",", "entries_b", ")", ":", "# Determine which bits we don't need to explicitly test for", "common_xs", "=", "get_common_xs", "(", "entries_b", ")", "# For every entry in the first table", "for", "entry", "in", "expand_entries", ...
Check that every key matched by every entry in one table results in the same route when checked against the other table. For example, the table:: >>> from rig.routing_table import Routes >>> table = [ ... RoutingTableEntry({Routes.north, Routes.north_east}, 0x0, 0xf), ... ...
[ "Check", "that", "every", "key", "matched", "by", "every", "entry", "in", "one", "table", "results", "in", "the", "same", "route", "when", "checked", "against", "the", "other", "table", "." ]
python
train
37.065934
codelv/enaml-native-cli
enamlnativecli/main.py
https://github.com/codelv/enaml-native-cli/blob/81d6faa7e3dd437956f661c512031e49c0d44b63/enamlnativecli/main.py#L1678-L1706
def _default_ctx(self): """ Return the package config or context and normalize some of the values """ if not self.in_app_directory: print("Warning: {} does not exist. Using the default.".format( self.package)) ctx = {} else: ...
[ "def", "_default_ctx", "(", "self", ")", ":", "if", "not", "self", ".", "in_app_directory", ":", "print", "(", "\"Warning: {} does not exist. Using the default.\"", ".", "format", "(", "self", ".", "package", ")", ")", "ctx", "=", "{", "}", "else", ":", "wit...
Return the package config or context and normalize some of the values
[ "Return", "the", "package", "config", "or", "context", "and", "normalize", "some", "of", "the", "values" ]
python
train
36.034483
JoelBender/bacpypes
py25/bacpypes/constructeddata.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/constructeddata.py#L1470-L1481
def cast_in(self, element): """encode the element into the internal tag list.""" if _debug: SequenceOfAny._debug("cast_in %r", element) # make sure it is a list if not isinstance(element, List): raise EncodingError("%r is not a list" % (element,)) t = TagList() ...
[ "def", "cast_in", "(", "self", ",", "element", ")", ":", "if", "_debug", ":", "SequenceOfAny", ".", "_debug", "(", "\"cast_in %r\"", ",", "element", ")", "# make sure it is a list", "if", "not", "isinstance", "(", "element", ",", "List", ")", ":", "raise", ...
encode the element into the internal tag list.
[ "encode", "the", "element", "into", "the", "internal", "tag", "list", "." ]
python
train
30.833333
theelous3/asks
asks/request_object.py
https://github.com/theelous3/asks/blob/ea522ea971ecb031d488a6301dc2718516cadcd6/asks/request_object.py#L710-L721
async def _body_callback(self, h11_connection): ''' A callback func to be supplied if the user wants to do something directly with the response body's stream. ''' # pylint: disable=not-callable while True: next_event = await self._recv_event(h11_connection) ...
[ "async", "def", "_body_callback", "(", "self", ",", "h11_connection", ")", ":", "# pylint: disable=not-callable", "while", "True", ":", "next_event", "=", "await", "self", ".", "_recv_event", "(", "h11_connection", ")", "if", "isinstance", "(", "next_event", ",", ...
A callback func to be supplied if the user wants to do something directly with the response body's stream.
[ "A", "callback", "func", "to", "be", "supplied", "if", "the", "user", "wants", "to", "do", "something", "directly", "with", "the", "response", "body", "s", "stream", "." ]
python
train
38.333333
bram85/topydo
topydo/ui/columns/TodoWidget.py
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/TodoWidget.py#L164-L195
def create(p_class, p_todo, p_id_width=4): """ Creates a TodoWidget instance for the given todo. Widgets are cached, the same object is returned for the same todo item. """ def parent_progress_may_have_changed(p_todo): """ Returns True when a todo's progr...
[ "def", "create", "(", "p_class", ",", "p_todo", ",", "p_id_width", "=", "4", ")", ":", "def", "parent_progress_may_have_changed", "(", "p_todo", ")", ":", "\"\"\"\n Returns True when a todo's progress should be updated because it is\n dependent on the parent...
Creates a TodoWidget instance for the given todo. Widgets are cached, the same object is returned for the same todo item.
[ "Creates", "a", "TodoWidget", "instance", "for", "the", "given", "todo", ".", "Widgets", "are", "cached", "the", "same", "object", "is", "returned", "for", "the", "same", "todo", "item", "." ]
python
train
35.5625
senaite/senaite.core
bika/lims/browser/workflow/analysisrequest.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/workflow/analysisrequest.py#L275-L286
def set_printed_time(self, sample): """Updates the printed time of the last results report from the sample """ if api.get_workflow_status_of(sample) != "published": return False reports = sample.objectValues("ARReport") reports = sorted(reports, key=lambda report: rep...
[ "def", "set_printed_time", "(", "self", ",", "sample", ")", ":", "if", "api", ".", "get_workflow_status_of", "(", "sample", ")", "!=", "\"published\"", ":", "return", "False", "reports", "=", "sample", ".", "objectValues", "(", "\"ARReport\"", ")", "reports", ...
Updates the printed time of the last results report from the sample
[ "Updates", "the", "printed", "time", "of", "the", "last", "results", "report", "from", "the", "sample" ]
python
train
44.666667
inasafe/inasafe
safe/gui/widgets/field_mapping_widget.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/widgets/field_mapping_widget.py#L88-L104
def get_field_mapping(self): """Obtain metadata from current state of the widget. :returns: Dictionary of values by type in this format: {'fields': {}, 'values': {}}. :rtype: dict """ fields = {} values = {} for tab in self.tabs: parameter...
[ "def", "get_field_mapping", "(", "self", ")", ":", "fields", "=", "{", "}", "values", "=", "{", "}", "for", "tab", "in", "self", ".", "tabs", ":", "parameter_values", "=", "tab", ".", "get_parameter_value", "(", ")", "fields", ".", "update", "(", "para...
Obtain metadata from current state of the widget. :returns: Dictionary of values by type in this format: {'fields': {}, 'values': {}}. :rtype: dict
[ "Obtain", "metadata", "from", "current", "state", "of", "the", "widget", "." ]
python
train
31.352941
gtaylor/python-colormath
examples/conversions.py
https://github.com/gtaylor/python-colormath/blob/1d168613718d2d7d31ec4230524e987ef66823c7/examples/conversions.py#L17-L30
def example_lab_to_xyz(): """ This function shows a simple conversion of an Lab color to an XYZ color. """ print("=== Simple Example: Lab->XYZ ===") # Instantiate an Lab color object with the given values. lab = LabColor(0.903, 16.296, -2.22) # Show a string representation. print(lab) ...
[ "def", "example_lab_to_xyz", "(", ")", ":", "print", "(", "\"=== Simple Example: Lab->XYZ ===\"", ")", "# Instantiate an Lab color object with the given values.", "lab", "=", "LabColor", "(", "0.903", ",", "16.296", ",", "-", "2.22", ")", "# Show a string representation.", ...
This function shows a simple conversion of an Lab color to an XYZ color.
[ "This", "function", "shows", "a", "simple", "conversion", "of", "an", "Lab", "color", "to", "an", "XYZ", "color", "." ]
python
train
29.714286
saltstack/salt
salt/modules/inspectlib/collector.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/collector.py#L126-L152
def __get_cfg_pkgs_rpm(self): ''' Get packages with configuration files on RPM systems. ''' out, err = self._syscall('rpm', None, None, '-qa', '--configfiles', '--queryformat', '%{name}-%{version}-%{release}\\n') data = dict() pkg_name = N...
[ "def", "__get_cfg_pkgs_rpm", "(", "self", ")", ":", "out", ",", "err", "=", "self", ".", "_syscall", "(", "'rpm'", ",", "None", ",", "None", ",", "'-qa'", ",", "'--configfiles'", ",", "'--queryformat'", ",", "'%{name}-%{version}-%{release}\\\\n'", ")", "data",...
Get packages with configuration files on RPM systems.
[ "Get", "packages", "with", "configuration", "files", "on", "RPM", "systems", "." ]
python
train
31.703704
tanghaibao/jcvi
jcvi/apps/gbsubmit.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/gbsubmit.py#L125-L175
def fcs(args): """ %prog fcs fcsfile Process the results from Genbank contaminant screen. An example of the file looks like: contig name, length, span(s), apparent source contig0746 11760 1..141 vector contig0751 14226 13476..14226 vector contig0800 124133 30512...
[ "def", "fcs", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "fcs", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--cutoff\"", ",", "default", "=", "200", ",", "help", "=", "\"Skip small components less than [default: %default]\"", ")", "opts", ...
%prog fcs fcsfile Process the results from Genbank contaminant screen. An example of the file looks like: contig name, length, span(s), apparent source contig0746 11760 1..141 vector contig0751 14226 13476..14226 vector contig0800 124133 30512..30559 primer/adapter
[ "%prog", "fcs", "fcsfile" ]
python
train
28.156863
ArchiveTeam/wpull
wpull/warc/recorder.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/warc/recorder.py#L595-L623
def _record_revisit(self, payload_offset: int): '''Record the revisit if possible.''' fields = self._response_record.fields ref_record_id = self._url_table.get_revisit_id( fields['WARC-Target-URI'], fields.get('WARC-Payload-Digest', '').upper().replace('SHA1:', '') ...
[ "def", "_record_revisit", "(", "self", ",", "payload_offset", ":", "int", ")", ":", "fields", "=", "self", ".", "_response_record", ".", "fields", "ref_record_id", "=", "self", ".", "_url_table", ".", "get_revisit_id", "(", "fields", "[", "'WARC-Target-URI'", ...
Record the revisit if possible.
[ "Record", "the", "revisit", "if", "possible", "." ]
python
train
38.137931
mikedh/trimesh
trimesh/path/packing.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/packing.py#L178-L222
def pack_paths(paths, sheet_size=None): """ Pack a list of Path2D objects into a rectangle. Parameters ------------ paths: (n,) Path2D Geometry to be packed Returns ------------ packed : trimesh.path.Path2D Object containing input geometry inserted : (m,) int Inde...
[ "def", "pack_paths", "(", "paths", ",", "sheet_size", "=", "None", ")", ":", "from", ".", "util", "import", "concatenate", "if", "sheet_size", "is", "not", "None", ":", "sheet_size", "=", "np", ".", "sort", "(", "sheet_size", ")", "[", ":", ":", "-", ...
Pack a list of Path2D objects into a rectangle. Parameters ------------ paths: (n,) Path2D Geometry to be packed Returns ------------ packed : trimesh.path.Path2D Object containing input geometry inserted : (m,) int Indexes of paths inserted into result
[ "Pack", "a", "list", "of", "Path2D", "objects", "into", "a", "rectangle", "." ]
python
train
26.622222
humilis/humilis-lambdautils
lambdautils/state.py
https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/state.py#L395-L401
def get_context(namespace, context_id): """Get stored context object.""" context_obj = get_state(context_id, namespace=namespace) if not context_obj: raise ContextError("Context '{}' not found in namespace '{}'".format( context_id, namespace)) return context_obj
[ "def", "get_context", "(", "namespace", ",", "context_id", ")", ":", "context_obj", "=", "get_state", "(", "context_id", ",", "namespace", "=", "namespace", ")", "if", "not", "context_obj", ":", "raise", "ContextError", "(", "\"Context '{}' not found in namespace '{...
Get stored context object.
[ "Get", "stored", "context", "object", "." ]
python
train
41.714286
openbermuda/ripl
ripl/md2slides.py
https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/md2slides.py#L62-L109
def generate_slides(self, infile): """ Process a file of rest and yield dictionaries """ state = 0 # each slide is a dict slide = {} last_heading = 0 for item in self.generate_lines(infile): line = item['line'] heading = item['heading'] ...
[ "def", "generate_slides", "(", "self", ",", "infile", ")", ":", "state", "=", "0", "# each slide is a dict", "slide", "=", "{", "}", "last_heading", "=", "0", "for", "item", "in", "self", ".", "generate_lines", "(", "infile", ")", ":", "line", "=", "item...
Process a file of rest and yield dictionaries
[ "Process", "a", "file", "of", "rest", "and", "yield", "dictionaries" ]
python
train
25.729167
genialis/resolwe
resolwe/elastic/builder.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/elastic/builder.py#L45-L51
def _get_cache_key(self, obj): """Derive cache key for given object.""" if obj is not None: # Make sure that key is REALLY unique. return '{}-{}'.format(id(self), obj.pk) return "{}-None".format(id(self))
[ "def", "_get_cache_key", "(", "self", ",", "obj", ")", ":", "if", "obj", "is", "not", "None", ":", "# Make sure that key is REALLY unique.", "return", "'{}-{}'", ".", "format", "(", "id", "(", "self", ")", ",", "obj", ".", "pk", ")", "return", "\"{}-None\"...
Derive cache key for given object.
[ "Derive", "cache", "key", "for", "given", "object", "." ]
python
train
35.285714
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msvs.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msvs.py#L1752-L1856
def projectEmitter(target, source, env): """Sets up the DSP dependencies.""" # todo: Not sure what sets source to what user has passed as target, # but this is what happens. When that is fixed, we also won't have # to make the user always append env['MSVSPROJECTSUFFIX'] to target. if source[0] == t...
[ "def", "projectEmitter", "(", "target", ",", "source", ",", "env", ")", ":", "# todo: Not sure what sets source to what user has passed as target,", "# but this is what happens. When that is fixed, we also won't have", "# to make the user always append env['MSVSPROJECTSUFFIX'] to target.", ...
Sets up the DSP dependencies.
[ "Sets", "up", "the", "DSP", "dependencies", "." ]
python
train
47.466667
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/win32/kernel32.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/win32/kernel32.py#L726-L740
def wait(self, dwMilliseconds = None): """ Wait for the Win32 object to be signaled. @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout value in milliseconds. Use C{INFINITE} or C{None} for no timeout. """ if self.value is None: ...
[ "def", "wait", "(", "self", ",", "dwMilliseconds", "=", "None", ")", ":", "if", "self", ".", "value", "is", "None", ":", "raise", "ValueError", "(", "\"Handle is already closed!\"", ")", "if", "dwMilliseconds", "is", "None", ":", "dwMilliseconds", "=", "INFI...
Wait for the Win32 object to be signaled. @type dwMilliseconds: int @param dwMilliseconds: (Optional) Timeout value in milliseconds. Use C{INFINITE} or C{None} for no timeout.
[ "Wait", "for", "the", "Win32", "object", "to", "be", "signaled", "." ]
python
train
36.8
gwastro/pycbc
pycbc/io/record.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/io/record.py#L366-L465
def add_fields(input_array, arrays, names=None, assubarray=False): """Adds the given array(s) as new field(s) to the given input array. Returns a new instance of the input_array with the new fields added. Parameters ---------- input_array : instance of a numpy.ndarray or numpy recarray The ...
[ "def", "add_fields", "(", "input_array", ",", "arrays", ",", "names", "=", "None", ",", "assubarray", "=", "False", ")", ":", "if", "not", "isinstance", "(", "arrays", ",", "list", ")", ":", "arrays", "=", "[", "arrays", "]", "# ensure that all arrays in a...
Adds the given array(s) as new field(s) to the given input array. Returns a new instance of the input_array with the new fields added. Parameters ---------- input_array : instance of a numpy.ndarray or numpy recarray The array to to add the fields to. arrays : (list of) numpy array(s) ...
[ "Adds", "the", "given", "array", "(", "s", ")", "as", "new", "field", "(", "s", ")", "to", "the", "given", "input", "array", ".", "Returns", "a", "new", "instance", "of", "the", "input_array", "with", "the", "new", "fields", "added", "." ]
python
train
44.23
square/pylink
pylink/jlink.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L1589-L1621
def gpio_set(self, pins, states): """Sets the state for one or more user-controllable GPIOs. For each of the given pins, sets the the corresponding state based on the index. Args: self (JLink): the ``JLink`` instance pins (list): list of GPIO indices state...
[ "def", "gpio_set", "(", "self", ",", "pins", ",", "states", ")", ":", "if", "len", "(", "pins", ")", "!=", "len", "(", "states", ")", ":", "raise", "ValueError", "(", "'Length mismatch between pins and states.'", ")", "size", "=", "len", "(", "pins", ")"...
Sets the state for one or more user-controllable GPIOs. For each of the given pins, sets the the corresponding state based on the index. Args: self (JLink): the ``JLink`` instance pins (list): list of GPIO indices states (list): list of states to set Retu...
[ "Sets", "the", "state", "for", "one", "or", "more", "user", "-", "controllable", "GPIOs", "." ]
python
train
35.393939
numenta/htmresearch
htmresearch/frameworks/layers/l2_l4_network_creation.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/layers/l2_l4_network_creation.py#L296-L355
def createMultipleL4L2Columns(network, networkConfig): """ Create a network consisting of multiple columns. Each column contains one L4 and one L2, is identical in structure to the network created by createL4L2Column. In addition all the L2 columns are fully connected to each other through their lateral inpu...
[ "def", "createMultipleL4L2Columns", "(", "network", ",", "networkConfig", ")", ":", "# Create each column", "numCorticalColumns", "=", "networkConfig", "[", "\"numCorticalColumns\"", "]", "for", "i", "in", "xrange", "(", "numCorticalColumns", ")", ":", "networkConfigCop...
Create a network consisting of multiple columns. Each column contains one L4 and one L2, is identical in structure to the network created by createL4L2Column. In addition all the L2 columns are fully connected to each other through their lateral inputs. Region names have a column number appended as in externa...
[ "Create", "a", "network", "consisting", "of", "multiple", "columns", ".", "Each", "column", "contains", "one", "L4", "and", "one", "L2", "is", "identical", "in", "structure", "to", "the", "network", "created", "by", "createL4L2Column", ".", "In", "addition", ...
python
train
31.683333
mozilla/amo-validator
validator/contextgenerator.py
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/contextgenerator.py#L108-L120
def get_line(self, position): 'Returns the line number that the given string position is found on' datalen = len(self.data) count = len(self.data[0]) line = 1 while count < position: if line >= datalen: break count += len(self.data[line]) ...
[ "def", "get_line", "(", "self", ",", "position", ")", ":", "datalen", "=", "len", "(", "self", ".", "data", ")", "count", "=", "len", "(", "self", ".", "data", "[", "0", "]", ")", "line", "=", "1", "while", "count", "<", "position", ":", "if", ...
Returns the line number that the given string position is found on
[ "Returns", "the", "line", "number", "that", "the", "given", "string", "position", "is", "found", "on" ]
python
train
27.230769
F5Networks/f5-common-python
f5/bigip/resource.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/bigip/resource.py#L783-L819
def get_collection(self, **kwargs): """Get an iterator of Python ``Resource`` objects that represent URIs. The returned objects are Pythonic `Resource`s that map to the most recently `refreshed` state of uris-resources published by the device. In order to instantiate the correct types, ...
[ "def", "get_collection", "(", "self", ",", "*", "*", "kwargs", ")", ":", "list_of_contents", "=", "[", "]", "self", ".", "refresh", "(", "*", "*", "kwargs", ")", "if", "'items'", "in", "self", ".", "__dict__", ":", "for", "item", "in", "self", ".", ...
Get an iterator of Python ``Resource`` objects that represent URIs. The returned objects are Pythonic `Resource`s that map to the most recently `refreshed` state of uris-resources published by the device. In order to instantiate the correct types, the concrete subclass must populate its...
[ "Get", "an", "iterator", "of", "Python", "Resource", "objects", "that", "represent", "URIs", "." ]
python
train
45.945946
learningequality/iceqube
src/iceqube/storage/backends/inmem.py
https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L93-L116
def schedule_job(self, j): """ Add the job given by j to the job queue. Note: Does not actually run the job. """ job_id = uuid.uuid4().hex j.job_id = job_id session = self.sessionmaker() orm_job = ORMJob( id=job_id, state=j.state,...
[ "def", "schedule_job", "(", "self", ",", "j", ")", ":", "job_id", "=", "uuid", ".", "uuid4", "(", ")", ".", "hex", "j", ".", "job_id", "=", "job_id", "session", "=", "self", ".", "sessionmaker", "(", ")", "orm_job", "=", "ORMJob", "(", "id", "=", ...
Add the job given by j to the job queue. Note: Does not actually run the job.
[ "Add", "the", "job", "given", "by", "j", "to", "the", "job", "queue", "." ]
python
train
25.125
openego/eDisGo
edisgo/grid/network.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/network.py#L2035-L2054
def _check_timeindex(self, timeseries): """ Raises an error if time index of storage time series does not comply with the time index of load and feed-in time series. Parameters ----------- timeseries : :pandas:`pandas.DataFrame<dataframe>` DataFrame containin...
[ "def", "_check_timeindex", "(", "self", ",", "timeseries", ")", ":", "try", ":", "timeseries", ".", "loc", "[", "self", ".", "edisgo", ".", "network", ".", "timeseries", ".", "timeindex", "]", "except", ":", "message", "=", "'Time index of storage time series ...
Raises an error if time index of storage time series does not comply with the time index of load and feed-in time series. Parameters ----------- timeseries : :pandas:`pandas.DataFrame<dataframe>` DataFrame containing active power the storage is charged (negative) ...
[ "Raises", "an", "error", "if", "time", "index", "of", "storage", "time", "series", "does", "not", "comply", "with", "the", "time", "index", "of", "load", "and", "feed", "-", "in", "time", "series", "." ]
python
train
39.1
aio-libs/yarl
yarl/__init__.py
https://github.com/aio-libs/yarl/blob/e47da02c00ad764e030ca7647a9565548c97d362/yarl/__init__.py#L873-L891
def with_query(self, *args, **kwargs): """Return a new URL with query part replaced. Accepts any Mapping (e.g. dict, multidict.MultiDict instances) or str, autoencode the argument if needed. A sequence of (key, value) pairs is supported as well. It also can take an arbitrary n...
[ "def", "with_query", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# N.B. doesn't cleanup query/fragment", "new_query", "=", "self", ".", "_get_str_query", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "URL", "(", "self", ...
Return a new URL with query part replaced. Accepts any Mapping (e.g. dict, multidict.MultiDict instances) or str, autoencode the argument if needed. A sequence of (key, value) pairs is supported as well. It also can take an arbitrary number of keyword arguments. Clear query i...
[ "Return", "a", "new", "URL", "with", "query", "part", "replaced", "." ]
python
train
31.526316
emory-libraries/eulfedora
eulfedora/views.py
https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/views.py#L175-L360
def raw_datastream_old(request, pid, dsid, type=None, repo=None, headers=None, accept_range_request=False, as_of_date=None, streaming=False): ''' .. NOTE:: This version of :meth:`raw_datastream` is deprecated, and you should update to the new :meth:...
[ "def", "raw_datastream_old", "(", "request", ",", "pid", ",", "dsid", ",", "type", "=", "None", ",", "repo", "=", "None", ",", "headers", "=", "None", ",", "accept_range_request", "=", "False", ",", "as_of_date", "=", "None", ",", "streaming", "=", "Fals...
.. NOTE:: This version of :meth:`raw_datastream` is deprecated, and you should update to the new :meth:`raw_datastream`. This version is still available if you are using a version of Fedora prior to 3.7 and need the additional functionality. View to display a raw datastream that b...
[ "..", "NOTE", "::" ]
python
train
43.650538
openstax/cnx-easybake
cnxeasybake/oven.py
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L709-L821
def eval_string_value(self, element, value): """Evaluate parsed string. Returns a list of current and delayed values. """ strval = '' vals = [] for term in value: if type(term) is ast.WhitespaceToken: pass elif type(term) is ast....
[ "def", "eval_string_value", "(", "self", ",", "element", ",", "value", ")", ":", "strval", "=", "''", "vals", "=", "[", "]", "for", "term", "in", "value", ":", "if", "type", "(", "term", ")", "is", "ast", ".", "WhitespaceToken", ":", "pass", "elif", ...
Evaluate parsed string. Returns a list of current and delayed values.
[ "Evaluate", "parsed", "string", "." ]
python
train
42.654867
alimanfoo/csvvalidator
csvvalidator.py
https://github.com/alimanfoo/csvvalidator/blob/50a86eefdc549c48f65a91a5c0a66099010ee65d/csvvalidator.py#L943-L955
def match_pattern(regex): """ Return a value check function which raises a ValueError if the value does not match the supplied regular expression, see also `re.match`. """ prog = re.compile(regex) def checker(v): result = prog.match(v) if result is None: raise Value...
[ "def", "match_pattern", "(", "regex", ")", ":", "prog", "=", "re", ".", "compile", "(", "regex", ")", "def", "checker", "(", "v", ")", ":", "result", "=", "prog", ".", "match", "(", "v", ")", "if", "result", "is", "None", ":", "raise", "ValueError"...
Return a value check function which raises a ValueError if the value does not match the supplied regular expression, see also `re.match`.
[ "Return", "a", "value", "check", "function", "which", "raises", "a", "ValueError", "if", "the", "value", "does", "not", "match", "the", "supplied", "regular", "expression", "see", "also", "re", ".", "match", "." ]
python
valid
25.769231