repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
openstates/billy
billy/importers/utils.py
https://github.com/openstates/billy/blob/5fc795347f12a949e410a8cfad0c911ea6bced67/billy/importers/utils.py#L199-L212
def split_name(obj): """ If the supplied legislator/person object is missing 'first_name' or 'last_name' then use name_tools to split. """ if obj['_type'] in ('person', 'legislator'): for key in ('first_name', 'last_name'): if key not in obj or not obj[key]: # Nee...
[ "def", "split_name", "(", "obj", ")", ":", "if", "obj", "[", "'_type'", "]", "in", "(", "'person'", ",", "'legislator'", ")", ":", "for", "key", "in", "(", "'first_name'", ",", "'last_name'", ")", ":", "if", "key", "not", "in", "obj", "or", "not", ...
If the supplied legislator/person object is missing 'first_name' or 'last_name' then use name_tools to split.
[ "If", "the", "supplied", "legislator", "/", "person", "object", "is", "missing", "first_name", "or", "last_name", "then", "use", "name_tools", "to", "split", "." ]
python
train
graphql-python/graphql-core
graphql/execution/executor.py
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/execution/executor.py#L630-L676
def complete_abstract_value( exe_context, # type: ExecutionContext return_type, # type: Union[GraphQLInterfaceType, GraphQLUnionType] field_asts, # type: List[Field] info, # type: ResolveInfo path, # type: List[Union[int, str]] result, # type: Any ): # type: (...) -> Dict[str, Any] ...
[ "def", "complete_abstract_value", "(", "exe_context", ",", "# type: ExecutionContext", "return_type", ",", "# type: Union[GraphQLInterfaceType, GraphQLUnionType]", "field_asts", ",", "# type: List[Field]", "info", ",", "# type: ResolveInfo", "path", ",", "# type: List[Union[int, st...
Complete an value of an abstract type by determining the runtime type of that value, then completing based on that type.
[ "Complete", "an", "value", "of", "an", "abstract", "type", "by", "determining", "the", "runtime", "type", "of", "that", "value", "then", "completing", "based", "on", "that", "type", "." ]
python
train
mozilla-iot/webthing-python
webthing/thing.py
https://github.com/mozilla-iot/webthing-python/blob/65d467c89ed79d0bbc42b8b3c8f9e5a320edd237/webthing/thing.py#L442-L457
def action_notify(self, action): """ Notify all subscribers of an action status change. action -- the action whose status changed """ message = json.dumps({ 'messageType': 'actionStatus', 'data': action.as_action_description(), }) for sub...
[ "def", "action_notify", "(", "self", ",", "action", ")", ":", "message", "=", "json", ".", "dumps", "(", "{", "'messageType'", ":", "'actionStatus'", ",", "'data'", ":", "action", ".", "as_action_description", "(", ")", ",", "}", ")", "for", "subscriber", ...
Notify all subscribers of an action status change. action -- the action whose status changed
[ "Notify", "all", "subscribers", "of", "an", "action", "status", "change", "." ]
python
test
jlmadurga/permabots
permabots/views/api/handler.py
https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/api/handler.py#L159-L168
def get(self, request, bot_id, id, format=None): """ Get list of header parameters of a handler --- serializer: AbsParamSerializer responseMessages: - code: 401 message: Not authenticated """ return super(HeaderParameterList, self).get(re...
[ "def", "get", "(", "self", ",", "request", ",", "bot_id", ",", "id", ",", "format", "=", "None", ")", ":", "return", "super", "(", "HeaderParameterList", ",", "self", ")", ".", "get", "(", "request", ",", "bot_id", ",", "id", ",", "format", ")" ]
Get list of header parameters of a handler --- serializer: AbsParamSerializer responseMessages: - code: 401 message: Not authenticated
[ "Get", "list", "of", "header", "parameters", "of", "a", "handler", "---", "serializer", ":", "AbsParamSerializer", "responseMessages", ":", "-", "code", ":", "401", "message", ":", "Not", "authenticated" ]
python
train
nickoala/telepot
telepot/__init__.py
https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L961-L967
def addStickerToSet(self, user_id, name, png_sticker, emojis, mask_position=None): """ See: https://core.telegram.org/bots/api#addstickertoset """ p = _strip(locals(), more=['png_sticker']) return self._api_request_with_file('addStickerToSet', _rectify(p),...
[ "def", "addStickerToSet", "(", "self", ",", "user_id", ",", "name", ",", "png_sticker", ",", "emojis", ",", "mask_position", "=", "None", ")", ":", "p", "=", "_strip", "(", "locals", "(", ")", ",", "more", "=", "[", "'png_sticker'", "]", ")", "return",...
See: https://core.telegram.org/bots/api#addstickertoset
[ "See", ":", "https", ":", "//", "core", ".", "telegram", ".", "org", "/", "bots", "/", "api#addstickertoset" ]
python
train
google/prettytensor
prettytensor/functions.py
https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/functions.py#L129-L146
def cos_distance(t1, t2, epsilon=1e-12, name=None): """Cos distance between t1 and t2 and caps the gradient of the Square Root. Args: t1: A tensor t2: A tensor that can be multiplied by t1. epsilon: A lower bound value for the distance. The square root is used as the normalizer. name: Optiona...
[ "def", "cos_distance", "(", "t1", ",", "t2", ",", "epsilon", "=", "1e-12", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "name", ",", "'cos_distance'", ",", "[", "t1", ",", "t2", "]", ")", "as", "scope", ":", "t1", "="...
Cos distance between t1 and t2 and caps the gradient of the Square Root. Args: t1: A tensor t2: A tensor that can be multiplied by t1. epsilon: A lower bound value for the distance. The square root is used as the normalizer. name: Optional name for this op. Returns: The cos distance betwe...
[ "Cos", "distance", "between", "t1", "and", "t2", "and", "caps", "the", "gradient", "of", "the", "Square", "Root", "." ]
python
train
cni/MRS
MRS/qc.py
https://github.com/cni/MRS/blob/16098b3cf4830780efd787fee9efa46513850283/MRS/qc.py#L11-L88
def motioncheck(ref_file, end_file, out_path=None, thres=5.0): """ Checks motion between structural scans of the same modality. Ideally obtained at the beginning and end of a scanning session. Parameters ---------- ref_file: nifti file Nifti file of first localizer acquired at the beg...
[ "def", "motioncheck", "(", "ref_file", ",", "end_file", ",", "out_path", "=", "None", ",", "thres", "=", "5.0", ")", ":", "ref", "=", "nib", ".", "load", "(", "ref_file", ")", "end", "=", "nib", ".", "load", "(", "end_file", ")", "ref_data", "=", "...
Checks motion between structural scans of the same modality. Ideally obtained at the beginning and end of a scanning session. Parameters ---------- ref_file: nifti file Nifti file of first localizer acquired at the beginning of the session end_file: nifti nifti file of the locali...
[ "Checks", "motion", "between", "structural", "scans", "of", "the", "same", "modality", ".", "Ideally", "obtained", "at", "the", "beginning", "and", "end", "of", "a", "scanning", "session", "." ]
python
train
Riffstation/flask-philo
flask_philo/views.py
https://github.com/Riffstation/flask-philo/blob/76c9d562edb4a77010c8da6dfdb6489fa29cbc9e/flask_philo/views.py#L49-L59
def template_response(self, template_name, headers={}, **values): """ Constructs a response, allowing custom template name and content_type """ response = make_response( self.render_template(template_name, **values)) for field, value in headers.items(): r...
[ "def", "template_response", "(", "self", ",", "template_name", ",", "headers", "=", "{", "}", ",", "*", "*", "values", ")", ":", "response", "=", "make_response", "(", "self", ".", "render_template", "(", "template_name", ",", "*", "*", "values", ")", ")...
Constructs a response, allowing custom template name and content_type
[ "Constructs", "a", "response", "allowing", "custom", "template", "name", "and", "content_type" ]
python
train
apache/incubator-heron
heron/tools/cli/src/python/submit.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/cli/src/python/submit.py#L253-L291
def submit_fatjar(cl_args, unknown_args, tmp_dir): ''' We use the packer to make a package for the jar and dump it to a well-known location. We then run the main method of class with the specified arguments. We pass arguments as an environment variable HERON_OPTIONS. This will run the jar file with the topol...
[ "def", "submit_fatjar", "(", "cl_args", ",", "unknown_args", ",", "tmp_dir", ")", ":", "# execute main of the topology to create the topology definition", "topology_file", "=", "cl_args", "[", "'topology-file-name'", "]", "main_class", "=", "cl_args", "[", "'topology-class-...
We use the packer to make a package for the jar and dump it to a well-known location. We then run the main method of class with the specified arguments. We pass arguments as an environment variable HERON_OPTIONS. This will run the jar file with the topology_class_name. The submitter inside will write out the t...
[ "We", "use", "the", "packer", "to", "make", "a", "package", "for", "the", "jar", "and", "dump", "it", "to", "a", "well", "-", "known", "location", ".", "We", "then", "run", "the", "main", "method", "of", "class", "with", "the", "specified", "arguments"...
python
valid
apache/incubator-heron
heron/tools/ui/src/python/handlers/topology.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/ui/src/python/handlers/topology.py#L99-L115
def get(self): ''' :return: ''' clusters = yield access.get_clusters() # pylint: disable=no-member options = dict( topologies=[], # no topologies clusters=[str(cluster) for cluster in clusters], active="topologies", # active icon the nav bar function=common.cla...
[ "def", "get", "(", "self", ")", ":", "clusters", "=", "yield", "access", ".", "get_clusters", "(", ")", "# pylint: disable=no-member", "options", "=", "dict", "(", "topologies", "=", "[", "]", ",", "# no topologies", "clusters", "=", "[", "str", "(", "clus...
:return:
[ ":", "return", ":" ]
python
valid
mitsei/dlkit
dlkit/handcar/osid/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/osid/sessions.py#L101-L109
def _init_object(self, catalog_id, proxy, runtime, cat_name, cat_class): """Initialize this object as an OsidObject....do we need this?? From the Mongo learning impl, but seems unnecessary for Handcar""" self._catalog_identifier = None self._init_proxy_and_runtime(proxy, runtime) ...
[ "def", "_init_object", "(", "self", ",", "catalog_id", ",", "proxy", ",", "runtime", ",", "cat_name", ",", "cat_class", ")", ":", "self", ".", "_catalog_identifier", "=", "None", "self", ".", "_init_proxy_and_runtime", "(", "proxy", ",", "runtime", ")", "sel...
Initialize this object as an OsidObject....do we need this?? From the Mongo learning impl, but seems unnecessary for Handcar
[ "Initialize", "this", "object", "as", "an", "OsidObject", "....", "do", "we", "need", "this??", "From", "the", "Mongo", "learning", "impl", "but", "seems", "unnecessary", "for", "Handcar" ]
python
train
WebarchivCZ/WA-KAT
src/wa_kat/settings.py
https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/settings.py#L108-L123
def _get_all_constants(): """ Get list of all uppercase, non-private globals (doesn't start with ``_``). Returns: list: Uppercase names defined in `globals()` (variables from this \ module). """ return [ key for key in globals().keys() if all([ not ...
[ "def", "_get_all_constants", "(", ")", ":", "return", "[", "key", "for", "key", "in", "globals", "(", ")", ".", "keys", "(", ")", "if", "all", "(", "[", "not", "key", ".", "startswith", "(", "\"_\"", ")", ",", "# publicly accesible", "key", ".", "upp...
Get list of all uppercase, non-private globals (doesn't start with ``_``). Returns: list: Uppercase names defined in `globals()` (variables from this \ module).
[ "Get", "list", "of", "all", "uppercase", "non", "-", "private", "globals", "(", "doesn", "t", "start", "with", "_", ")", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex_ti/tcex_ti.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/tcex_ti.py#L80-L92
def email_address(self, address, owner=None, **kwargs): """ Create the Email Address TI object. Args: owner: address: **kwargs: Return: """ return EmailAddress(self.tcex, address, owner=owner, **kwargs)
[ "def", "email_address", "(", "self", ",", "address", ",", "owner", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "EmailAddress", "(", "self", ".", "tcex", ",", "address", ",", "owner", "=", "owner", ",", "*", "*", "kwargs", ")" ]
Create the Email Address TI object. Args: owner: address: **kwargs: Return:
[ "Create", "the", "Email", "Address", "TI", "object", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17r_1_01a/load_balance_lag/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/load_balance_lag/__init__.py#L94-L115
def _set_load_balance(self, v, load=False): """ Setter method for load_balance, mapped from YANG variable /load_balance_lag/load_balance (container) If this variable is read-only (config: false) in the source YANG file, then _set_load_balance is considered as a private method. Backends looking to po...
[ "def", "_set_load_balance", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "b...
Setter method for load_balance, mapped from YANG variable /load_balance_lag/load_balance (container) If this variable is read-only (config: false) in the source YANG file, then _set_load_balance is considered as a private method. Backends looking to populate this variable should do so via calling thisOb...
[ "Setter", "method", "for", "load_balance", "mapped", "from", "YANG", "variable", "/", "load_balance_lag", "/", "load_balance", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source"...
python
train
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_db.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_db.py#L1615-L1647
def connect(self, engine: str = None, interface: str = None, host: str = None, port: int = None, database: str = None, driver: str = None, dsn: str = None, odbc_connection_string: str = None, ...
[ "def", "connect", "(", "self", ",", "engine", ":", "str", "=", "None", ",", "interface", ":", "str", "=", "None", ",", "host", ":", "str", "=", "None", ",", "port", ":", "int", "=", "None", ",", "database", ":", "str", "=", "None", ",", "driver",...
engine: access, mysql, sqlserver interface: mysql, odbc, jdbc
[ "engine", ":", "access", "mysql", "sqlserver", "interface", ":", "mysql", "odbc", "jdbc" ]
python
train
deepmipt/DeepPavlov
deeppavlov/core/common/params.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/common/params.py#L57-L115
def from_params(params: Dict, mode: str = 'infer', serialized: Any = None, **kwargs) -> Component: """Builds and returns the Component from corresponding dictionary of parameters.""" # what is passed in json: config_params = {k: _resolve(v) for k, v in params.items()} # get component by reference (if a...
[ "def", "from_params", "(", "params", ":", "Dict", ",", "mode", ":", "str", "=", "'infer'", ",", "serialized", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ")", "->", "Component", ":", "# what is passed in json:", "config_params", "=", "{", "k", ":",...
Builds and returns the Component from corresponding dictionary of parameters.
[ "Builds", "and", "returns", "the", "Component", "from", "corresponding", "dictionary", "of", "parameters", "." ]
python
test
casouri/launchdman
launchdman/__init__.py
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L337-L347
def remove(self, *l): ''' remove elements from self.value by matching. Create the exactly same single you want to delete and pass it(them) in. Normally this method needs to be overwrited by subclass. It only looks inside current instance's value, not recursive. There is no need for a recursive ...
[ "def", "remove", "(", "self", ",", "*", "l", ")", ":", "removeList", "=", "list", "(", "flatten", "(", "l", ")", ")", "self", ".", "_remove", "(", "removeList", ",", "self", ".", "value", ")" ]
remove elements from self.value by matching. Create the exactly same single you want to delete and pass it(them) in. Normally this method needs to be overwrited by subclass. It only looks inside current instance's value, not recursive. There is no need for a recursive one anyway. Args: ...
[ "remove", "elements", "from", "self", ".", "value", "by", "matching", "." ]
python
train
inveniosoftware/invenio-config
invenio_config/utils.py
https://github.com/inveniosoftware/invenio-config/blob/8d1e63ac045cd9c58a3399c6b58845e6daa06102/invenio_config/utils.py#L20-L62
def create_config_loader(config=None, env_prefix='APP'): """Create a default configuration loader. A configuration loader takes a Flask application and keyword arguments and updates the Flask application's configuration as it sees fit. This default configuration loader will load configuration in the f...
[ "def", "create_config_loader", "(", "config", "=", "None", ",", "env_prefix", "=", "'APP'", ")", ":", "def", "_config_loader", "(", "app", ",", "*", "*", "kwargs_config", ")", ":", "InvenioConfigEntryPointModule", "(", "app", "=", "app", ")", "if", "config",...
Create a default configuration loader. A configuration loader takes a Flask application and keyword arguments and updates the Flask application's configuration as it sees fit. This default configuration loader will load configuration in the following order: 1. Load configuration from ``inveni...
[ "Create", "a", "default", "configuration", "loader", "." ]
python
train
aliyun/aliyun-odps-python-sdk
odps/lib/tzlocal/win32.py
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/lib/tzlocal/win32.py#L99-L104
def reload_localzone(): """Reload the cached localzone. You need to call this if the timezone has changed.""" global _cache_tz _cache_tz = pytz.timezone(get_localzone_name()) utils.assert_tz_offset(_cache_tz) return _cache_tz
[ "def", "reload_localzone", "(", ")", ":", "global", "_cache_tz", "_cache_tz", "=", "pytz", ".", "timezone", "(", "get_localzone_name", "(", ")", ")", "utils", ".", "assert_tz_offset", "(", "_cache_tz", ")", "return", "_cache_tz" ]
Reload the cached localzone. You need to call this if the timezone has changed.
[ "Reload", "the", "cached", "localzone", ".", "You", "need", "to", "call", "this", "if", "the", "timezone", "has", "changed", "." ]
python
train
DataBiosphere/dsub
dsub/providers/google_base.py
https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/google_base.py#L577-L593
def execute(api): """Executes operation. Args: api: The base API object Returns: A response body object """ try: return api.execute() except Exception as exception: now = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') _print_error('%s: Exception %s: %s' % (now, ...
[ "def", "execute", "(", "api", ")", ":", "try", ":", "return", "api", ".", "execute", "(", ")", "except", "Exception", "as", "exception", ":", "now", "=", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y-%m-%d %H:%M:%S.%f'", ")", "_print_error...
Executes operation. Args: api: The base API object Returns: A response body object
[ "Executes", "operation", "." ]
python
valid
awslabs/sockeye
sockeye/decoder.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/decoder.py#L176-L191
def state_shapes(self, batch_size: int, target_max_length: int, source_encoded_max_length: int, source_encoded_depth: int) -> List[mx.io.DataDesc]: """ Returns a list of shape descriptions given batch size, encoded sourc...
[ "def", "state_shapes", "(", "self", ",", "batch_size", ":", "int", ",", "target_max_length", ":", "int", ",", "source_encoded_max_length", ":", "int", ",", "source_encoded_depth", ":", "int", ")", "->", "List", "[", "mx", ".", "io", ".", "DataDesc", "]", "...
Returns a list of shape descriptions given batch size, encoded source max length and encoded source depth. Used for inference. :param batch_size: Batch size during inference. :param target_max_length: Current target sequence length. :param source_encoded_max_length: Size of encoder time...
[ "Returns", "a", "list", "of", "shape", "descriptions", "given", "batch", "size", "encoded", "source", "max", "length", "and", "encoded", "source", "depth", ".", "Used", "for", "inference", "." ]
python
train
FulcrumTechnologies/pyconfluence
pyconfluence/api.py
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/api.py#L21-L36
def load_variables(): """Load variables from environment variables.""" if (not os.environ.get("PYCONFLUENCE_TOKEN") or not os.environ.get("PYCONFLUENCE_USER") or not os.environ.get("PYCONFLUENCE_ORG")): print ("One or more pyconfluence environment variables are not set. " ...
[ "def", "load_variables", "(", ")", ":", "if", "(", "not", "os", ".", "environ", ".", "get", "(", "\"PYCONFLUENCE_TOKEN\"", ")", "or", "not", "os", ".", "environ", ".", "get", "(", "\"PYCONFLUENCE_USER\"", ")", "or", "not", "os", ".", "environ", ".", "g...
Load variables from environment variables.
[ "Load", "variables", "from", "environment", "variables", "." ]
python
train
apache/incubator-heron
heron/tools/tracker/src/python/topology.py
https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/tracker/src/python/topology.py#L174-L191
def num_instances(self): """ Number of spouts + bolts """ num = 0 # Get all the components components = self.spouts() + self.bolts() # Get instances for each worker for component in components: config = component.comp.config for kvs in config.kvs: if kvs.key == api_...
[ "def", "num_instances", "(", "self", ")", ":", "num", "=", "0", "# Get all the components", "components", "=", "self", ".", "spouts", "(", ")", "+", "self", ".", "bolts", "(", ")", "# Get instances for each worker", "for", "component", "in", "components", ":",...
Number of spouts + bolts
[ "Number", "of", "spouts", "+", "bolts" ]
python
valid
MacHu-GWU/crawlib-project
crawlib/pipeline/mongodb/query_builder.py
https://github.com/MacHu-GWU/crawlib-project/blob/241516f2a7a0a32c692f7af35a1f44064e8ce1ab/crawlib/pipeline/mongodb/query_builder.py#L18-L42
def finished(finished_status, update_interval, status_key, edit_at_key): """ Create dict query for pymongo that getting all finished task. :param finished_status: int, status code that greater or equal than this will be considered as finished. :param updat...
[ "def", "finished", "(", "finished_status", ",", "update_interval", ",", "status_key", ",", "edit_at_key", ")", ":", "return", "{", "status_key", ":", "{", "\"$gte\"", ":", "finished_status", "}", ",", "edit_at_key", ":", "{", "\"$gte\"", ":", "x_seconds_before_n...
Create dict query for pymongo that getting all finished task. :param finished_status: int, status code that greater or equal than this will be considered as finished. :param update_interval: int, the record will be updated every x seconds. :param status_key: status code field key, support dot notat...
[ "Create", "dict", "query", "for", "pymongo", "that", "getting", "all", "finished", "task", "." ]
python
train
sammchardy/python-binance
binance/client.py
https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1798-L1835
def get_asset_details(self, **params): """Fetch details on assets. https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int :returns...
[ "def", "get_asset_details", "(", "self", ",", "*", "*", "params", ")", ":", "res", "=", "self", ".", "_request_withdraw_api", "(", "'get'", ",", "'assetDetail.html'", ",", "True", ",", "data", "=", "params", ")", "if", "not", "res", "[", "'success'", "]"...
Fetch details on assets. https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int :returns: API response .. code-block:: python ...
[ "Fetch", "details", "on", "assets", "." ]
python
train
teepark/junction
junction/hub.py
https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/hub.py#L378-L383
def add_peer(self, peer_addr): "Build a connection to the Hub at a given ``(host, port)`` address" peer = connection.Peer( self._ident, self._dispatcher, peer_addr, backend.Socket()) peer.start() self._started_peers[peer_addr] = peer
[ "def", "add_peer", "(", "self", ",", "peer_addr", ")", ":", "peer", "=", "connection", ".", "Peer", "(", "self", ".", "_ident", ",", "self", ".", "_dispatcher", ",", "peer_addr", ",", "backend", ".", "Socket", "(", ")", ")", "peer", ".", "start", "("...
Build a connection to the Hub at a given ``(host, port)`` address
[ "Build", "a", "connection", "to", "the", "Hub", "at", "a", "given", "(", "host", "port", ")", "address" ]
python
train
NASA-AMMOS/AIT-Core
ait/core/seq.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/seq.py#L720-L730
def location (self, pos): """Formats the location of the given SeqPos as: filename:line:col: """ result = '' if self.filename: result += self.filename + ':' if pos: result += str(pos) return result
[ "def", "location", "(", "self", ",", "pos", ")", ":", "result", "=", "''", "if", "self", ".", "filename", ":", "result", "+=", "self", ".", "filename", "+", "':'", "if", "pos", ":", "result", "+=", "str", "(", "pos", ")", "return", "result" ]
Formats the location of the given SeqPos as: filename:line:col:
[ "Formats", "the", "location", "of", "the", "given", "SeqPos", "as", ":" ]
python
train
MinchinWeb/colourettu
make_release.py
https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/make_release.py#L171-L196
def add_release_to_changelog(version): """Add release line at the top of the first list it finds Assumes your changelog in managed with `releases`""" temp_file = changelog_file().parent / ("~" + changelog_file().name) now = datetime.today() release_added = False with open(str(temp_file), 'w') a...
[ "def", "add_release_to_changelog", "(", "version", ")", ":", "temp_file", "=", "changelog_file", "(", ")", ".", "parent", "/", "(", "\"~\"", "+", "changelog_file", "(", ")", ".", "name", ")", "now", "=", "datetime", ".", "today", "(", ")", "release_added",...
Add release line at the top of the first list it finds Assumes your changelog in managed with `releases`
[ "Add", "release", "line", "at", "the", "top", "of", "the", "first", "list", "it", "finds" ]
python
train
Legobot/Legobot
Legobot/Connectors/IRC.py
https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/IRC.py#L133-L152
def on_welcome(self, c, e): """ This function runs when the bot successfully connects to the IRC server """ self.backoff = 1 # Assume we had a good connection. Reset backoff. if self.nickserv: if Utilities.isNotEmpty(self.nickserv_pass): self.identify...
[ "def", "on_welcome", "(", "self", ",", "c", ",", "e", ")", ":", "self", ".", "backoff", "=", "1", "# Assume we had a good connection. Reset backoff.", "if", "self", ".", "nickserv", ":", "if", "Utilities", ".", "isNotEmpty", "(", "self", ".", "nickserv_pass", ...
This function runs when the bot successfully connects to the IRC server
[ "This", "function", "runs", "when", "the", "bot", "successfully", "connects", "to", "the", "IRC", "server" ]
python
train
Blueqat/Blueqat
blueqat/gate.py
https://github.com/Blueqat/Blueqat/blob/2ac8592c79e7acf4f385d982af82fbd68dafa5cc/blueqat/gate.py#L354-L360
def slicing(args, length): """Internally used.""" if isinstance(args, tuple): for arg in args: yield from slicing_singlevalue(arg, length) else: yield from slicing_singlevalue(args, length)
[ "def", "slicing", "(", "args", ",", "length", ")", ":", "if", "isinstance", "(", "args", ",", "tuple", ")", ":", "for", "arg", "in", "args", ":", "yield", "from", "slicing_singlevalue", "(", "arg", ",", "length", ")", "else", ":", "yield", "from", "s...
Internally used.
[ "Internally", "used", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_monitoring.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/ietf_netconf_monitoring.py#L252-L265
def netconf_state_sessions_session_source_host(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") netconf_state = ET.SubElement(config, "netconf-state", xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring") sessions = ET.SubElement(netconf_state, "se...
[ "def", "netconf_state_sessions_session_source_host", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "netconf_state", "=", "ET", ".", "SubElement", "(", "config", ",", "\"netconf-state\"", ",", "xmln...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
apache/spark
python/pyspark/mllib/classification.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/classification.py#L657-L679
def train(cls, data, lambda_=1.0): """ Train a Naive Bayes model given an RDD of (label, features) vectors. This is the Multinomial NB (U{http://tinyurl.com/lsdw6p}) which can handle all kinds of discrete data. For example, by converting documents into TF-IDF vectors, i...
[ "def", "train", "(", "cls", ",", "data", ",", "lambda_", "=", "1.0", ")", ":", "first", "=", "data", ".", "first", "(", ")", "if", "not", "isinstance", "(", "first", ",", "LabeledPoint", ")", ":", "raise", "ValueError", "(", "\"`data` should be an RDD of...
Train a Naive Bayes model given an RDD of (label, features) vectors. This is the Multinomial NB (U{http://tinyurl.com/lsdw6p}) which can handle all kinds of discrete data. For example, by converting documents into TF-IDF vectors, it can be used for document classification. By m...
[ "Train", "a", "Naive", "Bayes", "model", "given", "an", "RDD", "of", "(", "label", "features", ")", "vectors", "." ]
python
train
manns/pyspread
pyspread/src/gui/_chart_dialog.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_chart_dialog.py#L630-L637
def OnDirectionChoice(self, event): """Direction choice event handler""" label = self.direction_choicectrl.GetItems()[event.GetSelection()] param = self.choice_label2param[label] self.attrs["direction"] = param post_command_event(self, self.DrawChartMsg)
[ "def", "OnDirectionChoice", "(", "self", ",", "event", ")", ":", "label", "=", "self", ".", "direction_choicectrl", ".", "GetItems", "(", ")", "[", "event", ".", "GetSelection", "(", ")", "]", "param", "=", "self", ".", "choice_label2param", "[", "label", ...
Direction choice event handler
[ "Direction", "choice", "event", "handler" ]
python
train
flowersteam/explauto
explauto/environment/poppy/poppy_env.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/environment/poppy/poppy_env.py#L42-L45
def compute_motor_command(self, m_ag): """ Compute the motor command by restricting it to the bounds. """ m_env = bounds_min_max(m_ag, self.conf.m_mins, self.conf.m_maxs) return m_env
[ "def", "compute_motor_command", "(", "self", ",", "m_ag", ")", ":", "m_env", "=", "bounds_min_max", "(", "m_ag", ",", "self", ".", "conf", ".", "m_mins", ",", "self", ".", "conf", ".", "m_maxs", ")", "return", "m_env" ]
Compute the motor command by restricting it to the bounds.
[ "Compute", "the", "motor", "command", "by", "restricting", "it", "to", "the", "bounds", "." ]
python
train
cournape/audiolab
pavement.py
https://github.com/cournape/audiolab/blob/e4918832c1e52b56428c5f3535ddeb9d9daff9ac/pavement.py#L96-L103
def clean(): """Remove build, dist, egg-info garbage.""" d = ['build', 'dist', 'scikits.audiolab.egg-info', HTML_DESTDIR, PDF_DESTDIR] for i in d: paver.path.path(i).rmtree() (paver.path.path('docs') / options.sphinx.builddir).rmtree()
[ "def", "clean", "(", ")", ":", "d", "=", "[", "'build'", ",", "'dist'", ",", "'scikits.audiolab.egg-info'", ",", "HTML_DESTDIR", ",", "PDF_DESTDIR", "]", "for", "i", "in", "d", ":", "paver", ".", "path", ".", "path", "(", "i", ")", ".", "rmtree", "("...
Remove build, dist, egg-info garbage.
[ "Remove", "build", "dist", "egg", "-", "info", "garbage", "." ]
python
train
quora/qcore
qcore/events.py
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L46-L49
def subscribe(self, handler): """Adds a new event handler.""" assert callable(handler), "Invalid handler %s" % handler self.handlers.append(handler)
[ "def", "subscribe", "(", "self", ",", "handler", ")", ":", "assert", "callable", "(", "handler", ")", ",", "\"Invalid handler %s\"", "%", "handler", "self", ".", "handlers", ".", "append", "(", "handler", ")" ]
Adds a new event handler.
[ "Adds", "a", "new", "event", "handler", "." ]
python
train
svinota/mdns
mdns/zeroconf.py
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L953-L957
def write_string(self, value, length): """Writes a string to the packet""" format = '!' + str(length) + 's' self.data.append(struct.pack(format, value)) self.size += length
[ "def", "write_string", "(", "self", ",", "value", ",", "length", ")", ":", "format", "=", "'!'", "+", "str", "(", "length", ")", "+", "'s'", "self", ".", "data", ".", "append", "(", "struct", ".", "pack", "(", "format", ",", "value", ")", ")", "s...
Writes a string to the packet
[ "Writes", "a", "string", "to", "the", "packet" ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py#L1892-L1916
def _adjust_scrollbars(self): """ Expands the vertical scrollbar beyond the range set by Qt. """ # This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp # and qtextedit.cpp. document = self._control.document() scrollbar = self._control.verticalScrollBar() ...
[ "def", "_adjust_scrollbars", "(", "self", ")", ":", "# This code is adapted from _q_adjustScrollbars in qplaintextedit.cpp", "# and qtextedit.cpp.", "document", "=", "self", ".", "_control", ".", "document", "(", ")", "scrollbar", "=", "self", ".", "_control", ".", "ver...
Expands the vertical scrollbar beyond the range set by Qt.
[ "Expands", "the", "vertical", "scrollbar", "beyond", "the", "range", "set", "by", "Qt", "." ]
python
test
martijnvermaat/monoseq
monoseq/commands.py
https://github.com/martijnvermaat/monoseq/blob/02b92f6aa482ba169787a1a4bcad28372662dc36/monoseq/commands.py#L129-L162
def main(): """ Command line interface. """ parser = argparse.ArgumentParser( description='monoseq: pretty-printing DNA and protein sequences', epilog='If INPUT is in FASTA format, each record is pretty-printed ' 'after printing its name and ANNOTATION (if supplied) is used by ' ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'monoseq: pretty-printing DNA and protein sequences'", ",", "epilog", "=", "'If INPUT is in FASTA format, each record is pretty-printed '", "'after printing its name and ANNO...
Command line interface.
[ "Command", "line", "interface", "." ]
python
train
lkreidberg/batman
batman/transitmodel.py
https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L284-L289
def get_t_periastron(self, params): """ Return the time of periastron passage (calculated using `params.t0`). """ phase = self._get_phase(params, "primary") return params.t0 - params.per*phase
[ "def", "get_t_periastron", "(", "self", ",", "params", ")", ":", "phase", "=", "self", ".", "_get_phase", "(", "params", ",", "\"primary\"", ")", "return", "params", ".", "t0", "-", "params", ".", "per", "*", "phase" ]
Return the time of periastron passage (calculated using `params.t0`).
[ "Return", "the", "time", "of", "periastron", "passage", "(", "calculated", "using", "params", ".", "t0", ")", "." ]
python
test
cakebread/yolk
yolk/pypi.py
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L95-L117
def check_proxy_setting(): """ If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xml...
[ "def", "check_proxy_setting", "(", ")", ":", "try", ":", "http_proxy", "=", "os", ".", "environ", "[", "'HTTP_PROXY'", "]", "except", "KeyError", ":", "return", "if", "not", "http_proxy", ".", "startswith", "(", "'http://'", ")", ":", "match", "=", "re", ...
If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xmlrpc.
[ "If", "the", "environmental", "variable", "HTTP_PROXY", "is", "set", "it", "will", "most", "likely", "be", "in", "one", "of", "these", "forms", ":" ]
python
train
EconForge/dolo
dolo/numeric/discretization/quadrature.py
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/numeric/discretization/quadrature.py#L59-L122
def gauss_hermite_nodes(orders, sigma, mu=None): ''' Computes the weights and nodes for Gauss Hermite quadrature. Parameters ---------- orders : int, list, array The order of integration used in the quadrature routine sigma : array-like If one dimensional, the variance of the no...
[ "def", "gauss_hermite_nodes", "(", "orders", ",", "sigma", ",", "mu", "=", "None", ")", ":", "if", "isinstance", "(", "orders", ",", "int", ")", ":", "orders", "=", "[", "orders", "]", "import", "numpy", "if", "mu", "is", "None", ":", "mu", "=", "n...
Computes the weights and nodes for Gauss Hermite quadrature. Parameters ---------- orders : int, list, array The order of integration used in the quadrature routine sigma : array-like If one dimensional, the variance of the normal distribution being approximated. If multidimensi...
[ "Computes", "the", "weights", "and", "nodes", "for", "Gauss", "Hermite", "quadrature", "." ]
python
train
brendonh/pyth
pyth/plugins/xhtml/css.py
https://github.com/brendonh/pyth/blob/f2a06fc8dc9b1cfc439ea14252d39b9845a7fa4b/pyth/plugins/xhtml/css.py#L73-L85
def parse_css(self, css): """ Parse a css style sheet into the CSS object. For the moment this will only work for very simple css documents. It works by using regular expression matching css syntax. This is not bullet proof. """ rulesets = self.ruleset_re.finda...
[ "def", "parse_css", "(", "self", ",", "css", ")", ":", "rulesets", "=", "self", ".", "ruleset_re", ".", "findall", "(", "css", ")", "for", "(", "selector", ",", "declarations", ")", "in", "rulesets", ":", "rule", "=", "Rule", "(", "self", ".", "parse...
Parse a css style sheet into the CSS object. For the moment this will only work for very simple css documents. It works by using regular expression matching css syntax. This is not bullet proof.
[ "Parse", "a", "css", "style", "sheet", "into", "the", "CSS", "object", "." ]
python
train
dyve/django-bootstrap3
bootstrap3/templatetags/bootstrap3.py
https://github.com/dyve/django-bootstrap3/blob/1d4095ba113a1faff228f9592bdad4f0b3aed653/bootstrap3/templatetags/bootstrap3.py#L63-L84
def bootstrap_message_classes(message): """ Return the message classes for a message """ extra_tags = None try: extra_tags = message.extra_tags except AttributeError: pass if not extra_tags: extra_tags = "" classes = [extra_tags] try: level = message.l...
[ "def", "bootstrap_message_classes", "(", "message", ")", ":", "extra_tags", "=", "None", "try", ":", "extra_tags", "=", "message", ".", "extra_tags", "except", "AttributeError", ":", "pass", "if", "not", "extra_tags", ":", "extra_tags", "=", "\"\"", "classes", ...
Return the message classes for a message
[ "Return", "the", "message", "classes", "for", "a", "message" ]
python
train
pypa/pipenv
pipenv/vendor/requirementslib/models/url.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/url.py#L47-L62
def remove_password_from_url(url): # type: (S) -> S """ Given a url, remove the password and insert 4 dashes :param url: The url to replace the authentication in :type url: S :return: The new URL without authentication :rtype: S """ parsed = _get_parsed_url(url) if parsed.auth:...
[ "def", "remove_password_from_url", "(", "url", ")", ":", "# type: (S) -> S", "parsed", "=", "_get_parsed_url", "(", "url", ")", "if", "parsed", ".", "auth", ":", "auth", ",", "_", ",", "_", "=", "parsed", ".", "auth", ".", "partition", "(", "\":\"", ")",...
Given a url, remove the password and insert 4 dashes :param url: The url to replace the authentication in :type url: S :return: The new URL without authentication :rtype: S
[ "Given", "a", "url", "remove", "the", "password", "and", "insert", "4", "dashes" ]
python
train
Alignak-monitoring/alignak
alignak/daemons/arbiterdaemon.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daemons/arbiterdaemon.py#L327-L345
def get_broks_from_satellites(self): # pragma: no cover - not used! """Get broks from my all internal satellite links The arbiter get the broks from ALL the known satellites :return: None """ for satellites in [self.conf.brokers, self.conf.schedulers, ...
[ "def", "get_broks_from_satellites", "(", "self", ")", ":", "# pragma: no cover - not used!", "for", "satellites", "in", "[", "self", ".", "conf", ".", "brokers", ",", "self", ".", "conf", ".", "schedulers", ",", "self", ".", "conf", ".", "pollers", ",", "sel...
Get broks from my all internal satellite links The arbiter get the broks from ALL the known satellites :return: None
[ "Get", "broks", "from", "my", "all", "internal", "satellite", "links" ]
python
train
PyGithub/PyGithub
github/Repository.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/Repository.py#L1376-L1396
def get_collaborators(self, affiliation=github.GithubObject.NotSet): """ :calls: `GET /repos/:owner/:repo/collaborators <http://developer.github.com/v3/repos/collaborators>`_ :param affiliation: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedU...
[ "def", "get_collaborators", "(", "self", ",", "affiliation", "=", "github", ".", "GithubObject", ".", "NotSet", ")", ":", "url_parameters", "=", "dict", "(", ")", "allowed_affiliations", "=", "[", "'outside'", ",", "'direct'", ",", "'all'", "]", "if", "affil...
:calls: `GET /repos/:owner/:repo/collaborators <http://developer.github.com/v3/repos/collaborators>`_ :param affiliation: string :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
[ ":", "calls", ":", "GET", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "collaborators", "<http", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "repos", "/", "collaborators", ">", "_", ":", "param", "affiliation", ":", ...
python
train
KeithSSmith/switcheo-python
switcheo/public_client.py
https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/public_client.py#L490-L585
def get_orders(self, address, chain_name='NEO', contract_version='V2', pair=None, from_epoch_time=None, order_status=None, before_id=None, limit=50): """ Function to fetch the order history of the given address. Execution of this function is as follows:: get_order...
[ "def", "get_orders", "(", "self", ",", "address", ",", "chain_name", "=", "'NEO'", ",", "contract_version", "=", "'V2'", ",", "pair", "=", "None", ",", "from_epoch_time", "=", "None", ",", "order_status", "=", "None", ",", "before_id", "=", "None", ",", ...
Function to fetch the order history of the given address. Execution of this function is as follows:: get_orders(address=neo_get_scripthash_from_address(address=address)) The expected return result for this function is as follows:: [{ 'id': '7cbdf481-6acf-4bf3-a...
[ "Function", "to", "fetch", "the", "order", "history", "of", "the", "given", "address", ".", "Execution", "of", "this", "function", "is", "as", "follows", "::" ]
python
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L502-L527
def get_measurement_responses(self): """Return a dictionary of sip_responses for the modeled SIP spectra Note that this function does NOT check that each frequency contains the same configurations! Returns ------- responses : dict Dictionary with configurati...
[ "def", "get_measurement_responses", "(", "self", ")", ":", "# take configurations from first tomodir", "configs", "=", "self", ".", "tds", "[", "sorted", "(", "self", ".", "tds", ".", "keys", "(", ")", ")", "[", "0", "]", "]", ".", "configs", ".", "configs...
Return a dictionary of sip_responses for the modeled SIP spectra Note that this function does NOT check that each frequency contains the same configurations! Returns ------- responses : dict Dictionary with configurations as keys
[ "Return", "a", "dictionary", "of", "sip_responses", "for", "the", "modeled", "SIP", "spectra" ]
python
train
django-import-export/django-import-export
import_export/admin.py
https://github.com/django-import-export/django-import-export/blob/127f00d03fd0ad282615b064b7f444a639e6ff0c/import_export/admin.py#L546-L564
def export_admin_action(self, request, queryset): """ Exports the selected rows using file_format. """ export_format = request.POST.get('file_format') if not export_format: messages.warning(request, _('You must select an export format.')) else: fo...
[ "def", "export_admin_action", "(", "self", ",", "request", ",", "queryset", ")", ":", "export_format", "=", "request", ".", "POST", ".", "get", "(", "'file_format'", ")", "if", "not", "export_format", ":", "messages", ".", "warning", "(", "request", ",", "...
Exports the selected rows using file_format.
[ "Exports", "the", "selected", "rows", "using", "file_format", "." ]
python
train
telminov/sw-django-utils
djutils/views/helpers.py
https://github.com/telminov/sw-django-utils/blob/43b8491c87a5dd8fce145834c00198f4de14ceb9/djutils/views/helpers.py#L7-L26
def url_path(request, base_url=None, is_full=False, *args, **kwargs): """ join base_url and some GET-parameters to one; it could be absolute url optionally usage example: c['current_url'] = url_path(request, use_urllib=True, is_full=False) ... <a href="{{ current_url }}">Лабораторн...
[ "def", "url_path", "(", "request", ",", "base_url", "=", "None", ",", "is_full", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "base_url", ":", "base_url", "=", "request", ".", "path", "if", "is_full", ":", "protocol...
join base_url and some GET-parameters to one; it could be absolute url optionally usage example: c['current_url'] = url_path(request, use_urllib=True, is_full=False) ... <a href="{{ current_url }}">Лабораторный номер</a>
[ "join", "base_url", "and", "some", "GET", "-", "parameters", "to", "one", ";", "it", "could", "be", "absolute", "url", "optionally" ]
python
train
lago-project/lago
lago/providers/libvirt/cpu.py
https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/providers/libvirt/cpu.py#L372-L391
def get_cpu_props(cls, family, arch='x86'): """ Get CPU info XML Args: family(str): CPU family arch(str): CPU arch Returns: lxml.etree.Element: CPU xml Raises: :exc:`~LagoException`: If no such CPU family exists """ ...
[ "def", "get_cpu_props", "(", "cls", ",", "family", ",", "arch", "=", "'x86'", ")", ":", "cpus", "=", "cls", ".", "get_cpus_by_arch", "(", "arch", ")", "try", ":", "return", "cpus", ".", "xpath", "(", "'model[@name=\"{0}\"]'", ".", "format", "(", "family"...
Get CPU info XML Args: family(str): CPU family arch(str): CPU arch Returns: lxml.etree.Element: CPU xml Raises: :exc:`~LagoException`: If no such CPU family exists
[ "Get", "CPU", "info", "XML" ]
python
train
rbit/pydtls
dtls/sslconnection.py
https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L267-L276
def set_ssl_logging(self, enable=False, func=_ssl_logging_cb): u''' Enable or disable SSL logging :param True | False enable: Enable or disable SSL logging :param func: Callback function for logging ''' if enable: SSL_CTX_set_info_callback(self._ctx, func) el...
[ "def", "set_ssl_logging", "(", "self", ",", "enable", "=", "False", ",", "func", "=", "_ssl_logging_cb", ")", ":", "if", "enable", ":", "SSL_CTX_set_info_callback", "(", "self", ".", "_ctx", ",", "func", ")", "else", ":", "SSL_CTX_set_info_callback", "(", "s...
u''' Enable or disable SSL logging :param True | False enable: Enable or disable SSL logging :param func: Callback function for logging
[ "u", "Enable", "or", "disable", "SSL", "logging" ]
python
train
phoebe-project/phoebe2
phoebe/dependencies/autofig/axes.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/dependencies/autofig/axes.py#L1185-L1224
def lim(self, lim): """ set lim (limits) """ if lim is None: self._lim = lim return typeerror_msg = "lim must be of type tuple, float, None, or in ['fixed', 'symmetric', 'frame', 'sliding']" if isinstance(lim, str): if lim in ['fixed'...
[ "def", "lim", "(", "self", ",", "lim", ")", ":", "if", "lim", "is", "None", ":", "self", ".", "_lim", "=", "lim", "return", "typeerror_msg", "=", "\"lim must be of type tuple, float, None, or in ['fixed', 'symmetric', 'frame', 'sliding']\"", "if", "isinstance", "(", ...
set lim (limits)
[ "set", "lim", "(", "limits", ")" ]
python
train
scanny/python-pptx
pptx/text/layout.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/layout.py#L141-L150
def from_ordered_sequence(cls, iseq): """ Return the root of a balanced binary search tree populated with the values in iterable *iseq*. """ seq = list(iseq) # optimize for usually all fits by making longest first bst = cls(seq.pop()) bst._insert_from_orde...
[ "def", "from_ordered_sequence", "(", "cls", ",", "iseq", ")", ":", "seq", "=", "list", "(", "iseq", ")", "# optimize for usually all fits by making longest first", "bst", "=", "cls", "(", "seq", ".", "pop", "(", ")", ")", "bst", ".", "_insert_from_ordered_sequen...
Return the root of a balanced binary search tree populated with the values in iterable *iseq*.
[ "Return", "the", "root", "of", "a", "balanced", "binary", "search", "tree", "populated", "with", "the", "values", "in", "iterable", "*", "iseq", "*", "." ]
python
train
inveniosoftware-contrib/invenio-workflows
invenio_workflows/ext.py
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/ext.py#L71-L83
def init_app(self, app, entry_point_group='invenio_workflows.workflows', **kwargs): """Flask application initialization.""" app.config.setdefault( "WORKFLOWS_OBJECT_CLASS", "invenio_workflows.api.WorkflowObject" ) state = _Workflo...
[ "def", "init_app", "(", "self", ",", "app", ",", "entry_point_group", "=", "'invenio_workflows.workflows'", ",", "*", "*", "kwargs", ")", ":", "app", ".", "config", ".", "setdefault", "(", "\"WORKFLOWS_OBJECT_CLASS\"", ",", "\"invenio_workflows.api.WorkflowObject\"", ...
Flask application initialization.
[ "Flask", "application", "initialization", "." ]
python
train
evhub/coconut
coconut/compiler/compiler.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L973-L997
def endline_repl(self, inputstring, reformatting=False, **kwargs): """Add end of line comments.""" out = [] ln = 1 # line number for line in inputstring.splitlines(): add_one_to_ln = False try: if line.endswith(lnwrapper): line...
[ "def", "endline_repl", "(", "self", ",", "inputstring", ",", "reformatting", "=", "False", ",", "*", "*", "kwargs", ")", ":", "out", "=", "[", "]", "ln", "=", "1", "# line number", "for", "line", "in", "inputstring", ".", "splitlines", "(", ")", ":", ...
Add end of line comments.
[ "Add", "end", "of", "line", "comments", "." ]
python
train
opendns/pyinvestigate
investigate/investigate.py
https://github.com/opendns/pyinvestigate/blob/a182e73a750f03e906d9b25842d556db8d2fd54f/investigate/investigate.py#L255-L261
def samples(self, anystring, limit=None, offset=None, sortby=None): '''Return an object representing the samples identified by the input domain, IP, or URL''' uri = self._uris['samples'].format(anystring) params = {'limit': limit, 'offset': offset, 'sortby': sortby} return self.get_par...
[ "def", "samples", "(", "self", ",", "anystring", ",", "limit", "=", "None", ",", "offset", "=", "None", ",", "sortby", "=", "None", ")", ":", "uri", "=", "self", ".", "_uris", "[", "'samples'", "]", ".", "format", "(", "anystring", ")", "params", "...
Return an object representing the samples identified by the input domain, IP, or URL
[ "Return", "an", "object", "representing", "the", "samples", "identified", "by", "the", "input", "domain", "IP", "or", "URL" ]
python
train
danielperna84/pyhomematic
pyhomematic/_hm.py
https://github.com/danielperna84/pyhomematic/blob/8b91f3e84c83f05d289c740d507293a0d6759d8e/pyhomematic/_hm.py#L583-L607
def proxyInit(self): """ To receive events the proxy has to tell the CCU / Homegear where to send the events. For that we call the init-method. """ # Call init() with local XML RPC config and interface_id (the name of # the receiver) to receive events. XML RPC server has to be ru...
[ "def", "proxyInit", "(", "self", ")", ":", "# Call init() with local XML RPC config and interface_id (the name of", "# the receiver) to receive events. XML RPC server has to be running.", "for", "interface_id", ",", "proxy", "in", "self", ".", "proxies", ".", "items", "(", ")",...
To receive events the proxy has to tell the CCU / Homegear where to send the events. For that we call the init-method.
[ "To", "receive", "events", "the", "proxy", "has", "to", "tell", "the", "CCU", "/", "Homegear", "where", "to", "send", "the", "events", ".", "For", "that", "we", "call", "the", "init", "-", "method", "." ]
python
train
saltstack/salt
salt/states/timezone.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/timezone.py#L43-L127
def system(name, utc=True): ''' Set the timezone for the system. name The name of the timezone to use (e.g.: America/Denver) utc Whether or not to set the hardware clock to UTC (default is True) ''' ret = {'name': name, 'changes': {}, 'result': None, ...
[ "def", "system", "(", "name", ",", "utc", "=", "True", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "None", ",", "'comment'", ":", "''", "}", "# Set up metadata", "do_utc", "=", "False", "...
Set the timezone for the system. name The name of the timezone to use (e.g.: America/Denver) utc Whether or not to set the hardware clock to UTC (default is True)
[ "Set", "the", "timezone", "for", "the", "system", "." ]
python
train
saltstack/salt
salt/cloud/clouds/packet.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/packet.py#L464-L489
def list_nodes_min(call=None): ''' Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt...
[ "def", "list_nodes_min", "(", "call", "=", "None", ")", ":", "if", "call", "==", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_nodes_min function must be called with -f or --function.'", ")", "ret", "=", "{", "}", "for", "device", "in", "get_devic...
Return a list of the VMs that are on the provider. Only a list of VM names and their state is returned. This is the minimum amount of information needed to check for existing VMs. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt-cloud -f list_nodes_min packet-provider ...
[ "Return", "a", "list", "of", "the", "VMs", "that", "are", "on", "the", "provider", ".", "Only", "a", "list", "of", "VM", "names", "and", "their", "state", "is", "returned", ".", "This", "is", "the", "minimum", "amount", "of", "information", "needed", "...
python
train
serge-sans-paille/pythran
pythran/passmanager.py
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/passmanager.py#L213-L219
def dump(self, backend, node): '''High-level function to call a `backend' on a `node' to generate code for module `module_name'.''' assert issubclass(backend, Backend) b = backend() b.attach(self) return b.run(node)
[ "def", "dump", "(", "self", ",", "backend", ",", "node", ")", ":", "assert", "issubclass", "(", "backend", ",", "Backend", ")", "b", "=", "backend", "(", ")", "b", ".", "attach", "(", "self", ")", "return", "b", ".", "run", "(", "node", ")" ]
High-level function to call a `backend' on a `node' to generate code for module `module_name'.
[ "High", "-", "level", "function", "to", "call", "a", "backend", "on", "a", "node", "to", "generate", "code", "for", "module", "module_name", "." ]
python
train
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L2177-L2180
def p_single_statement_systemcall(self, p): 'single_statement : systemcall SEMICOLON' p[0] = SingleStatement(p[1], lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_single_statement_systemcall", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "SingleStatement", "(", "p", "[", "1", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", "p", ".", "set_lineno", "(", "0", ",", "p", ...
single_statement : systemcall SEMICOLON
[ "single_statement", ":", "systemcall", "SEMICOLON" ]
python
train
ocaballeror/LyricFetch
lyricfetch/scraping.py
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L71-L103
def normalize(string, chars_to_remove=None, replacement=''): """ Remove accented characters and such. The argument chars_to_remove is a dictionary that maps a string of chars to a single character. Every occurrence of every character in the first string will be replaced by that second character pas...
[ "def", "normalize", "(", "string", ",", "chars_to_remove", "=", "None", ",", "replacement", "=", "''", ")", ":", "ret", "=", "string", ".", "translate", "(", "str", ".", "maketrans", "(", "{", "'á':", " ", "a',", "", "'ä':", " ", "a',", "", "'æ':", ...
Remove accented characters and such. The argument chars_to_remove is a dictionary that maps a string of chars to a single character. Every occurrence of every character in the first string will be replaced by that second character passed as value. If only one mapping is desired, chars_to_remove may be ...
[ "Remove", "accented", "characters", "and", "such", "." ]
python
train
tsnaomi/finnsyll
ez_setup.py
https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/ez_setup.py#L162-L173
def download_file_powershell(url, target): ''' Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. ''' target = os.path.abspath(target) cmd = [ 'powershell', '-Command', '(new-object System.Ne...
[ "def", "download_file_powershell", "(", "url", ",", "target", ")", ":", "target", "=", "os", ".", "path", ".", "abspath", "(", "target", ")", "cmd", "=", "[", "'powershell'", ",", "'-Command'", ",", "'(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)...
Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete.
[ "Download", "the", "file", "at", "url", "to", "target", "using", "Powershell", "(", "which", "will", "validate", "trust", ")", ".", "Raise", "an", "exception", "if", "the", "command", "cannot", "complete", "." ]
python
train
BDNYC/astrodbkit
astrodbkit/astrodb.py
https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrodb.py#L1277-L1299
def modify(self, SQL, params='', verbose=True): """ Wrapper for CRUD operations to make them distinct from queries and automatically pass commit() method to cursor. Parameters ---------- SQL: str The SQL query to execute params: sequence Mimics th...
[ "def", "modify", "(", "self", ",", "SQL", ",", "params", "=", "''", ",", "verbose", "=", "True", ")", ":", "# Make sure the database isn't locked", "self", ".", "conn", ".", "commit", "(", ")", "if", "SQL", ".", "lower", "(", ")", ".", "startswith", "(...
Wrapper for CRUD operations to make them distinct from queries and automatically pass commit() method to cursor. Parameters ---------- SQL: str The SQL query to execute params: sequence Mimics the native parameter substitution of sqlite3 verbose: bool ...
[ "Wrapper", "for", "CRUD", "operations", "to", "make", "them", "distinct", "from", "queries", "and", "automatically", "pass", "commit", "()", "method", "to", "cursor", "." ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/paulaxml/paula.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/paulaxml/paula.py#L588-L595
def gen_paula_etree(paula_id): """ creates an element tree representation of an empty PAULA XML file. """ E = ElementMaker(nsmap=NSMAP) tree = E('paula', version='1.1') tree.append(E('header', paula_id=paula_id)) return E, tree
[ "def", "gen_paula_etree", "(", "paula_id", ")", ":", "E", "=", "ElementMaker", "(", "nsmap", "=", "NSMAP", ")", "tree", "=", "E", "(", "'paula'", ",", "version", "=", "'1.1'", ")", "tree", ".", "append", "(", "E", "(", "'header'", ",", "paula_id", "=...
creates an element tree representation of an empty PAULA XML file.
[ "creates", "an", "element", "tree", "representation", "of", "an", "empty", "PAULA", "XML", "file", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/completer.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/completer.py#L873-L933
def rlcomplete(self, text, state): """Return the state-th possible completion for 'text'. This is called successively with state == 0, 1, 2, ... until it returns None. The completion should begin with 'text'. Parameters ---------- text : string Text to pe...
[ "def", "rlcomplete", "(", "self", ",", "text", ",", "state", ")", ":", "if", "state", "==", "0", ":", "self", ".", "line_buffer", "=", "line_buffer", "=", "self", ".", "readline", ".", "get_line_buffer", "(", ")", "cursor_pos", "=", "self", ".", "readl...
Return the state-th possible completion for 'text'. This is called successively with state == 0, 1, 2, ... until it returns None. The completion should begin with 'text'. Parameters ---------- text : string Text to perform the completion on. state : in...
[ "Return", "the", "state", "-", "th", "possible", "completion", "for", "text", "." ]
python
test
odlgroup/odl
odl/discr/discretization.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/discr/discretization.py#L483-L530
def tspace_type(space, impl, dtype=None): """Select the correct corresponding tensor space. Parameters ---------- space : `LinearSpace` Template space from which to infer an adequate tensor space. If it has a ``field`` attribute, ``dtype`` must be consistent with it. impl : string ...
[ "def", "tspace_type", "(", "space", ",", "impl", ",", "dtype", "=", "None", ")", ":", "field_type", "=", "type", "(", "getattr", "(", "space", ",", "'field'", ",", "None", ")", ")", "if", "dtype", "is", "None", ":", "pass", "elif", "is_real_floating_dt...
Select the correct corresponding tensor space. Parameters ---------- space : `LinearSpace` Template space from which to infer an adequate tensor space. If it has a ``field`` attribute, ``dtype`` must be consistent with it. impl : string Implementation backend for the tensor spac...
[ "Select", "the", "correct", "corresponding", "tensor", "space", "." ]
python
train
openpermissions/perch
perch/user.py
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/user.py#L320-L332
def valid(cls, token, **kwargs): """ Check if a token exists and has not expired :param token: the token :return: bool """ try: token = yield cls.get(token) except couch.NotFound: raise Return(False) raise Return(token.ttl >= date...
[ "def", "valid", "(", "cls", ",", "token", ",", "*", "*", "kwargs", ")", ":", "try", ":", "token", "=", "yield", "cls", ".", "get", "(", "token", ")", "except", "couch", ".", "NotFound", ":", "raise", "Return", "(", "False", ")", "raise", "Return", ...
Check if a token exists and has not expired :param token: the token :return: bool
[ "Check", "if", "a", "token", "exists", "and", "has", "not", "expired" ]
python
train
TheHive-Project/TheHive4py
thehive4py/models.py
https://github.com/TheHive-Project/TheHive4py/blob/35762bbd50d8376943268464326b59c752d6241b/thehive4py/models.py#L154-L174
def create(self, title, description, **kwargs): """ Create an instance of the Case class. :param title: Case title. :param description: Case description. :param kwargs: Additional arguments. :return: The created instance. """ case = Case(title=title, des...
[ "def", "create", "(", "self", ",", "title", ",", "description", ",", "*", "*", "kwargs", ")", ":", "case", "=", "Case", "(", "title", "=", "title", ",", "description", "=", "description", ",", "*", "*", "kwargs", ")", "response", "=", "self", ".", ...
Create an instance of the Case class. :param title: Case title. :param description: Case description. :param kwargs: Additional arguments. :return: The created instance.
[ "Create", "an", "instance", "of", "the", "Case", "class", ".", ":", "param", "title", ":", "Case", "title", ".", ":", "param", "description", ":", "Case", "description", ".", ":", "param", "kwargs", ":", "Additional", "arguments", "." ]
python
train
f3at/feat
src/feat/agencies/net/broker.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/agencies/net/broker.py#L280-L285
def has_slave(self): '''Returns True/False wether we have a slave agency which is not standalone running.''' slave = first(x for x in self.slaves.itervalues() if not x.is_standalone) return slave is not None
[ "def", "has_slave", "(", "self", ")", ":", "slave", "=", "first", "(", "x", "for", "x", "in", "self", ".", "slaves", ".", "itervalues", "(", ")", "if", "not", "x", ".", "is_standalone", ")", "return", "slave", "is", "not", "None" ]
Returns True/False wether we have a slave agency which is not standalone running.
[ "Returns", "True", "/", "False", "wether", "we", "have", "a", "slave", "agency", "which", "is", "not", "standalone", "running", "." ]
python
train
osrg/ryu
ryu/lib/packet/vlan.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/packet/vlan.py#L79-L88
def get_packet_type(cls, type_): """Override method for the Length/Type field (self.ethertype). The Length/Type field means Length or Type interpretation, same as ethernet IEEE802.3. If the value of Length/Type field is less than or equal to 1500 decimal(05DC hexadecimal), it mea...
[ "def", "get_packet_type", "(", "cls", ",", "type_", ")", ":", "if", "type_", "<=", "ether", ".", "ETH_TYPE_IEEE802_3", ":", "type_", "=", "ether", ".", "ETH_TYPE_IEEE802_3", "return", "cls", ".", "_TYPES", ".", "get", "(", "type_", ")" ]
Override method for the Length/Type field (self.ethertype). The Length/Type field means Length or Type interpretation, same as ethernet IEEE802.3. If the value of Length/Type field is less than or equal to 1500 decimal(05DC hexadecimal), it means Length interpretation and be pass...
[ "Override", "method", "for", "the", "Length", "/", "Type", "field", "(", "self", ".", "ethertype", ")", ".", "The", "Length", "/", "Type", "field", "means", "Length", "or", "Type", "interpretation", "same", "as", "ethernet", "IEEE802", ".", "3", ".", "If...
python
train
BerkeleyAutomation/perception
perception/kinect2_sensor.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L673-L709
def frames(self): """Retrieve the next frame from the image directory and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj...
[ "def", "frames", "(", "self", ")", ":", "if", "not", "self", ".", "_running", ":", "raise", "RuntimeError", "(", "'VirtualKinect2 device pointing to %s not runnning. Cannot read frames'", "%", "(", "self", ".", "_path_to_images", ")", ")", "if", "self", ".", "_im_...
Retrieve the next frame from the image directory and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj:`tuple` of :obj:`ColorImage`...
[ "Retrieve", "the", "next", "frame", "from", "the", "image", "directory", "and", "convert", "it", "to", "a", "ColorImage", "a", "DepthImage", "and", "an", "IrImage", "." ]
python
train
python-visualization/branca
branca/element.py
https://github.com/python-visualization/branca/blob/4e89e88a5a7ff3586f0852249c2c125f72316da8/branca/element.py#L79-L97
def get_bounds(self): """Computes the bounds of the object and all it's children in the form [[lat_min, lon_min], [lat_max, lon_max]]. """ bounds = self._get_self_bounds() for child in self._children.values(): child_bounds = child.get_bounds() bounds = [ ...
[ "def", "get_bounds", "(", "self", ")", ":", "bounds", "=", "self", ".", "_get_self_bounds", "(", ")", "for", "child", "in", "self", ".", "_children", ".", "values", "(", ")", ":", "child_bounds", "=", "child", ".", "get_bounds", "(", ")", "bounds", "="...
Computes the bounds of the object and all it's children in the form [[lat_min, lon_min], [lat_max, lon_max]].
[ "Computes", "the", "bounds", "of", "the", "object", "and", "all", "it", "s", "children", "in", "the", "form", "[[", "lat_min", "lon_min", "]", "[", "lat_max", "lon_max", "]]", "." ]
python
train
cs50/check50
check50/__main__.py
https://github.com/cs50/check50/blob/42c1f0c36baa6a24f69742d74551a9ea7a5ceb33/check50/__main__.py#L134-L144
def install_translations(config): """Add check translations according to ``config`` as a fallback to existing translations""" if not config: return from . import _translation checks_translation = gettext.translation(domain=config["domain"], localedi...
[ "def", "install_translations", "(", "config", ")", ":", "if", "not", "config", ":", "return", "from", ".", "import", "_translation", "checks_translation", "=", "gettext", ".", "translation", "(", "domain", "=", "config", "[", "\"domain\"", "]", ",", "localedir...
Add check translations according to ``config`` as a fallback to existing translations
[ "Add", "check", "translations", "according", "to", "config", "as", "a", "fallback", "to", "existing", "translations" ]
python
train
fedora-infra/fedmsg_meta_fedora_infrastructure
fedmsg_meta_fedora_infrastructure/conglomerators/bodhi/overrides.py
https://github.com/fedora-infra/fedmsg_meta_fedora_infrastructure/blob/85bf4162692e3042c7dbcc12dfafaca4764b4ae6/fedmsg_meta_fedora_infrastructure/conglomerators/bodhi/overrides.py#L11-L17
def matches(self, a, b, **config): """ The message must match by username """ submitter_a = a['msg']['override']['submitter']['name'] submitter_b = b['msg']['override']['submitter']['name'] if submitter_a != submitter_b: return False return True
[ "def", "matches", "(", "self", ",", "a", ",", "b", ",", "*", "*", "config", ")", ":", "submitter_a", "=", "a", "[", "'msg'", "]", "[", "'override'", "]", "[", "'submitter'", "]", "[", "'name'", "]", "submitter_b", "=", "b", "[", "'msg'", "]", "["...
The message must match by username
[ "The", "message", "must", "match", "by", "username" ]
python
train
Unidata/siphon
siphon/catalog.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L652-L705
def access_with_service(self, service, use_xarray=None): """Access the dataset using a particular service. Return an Python object capable of communicating with the server using the particular service. For instance, for 'HTTPServer' this is a file-like object capable of HTTP communicati...
[ "def", "access_with_service", "(", "self", ",", "service", ",", "use_xarray", "=", "None", ")", ":", "service", "=", "CaseInsensitiveStr", "(", "service", ")", "if", "service", "==", "'CdmRemote'", ":", "if", "use_xarray", ":", "from", ".", "cdmr", ".", "x...
Access the dataset using a particular service. Return an Python object capable of communicating with the server using the particular service. For instance, for 'HTTPServer' this is a file-like object capable of HTTP communication; for OPENDAP this is a netCDF4 dataset. Parameters ...
[ "Access", "the", "dataset", "using", "a", "particular", "service", "." ]
python
train
mikedh/trimesh
trimesh/transformations.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/transformations.py#L2033-L2052
def spherical_matrix(theta, phi, axes='sxyz'): """ Give a spherical coordinate vector, find the rotation that will transform a [0,0,1] vector to those coordinates Parameters ----------- theta: float, rotation angle in radians phi: float, rotation angle in radians Returns --------...
[ "def", "spherical_matrix", "(", "theta", ",", "phi", ",", "axes", "=", "'sxyz'", ")", ":", "result", "=", "euler_matrix", "(", "0.0", ",", "phi", ",", "theta", ",", "axes", "=", "axes", ")", "return", "result" ]
Give a spherical coordinate vector, find the rotation that will transform a [0,0,1] vector to those coordinates Parameters ----------- theta: float, rotation angle in radians phi: float, rotation angle in radians Returns ---------- matrix: (4,4) rotation matrix where the following wi...
[ "Give", "a", "spherical", "coordinate", "vector", "find", "the", "rotation", "that", "will", "transform", "a", "[", "0", "0", "1", "]", "vector", "to", "those", "coordinates" ]
python
train
polyaxon/polyaxon
polyaxon/query/parser.py
https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/query/parser.py#L180-L199
def parse_expression(expression: str) -> Tuple[str, str]: """Base parsing for expressions. Every expression must follow a basic format: `name:[modifier|operator]operation[*[operator]operation]` So this parser just split the expression into: field name, operation. """ try: _expressi...
[ "def", "parse_expression", "(", "expression", ":", "str", ")", "->", "Tuple", "[", "str", ",", "str", "]", ":", "try", ":", "_expression", "=", "expression", ".", "strip", "(", ")", "name", ",", "operation", "=", "_expression", ".", "split", "(", "':'"...
Base parsing for expressions. Every expression must follow a basic format: `name:[modifier|operator]operation[*[operator]operation]` So this parser just split the expression into: field name, operation.
[ "Base", "parsing", "for", "expressions", "." ]
python
train
gbiggs/rtsprofile
rtsprofile/targets.py
https://github.com/gbiggs/rtsprofile/blob/fded6eddcb0b25fe9808b1b12336a4413ea00905/rtsprofile/targets.py#L232-L236
def to_dict(self): '''Save this target port into a dictionary.''' d = super(TargetPort, self).to_dict() d['portName'] = self.port_name return d
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "super", "(", "TargetPort", ",", "self", ")", ".", "to_dict", "(", ")", "d", "[", "'portName'", "]", "=", "self", ".", "port_name", "return", "d" ]
Save this target port into a dictionary.
[ "Save", "this", "target", "port", "into", "a", "dictionary", "." ]
python
train
shaypal5/pdutil
pdutil/display/display.py
https://github.com/shaypal5/pdutil/blob/231059634643af2558d22070f89767410978cf56/pdutil/display/display.py#L80-L106
def df_to_html(df, percentage_columns=None): # pragma: no cover """Return a nicely formatted HTML code string for the given dataframe. Arguments --------- df : pandas.DataFrame A dataframe object. percentage_columns : iterable A list of cloumn names to be displayed with a percentag...
[ "def", "df_to_html", "(", "df", ",", "percentage_columns", "=", "None", ")", ":", "# pragma: no cover", "big_dataframe_setup", "(", ")", "try", ":", "res", "=", "'<br><h2> {} </h2>'", ".", "format", "(", "df", ".", "name", ")", "except", "AttributeError", ":",...
Return a nicely formatted HTML code string for the given dataframe. Arguments --------- df : pandas.DataFrame A dataframe object. percentage_columns : iterable A list of cloumn names to be displayed with a percentage sign. Returns ------- str A nicely formatted stri...
[ "Return", "a", "nicely", "formatted", "HTML", "code", "string", "for", "the", "given", "dataframe", "." ]
python
train
jazzband/django-widget-tweaks
widget_tweaks/templatetags/widget_tweaks.py
https://github.com/jazzband/django-widget-tweaks/blob/f50ee92410d68e81528a7643a10544e7331af8fb/widget_tweaks/templatetags/widget_tweaks.py#L138-L172
def render_field(parser, token): """ Render a form field using given attribute-value pairs Takes form field as first argument and list of attribute-value pairs for all other arguments. Attribute-value pairs should be in the form of attribute=value or attribute="a value" for assignment and attribut...
[ "def", "render_field", "(", "parser", ",", "token", ")", ":", "error_msg", "=", "'%r tag requires a form field followed by a list of attributes and values in the form attr=\"value\"'", "%", "token", ".", "split_contents", "(", ")", "[", "0", "]", "try", ":", "bits", "="...
Render a form field using given attribute-value pairs Takes form field as first argument and list of attribute-value pairs for all other arguments. Attribute-value pairs should be in the form of attribute=value or attribute="a value" for assignment and attribute+=value or attribute+="value" for append...
[ "Render", "a", "form", "field", "using", "given", "attribute", "-", "value", "pairs" ]
python
train
ocaballeror/LyricFetch
lyricfetch/scraping.py
https://github.com/ocaballeror/LyricFetch/blob/86e62fb39c4c413ad7e1acf5bf0d28c9ed7c8fcb/lyricfetch/scraping.py#L215-L244
def metalarchives(song): """ Returns the lyrics found in MetalArchives for the specified mp3 file or an empty string if not found. """ artist = normalize(song.artist) title = normalize(song.title) url = 'https://www.metal-archives.com/search/ajax-advanced/searching/songs' url += f'/?son...
[ "def", "metalarchives", "(", "song", ")", ":", "artist", "=", "normalize", "(", "song", ".", "artist", ")", "title", "=", "normalize", "(", "song", ".", "title", ")", "url", "=", "'https://www.metal-archives.com/search/ajax-advanced/searching/songs'", "url", "+=",...
Returns the lyrics found in MetalArchives for the specified mp3 file or an empty string if not found.
[ "Returns", "the", "lyrics", "found", "in", "MetalArchives", "for", "the", "specified", "mp3", "file", "or", "an", "empty", "string", "if", "not", "found", "." ]
python
train
a1ezzz/wasp-general
wasp_general/os/linux/lvm.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/os/linux/lvm.py#L492-L499
def remove_volume(self): """ Remove this volume :return: None """ lvremove_cmd = ['sudo'] if self.lvm_command().sudo() is True else [] lvremove_cmd.extend(['lvremove', '-f', self.volume_path()]) subprocess.check_output(lvremove_cmd, timeout=self.__class__.__lvm_snapshot_remove_cmd_timeout__)
[ "def", "remove_volume", "(", "self", ")", ":", "lvremove_cmd", "=", "[", "'sudo'", "]", "if", "self", ".", "lvm_command", "(", ")", ".", "sudo", "(", ")", "is", "True", "else", "[", "]", "lvremove_cmd", ".", "extend", "(", "[", "'lvremove'", ",", "'-...
Remove this volume :return: None
[ "Remove", "this", "volume" ]
python
train
mdsol/rwslib
rwslib/builders/metadata.py
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L250-L257
def build(self, builder): """Build XML by appending to builder""" params = {} if self.lang is not None: params["xml:lang"] = self.lang builder.start("TranslatedText", params) builder.data(self.text) builder.end("TranslatedText")
[ "def", "build", "(", "self", ",", "builder", ")", ":", "params", "=", "{", "}", "if", "self", ".", "lang", "is", "not", "None", ":", "params", "[", "\"xml:lang\"", "]", "=", "self", ".", "lang", "builder", ".", "start", "(", "\"TranslatedText\"", ","...
Build XML by appending to builder
[ "Build", "XML", "by", "appending", "to", "builder" ]
python
train
PyProphet/pyprophet
pyprophet/main.py
https://github.com/PyProphet/pyprophet/blob/f546ad171750cd7685afbde6785fe71f82cadb35/pyprophet/main.py#L304-L319
def export_compound(infile, outfile, format, outcsv, max_rs_peakgroup_qvalue): """ Export Compound TSV/CSV tables """ if format == "score_plots": export_score_plots(infile) else: if outfile is None: if outcsv: outfile = infile.split(".osw")[0] + ".csv" ...
[ "def", "export_compound", "(", "infile", ",", "outfile", ",", "format", ",", "outcsv", ",", "max_rs_peakgroup_qvalue", ")", ":", "if", "format", "==", "\"score_plots\"", ":", "export_score_plots", "(", "infile", ")", "else", ":", "if", "outfile", "is", "None",...
Export Compound TSV/CSV tables
[ "Export", "Compound", "TSV", "/", "CSV", "tables" ]
python
test
mbedmicro/pyOCD
pyocd/target/pack/cmsis_pack.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/cmsis_pack.py#L462-L475
def memory_map(self): """! @brief MemoryMap object.""" # Lazily construct the memory map. if self._memory_map is None: self._build_memory_regions() self._build_flash_regions() # Warn if there was no boot memory. if not self._saw_startup: ...
[ "def", "memory_map", "(", "self", ")", ":", "# Lazily construct the memory map.", "if", "self", ".", "_memory_map", "is", "None", ":", "self", ".", "_build_memory_regions", "(", ")", "self", ".", "_build_flash_regions", "(", ")", "# Warn if there was no boot memory.",...
! @brief MemoryMap object.
[ "!" ]
python
train
ioos/compliance-checker
compliance_checker/suite.py
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/suite.py#L216-L243
def _process_skip_checks(cls, skip_checks): """ Processes an iterable of skip_checks with strings and returns a dict with <check_name>: <max_skip_level> pairs """ check_dict = defaultdict(lambda: None) # A is for "all", "M" is for medium, "L" is for low check_loo...
[ "def", "_process_skip_checks", "(", "cls", ",", "skip_checks", ")", ":", "check_dict", "=", "defaultdict", "(", "lambda", ":", "None", ")", "# A is for \"all\", \"M\" is for medium, \"L\" is for low", "check_lookup", "=", "{", "'A'", ":", "BaseCheck", ".", "HIGH", "...
Processes an iterable of skip_checks with strings and returns a dict with <check_name>: <max_skip_level> pairs
[ "Processes", "an", "iterable", "of", "skip_checks", "with", "strings", "and", "returns", "a", "dict", "with", "<check_name", ">", ":", "<max_skip_level", ">", "pairs" ]
python
train
annoviko/pyclustering
pyclustering/container/cftree.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/container/cftree.py#L668-L677
def remove_entry(self, entry): """! @brief Remove clustering feature from the leaf node. @param[in] entry (cfentry): Clustering feature. """ self.feature -= entry; self.entries.remove(entry);
[ "def", "remove_entry", "(", "self", ",", "entry", ")", ":", "self", ".", "feature", "-=", "entry", "self", ".", "entries", ".", "remove", "(", "entry", ")" ]
! @brief Remove clustering feature from the leaf node. @param[in] entry (cfentry): Clustering feature.
[ "!" ]
python
valid
unistra/django-rest-framework-fine-permissions
rest_framework_fine_permissions/utils.py
https://github.com/unistra/django-rest-framework-fine-permissions/blob/71af5953648ef9f9bdfb64a4c0ed0ea62661fa61/rest_framework_fine_permissions/utils.py#L28-L39
def get_serializer(serializer): """ Load a serializer. """ if isinstance(serializer, string_types): try: app_label, serializer_name = serializer.split('.') app_package = get_application(app_label) serializer_module = import_module('%s.serializers' % app_package) ...
[ "def", "get_serializer", "(", "serializer", ")", ":", "if", "isinstance", "(", "serializer", ",", "string_types", ")", ":", "try", ":", "app_label", ",", "serializer_name", "=", "serializer", ".", "split", "(", "'.'", ")", "app_package", "=", "get_application"...
Load a serializer.
[ "Load", "a", "serializer", "." ]
python
train
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L139-L152
def visitInlineShapeAtomNodeConstraint(self, ctx: ShExDocParser.InlineShapeAtomNodeConstraintContext): """ inlineShapeAtomNodeConstraint: nodeConstraint inlineShapeOrRef? # inlineShapeAtomShapeOrRef """ nc = ShexNodeExpressionParser(self.context, self.label) nc.visit(ctx.nodeConstraint()) ...
[ "def", "visitInlineShapeAtomNodeConstraint", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "InlineShapeAtomNodeConstraintContext", ")", ":", "nc", "=", "ShexNodeExpressionParser", "(", "self", ".", "context", ",", "self", ".", "label", ")", "nc", ".", "visit...
inlineShapeAtomNodeConstraint: nodeConstraint inlineShapeOrRef? # inlineShapeAtomShapeOrRef
[ "inlineShapeAtomNodeConstraint", ":", "nodeConstraint", "inlineShapeOrRef?", "#", "inlineShapeAtomShapeOrRef" ]
python
train
Danielhiversen/pymill
mill/__init__.py
https://github.com/Danielhiversen/pymill/blob/f091385914b53682012d0948c549beb4a5a96794/mill/__init__.py#L281-L308
async def update_heaters(self): """Request data.""" homes = await self.get_home_list() for home in homes: payload = {"homeId": home.get("homeId")} data = await self.request("getIndependentDevices", payload) if data is None: continue ...
[ "async", "def", "update_heaters", "(", "self", ")", ":", "homes", "=", "await", "self", ".", "get_home_list", "(", ")", "for", "home", "in", "homes", ":", "payload", "=", "{", "\"homeId\"", ":", "home", ".", "get", "(", "\"homeId\"", ")", "}", "data", ...
Request data.
[ "Request", "data", "." ]
python
train
pahaz/sshtunnel
sshtunnel.py
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1198-L1241
def read_private_key_file(pkey_file, pkey_password=None, key_type=None, logger=None): """ Get SSH Public key from a private key file, given an optional password Arguments: pkey_file (str): ...
[ "def", "read_private_key_file", "(", "pkey_file", ",", "pkey_password", "=", "None", ",", "key_type", "=", "None", ",", "logger", "=", "None", ")", ":", "ssh_pkey", "=", "None", "for", "pkey_class", "in", "(", "key_type", ",", ")", "if", "key_type", "else"...
Get SSH Public key from a private key file, given an optional password Arguments: pkey_file (str): File containing a private key (RSA, DSS or ECDSA) Keyword Arguments: pkey_password (Optional[str]): Password to decrypt the private key ...
[ "Get", "SSH", "Public", "key", "from", "a", "private", "key", "file", "given", "an", "optional", "password" ]
python
train
angr/angr
angr/sim_manager.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_manager.py#L217-L241
def explore(self, stash='active', n=None, find=None, avoid=None, find_stash='found', avoid_stash='avoid', cfg=None, num_find=1, **kwargs): """ Tick stash "stash" forward (up to "n" times or until "num_find" states are found), looking for condition "find", avoiding condition "avoi...
[ "def", "explore", "(", "self", ",", "stash", "=", "'active'", ",", "n", "=", "None", ",", "find", "=", "None", ",", "avoid", "=", "None", ",", "find_stash", "=", "'found'", ",", "avoid_stash", "=", "'avoid'", ",", "cfg", "=", "None", ",", "num_find",...
Tick stash "stash" forward (up to "n" times or until "num_find" states are found), looking for condition "find", avoiding condition "avoid". Stores found states into "find_stash' and avoided states into "avoid_stash". The "find" and "avoid" parameters may be any of: - An address to find ...
[ "Tick", "stash", "stash", "forward", "(", "up", "to", "n", "times", "or", "until", "num_find", "states", "are", "found", ")", "looking", "for", "condition", "find", "avoiding", "condition", "avoid", ".", "Stores", "found", "states", "into", "find_stash", "an...
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L736-L752
def ip_rtm_config_route_static_route_oif_static_route_dest(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") ip = ET.SubElement(config, "ip", xmlns="urn:brocade.com:mgmt:brocade-common-def") rtm_config = ET.SubElement(ip, "rtm-config", xmlns="urn:brocade.c...
[ "def", "ip_rtm_config_route_static_route_oif_static_route_dest", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "ip", "=", "ET", ".", "SubElement", "(", "config", ",", "\"ip\"", ",", "xmlns", "=",...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
allenai/allennlp
allennlp/data/instance.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/instance.py#L74-L82
def get_padding_lengths(self) -> Dict[str, Dict[str, int]]: """ Returns a dictionary of padding lengths, keyed by field name. Each ``Field`` returns a mapping from padding keys to actual lengths, and we just key that dictionary by field name. """ lengths = {} for field_n...
[ "def", "get_padding_lengths", "(", "self", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "int", "]", "]", ":", "lengths", "=", "{", "}", "for", "field_name", ",", "field", "in", "self", ".", "fields", ".", "items", "(", ")", ":", "...
Returns a dictionary of padding lengths, keyed by field name. Each ``Field`` returns a mapping from padding keys to actual lengths, and we just key that dictionary by field name.
[ "Returns", "a", "dictionary", "of", "padding", "lengths", "keyed", "by", "field", "name", ".", "Each", "Field", "returns", "a", "mapping", "from", "padding", "keys", "to", "actual", "lengths", "and", "we", "just", "key", "that", "dictionary", "by", "field", ...
python
train
iopipe/iopipe-python
iopipe/report.py
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/report.py#L82-L117
def extract_context_data(self): """ Returns the contents of a AWS Lambda context. :returns: A dict of relevant context data. :rtype: dict """ data = {} for k, v in { # camel case names in the report to align with AWS standards "functionNam...
[ "def", "extract_context_data", "(", "self", ")", ":", "data", "=", "{", "}", "for", "k", ",", "v", "in", "{", "# camel case names in the report to align with AWS standards", "\"functionName\"", ":", "\"function_name\"", ",", "\"functionVersion\"", ":", "\"function_versi...
Returns the contents of a AWS Lambda context. :returns: A dict of relevant context data. :rtype: dict
[ "Returns", "the", "contents", "of", "a", "AWS", "Lambda", "context", "." ]
python
train
benfred/implicit
implicit/datasets/_download.py
https://github.com/benfred/implicit/blob/6b16c50d1d514a814f2e5b8cf2a829ff23dbba63/implicit/datasets/_download.py#L13-L25
def download_file(url, local_filename): """ Simple wrapper around urlretrieve that uses tqdm to display a progress bar of download progress """ local_filename = os.path.abspath(local_filename) path = os.path.dirname(local_filename) if not os.path.isdir(path): os.makedirs(path) with tqdm...
[ "def", "download_file", "(", "url", ",", "local_filename", ")", ":", "local_filename", "=", "os", ".", "path", ".", "abspath", "(", "local_filename", ")", "path", "=", "os", ".", "path", ".", "dirname", "(", "local_filename", ")", "if", "not", "os", ".",...
Simple wrapper around urlretrieve that uses tqdm to display a progress bar of download progress
[ "Simple", "wrapper", "around", "urlretrieve", "that", "uses", "tqdm", "to", "display", "a", "progress", "bar", "of", "download", "progress" ]
python
train
dpkp/kafka-python
kafka/consumer/fetcher.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/fetcher.py#L247-L293
def _retrieve_offsets(self, timestamps, timeout_ms=float("inf")): """Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} d...
[ "def", "_retrieve_offsets", "(", "self", ",", "timestamps", ",", "timeout_ms", "=", "float", "(", "\"inf\"", ")", ")", ":", "if", "not", "timestamps", ":", "return", "{", "}", "start_time", "=", "time", ".", "time", "(", ")", "remaining_ms", "=", "timeou...
Fetch offset for each partition passed in ``timestamps`` map. Blocks until offsets are obtained, a non-retriable exception is raised or ``timeout_ms`` passed. Arguments: timestamps: {TopicPartition: int} dict with timestamps to fetch offsets by. -1 for the latest av...
[ "Fetch", "offset", "for", "each", "partition", "passed", "in", "timestamps", "map", "." ]
python
train