repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
emirozer/fake2db | fake2db/sqlite_handler.py | https://github.com/emirozer/fake2db/blob/568cf42afb3ac10fc15c4faaa1cdb84fc1f4946c/fake2db/sqlite_handler.py#L73-L91 | def database_caller_creator(self, name=None):
'''creates a sqlite3 db
returns the related connection object
which will be later used to spawn the cursor
'''
try:
if name:
database = name + '.db'
else:
database = 'sqlite_' +... | [
"def",
"database_caller_creator",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"if",
"name",
":",
"database",
"=",
"name",
"+",
"'.db'",
"else",
":",
"database",
"=",
"'sqlite_'",
"+",
"str_generator",
"(",
"self",
")",
"+",
"'.db'",
"c... | creates a sqlite3 db
returns the related connection object
which will be later used to spawn the cursor | [
"creates",
"a",
"sqlite3",
"db",
"returns",
"the",
"related",
"connection",
"object",
"which",
"will",
"be",
"later",
"used",
"to",
"spawn",
"the",
"cursor"
] | python | train | 33.421053 |
odlgroup/odl | odl/contrib/mrc/mrc.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/contrib/mrc/mrc.py#L404-L424 | def labels(self):
"""Return the 10-tuple of text labels from `header`.
The value is determined from the header entries ``'nlabl'`` and
``'label'``.
"""
label_array = self.header['label']['value']
labels = tuple(''.join(row.astype(str)) for row in label_array)
tr... | [
"def",
"labels",
"(",
"self",
")",
":",
"label_array",
"=",
"self",
".",
"header",
"[",
"'label'",
"]",
"[",
"'value'",
"]",
"labels",
"=",
"tuple",
"(",
"''",
".",
"join",
"(",
"row",
".",
"astype",
"(",
"str",
")",
")",
"for",
"row",
"in",
"lab... | Return the 10-tuple of text labels from `header`.
The value is determined from the header entries ``'nlabl'`` and
``'label'``. | [
"Return",
"the",
"10",
"-",
"tuple",
"of",
"text",
"labels",
"from",
"header",
"."
] | python | train | 34.428571 |
inasafe/inasafe | safe/gui/tools/help/batch_help.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/batch_help.py#L14-L27 | def batch_help():
"""Help message for Batch Dialog.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message
"""
message = m.Message()
message.add(m.Brand())
message.add(heading())
message.add(content())
return messag... | [
"def",
"batch_help",
"(",
")",
":",
"message",
"=",
"m",
".",
"Message",
"(",
")",
"message",
".",
"add",
"(",
"m",
".",
"Brand",
"(",
")",
")",
"message",
".",
"add",
"(",
"heading",
"(",
")",
")",
"message",
".",
"add",
"(",
"content",
"(",
"... | Help message for Batch Dialog.
.. versionadded:: 3.2.1
:returns: A message object containing helpful information.
:rtype: messaging.message.Message | [
"Help",
"message",
"for",
"Batch",
"Dialog",
"."
] | python | train | 22 |
carpedm20/fbchat | fbchat/_client.py | https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2334-L2343 | def muteThread(self, mute_time=-1, thread_id=None):
"""
Mutes thread
:param mute_time: Mute time in seconds, leave blank to mute forever
:param thread_id: User/Group ID to mute. See :ref:`intro_threads`
"""
thread_id, thread_type = self._getThread(thread_id, None)
... | [
"def",
"muteThread",
"(",
"self",
",",
"mute_time",
"=",
"-",
"1",
",",
"thread_id",
"=",
"None",
")",
":",
"thread_id",
",",
"thread_type",
"=",
"self",
".",
"_getThread",
"(",
"thread_id",
",",
"None",
")",
"data",
"=",
"{",
"\"mute_settings\"",
":",
... | Mutes thread
:param mute_time: Mute time in seconds, leave blank to mute forever
:param thread_id: User/Group ID to mute. See :ref:`intro_threads` | [
"Mutes",
"thread"
] | python | train | 45.8 |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L216-L265 | def arithmetic_crossover(random, mom, dad, args):
"""Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha*... | [
"def",
"arithmetic_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"ax_alpha",
"=",
"args",
".",
"setdefault",
"(",
"'ax_alpha'",
",",
"0.5",
")",
"ax_points",
"=",
"args",
".",
"setdefault",
"(",
"'ax_points'",
",",
"None",
")"... | Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha* keyword argument, and
the allele of the complement p... | [
"Return",
"the",
"offspring",
"of",
"arithmetic",
"crossover",
"on",
"the",
"candidates",
"."
] | python | train | 40.56 |
foremast/foremast | src/foremast/configs/outputs.py | https://github.com/foremast/foremast/blob/fb70f29b8ce532f061685a17d120486e47b215ba/src/foremast/configs/outputs.py#L29-L63 | def convert_ini(config_dict):
"""Convert _config_dict_ into a list of INI formatted strings.
Args:
config_dict (dict): Configuration dictionary to be flattened.
Returns:
(list) Lines to be written to a file in the format of KEY1_KEY2=value.
"""
config_lines = []
for env, confi... | [
"def",
"convert_ini",
"(",
"config_dict",
")",
":",
"config_lines",
"=",
"[",
"]",
"for",
"env",
",",
"configs",
"in",
"sorted",
"(",
"config_dict",
".",
"items",
"(",
")",
")",
":",
"for",
"resource",
",",
"app_properties",
"in",
"sorted",
"(",
"configs... | Convert _config_dict_ into a list of INI formatted strings.
Args:
config_dict (dict): Configuration dictionary to be flattened.
Returns:
(list) Lines to be written to a file in the format of KEY1_KEY2=value. | [
"Convert",
"_config_dict_",
"into",
"a",
"list",
"of",
"INI",
"formatted",
"strings",
"."
] | python | train | 39.628571 |
bitesofcode/projexui | projexui/xtimer.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xtimer.py#L175-L190 | def start(self, interval=None):
"""
Emits the start requested signal for this timer, effectively starting
its internal timer.
:param interval | <int>
"""
# update the interval value
with QtCore.QReadLocker(self.__lock):
if interv... | [
"def",
"start",
"(",
"self",
",",
"interval",
"=",
"None",
")",
":",
"# update the interval value\r",
"with",
"QtCore",
".",
"QReadLocker",
"(",
"self",
".",
"__lock",
")",
":",
"if",
"interval",
"is",
"None",
":",
"interval",
"=",
"self",
".",
"__interval... | Emits the start requested signal for this timer, effectively starting
its internal timer.
:param interval | <int> | [
"Emits",
"the",
"start",
"requested",
"signal",
"for",
"this",
"timer",
"effectively",
"starting",
"its",
"internal",
"timer",
".",
":",
"param",
"interval",
"|",
"<int",
">"
] | python | train | 32.25 |
theislab/scanpy | scanpy/preprocessing/_simple.py | https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/preprocessing/_simple.py#L34-L150 | def filter_cells(
data: AnnData,
min_counts: Optional[int] = None,
min_genes: Optional[int] = None,
max_counts: Optional[int] = None,
max_genes: Optional[int] = None,
inplace: bool = True,
copy: bool = False,
) -> Optional[Tuple[np.ndarray, np.ndarray]]:
"""Filter cell outliers based o... | [
"def",
"filter_cells",
"(",
"data",
":",
"AnnData",
",",
"min_counts",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"min_genes",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"max_counts",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
"... | Filter cell outliers based on counts and numbers of genes expressed.
For instance, only keep cells with at least `min_counts` counts or
`min_genes` genes expressed. This is to filter measurement outliers,
i.e. “unreliable” observations.
Only provide one of the optional parameters ``min_counts``, ``min... | [
"Filter",
"cell",
"outliers",
"based",
"on",
"counts",
"and",
"numbers",
"of",
"genes",
"expressed",
"."
] | python | train | 38.042735 |
tanghaibao/goatools | goatools/obo_parser.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/obo_parser.py#L94-L99 | def _init_obo_version(self, line):
"""Save obo version and release."""
if line[0:14] == "format-version":
self.format_version = line[16:-1]
if line[0:12] == "data-version":
self.data_version = line[14:-1] | [
"def",
"_init_obo_version",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
"[",
"0",
":",
"14",
"]",
"==",
"\"format-version\"",
":",
"self",
".",
"format_version",
"=",
"line",
"[",
"16",
":",
"-",
"1",
"]",
"if",
"line",
"[",
"0",
":",
"12",
... | Save obo version and release. | [
"Save",
"obo",
"version",
"and",
"release",
"."
] | python | train | 41.166667 |
freevoid/django-datafilters | datafilters/declarative.py | https://github.com/freevoid/django-datafilters/blob/99051b3b3e97946981c0e9697576b0100093287c/datafilters/declarative.py#L6-L37 | def get_declared_fields(bases, attrs, cls_filter,
with_base_fields=True,
extra_attr_name='base_fields'):
"""
Create a list of form field instances from the passed in 'attrs', plus any
similar fields on the base classes (in 'bases'). This is used by both the
Form and ModelForm metclasses.... | [
"def",
"get_declared_fields",
"(",
"bases",
",",
"attrs",
",",
"cls_filter",
",",
"with_base_fields",
"=",
"True",
",",
"extra_attr_name",
"=",
"'base_fields'",
")",
":",
"fields",
"=",
"[",
"(",
"field_name",
",",
"attrs",
".",
"pop",
"(",
"field_name",
")"... | Create a list of form field instances from the passed in 'attrs', plus any
similar fields on the base classes (in 'bases'). This is used by both the
Form and ModelForm metclasses.
If 'with_base_fields' is True, all fields from the bases are used.
Otherwise, only fields in the 'declared_fields' attribut... | [
"Create",
"a",
"list",
"of",
"form",
"field",
"instances",
"from",
"the",
"passed",
"in",
"attrs",
"plus",
"any",
"similar",
"fields",
"on",
"the",
"base",
"classes",
"(",
"in",
"bases",
")",
".",
"This",
"is",
"used",
"by",
"both",
"the",
"Form",
"and... | python | train | 41.84375 |
masfaraud/BMSpy | bms/core.py | https://github.com/masfaraud/BMSpy/blob/5ac6b9539c1141dd955560afb532e6b915b77bdc/bms/core.py#L222-L234 | def _AddVariable(self, variable):
"""
Add a variable to the model. Should not be used by end-user
"""
if isinstance(variable, Signal):
if not variable in self.signals:
self.signals.append(variable)
elif isinstance(variable, Variable):
if no... | [
"def",
"_AddVariable",
"(",
"self",
",",
"variable",
")",
":",
"if",
"isinstance",
"(",
"variable",
",",
"Signal",
")",
":",
"if",
"not",
"variable",
"in",
"self",
".",
"signals",
":",
"self",
".",
"signals",
".",
"append",
"(",
"variable",
")",
"elif"... | Add a variable to the model. Should not be used by end-user | [
"Add",
"a",
"variable",
"to",
"the",
"model",
".",
"Should",
"not",
"be",
"used",
"by",
"end",
"-",
"user"
] | python | train | 35.307692 |
wtsi-hgi/python-baton-wrapper | baton/collections.py | https://github.com/wtsi-hgi/python-baton-wrapper/blob/ae0c9e3630e2c4729a0614cc86f493688436b0b7/baton/collections.py#L110-L121 | def remove(self, identifier: Union[DataObjectReplica, int]):
"""
Removes a data object from this collection that has the given unique identifier. A `ValueError` will be raised
if a data object with the given identifier does not exist.
:param identifier: the identifier of the data object
... | [
"def",
"remove",
"(",
"self",
",",
"identifier",
":",
"Union",
"[",
"DataObjectReplica",
",",
"int",
"]",
")",
":",
"if",
"isinstance",
"(",
"identifier",
",",
"int",
")",
":",
"self",
".",
"_remove_by_number",
"(",
"identifier",
")",
"elif",
"isinstance",... | Removes a data object from this collection that has the given unique identifier. A `ValueError` will be raised
if a data object with the given identifier does not exist.
:param identifier: the identifier of the data object | [
"Removes",
"a",
"data",
"object",
"from",
"this",
"collection",
"that",
"has",
"the",
"given",
"unique",
"identifier",
".",
"A",
"ValueError",
"will",
"be",
"raised",
"if",
"a",
"data",
"object",
"with",
"the",
"given",
"identifier",
"does",
"not",
"exist",
... | python | train | 52.916667 |
FactoryBoy/factory_boy | factory/base.py | https://github.com/FactoryBoy/factory_boy/blob/edaa7c7f5a14065b229927903bd7989cc93cd069/factory/base.py#L246-L259 | def _initialize_counter(self):
"""Initialize our counter pointer.
If we're the top-level factory, instantiate a new counter
Otherwise, point to the top-level factory's counter.
"""
if self._counter is not None:
return
if self.counter_reference is self:
... | [
"def",
"_initialize_counter",
"(",
"self",
")",
":",
"if",
"self",
".",
"_counter",
"is",
"not",
"None",
":",
"return",
"if",
"self",
".",
"counter_reference",
"is",
"self",
":",
"self",
".",
"_counter",
"=",
"_Counter",
"(",
"seq",
"=",
"self",
".",
"... | Initialize our counter pointer.
If we're the top-level factory, instantiate a new counter
Otherwise, point to the top-level factory's counter. | [
"Initialize",
"our",
"counter",
"pointer",
"."
] | python | train | 36.428571 |
totalgood/twip | docs/notebooks/shakescorpus.py | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L52-L62 | def generate_lines(input_file,
start=0,
stop=float('inf')):
"""Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time"""
with gzip.GzipFile(input_file, 'rU') as f:
for i, line in enumerate(f):
if i < start:
continue
... | [
"def",
"generate_lines",
"(",
"input_file",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"float",
"(",
"'inf'",
")",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"input_file",
",",
"'rU'",
")",
"as",
"f",
":",
"for",
"i",
",",
"line",
"in",
"enumer... | Generate (yield) lines in a gzipped file (*.txt.gz) one line at a time | [
"Generate",
"(",
"yield",
")",
"lines",
"in",
"a",
"gzipped",
"file",
"(",
"*",
".",
"txt",
".",
"gz",
")",
"one",
"line",
"at",
"a",
"time"
] | python | train | 34.818182 |
Duke-GCB/DukeDSClient | ddsc/cmdparser.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/cmdparser.py#L345-L357 | def register_upload_command(self, upload_func):
"""
Add the upload command to the parser and call upload_func(project_name, folders, follow_symlinks) when chosen.
:param upload_func: func Called when this option is chosen: upload_func(project_name, folders, follow_symlinks).
"""
... | [
"def",
"register_upload_command",
"(",
"self",
",",
"upload_func",
")",
":",
"description",
"=",
"\"Uploads local files and folders to a remote host.\"",
"upload_parser",
"=",
"self",
".",
"subparsers",
".",
"add_parser",
"(",
"'upload'",
",",
"description",
"=",
"descr... | Add the upload command to the parser and call upload_func(project_name, folders, follow_symlinks) when chosen.
:param upload_func: func Called when this option is chosen: upload_func(project_name, folders, follow_symlinks). | [
"Add",
"the",
"upload",
"command",
"to",
"the",
"parser",
"and",
"call",
"upload_func",
"(",
"project_name",
"folders",
"follow_symlinks",
")",
"when",
"chosen",
".",
":",
"param",
"upload_func",
":",
"func",
"Called",
"when",
"this",
"option",
"is",
"chosen",... | python | train | 68 |
python-diamond/Diamond | src/diamond/handler/sentry.py | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L339-L347 | def configure_sentry_errors(self):
"""
Configure sentry.errors to use the same loggers as the root handler
@rtype: None
"""
sentry_errors_logger = logging.getLogger('sentry.errors')
root_logger = logging.getLogger()
for handler in root_logger.handlers:
... | [
"def",
"configure_sentry_errors",
"(",
"self",
")",
":",
"sentry_errors_logger",
"=",
"logging",
".",
"getLogger",
"(",
"'sentry.errors'",
")",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"for",
"handler",
"in",
"root_logger",
".",
"handlers",
":"... | Configure sentry.errors to use the same loggers as the root handler
@rtype: None | [
"Configure",
"sentry",
".",
"errors",
"to",
"use",
"the",
"same",
"loggers",
"as",
"the",
"root",
"handler"
] | python | train | 39.222222 |
blockcypher/blockcypher-python | blockcypher/utils.py | https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/utils.py#L27-L39 | def to_satoshis(input_quantity, input_type):
''' convert to satoshis, no rounding '''
assert input_type in UNIT_CHOICES, input_type
# convert to satoshis
if input_type in ('btc', 'mbtc', 'bit'):
satoshis = float(input_quantity) * float(UNIT_MAPPINGS[input_type]['satoshis_per'])
elif input_t... | [
"def",
"to_satoshis",
"(",
"input_quantity",
",",
"input_type",
")",
":",
"assert",
"input_type",
"in",
"UNIT_CHOICES",
",",
"input_type",
"# convert to satoshis",
"if",
"input_type",
"in",
"(",
"'btc'",
",",
"'mbtc'",
",",
"'bit'",
")",
":",
"satoshis",
"=",
... | convert to satoshis, no rounding | [
"convert",
"to",
"satoshis",
"no",
"rounding"
] | python | train | 35.307692 |
ask/carrot | carrot/connection.py | https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/connection.py#L223-L236 | def info(self):
"""Get connection info."""
backend_cls = self.backend_cls or "amqplib"
port = self.port or self.create_backend().default_port
return {"hostname": self.hostname,
"userid": self.userid,
"password": self.password,
"virtual_host... | [
"def",
"info",
"(",
"self",
")",
":",
"backend_cls",
"=",
"self",
".",
"backend_cls",
"or",
"\"amqplib\"",
"port",
"=",
"self",
".",
"port",
"or",
"self",
".",
"create_backend",
"(",
")",
".",
"default_port",
"return",
"{",
"\"hostname\"",
":",
"self",
"... | Get connection info. | [
"Get",
"connection",
"info",
"."
] | python | train | 41.214286 |
junzis/pyModeS | pyModeS/decoder/bds/bds08.py | https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds08.py#L26-L40 | def category(msg):
"""Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number
"""
if common.typecode(msg) < 1 or common.typecode(msg) > 4:
raise RuntimeError("%s: Not a identification message" % msg)
msgbin = comm... | [
"def",
"category",
"(",
"msg",
")",
":",
"if",
"common",
".",
"typecode",
"(",
"msg",
")",
"<",
"1",
"or",
"common",
".",
"typecode",
"(",
"msg",
")",
">",
"4",
":",
"raise",
"RuntimeError",
"(",
"\"%s: Not a identification message\"",
"%",
"msg",
")",
... | Aircraft category number
Args:
msg (string): 28 bytes hexadecimal message string
Returns:
int: category number | [
"Aircraft",
"category",
"number"
] | python | train | 24 |
icgood/pymap | pymap/mime/__init__.py | https://github.com/icgood/pymap/blob/e77d9a54d760e3cbe044a548883bb4299ed61dc2/pymap/mime/__init__.py#L64-L73 | def parse(cls, data: bytes) -> 'MessageContent':
"""Parse the bytestring into message content.
Args:
data: The bytestring to parse.
"""
lines = cls._find_lines(data)
view = memoryview(data)
return cls._parse(data, view, lines) | [
"def",
"parse",
"(",
"cls",
",",
"data",
":",
"bytes",
")",
"->",
"'MessageContent'",
":",
"lines",
"=",
"cls",
".",
"_find_lines",
"(",
"data",
")",
"view",
"=",
"memoryview",
"(",
"data",
")",
"return",
"cls",
".",
"_parse",
"(",
"data",
",",
"view... | Parse the bytestring into message content.
Args:
data: The bytestring to parse. | [
"Parse",
"the",
"bytestring",
"into",
"message",
"content",
"."
] | python | train | 27.9 |
sastrarobotics/pyHerkulex | herkulex.py | https://github.com/sastrarobotics/pyHerkulex/blob/3a42046cbfea8c7e343a04f42facba5e7bca570e/herkulex.py#L623-L654 | def get_servo_torque(self):
""" Gets the current torque of Herkulex
Gives the current load on the servo shaft.
It is actually the PWM value to the motors
Args:
none
Returns:
int: the torque on servo shaft. range from -1023 to 1023
Raises:
... | [
"def",
"get_servo_torque",
"(",
"self",
")",
":",
"data",
"=",
"[",
"]",
"data",
".",
"append",
"(",
"0x09",
")",
"data",
".",
"append",
"(",
"self",
".",
"servoid",
")",
"data",
".",
"append",
"(",
"RAM_READ_REQ",
")",
"data",
".",
"append",
"(",
... | Gets the current torque of Herkulex
Gives the current load on the servo shaft.
It is actually the PWM value to the motors
Args:
none
Returns:
int: the torque on servo shaft. range from -1023 to 1023
Raises:
SerialException: Error occured wh... | [
"Gets",
"the",
"current",
"torque",
"of",
"Herkulex"
] | python | train | 29.28125 |
PiotrDabkowski/Js2Py | js2py/legecy_translators/functions.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/legecy_translators/functions.py#L19-L93 | def remove_functions(source, all_inline=False):
"""removes functions and returns new source, and 2 dicts.
first dict with removed hoisted(global) functions and second with replaced inline functions"""
global INLINE_COUNT
inline = {}
hoisted = {}
n = 0
limit = len(source) - 9 # 8 is leng... | [
"def",
"remove_functions",
"(",
"source",
",",
"all_inline",
"=",
"False",
")",
":",
"global",
"INLINE_COUNT",
"inline",
"=",
"{",
"}",
"hoisted",
"=",
"{",
"}",
"n",
"=",
"0",
"limit",
"=",
"len",
"(",
"source",
")",
"-",
"9",
"# 8 is length of 'functio... | removes functions and returns new source, and 2 dicts.
first dict with removed hoisted(global) functions and second with replaced inline functions | [
"removes",
"functions",
"and",
"returns",
"new",
"source",
"and",
"2",
"dicts",
".",
"first",
"dict",
"with",
"removed",
"hoisted",
"(",
"global",
")",
"functions",
"and",
"second",
"with",
"replaced",
"inline",
"functions"
] | python | valid | 45.053333 |
dnanexus/dx-toolkit | src/python/dxpy/api.py | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L899-L905 | def org_remove_member(object_id, input_params={}, always_retry=True, **kwargs):
"""
Invokes the /org-xxxx/removeMember API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Organizations#API-method%3A-%2Forg-xxxx%2FremoveMember
"""
return DXHTTPRequest('/%s/removeMember... | [
"def",
"org_remove_member",
"(",
"object_id",
",",
"input_params",
"=",
"{",
"}",
",",
"always_retry",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DXHTTPRequest",
"(",
"'/%s/removeMember'",
"%",
"object_id",
",",
"input_params",
",",
"always_ret... | Invokes the /org-xxxx/removeMember API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Organizations#API-method%3A-%2Forg-xxxx%2FremoveMember | [
"Invokes",
"the",
"/",
"org",
"-",
"xxxx",
"/",
"removeMember",
"API",
"method",
"."
] | python | train | 54.142857 |
peri-source/peri | peri/opt/optimize.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/opt/optimize.py#L2408-L2435 | def do_levmarq_n_directions(s, directions, max_iter=2, run_length=2,
damping=1e-3, collect_stats=False, marquardt_damping=True, **kwargs):
"""
Optimization of a state along a specific set of directions in parameter
space.
Parameters
----------
s : :class:`peri.states.State`
... | [
"def",
"do_levmarq_n_directions",
"(",
"s",
",",
"directions",
",",
"max_iter",
"=",
"2",
",",
"run_length",
"=",
"2",
",",
"damping",
"=",
"1e-3",
",",
"collect_stats",
"=",
"False",
",",
"marquardt_damping",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
"... | Optimization of a state along a specific set of directions in parameter
space.
Parameters
----------
s : :class:`peri.states.State`
The state to optimize
directions : np.ndarray
[n,d] element numpy.ndarray of the n directions in the d-
dimensional space t... | [
"Optimization",
"of",
"a",
"state",
"along",
"a",
"specific",
"set",
"of",
"directions",
"in",
"parameter",
"space",
"."
] | python | valid | 40.142857 |
dpkp/kafka-python | kafka/consumer/subscription_state.py | https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/consumer/subscription_state.py#L180-L191 | def group_subscribe(self, topics):
"""Add topics to the current group subscription.
This is used by the group leader to ensure that it receives metadata
updates for all topics that any member of the group is subscribed to.
Arguments:
topics (list of str): topics to add to t... | [
"def",
"group_subscribe",
"(",
"self",
",",
"topics",
")",
":",
"if",
"self",
".",
"_user_assignment",
":",
"raise",
"IllegalStateError",
"(",
"self",
".",
"_SUBSCRIPTION_EXCEPTION_MESSAGE",
")",
"self",
".",
"_group_subscription",
".",
"update",
"(",
"topics",
... | Add topics to the current group subscription.
This is used by the group leader to ensure that it receives metadata
updates for all topics that any member of the group is subscribed to.
Arguments:
topics (list of str): topics to add to the group subscription | [
"Add",
"topics",
"to",
"the",
"current",
"group",
"subscription",
"."
] | python | train | 41.5 |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/_backends/iam/apis/account_admin_api.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/iam/apis/account_admin_api.py#L1371-L1395 | def get_groups_of_user(self, user_id, **kwargs): # noqa: E501
"""Get groups of the user. # noqa: E501
An endpoint for retrieving groups of the user. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/users/{user-id}/groups -H 'Authorization: Bearer API_KEY'` # noqa: E501
This ... | [
"def",
"get_groups_of_user",
"(",
"self",
",",
"user_id",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'asynchronous'",
")",
":",
"return",
"self",
".",
"g... | Get groups of the user. # noqa: E501
An endpoint for retrieving groups of the user. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/users/{user-id}/groups -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asy... | [
"Get",
"groups",
"of",
"the",
"user",
".",
"#",
"noqa",
":",
"E501"
] | python | train | 58.68 |
postlund/pyatv | pyatv/convert.py | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/convert.py#L20-L30 | def media_type_str(mediatype):
"""Convert internal API media type to string."""
if mediatype == const.MEDIA_TYPE_UNKNOWN:
return 'Unknown'
if mediatype == const.MEDIA_TYPE_VIDEO:
return 'Video'
if mediatype == const.MEDIA_TYPE_MUSIC:
return 'Music'
if mediatype == const.MEDIA... | [
"def",
"media_type_str",
"(",
"mediatype",
")",
":",
"if",
"mediatype",
"==",
"const",
".",
"MEDIA_TYPE_UNKNOWN",
":",
"return",
"'Unknown'",
"if",
"mediatype",
"==",
"const",
".",
"MEDIA_TYPE_VIDEO",
":",
"return",
"'Video'",
"if",
"mediatype",
"==",
"const",
... | Convert internal API media type to string. | [
"Convert",
"internal",
"API",
"media",
"type",
"to",
"string",
"."
] | python | train | 33.090909 |
mbj4668/pyang | pyang/translators/dsdl.py | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L548-L555 | def qname(self, stmt):
"""Return (prefixed) node name of `stmt`.
The result is prefixed with the local prefix unless we are
inside a global grouping.
"""
if self.gg_level: return stmt.arg
return self.prefix_stack[-1] + ":" + stmt.arg | [
"def",
"qname",
"(",
"self",
",",
"stmt",
")",
":",
"if",
"self",
".",
"gg_level",
":",
"return",
"stmt",
".",
"arg",
"return",
"self",
".",
"prefix_stack",
"[",
"-",
"1",
"]",
"+",
"\":\"",
"+",
"stmt",
".",
"arg"
] | Return (prefixed) node name of `stmt`.
The result is prefixed with the local prefix unless we are
inside a global grouping. | [
"Return",
"(",
"prefixed",
")",
"node",
"name",
"of",
"stmt",
"."
] | python | train | 34.375 |
dpkp/kafka-python | kafka/client_async.py | https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/client_async.py#L390-L402 | def ready(self, node_id, metadata_priority=True):
"""Check whether a node is connected and ok to send more requests.
Arguments:
node_id (int): the id of the node to check
metadata_priority (bool): Mark node as not-ready if a metadata
refresh is required. Default:... | [
"def",
"ready",
"(",
"self",
",",
"node_id",
",",
"metadata_priority",
"=",
"True",
")",
":",
"self",
".",
"maybe_connect",
"(",
"node_id",
")",
"return",
"self",
".",
"is_ready",
"(",
"node_id",
",",
"metadata_priority",
"=",
"metadata_priority",
")"
] | Check whether a node is connected and ok to send more requests.
Arguments:
node_id (int): the id of the node to check
metadata_priority (bool): Mark node as not-ready if a metadata
refresh is required. Default: True
Returns:
bool: True if we are read... | [
"Check",
"whether",
"a",
"node",
"is",
"connected",
"and",
"ok",
"to",
"send",
"more",
"requests",
"."
] | python | train | 39.923077 |
GNS3/gns3-server | gns3server/compute/nios/nio.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/nios/nio.py#L35-L43 | def startPacketCapture(self, pcap_output_file, pcap_data_link_type="DLT_EN10MB"):
"""
:param pcap_output_file: PCAP destination file for the capture
:param pcap_data_link_type: PCAP data link type (DLT_*), default is DLT_EN10MB
"""
self._capturing = True
self._pcap_outpu... | [
"def",
"startPacketCapture",
"(",
"self",
",",
"pcap_output_file",
",",
"pcap_data_link_type",
"=",
"\"DLT_EN10MB\"",
")",
":",
"self",
".",
"_capturing",
"=",
"True",
"self",
".",
"_pcap_output_file",
"=",
"pcap_output_file",
"self",
".",
"_pcap_data_link_type",
"=... | :param pcap_output_file: PCAP destination file for the capture
:param pcap_data_link_type: PCAP data link type (DLT_*), default is DLT_EN10MB | [
":",
"param",
"pcap_output_file",
":",
"PCAP",
"destination",
"file",
"for",
"the",
"capture",
":",
"param",
"pcap_data_link_type",
":",
"PCAP",
"data",
"link",
"type",
"(",
"DLT_",
"*",
")",
"default",
"is",
"DLT_EN10MB"
] | python | train | 43.666667 |
Vauxoo/pstats-print2list | pstats_print2list/pstats_print2list.py | https://github.com/Vauxoo/pstats-print2list/blob/a5ebf1790ed450c12103a665b7f49eb1982a8428/pstats_print2list/pstats_print2list.py#L51-L124 | def get_pstats_print2list(fnames, filter_fnames=None, exclude_fnames=None,
sort=None, sort_reverse=None, limit=None):
"""Print stats with a filter or exclude filenames, sort index and limit.
:param list fnames: cProfile standard files to process.
:param list filter_fnames: Relative... | [
"def",
"get_pstats_print2list",
"(",
"fnames",
",",
"filter_fnames",
"=",
"None",
",",
"exclude_fnames",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"sort_reverse",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"fnames",
",",
... | Print stats with a filter or exclude filenames, sort index and limit.
:param list fnames: cProfile standard files to process.
:param list filter_fnames: Relative paths to filter and show them.
:param list exclude_fnames: Relative paths to avoid show them.
:param str sort: Standard `pstats` key of value ... | [
"Print",
"stats",
"with",
"a",
"filter",
"or",
"exclude",
"filenames",
"sort",
"index",
"and",
"limit",
".",
":",
"param",
"list",
"fnames",
":",
"cProfile",
"standard",
"files",
"to",
"process",
".",
":",
"param",
"list",
"filter_fnames",
":",
"Relative",
... | python | train | 41.432432 |
fishtown-analytics/dbt | core/dbt/config/runtime.py | https://github.com/fishtown-analytics/dbt/blob/aa4f771df28b307af0cf9fe2fc24432f10a8236b/core/dbt/config/runtime.py#L152-L163 | def validate(self):
"""Validate the configuration against its contract.
:raises DbtProjectError: If the configuration fails validation.
"""
try:
Configuration(**self.serialize())
except ValidationException as e:
raise DbtProjectError(str(e))
if g... | [
"def",
"validate",
"(",
"self",
")",
":",
"try",
":",
"Configuration",
"(",
"*",
"*",
"self",
".",
"serialize",
"(",
")",
")",
"except",
"ValidationException",
"as",
"e",
":",
"raise",
"DbtProjectError",
"(",
"str",
"(",
"e",
")",
")",
"if",
"getattr",... | Validate the configuration against its contract.
:raises DbtProjectError: If the configuration fails validation. | [
"Validate",
"the",
"configuration",
"against",
"its",
"contract",
"."
] | python | train | 32.25 |
tensorpack/tensorpack | examples/FasterRCNN/config.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/config.py#L41-L44 | def to_dict(self):
"""Convert to a nested dict. """
return {k: v.to_dict() if isinstance(v, AttrDict) else v
for k, v in self.__dict__.items() if not k.startswith('_')} | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"k",
":",
"v",
".",
"to_dict",
"(",
")",
"if",
"isinstance",
"(",
"v",
",",
"AttrDict",
")",
"else",
"v",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
"if",... | Convert to a nested dict. | [
"Convert",
"to",
"a",
"nested",
"dict",
"."
] | python | train | 49.25 |
FlorianRhiem/pyGLFW | glfw/library.py | https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/library.py#L49-L66 | def _load_library(library_names, library_file_extensions,
library_search_paths, version_check_callback):
"""
Finds, loads and returns the most recent version of the library.
"""
candidates = _find_library_candidates(library_names,
library_file_... | [
"def",
"_load_library",
"(",
"library_names",
",",
"library_file_extensions",
",",
"library_search_paths",
",",
"version_check_callback",
")",
":",
"candidates",
"=",
"_find_library_candidates",
"(",
"library_names",
",",
"library_file_extensions",
",",
"library_search_paths"... | Finds, loads and returns the most recent version of the library. | [
"Finds",
"loads",
"and",
"returns",
"the",
"most",
"recent",
"version",
"of",
"the",
"library",
"."
] | python | train | 40.388889 |
myint/cppclean | cpp/find_warnings.py | https://github.com/myint/cppclean/blob/8a20c943dca1049e87d57137938f92d7735828dc/cpp/find_warnings.py#L239-L447 | def _determine_uses(self, included_files, forward_declarations):
"""Set up the use type of each symbol."""
file_uses = dict.fromkeys(included_files, UNUSED)
decl_uses = dict.fromkeys(forward_declarations, UNUSED)
symbol_table = self.symbol_table
for name, node in forward_declara... | [
"def",
"_determine_uses",
"(",
"self",
",",
"included_files",
",",
"forward_declarations",
")",
":",
"file_uses",
"=",
"dict",
".",
"fromkeys",
"(",
"included_files",
",",
"UNUSED",
")",
"decl_uses",
"=",
"dict",
".",
"fromkeys",
"(",
"forward_declarations",
","... | Set up the use type of each symbol. | [
"Set",
"up",
"the",
"use",
"type",
"of",
"each",
"symbol",
"."
] | python | train | 44.956938 |
spacetelescope/drizzlepac | drizzlepac/wcs_functions.py | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/wcs_functions.py#L711-L722 | def convertWCS(inwcs,drizwcs):
""" Copy WCSObject WCS into Drizzle compatible array."""
drizwcs[0] = inwcs.crpix[0]
drizwcs[1] = inwcs.crval[0]
drizwcs[2] = inwcs.crpix[1]
drizwcs[3] = inwcs.crval[1]
drizwcs[4] = inwcs.cd[0][0]
drizwcs[5] = inwcs.cd[1][0]
drizwcs[6] = inwcs.cd[0][1]
... | [
"def",
"convertWCS",
"(",
"inwcs",
",",
"drizwcs",
")",
":",
"drizwcs",
"[",
"0",
"]",
"=",
"inwcs",
".",
"crpix",
"[",
"0",
"]",
"drizwcs",
"[",
"1",
"]",
"=",
"inwcs",
".",
"crval",
"[",
"0",
"]",
"drizwcs",
"[",
"2",
"]",
"=",
"inwcs",
".",
... | Copy WCSObject WCS into Drizzle compatible array. | [
"Copy",
"WCSObject",
"WCS",
"into",
"Drizzle",
"compatible",
"array",
"."
] | python | train | 29.666667 |
monarch-initiative/dipper | dipper/sources/FlyBase.py | https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/FlyBase.py#L926-L965 | def _process_stock_genotype(self, limit):
"""
The genotypes of the stocks.
:param limit:
:return:
"""
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
raw = '/'.join((self.rawdir, 'stock_genotype'))
LOG.... | [
"def",
"_process_stock_genotype",
"(",
"self",
",",
"limit",
")",
":",
"if",
"self",
".",
"test_mode",
":",
"graph",
"=",
"self",
".",
"testgraph",
"else",
":",
"graph",
"=",
"self",
".",
"graph",
"raw",
"=",
"'/'",
".",
"join",
"(",
"(",
"self",
"."... | The genotypes of the stocks.
:param limit:
:return: | [
"The",
"genotypes",
"of",
"the",
"stocks",
"."
] | python | train | 30.175 |
wummel/linkchecker | linkcheck/checker/urlbase.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/urlbase.py#L177-L224 | def reset (self):
"""
Reset all variables to default values.
"""
# self.url is constructed by self.build_url() out of base_url
# and (base_ref or parent) as absolute and normed url.
# This the real url we use when checking so it also referred to
# as 'real url'
... | [
"def",
"reset",
"(",
"self",
")",
":",
"# self.url is constructed by self.build_url() out of base_url",
"# and (base_ref or parent) as absolute and normed url.",
"# This the real url we use when checking so it also referred to",
"# as 'real url'",
"self",
".",
"url",
"=",
"None",
"# a ... | Reset all variables to default values. | [
"Reset",
"all",
"variables",
"to",
"default",
"values",
"."
] | python | train | 36.395833 |
log2timeline/plaso | plaso/cli/log2timeline_tool.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/log2timeline_tool.py#L138-L277 | def ParseArguments(self):
"""Parses the command line arguments.
Returns:
bool: True if the arguments were successfully parsed.
"""
loggers.ConfigureLogging()
argument_parser = argparse.ArgumentParser(
description=self.DESCRIPTION, epilog=self.EPILOG, add_help=False,
formatter... | [
"def",
"ParseArguments",
"(",
"self",
")",
":",
"loggers",
".",
"ConfigureLogging",
"(",
")",
"argument_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"self",
".",
"DESCRIPTION",
",",
"epilog",
"=",
"self",
".",
"EPILOG",
",",
"add... | Parses the command line arguments.
Returns:
bool: True if the arguments were successfully parsed. | [
"Parses",
"the",
"command",
"line",
"arguments",
"."
] | python | train | 38.392857 |
matthiask/django-cte-forest | cte_forest/query.py | https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/query.py#L227-L246 | def get_compiler(self, using=None, connection=None):
""" Overrides the Query method get_compiler in order to return
an instance of the above custom compiler.
"""
# Copy the body of this method from Django except the final
# return statement. We will ignore code coverage for t... | [
"def",
"get_compiler",
"(",
"self",
",",
"using",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"# Copy the body of this method from Django except the final",
"# return statement. We will ignore code coverage for this.",
"if",
"using",
"is",
"None",
"and",
"connect... | Overrides the Query method get_compiler in order to return
an instance of the above custom compiler. | [
"Overrides",
"the",
"Query",
"method",
"get_compiler",
"in",
"order",
"to",
"return",
"an",
"instance",
"of",
"the",
"above",
"custom",
"compiler",
"."
] | python | train | 52.1 |
gbowerman/azurerm | azurerm/networkrp.py | https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/networkrp.py#L679-L697 | def update_load_balancer(access_token, subscription_id, resource_group, lb_name, body):
'''Updates a load balancer model, i.e. PUT an updated LB body.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure ... | [
"def",
"update_load_balancer",
"(",
"access_token",
",",
"subscription_id",
",",
"resource_group",
",",
"lb_name",
",",
"body",
")",
":",
"endpoint",
"=",
"''",
".",
"join",
"(",
"[",
"get_rm_endpoint",
"(",
")",
",",
"'/subscriptions/'",
",",
"subscription_id",... | Updates a load balancer model, i.e. PUT an updated LB body.
Args:
access_token (str): A valid Azure authentication token.
subscription_id (str): Azure subscription id.
resource_group (str): Azure resource group name.
lb_name (str): Name of the new load balancer.
body (str): ... | [
"Updates",
"a",
"load",
"balancer",
"model",
"i",
".",
"e",
".",
"PUT",
"an",
"updated",
"LB",
"body",
"."
] | python | train | 44.789474 |
sdispater/orator | orator/query/processors/processor.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/query/processors/processor.py#L20-L49 | def process_insert_get_id(self, query, sql, values, sequence=None):
"""
Process an "insert get ID" query.
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param sql: The sql query to execute
:type sql: str
:param values: The value bindings
... | [
"def",
"process_insert_get_id",
"(",
"self",
",",
"query",
",",
"sql",
",",
"values",
",",
"sequence",
"=",
"None",
")",
":",
"query",
".",
"get_connection",
"(",
")",
".",
"insert",
"(",
"sql",
",",
"values",
")",
"id",
"=",
"query",
".",
"get_connect... | Process an "insert get ID" query.
:param query: A QueryBuilder instance
:type query: QueryBuilder
:param sql: The sql query to execute
:type sql: str
:param values: The value bindings
:type values: list
:param sequence: The ids sequence
:type sequence:... | [
"Process",
"an",
"insert",
"get",
"ID",
"query",
"."
] | python | train | 23.2 |
lambdalisue/django-permission | src/permission/handlers.py | https://github.com/lambdalisue/django-permission/blob/580f7a1f857701d06ccf41163f188ac04fbc4fac/src/permission/handlers.py#L88-L113 | def get_supported_permissions(self):
"""
Get permissions which this handler can treat.
Specified with :attr:`includes` and :attr:`excludes` of this instance.
Returns
-------
set
A set instance of `app_label.codename` formatted permission strings
"""
... | [
"def",
"get_supported_permissions",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_perms_cache'",
")",
":",
"if",
"(",
"self",
".",
"includes",
"and",
"isinstance",
"(",
"self",
".",
"includes",
",",
"collections",
".",
"Callable",
")"... | Get permissions which this handler can treat.
Specified with :attr:`includes` and :attr:`excludes` of this instance.
Returns
-------
set
A set instance of `app_label.codename` formatted permission strings | [
"Get",
"permissions",
"which",
"this",
"handler",
"can",
"treat",
".",
"Specified",
"with",
":",
"attr",
":",
"includes",
"and",
":",
"attr",
":",
"excludes",
"of",
"this",
"instance",
"."
] | python | train | 37.384615 |
jquast/wcwidth | bin/wcwidth-browser.py | https://github.com/jquast/wcwidth/blob/78800b68911880ef4ef95ae83886154710441871/bin/wcwidth-browser.py#L459-L481 | def _process_keystroke_commands(self, inp):
"""Process keystrokes that issue commands (side effects)."""
if inp in (u'1', u'2'):
# chose 1 or 2-character wide
if int(inp) != self.screen.wide:
self.screen.wide = int(inp)
self.on_resize(None, None)
... | [
"def",
"_process_keystroke_commands",
"(",
"self",
",",
"inp",
")",
":",
"if",
"inp",
"in",
"(",
"u'1'",
",",
"u'2'",
")",
":",
"# chose 1 or 2-character wide",
"if",
"int",
"(",
"inp",
")",
"!=",
"self",
".",
"screen",
".",
"wide",
":",
"self",
".",
"... | Process keystrokes that issue commands (side effects). | [
"Process",
"keystrokes",
"that",
"issue",
"commands",
"(",
"side",
"effects",
")",
"."
] | python | train | 44.565217 |
matthewdeanmartin/jiggle_version | jiggle_version/schema_guesser.py | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/schema_guesser.py#L50-L109 | def version_object_and_next(string, retries=0): # type: (str, int) -> VersionThing
"""
Try three parsing strategies, favoring semver, then pep440, then whatev.
:param string:
:return:
"""
if retries > 2:
raise JiggleVersionException(
"Can't parse, ran out of retries: " + uni... | [
"def",
"version_object_and_next",
"(",
"string",
",",
"retries",
"=",
"0",
")",
":",
"# type: (str, int) -> VersionThing",
"if",
"retries",
">",
"2",
":",
"raise",
"JiggleVersionException",
"(",
"\"Can't parse, ran out of retries: \"",
"+",
"unicode",
"(",
"string",
"... | Try three parsing strategies, favoring semver, then pep440, then whatev.
:param string:
:return: | [
"Try",
"three",
"parsing",
"strategies",
"favoring",
"semver",
"then",
"pep440",
"then",
"whatev",
".",
":",
"param",
"string",
":",
":",
"return",
":"
] | python | train | 44.3 |
peopledoc/workalendar | workalendar/core.py | https://github.com/peopledoc/workalendar/blob/d044d5dfc1709ec388db34dab583dd554cc66c4e/workalendar/core.py#L246-L256 | def find_following_working_day(self, day):
"""Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters.
"""
day = cleaned_date(day)
... | [
"def",
"find_following_working_day",
"(",
"self",
",",
"day",
")",
":",
"day",
"=",
"cleaned_date",
"(",
"day",
")",
"while",
"day",
".",
"weekday",
"(",
")",
"in",
"self",
".",
"get_weekend_days",
"(",
")",
":",
"day",
"=",
"day",
"+",
"timedelta",
"(... | Looks for the following working day, if not already a working day.
**WARNING**: this function doesn't take into account the calendar
holidays, only the days of the week and the weekend days parameters. | [
"Looks",
"for",
"the",
"following",
"working",
"day",
"if",
"not",
"already",
"a",
"working",
"day",
"."
] | python | train | 38.545455 |
driftx/Telephus | telephus/cassandra/Cassandra.py | https://github.com/driftx/Telephus/blob/860a03a0fafe71605e1a4316dfdd8d0c29094703/telephus/cassandra/Cassandra.py#L723-L736 | def multiget_count(self, keys, column_parent, predicate, consistency_level):
"""
Perform a get_count in parallel on the given list<binary> keys. The return value maps keys to the count found.
Parameters:
- keys
- column_parent
- predicate
- consistency_level
"""
self._seqid += 1... | [
"def",
"multiget_count",
"(",
"self",
",",
"keys",
",",
"column_parent",
",",
"predicate",
",",
"consistency_level",
")",
":",
"self",
".",
"_seqid",
"+=",
"1",
"d",
"=",
"self",
".",
"_reqs",
"[",
"self",
".",
"_seqid",
"]",
"=",
"defer",
".",
"Deferr... | Perform a get_count in parallel on the given list<binary> keys. The return value maps keys to the count found.
Parameters:
- keys
- column_parent
- predicate
- consistency_level | [
"Perform",
"a",
"get_count",
"in",
"parallel",
"on",
"the",
"given",
"list<binary",
">",
"keys",
".",
"The",
"return",
"value",
"maps",
"keys",
"to",
"the",
"count",
"found",
"."
] | python | train | 32.214286 |
couchbase/couchbase-python-client | couchbase/n1ql.py | https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/couchbase/n1ql.py#L437-L461 | def meta_retrieve(self, meta_lookahead = None):
"""
Get metadata from the query itself. This is guaranteed to only
return a Python dictionary.
Note that if the query failed, the metadata might not be in JSON
format, in which case there may be additional, non-JSON data
wh... | [
"def",
"meta_retrieve",
"(",
"self",
",",
"meta_lookahead",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"__meta_received",
":",
"if",
"meta_lookahead",
"or",
"self",
".",
"meta_lookahead",
":",
"self",
".",
"buffered_remainder",
"=",
"list",
"(",
"self"... | Get metadata from the query itself. This is guaranteed to only
return a Python dictionary.
Note that if the query failed, the metadata might not be in JSON
format, in which case there may be additional, non-JSON data
which can be retrieved using the following
::
ra... | [
"Get",
"metadata",
"from",
"the",
"query",
"itself",
".",
"This",
"is",
"guaranteed",
"to",
"only",
"return",
"a",
"Python",
"dictionary",
"."
] | python | train | 33.24 |
user-cont/conu | conu/backend/docker/backend.py | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/backend.py#L85-L106 | def list_containers(self):
"""
List all available docker containers.
Container objects returned from this methods will contain a limited
amount of metadata in property `short_metadata`. These are just a subset
of `.inspect()`, but don't require an API call against dockerd.
... | [
"def",
"list_containers",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"d",
".",
"containers",
"(",
"all",
"=",
"True",
")",
":",
"name",
"=",
"None",
"names",
"=",
"c",
".",
"get",
"(",
"\"Names\"",
",",
"None",... | List all available docker containers.
Container objects returned from this methods will contain a limited
amount of metadata in property `short_metadata`. These are just a subset
of `.inspect()`, but don't require an API call against dockerd.
:return: collection of instances of :class:... | [
"List",
"all",
"available",
"docker",
"containers",
"."
] | python | train | 40.227273 |
apache/airflow | airflow/utils/dag_processing.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/dag_processing.py#L262-L272 | def get_dag(self, dag_id):
"""
:param dag_id: DAG ID
:type dag_id: unicode
:return: if the given DAG ID exists in the bag, return the BaseDag
corresponding to that ID. Otherwise, throw an Exception
:rtype: airflow.utils.dag_processing.SimpleDag
"""
if dag_... | [
"def",
"get_dag",
"(",
"self",
",",
"dag_id",
")",
":",
"if",
"dag_id",
"not",
"in",
"self",
".",
"dag_id_to_simple_dag",
":",
"raise",
"AirflowException",
"(",
"\"Unknown DAG ID {}\"",
".",
"format",
"(",
"dag_id",
")",
")",
"return",
"self",
".",
"dag_id_t... | :param dag_id: DAG ID
:type dag_id: unicode
:return: if the given DAG ID exists in the bag, return the BaseDag
corresponding to that ID. Otherwise, throw an Exception
:rtype: airflow.utils.dag_processing.SimpleDag | [
":",
"param",
"dag_id",
":",
"DAG",
"ID",
":",
"type",
"dag_id",
":",
"unicode",
":",
"return",
":",
"if",
"the",
"given",
"DAG",
"ID",
"exists",
"in",
"the",
"bag",
"return",
"the",
"BaseDag",
"corresponding",
"to",
"that",
"ID",
".",
"Otherwise",
"th... | python | test | 42.363636 |
StackStorm/pybind | pybind/slxos/v17r_1_01a/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/af_vrf/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/af_vrf/__init__.py#L124-L150 | def _set_af_vrf_name(self, v, load=False):
"""
Setter method for af_vrf_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/af_vrf/af_vrf_name (string)
If this variable is read-only (config: false) in the
source YANG file, then _set_af_vrf_name is considere... | [
"def",
"_set_af_vrf_name",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"parent",
"=",
"getattr",
"(",
"self",
",",
"\"_parent\"",
",",
"None",
")",
"if",
"parent",
"is",
"not",
"None",
"and",
"load",
"is",
"False",
":",
"raise",
"Attr... | Setter method for af_vrf_name, mapped from YANG variable /routing_system/router/router_bgp/address_family/ipv4/ipv4_unicast/af_vrf/af_vrf_name (string)
If this variable is read-only (config: false) in the
source YANG file, then _set_af_vrf_name is considered as a private
method. Backends looking to populate... | [
"Setter",
"method",
"for",
"af_vrf_name",
"mapped",
"from",
"YANG",
"variable",
"/",
"routing_system",
"/",
"router",
"/",
"router_bgp",
"/",
"address_family",
"/",
"ipv4",
"/",
"ipv4_unicast",
"/",
"af_vrf",
"/",
"af_vrf_name",
"(",
"string",
")",
"If",
"this... | python | train | 74 |
aodag/WebDispatch | webdispatch/urldispatcher.py | https://github.com/aodag/WebDispatch/blob/55f8658a2b4100498e098a80303a346c3940f1bc/webdispatch/urldispatcher.py#L32-L41 | def lookup(self, path_info: str) -> MatchResult:
""" lookup url match for path_info
"""
for name, pattern in self.patterns.items():
match = pattern.match(path_info)
if match is None:
continue
match.name = name
return match
r... | [
"def",
"lookup",
"(",
"self",
",",
"path_info",
":",
"str",
")",
"->",
"MatchResult",
":",
"for",
"name",
",",
"pattern",
"in",
"self",
".",
"patterns",
".",
"items",
"(",
")",
":",
"match",
"=",
"pattern",
".",
"match",
"(",
"path_info",
")",
"if",
... | lookup url match for path_info | [
"lookup",
"url",
"match",
"for",
"path_info"
] | python | train | 32.1 |
thebigmunch/audio-metadata | src/audio_metadata/api.py | https://github.com/thebigmunch/audio-metadata/blob/d17bdbdb71db79c1568d54438d42dcd940b76074/src/audio_metadata/api.py#L48-L82 | def load(f):
"""Load audio metadata from filepath or file-like object.
Parameters:
f (str, os.PathLike, or file-like object):
A filepath, path-like object or file-like object of an audio file.
Returns:
Format: An audio format object.
Raises:
UnsupportedFormat: If file is not of a supported format.
Val... | [
"def",
"load",
"(",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"(",
"os",
".",
"PathLike",
",",
"str",
")",
")",
":",
"fileobj",
"=",
"open",
"(",
"f",
",",
"'rb'",
")",
"else",
":",
"try",
":",
"f",
".",
"read",
"(",
"0",
")",
"exce... | Load audio metadata from filepath or file-like object.
Parameters:
f (str, os.PathLike, or file-like object):
A filepath, path-like object or file-like object of an audio file.
Returns:
Format: An audio format object.
Raises:
UnsupportedFormat: If file is not of a supported format.
ValueError: If filep... | [
"Load",
"audio",
"metadata",
"from",
"filepath",
"or",
"file",
"-",
"like",
"object",
"."
] | python | train | 24.485714 |
sass/libsass-python | sassutils/builder.py | https://github.com/sass/libsass-python/blob/fde5b18bc761f0253e71685ee5489e4beb8a403e/sassutils/builder.py#L225-L253 | def build(self, package_dir, output_style='nested'):
"""Builds the Sass/SCSS files in the specified :attr:`sass_path`.
It finds :attr:`sass_path` and locates :attr:`css_path`
as relative to the given ``package_dir``.
:param package_dir: the path of package directory
:type packag... | [
"def",
"build",
"(",
"self",
",",
"package_dir",
",",
"output_style",
"=",
"'nested'",
")",
":",
"sass_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"package_dir",
",",
"self",
".",
"sass_path",
")",
"css_path",
"=",
"os",
".",
"path",
".",
"join",
... | Builds the Sass/SCSS files in the specified :attr:`sass_path`.
It finds :attr:`sass_path` and locates :attr:`css_path`
as relative to the given ``package_dir``.
:param package_dir: the path of package directory
:type package_dir: :class:`str`, :class:`basestring`
:param output_s... | [
"Builds",
"the",
"Sass",
"/",
"SCSS",
"files",
"in",
"the",
"specified",
":",
"attr",
":",
"sass_path",
".",
"It",
"finds",
":",
"attr",
":",
"sass_path",
"and",
"locates",
":",
"attr",
":",
"css_path",
"as",
"relative",
"to",
"the",
"given",
"package_di... | python | train | 41.241379 |
MediaFire/mediafire-python-open-sdk | mediafire/media/conversion_server_client.py | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/media/conversion_server_client.py#L36-L80 | def request(self, hash_, quickkey, doc_type, page=None,
output=None, size_id=None, metadata=None,
request_conversion_only=None):
"""Query conversion server
hash_: 4 characters of file hash
quickkey: File quickkey
doc_type: "i" for image, "d" for documents... | [
"def",
"request",
"(",
"self",
",",
"hash_",
",",
"quickkey",
",",
"doc_type",
",",
"page",
"=",
"None",
",",
"output",
"=",
"None",
",",
"size_id",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"request_conversion_only",
"=",
"None",
")",
":",
"if",... | Query conversion server
hash_: 4 characters of file hash
quickkey: File quickkey
doc_type: "i" for image, "d" for documents
page: The page to convert. If page is set to 'initial', the first
10 pages of the document will be provided. (document)
output: "pdf", "img",... | [
"Query",
"conversion",
"server"
] | python | train | 34.488889 |
Faylixe/pygame_vkeyboard | pygame_vkeyboard/vkeyboard.py | https://github.com/Faylixe/pygame_vkeyboard/blob/72753a47b4d1d8bf22c9c51ca877aef742481d2a/pygame_vkeyboard/vkeyboard.py#L628-L644 | def on_event(self, event):
"""Pygame event processing callback method.
:param event: Event to process.
"""
if self.state > 0:
if event.type == MOUSEBUTTONDOWN:
key = self.layout.get_key_at(pygame.mouse.get_pos())
if key is not None:
... | [
"def",
"on_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"state",
">",
"0",
":",
"if",
"event",
".",
"type",
"==",
"MOUSEBUTTONDOWN",
":",
"key",
"=",
"self",
".",
"layout",
".",
"get_key_at",
"(",
"pygame",
".",
"mouse",
".",
"ge... | Pygame event processing callback method.
:param event: Event to process. | [
"Pygame",
"event",
"processing",
"callback",
"method",
"."
] | python | train | 39.705882 |
OCA/openupgradelib | openupgradelib/openupgrade_80.py | https://github.com/OCA/openupgradelib/blob/b220b6498075d62c1b64073cc934513a465cfd85/openupgradelib/openupgrade_80.py#L59-L84 | def set_message_last_post(cr, uid, pool, models):
"""
Given a list of models, set their 'message_last_post' fields to an
estimated last post datetime.
To be called in post-migration scripts
:param cr: database cursor
:param uid: user id, assumed to be openerp.SUPERUSER_ID
:param pool: orm p... | [
"def",
"set_message_last_post",
"(",
"cr",
",",
"uid",
",",
"pool",
",",
"models",
")",
":",
"if",
"type",
"(",
"models",
")",
"is",
"not",
"list",
":",
"models",
"=",
"[",
"models",
"]",
"for",
"model",
"in",
"models",
":",
"model_pool",
"=",
"pool"... | Given a list of models, set their 'message_last_post' fields to an
estimated last post datetime.
To be called in post-migration scripts
:param cr: database cursor
:param uid: user id, assumed to be openerp.SUPERUSER_ID
:param pool: orm pool, assumed to be openerp.pooler.get_pool(cr.dbname)
:par... | [
"Given",
"a",
"list",
"of",
"models",
"set",
"their",
"message_last_post",
"fields",
"to",
"an",
"estimated",
"last",
"post",
"datetime",
".",
"To",
"be",
"called",
"in",
"post",
"-",
"migration",
"scripts"
] | python | train | 34.884615 |
kubernauts/pyk | pyk/util.py | https://github.com/kubernauts/pyk/blob/88531b1f09f23c049b3ad7aa9caebfc02a4a420d/pyk/util.py#L12-L18 | def load_yaml(filename):
"""
Loads a YAML-formatted file.
"""
with open(filename) as f:
ydoc = yaml.safe_load(f.read())
return (ydoc, serialize_tojson(ydoc)) | [
"def",
"load_yaml",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"ydoc",
"=",
"yaml",
".",
"safe_load",
"(",
"f",
".",
"read",
"(",
")",
")",
"return",
"(",
"ydoc",
",",
"serialize_tojson",
"(",
"ydoc",
")",
")"
... | Loads a YAML-formatted file. | [
"Loads",
"a",
"YAML",
"-",
"formatted",
"file",
"."
] | python | train | 25.571429 |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1797-L1820 | def gradient(self, wrt):
"""Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the ... | [
"def",
"gradient",
"(",
"self",
",",
"wrt",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"c_wrt",
"=",
"c_str_array",
"(",
"wrt",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGrad",
"(",
"self",
".",
"handle",
",",
"mx_uint",
"(",
"len",
"(",
... | Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the symbol that the gradients are taken.... | [
"Gets",
"the",
"autodiff",
"of",
"current",
"symbol",
"."
] | python | train | 32.625 |
juju/theblues | theblues/charmstore.py | https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L207-L215 | def bundle_visualization_url(self, bundle_id, channel=None):
'''Generate the path to the visualization for bundles.
@param charm_id The ID of the bundle.
@param channel Optional channel name.
@return The url to the visualization.
'''
url = '{}/{}/diagram.svg'.format(self... | [
"def",
"bundle_visualization_url",
"(",
"self",
",",
"bundle_id",
",",
"channel",
"=",
"None",
")",
":",
"url",
"=",
"'{}/{}/diagram.svg'",
".",
"format",
"(",
"self",
".",
"url",
",",
"_get_path",
"(",
"bundle_id",
")",
")",
"return",
"_add_channel",
"(",
... | Generate the path to the visualization for bundles.
@param charm_id The ID of the bundle.
@param channel Optional channel name.
@return The url to the visualization. | [
"Generate",
"the",
"path",
"to",
"the",
"visualization",
"for",
"bundles",
"."
] | python | train | 42.333333 |
log2timeline/plaso | plaso/engine/single_process.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/single_process.py#L36-L79 | def _ProcessPathSpec(self, extraction_worker, parser_mediator, path_spec):
"""Processes a path specification.
Args:
extraction_worker (worker.ExtractionWorker): extraction worker.
parser_mediator (ParserMediator): parser mediator.
path_spec (dfvfs.PathSpec): path specification.
"""
se... | [
"def",
"_ProcessPathSpec",
"(",
"self",
",",
"extraction_worker",
",",
"parser_mediator",
",",
"path_spec",
")",
":",
"self",
".",
"_current_display_name",
"=",
"parser_mediator",
".",
"GetDisplayNameForPathSpec",
"(",
"path_spec",
")",
"try",
":",
"extraction_worker"... | Processes a path specification.
Args:
extraction_worker (worker.ExtractionWorker): extraction worker.
parser_mediator (ParserMediator): parser mediator.
path_spec (dfvfs.PathSpec): path specification. | [
"Processes",
"a",
"path",
"specification",
"."
] | python | train | 37.068182 |
mitsei/dlkit | dlkit/json_/grading/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/objects.py#L255-L273 | def set_input_score_end_range(self, score):
"""Sets the input score start range.
arg: score (decimal): the new start range
raise: InvalidArgument - ``score`` is invalid
raise: NoAccess - ``range`` cannot be modified
*compliance: mandatory -- This method must be implemented.... | [
"def",
"set_input_score_end_range",
"(",
"self",
",",
"score",
")",
":",
"# Implemented from template for osid.grading.GradeSystemForm.set_lowest_numeric_score",
"if",
"self",
".",
"get_input_score_end_range_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
... | Sets the input score start range.
arg: score (decimal): the new start range
raise: InvalidArgument - ``score`` is invalid
raise: NoAccess - ``range`` cannot be modified
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"input",
"score",
"start",
"range",
"."
] | python | train | 42.842105 |
blockchain-certificates/cert-issuer | cert_issuer/blockchain_handlers/ethereum/tx_utils.py | https://github.com/blockchain-certificates/cert-issuer/blob/e8a48e25472473b149bd411a9fd5f2ff0f8f100a/cert_issuer/blockchain_handlers/ethereum/tx_utils.py#L15-L31 | def verify_eth_transaction(signed_hextx, eth_data_field):
"""
Verify ethDataField field in transaction
:param signed_hextx:
:param eth_data_field:
:return:
"""
logging.info('verifying ethDataField value for transaction')
ethdata_hash = []
for s in signed_hextx.split('80a0'):
... | [
"def",
"verify_eth_transaction",
"(",
"signed_hextx",
",",
"eth_data_field",
")",
":",
"logging",
".",
"info",
"(",
"'verifying ethDataField value for transaction'",
")",
"ethdata_hash",
"=",
"[",
"]",
"for",
"s",
"in",
"signed_hextx",
".",
"split",
"(",
"'80a0'",
... | Verify ethDataField field in transaction
:param signed_hextx:
:param eth_data_field:
:return: | [
"Verify",
"ethDataField",
"field",
"in",
"transaction",
":",
"param",
"signed_hextx",
":",
":",
"param",
"eth_data_field",
":",
":",
"return",
":"
] | python | train | 35.352941 |
rytilahti/python-songpal | songpal/group.py | https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L136-L143 | async def info(self):
"""Return device info."""
"""
{'MasterCapability': 9, 'TransportPort': 3975}
"""
act = self.service.action("X_GetDeviceInfo")
res = await act.async_call()
return res | [
"async",
"def",
"info",
"(",
"self",
")",
":",
"\"\"\"\n {'MasterCapability': 9, 'TransportPort': 3975}\n \"\"\"",
"act",
"=",
"self",
".",
"service",
".",
"action",
"(",
"\"X_GetDeviceInfo\"",
")",
"res",
"=",
"await",
"act",
".",
"async_call",
"(",
"... | Return device info. | [
"Return",
"device",
"info",
"."
] | python | train | 29.5 |
pywbem/pywbem | pywbem/mof_compiler.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/mof_compiler.py#L1261-L1268 | def p_stringValueList(p):
"""stringValueList : stringValue
| stringValueList stringValue
"""
if len(p) == 2:
p[0] = _fixStringValue(p[1], p)
else:
p[0] = p[1] + _fixStringValue(p[2], p) | [
"def",
"p_stringValueList",
"(",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"_fixStringValue",
"(",
"p",
"[",
"1",
"]",
",",
"p",
")",
"else",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"+",... | stringValueList : stringValue
| stringValueList stringValue | [
"stringValueList",
":",
"stringValue",
"|",
"stringValueList",
"stringValue"
] | python | train | 31.5 |
tuomas2/automate | src/automate/services/plantumlserv.py | https://github.com/tuomas2/automate/blob/d8a8cd03cd0da047e033a2d305f3f260f8c4e017/src/automate/services/plantumlserv.py#L114-L122 | def write_svg(self):
"""
Returns PUML from the system as a SVG image. Requires plantuml library.
"""
import plantuml
puml = self.write_puml()
server = plantuml.PlantUML(url=self.url)
svg = server.processes(puml)
return svg | [
"def",
"write_svg",
"(",
"self",
")",
":",
"import",
"plantuml",
"puml",
"=",
"self",
".",
"write_puml",
"(",
")",
"server",
"=",
"plantuml",
".",
"PlantUML",
"(",
"url",
"=",
"self",
".",
"url",
")",
"svg",
"=",
"server",
".",
"processes",
"(",
"pum... | Returns PUML from the system as a SVG image. Requires plantuml library. | [
"Returns",
"PUML",
"from",
"the",
"system",
"as",
"a",
"SVG",
"image",
".",
"Requires",
"plantuml",
"library",
"."
] | python | train | 31.333333 |
tcalmant/ipopo | pelix/framework.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/framework.py#L1440-L1450 | def unget_service(self, service):
# type: (Any) -> bool
"""
Releases a service object for the associated service.
:param service: An instance of a service returned by ``get_service()``
:return: True if the bundle usage has been removed
"""
return self.__registry.... | [
"def",
"unget_service",
"(",
"self",
",",
"service",
")",
":",
"# type: (Any) -> bool",
"return",
"self",
".",
"__registry",
".",
"unget_service",
"(",
"self",
".",
"__bundle",
",",
"self",
".",
"__reference",
",",
"service",
")"
] | Releases a service object for the associated service.
:param service: An instance of a service returned by ``get_service()``
:return: True if the bundle usage has been removed | [
"Releases",
"a",
"service",
"object",
"for",
"the",
"associated",
"service",
"."
] | python | train | 35.181818 |
jtwhite79/pyemu | pyemu/utils/gw_utils.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/gw_utils.py#L582-L607 | def _write_mflist_ins(ins_filename,df,prefix):
""" write an instruction file for a MODFLOW list file
Parameters
----------
ins_filename : str
name of the instruction file to write
df : pandas.DataFrame
the dataframe of list file entries
prefix : str
the prefix to add to ... | [
"def",
"_write_mflist_ins",
"(",
"ins_filename",
",",
"df",
",",
"prefix",
")",
":",
"dt_str",
"=",
"df",
".",
"index",
".",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"strftime",
"(",
"\"%Y%m%d\"",
")",
")",
"name_len",
"=",
"11",
"-",
"(",
"len",
... | write an instruction file for a MODFLOW list file
Parameters
----------
ins_filename : str
name of the instruction file to write
df : pandas.DataFrame
the dataframe of list file entries
prefix : str
the prefix to add to the column names to form
obseravtions names | [
"write",
"an",
"instruction",
"file",
"for",
"a",
"MODFLOW",
"list",
"file"
] | python | train | 29.115385 |
fracpete/python-weka-wrapper3 | python/weka/flow/transformer.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L885-L906 | def fix_config(self, options):
"""
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict
"""
opt = "setup"
... | [
"def",
"fix_config",
"(",
"self",
",",
"options",
")",
":",
"opt",
"=",
"\"setup\"",
"if",
"opt",
"not",
"in",
"options",
":",
"options",
"[",
"opt",
"]",
"=",
"filters",
".",
"Filter",
"(",
"classname",
"=",
"\"weka.filters.AllFilter\"",
")",
"if",
"opt... | Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict | [
"Fixes",
"the",
"options",
"if",
"necessary",
".",
"I",
".",
"e",
".",
"it",
"adds",
"all",
"required",
"elements",
"to",
"the",
"dictionary",
"."
] | python | train | 35.5 |
koalalorenzo/python-digitalocean | digitalocean/Volume.py | https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Volume.py#L74-L108 | def create_from_snapshot(self, *args, **kwargs):
"""
Creates a Block Storage volume
Note: Every argument and parameter given to this method will be
assigned to the object.
Args:
name: string - a name for the volume
snapshot_id: string - unique identifier... | [
"def",
"create_from_snapshot",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get_data",
"(",
"'volumes/'",
",",
"type",
"=",
"POST",
",",
"params",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'... | Creates a Block Storage volume
Note: Every argument and parameter given to this method will be
assigned to the object.
Args:
name: string - a name for the volume
snapshot_id: string - unique identifier for the volume snapshot
size_gigabytes: int - size of th... | [
"Creates",
"a",
"Block",
"Storage",
"volume"
] | python | valid | 43.828571 |
Spinmob/spinmob | _functions.py | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L738-L763 | def fit_linear(xdata, ydata):
"""
Returns slope and intercept of line of best fit:
y = a*x + b
through the supplied data.
Parameters
----------
xdata, ydata:
Arrays of x data and y data (having matching lengths).
"""
x = _n.array(xdata)
y = _n.arra... | [
"def",
"fit_linear",
"(",
"xdata",
",",
"ydata",
")",
":",
"x",
"=",
"_n",
".",
"array",
"(",
"xdata",
")",
"y",
"=",
"_n",
".",
"array",
"(",
"ydata",
")",
"ax",
"=",
"_n",
".",
"average",
"(",
"x",
")",
"ay",
"=",
"_n",
".",
"average",
"(",... | Returns slope and intercept of line of best fit:
y = a*x + b
through the supplied data.
Parameters
----------
xdata, ydata:
Arrays of x data and y data (having matching lengths). | [
"Returns",
"slope",
"and",
"intercept",
"of",
"line",
"of",
"best",
"fit",
":",
"y",
"=",
"a",
"*",
"x",
"+",
"b",
"through",
"the",
"supplied",
"data",
".",
"Parameters",
"----------",
"xdata",
"ydata",
":",
"Arrays",
"of",
"x",
"data",
"and",
"y",
... | python | train | 19.615385 |
yyuu/botornado | boto/ec2/autoscale/__init__.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/autoscale/__init__.py#L217-L231 | def create_scaling_policy(self, scaling_policy):
"""
Creates a new Scaling Policy.
:type scaling_policy: :class:`boto.ec2.autoscale.policy.ScalingPolicy`
:param scaling_policy: ScalingPolicy object.
"""
params = {'AdjustmentType': scaling_policy.adjustment_type,
... | [
"def",
"create_scaling_policy",
"(",
"self",
",",
"scaling_policy",
")",
":",
"params",
"=",
"{",
"'AdjustmentType'",
":",
"scaling_policy",
".",
"adjustment_type",
",",
"'AutoScalingGroupName'",
":",
"scaling_policy",
".",
"as_name",
",",
"'PolicyName'",
":",
"scal... | Creates a new Scaling Policy.
:type scaling_policy: :class:`boto.ec2.autoscale.policy.ScalingPolicy`
:param scaling_policy: ScalingPolicy object. | [
"Creates",
"a",
"new",
"Scaling",
"Policy",
"."
] | python | train | 44.266667 |
JIC-CSB/jicbioimage.illustrate | jicbioimage/illustrate/__init__.py | https://github.com/JIC-CSB/jicbioimage.illustrate/blob/d88ddf81ee3eb3949677e2ef746af8169ce88092/jicbioimage/illustrate/__init__.py#L65-L86 | def draw_cross(self, position, color=(255, 0, 0), radius=4):
"""Draw a cross on the canvas.
:param position: (row, col) tuple
:param color: RGB tuple
:param radius: radius of the cross (int)
"""
y, x = position
for xmod in np.arange(-radius, radius+1, 1):
... | [
"def",
"draw_cross",
"(",
"self",
",",
"position",
",",
"color",
"=",
"(",
"255",
",",
"0",
",",
"0",
")",
",",
"radius",
"=",
"4",
")",
":",
"y",
",",
"x",
"=",
"position",
"for",
"xmod",
"in",
"np",
".",
"arange",
"(",
"-",
"radius",
",",
"... | Draw a cross on the canvas.
:param position: (row, col) tuple
:param color: RGB tuple
:param radius: radius of the cross (int) | [
"Draw",
"a",
"cross",
"on",
"the",
"canvas",
"."
] | python | test | 38.818182 |
ANTsX/ANTsPy | ants/core/ants_image_io.py | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L425-L515 | def image_read(filename, dimension=None, pixeltype='float', reorient=False):
"""
Read an ANTsImage from file
ANTsR function: `antsImageRead`
Arguments
---------
filename : string
Name of the file to read the image from.
dimension : int
Number of dimensions of the image rea... | [
"def",
"image_read",
"(",
"filename",
",",
"dimension",
"=",
"None",
",",
"pixeltype",
"=",
"'float'",
",",
"reorient",
"=",
"False",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.npy'",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expand... | Read an ANTsImage from file
ANTsR function: `antsImageRead`
Arguments
---------
filename : string
Name of the file to read the image from.
dimension : int
Number of dimensions of the image read. This need not be the same as
the dimensions of the image in the file. Allowed ... | [
"Read",
"an",
"ANTsImage",
"from",
"file"
] | python | train | 37.43956 |
glormph/msstitch | src/app/actions/headers/peptable.py | https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/headers/peptable.py#L58-L66 | def get_peptable_headerfields(headertypes, lookup=False, poolnames=False):
"""Called by driver to generate headerfields object"""
field_defs = {'isoquant': get_isoquant_fields,
'precursorquant': get_precursorquant_fields,
'peptidefdr': get_peptidefdr_fields,
... | [
"def",
"get_peptable_headerfields",
"(",
"headertypes",
",",
"lookup",
"=",
"False",
",",
"poolnames",
"=",
"False",
")",
":",
"field_defs",
"=",
"{",
"'isoquant'",
":",
"get_isoquant_fields",
",",
"'precursorquant'",
":",
"get_precursorquant_fields",
",",
"'peptide... | Called by driver to generate headerfields object | [
"Called",
"by",
"driver",
"to",
"generate",
"headerfields",
"object"
] | python | train | 55.888889 |
pywbem/pywbem | pywbem/cim_obj.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L415-L455 | def _qualifiers_tomof(qualifiers, indent, maxline=MAX_MOF_LINE):
"""
Return a MOF string with the qualifier values, including the surrounding
square brackets. The qualifiers are ordered by their name.
Return empty string if no qualifiers.
Normally multiline output and may fold qualifiers into mult... | [
"def",
"_qualifiers_tomof",
"(",
"qualifiers",
",",
"indent",
",",
"maxline",
"=",
"MAX_MOF_LINE",
")",
":",
"if",
"not",
"qualifiers",
":",
"return",
"u''",
"mof",
"=",
"[",
"]",
"mof",
".",
"append",
"(",
"_indent_str",
"(",
"indent",
")",
")",
"mof",
... | Return a MOF string with the qualifier values, including the surrounding
square brackets. The qualifiers are ordered by their name.
Return empty string if no qualifiers.
Normally multiline output and may fold qualifiers into multiple lines.
The order of qualifiers is preserved.
Parameters:
... | [
"Return",
"a",
"MOF",
"string",
"with",
"the",
"qualifier",
"values",
"including",
"the",
"surrounding",
"square",
"brackets",
".",
"The",
"qualifiers",
"are",
"ordered",
"by",
"their",
"name",
"."
] | python | train | 25.146341 |
fhamborg/news-please | newsplease/pipeline/extractor/comparer/comparer_date.py | https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/comparer/comparer_date.py#L4-L28 | def extract(self, item, list_article_candidate):
"""Compares the extracted publish dates.
:param item: The corresponding NewscrawlerItem
:param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted
:return: A string, the most likely publish date
... | [
"def",
"extract",
"(",
"self",
",",
"item",
",",
"list_article_candidate",
")",
":",
"list_publish_date",
"=",
"[",
"]",
"for",
"article_candidate",
"in",
"list_article_candidate",
":",
"if",
"article_candidate",
".",
"publish_date",
"!=",
"None",
":",
"list_publi... | Compares the extracted publish dates.
:param item: The corresponding NewscrawlerItem
:param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted
:return: A string, the most likely publish date | [
"Compares",
"the",
"extracted",
"publish",
"dates",
"."
] | python | train | 44.24 |
chrislit/abydos | abydos/distance/_mlipns.py | https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/distance/_mlipns.py#L48-L102 | def sim(self, src, tar, threshold=0.25, max_mismatches=2):
"""Return the MLIPNS similarity of two strings.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
threshold : float
A number [... | [
"def",
"sim",
"(",
"self",
",",
"src",
",",
"tar",
",",
"threshold",
"=",
"0.25",
",",
"max_mismatches",
"=",
"2",
")",
":",
"if",
"tar",
"==",
"src",
":",
"return",
"1.0",
"if",
"not",
"src",
"or",
"not",
"tar",
":",
"return",
"0.0",
"mismatches",... | Return the MLIPNS similarity of two strings.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
threshold : float
A number [0, 1] indicating the maximum similarity score, below
which... | [
"Return",
"the",
"MLIPNS",
"similarity",
"of",
"two",
"strings",
"."
] | python | valid | 27.727273 |
facelessuser/backrefs | backrefs/uniprops/__init__.py | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/uniprops/__init__.py#L411-L422 | def get_vertical_orientation_property(value, is_bytes=False):
"""Get `VO` property."""
obj = unidata.ascii_vertical_orientation if is_bytes else unidata.unicode_vertical_orientation
if value.startswith('^'):
negated = value[1:]
value = '^' + unidata.unicode_alias['verticalorientation'].get... | [
"def",
"get_vertical_orientation_property",
"(",
"value",
",",
"is_bytes",
"=",
"False",
")",
":",
"obj",
"=",
"unidata",
".",
"ascii_vertical_orientation",
"if",
"is_bytes",
"else",
"unidata",
".",
"unicode_vertical_orientation",
"if",
"value",
".",
"startswith",
"... | Get `VO` property. | [
"Get",
"VO",
"property",
"."
] | python | train | 36.583333 |
greenbender/pynntp | nntp/nntp.py | https://github.com/greenbender/pynntp/blob/991a76331cdf5d8f9dbf5b18f6e29adc80749a2f/nntp/nntp.py#L903-L929 | def list_gen(self, keyword=None, arg=None):
"""Generator for LIST command.
See list() for more information.
Yields:
An element in the list returned by list().
"""
if keyword:
keyword = keyword.upper()
if keyword is None or keyword == "ACTIVE":
... | [
"def",
"list_gen",
"(",
"self",
",",
"keyword",
"=",
"None",
",",
"arg",
"=",
"None",
")",
":",
"if",
"keyword",
":",
"keyword",
"=",
"keyword",
".",
"upper",
"(",
")",
"if",
"keyword",
"is",
"None",
"or",
"keyword",
"==",
"\"ACTIVE\"",
":",
"return"... | Generator for LIST command.
See list() for more information.
Yields:
An element in the list returned by list(). | [
"Generator",
"for",
"LIST",
"command",
"."
] | python | test | 32.518519 |
dwavesystems/dimod | dimod/binary_quadratic_model.py | https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/binary_quadratic_model.py#L1526-L1586 | def to_coo(self, fp=None, vartype_header=False):
"""Serialize the binary quadratic model to a COOrdinate_ format encoding.
.. _COOrdinate: https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_(COO)
Args:
fp (file, optional):
`.write()`-supporting `file object... | [
"def",
"to_coo",
"(",
"self",
",",
"fp",
"=",
"None",
",",
"vartype_header",
"=",
"False",
")",
":",
"import",
"dimod",
".",
"serialization",
".",
"coo",
"as",
"coo",
"if",
"fp",
"is",
"None",
":",
"return",
"coo",
".",
"dumps",
"(",
"self",
",",
"... | Serialize the binary quadratic model to a COOrdinate_ format encoding.
.. _COOrdinate: https://en.wikipedia.org/wiki/Sparse_matrix#Coordinate_list_(COO)
Args:
fp (file, optional):
`.write()`-supporting `file object`_ to save the linear and quadratic biases
o... | [
"Serialize",
"the",
"binary",
"quadratic",
"model",
"to",
"a",
"COOrdinate_",
"format",
"encoding",
"."
] | python | train | 36.393443 |
ecell/ecell4 | ecell4/extra/azure_batch.py | https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/extra/azure_batch.py#L370-L388 | def _read_stream_as_string(stream, encoding):
"""Read stream as string
Originally in azure-batch-samples.Python.Batch.common.helpers
:param stream: input stream generator
:param str encoding: The encoding of the file. The default is utf-8.
:return: The file content.
:rtype: str
"""
outp... | [
"def",
"_read_stream_as_string",
"(",
"stream",
",",
"encoding",
")",
":",
"output",
"=",
"io",
".",
"BytesIO",
"(",
")",
"try",
":",
"for",
"data",
"in",
"stream",
":",
"output",
".",
"write",
"(",
"data",
")",
"if",
"encoding",
"is",
"None",
":",
"... | Read stream as string
Originally in azure-batch-samples.Python.Batch.common.helpers
:param stream: input stream generator
:param str encoding: The encoding of the file. The default is utf-8.
:return: The file content.
:rtype: str | [
"Read",
"stream",
"as",
"string",
"Originally",
"in",
"azure",
"-",
"batch",
"-",
"samples",
".",
"Python",
".",
"Batch",
".",
"common",
".",
"helpers"
] | python | train | 31.894737 |
mbedmicro/pyOCD | pyocd/probe/pydapaccess/interface/pywinusb_backend.py | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/interface/pywinusb_backend.py#L153-L169 | def read(self, timeout=20.0):
"""
read data on the IN endpoint associated to the HID interface
"""
start = time()
while len(self.rcv_data) == 0:
sleep(0)
if time() - start > timeout:
# Read operations should typically take ~1-2ms.
... | [
"def",
"read",
"(",
"self",
",",
"timeout",
"=",
"20.0",
")",
":",
"start",
"=",
"time",
"(",
")",
"while",
"len",
"(",
"self",
".",
"rcv_data",
")",
"==",
"0",
":",
"sleep",
"(",
"0",
")",
"if",
"time",
"(",
")",
"-",
"start",
">",
"timeout",
... | read data on the IN endpoint associated to the HID interface | [
"read",
"data",
"on",
"the",
"IN",
"endpoint",
"associated",
"to",
"the",
"HID",
"interface"
] | python | train | 46.705882 |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/dataframeeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L586-L604 | def copy(self):
"""Copy text to clipboard"""
if not self.selectedIndexes():
return
(row_min, row_max,
col_min, col_max) = get_idx_rect(self.selectedIndexes())
index = header = False
df = self.model().df
obj = df.iloc[slice(row_min, row_max + 1... | [
"def",
"copy",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"selectedIndexes",
"(",
")",
":",
"return",
"(",
"row_min",
",",
"row_max",
",",
"col_min",
",",
"col_max",
")",
"=",
"get_idx_rect",
"(",
"self",
".",
"selectedIndexes",
"(",
")",
")",
... | Copy text to clipboard | [
"Copy",
"text",
"to",
"clipboard"
] | python | train | 36.684211 |
twilio/twilio-python | twilio/rest/serverless/v1/service/function/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/serverless/v1/service/function/__init__.py#L342-L356 | def _proxy(self):
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FunctionContext for this FunctionInstance
:rtype: twilio.rest.serverless.v1.service.function.Func... | [
"def",
"_proxy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_context",
"is",
"None",
":",
"self",
".",
"_context",
"=",
"FunctionContext",
"(",
"self",
".",
"_version",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
... | Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: FunctionContext for this FunctionInstance
:rtype: twilio.rest.serverless.v1.service.function.FunctionContext | [
"Generate",
"an",
"instance",
"context",
"for",
"the",
"instance",
"the",
"context",
"is",
"capable",
"of",
"performing",
"various",
"actions",
".",
"All",
"instance",
"actions",
"are",
"proxied",
"to",
"the",
"context"
] | python | train | 38.933333 |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/case_mixin.py | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/case_mixin.py#L22-L35 | def add_case(self, case_obj):
"""Add a case obj with individuals to adapter
Args:
case_obj (puzzle.models.Case)
"""
for ind_obj in case_obj.individuals:
self._add_individual(ind_obj)
logger.debug("Adding case {0} to plugin... | [
"def",
"add_case",
"(",
"self",
",",
"case_obj",
")",
":",
"for",
"ind_obj",
"in",
"case_obj",
".",
"individuals",
":",
"self",
".",
"_add_individual",
"(",
"ind_obj",
")",
"logger",
".",
"debug",
"(",
"\"Adding case {0} to plugin\"",
".",
"format",
"(",
"ca... | Add a case obj with individuals to adapter
Args:
case_obj (puzzle.models.Case) | [
"Add",
"a",
"case",
"obj",
"with",
"individuals",
"to",
"adapter",
"Args",
":",
"case_obj",
"(",
"puzzle",
".",
"models",
".",
"Case",
")"
] | python | train | 37.5 |
ponty/PyVirtualDisplay | pyvirtualdisplay/abstractdisplay.py | https://github.com/ponty/PyVirtualDisplay/blob/903841f5ef13bf162be6fdd22daa5c349af45d67/pyvirtualdisplay/abstractdisplay.py#L154-L169 | def _setup_xauth(self):
'''
Set up the Xauthority file and the XAUTHORITY environment variable.
'''
handle, filename = tempfile.mkstemp(prefix='PyVirtualDisplay.',
suffix='.Xauthority')
self._xauth_filename = filename
os.close(h... | [
"def",
"_setup_xauth",
"(",
"self",
")",
":",
"handle",
",",
"filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
"prefix",
"=",
"'PyVirtualDisplay.'",
",",
"suffix",
"=",
"'.Xauthority'",
")",
"self",
".",
"_xauth_filename",
"=",
"filename",
"os",
".",
"close"... | Set up the Xauthority file and the XAUTHORITY environment variable. | [
"Set",
"up",
"the",
"Xauthority",
"file",
"and",
"the",
"XAUTHORITY",
"environment",
"variable",
"."
] | python | train | 41.75 |
barnybug/finite | finite/dfa.py | https://github.com/barnybug/finite/blob/a587fef255dc90377e86ba1449a19070ce910a36/finite/dfa.py#L234-L290 | def load(self, config):
"""load the configuration"""
self.config = config
if 'start' not in self.config:
raise ParseError('missing start entry')
if 'states' not in self.config:
raise ParseError('missing states entry')
if 'transitions' not in self.... | [
"def",
"load",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config",
"if",
"'start'",
"not",
"in",
"self",
".",
"config",
":",
"raise",
"ParseError",
"(",
"'missing start entry'",
")",
"if",
"'states'",
"not",
"in",
"self",
".",
"... | load the configuration | [
"load",
"the",
"configuration"
] | python | train | 38.929825 |
moonso/query_phenomizer | query_phenomizer/cli.py | https://github.com/moonso/query_phenomizer/blob/19883ed125e224fc17cbb71240428fd60082e017/query_phenomizer/cli.py#L62-L115 | def cli(ctx, hpo_term, check_terms, output, p_value_limit, verbose, username,
password, to_json):
"Give hpo terms either on the form 'HP:0001623', or '0001623'"
loglevel = LEVELS.get(min(verbose, 3))
configure_stream(level=loglevel)
if not hpo_term:
logger.info("Please specify ... | [
"def",
"cli",
"(",
"ctx",
",",
"hpo_term",
",",
"check_terms",
",",
"output",
",",
"p_value_limit",
",",
"verbose",
",",
"username",
",",
"password",
",",
"to_json",
")",
":",
"loglevel",
"=",
"LEVELS",
".",
"get",
"(",
"min",
"(",
"verbose",
",",
"3",... | Give hpo terms either on the form 'HP:0001623', or '0001623 | [
"Give",
"hpo",
"terms",
"either",
"on",
"the",
"form",
"HP",
":",
"0001623",
"or",
"0001623"
] | python | train | 36.222222 |
CalebBell/fluids | fluids/flow_meter.py | https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/flow_meter.py#L1719-L1839 | def differential_pressure_meter_solver(D, rho, mu, k, D2=None, P1=None, P2=None,
m=None, meter_type=ISO_5167_ORIFICE,
taps=None):
r'''Calculates either the mass flow rate, the upstream pressure, the second
pressure value, or the ori... | [
"def",
"differential_pressure_meter_solver",
"(",
"D",
",",
"rho",
",",
"mu",
",",
"k",
",",
"D2",
"=",
"None",
",",
"P1",
"=",
"None",
",",
"P2",
"=",
"None",
",",
"m",
"=",
"None",
",",
"meter_type",
"=",
"ISO_5167_ORIFICE",
",",
"taps",
"=",
"None... | r'''Calculates either the mass flow rate, the upstream pressure, the second
pressure value, or the orifice diameter for a differential
pressure flow meter based on the geometry of the meter, measured pressures
of the meter, and the density, viscosity, and isentropic exponent of the
fluid. This solves ... | [
"r",
"Calculates",
"either",
"the",
"mass",
"flow",
"rate",
"the",
"upstream",
"pressure",
"the",
"second",
"pressure",
"value",
"or",
"the",
"orifice",
"diameter",
"for",
"a",
"differential",
"pressure",
"flow",
"meter",
"based",
"on",
"the",
"geometry",
"of"... | python | train | 46.429752 |
sixty-north/added-value | source/added_value/str_role.py | https://github.com/sixty-north/added-value/blob/7ae75b56712822b074fc874612d6058bb7d16a1e/source/added_value/str_role.py#L6-L19 | def make_str_node(rawtext, app, prefixed_name, obj, parent, modname, options):
"""Render a Python object to text using the repr() function.
:param rawtext: Text being replaced with link node.
:param app: Sphinx application context
:param prefixed_name: The dotted Python name for obj.
:param obj: Th... | [
"def",
"make_str_node",
"(",
"rawtext",
",",
"app",
",",
"prefixed_name",
",",
"obj",
",",
"parent",
",",
"modname",
",",
"options",
")",
":",
"text",
"=",
"str",
"(",
"obj",
")",
"node",
"=",
"nodes",
".",
"Text",
"(",
"text",
",",
"rawsource",
"=",... | Render a Python object to text using the repr() function.
:param rawtext: Text being replaced with link node.
:param app: Sphinx application context
:param prefixed_name: The dotted Python name for obj.
:param obj: The Python object to be rendered to text.
:param parent: The parent Python object of... | [
"Render",
"a",
"Python",
"object",
"to",
"text",
"using",
"the",
"repr",
"()",
"function",
"."
] | python | train | 43.357143 |
pydata/xarray | xarray/core/dataset.py | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataset.py#L3060-L3083 | def ffill(self, dim, limit=None):
'''Fill NaN values by propogating values forward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
... | [
"def",
"ffill",
"(",
"self",
",",
"dim",
",",
"limit",
"=",
"None",
")",
":",
"from",
".",
"missing",
"import",
"ffill",
",",
"_apply_over_vars_with_dim",
"new",
"=",
"_apply_over_vars_with_dim",
"(",
"ffill",
",",
"self",
",",
"dim",
"=",
"dim",
",",
"l... | Fill NaN values by propogating values forward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
The maximum number of consecutive NaN values ... | [
"Fill",
"NaN",
"values",
"by",
"propogating",
"values",
"forward"
] | python | train | 32.208333 |
DerMitch/fritzbox-smarthome | fritzhome/__main__.py | https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L101-L157 | def graphite(context, server, port, interval, prefix):
"""Display energy stats of all actors"""
fritz = context.obj
fritz.login()
sid_ttl = time.time() + 600
# Find actors and create carbon keys
click.echo(" * Requesting actors list")
simple_chars = re.compile('[^A-Za-z0-9]+')
actors = ... | [
"def",
"graphite",
"(",
"context",
",",
"server",
",",
"port",
",",
"interval",
",",
"prefix",
")",
":",
"fritz",
"=",
"context",
".",
"obj",
"fritz",
".",
"login",
"(",
")",
"sid_ttl",
"=",
"time",
".",
"time",
"(",
")",
"+",
"600",
"# Find actors a... | Display energy stats of all actors | [
"Display",
"energy",
"stats",
"of",
"all",
"actors"
] | python | train | 30.105263 |
saltstack/salt | salt/states/file.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L4306-L4475 | def line(name, content=None, match=None, mode=None, location=None,
before=None, after=None, show_changes=True, backup=False,
quiet=False, indent=True, create=False, user=None,
group=None, file_mode=None):
'''
Line-based editing of a file.
.. versionadded:: 2015.8.0
:param na... | [
"def",
"line",
"(",
"name",
",",
"content",
"=",
"None",
",",
"match",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"location",
"=",
"None",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
",",
"show_changes",
"=",
"True",
",",
"backup",
"=",... | Line-based editing of a file.
.. versionadded:: 2015.8.0
:param name:
Filesystem path to the file to be edited.
:param content:
Content of the line. Allowed to be empty if mode=delete.
:param match:
Match the target line for an action by
a fragment of a string or regu... | [
"Line",
"-",
"based",
"editing",
"of",
"a",
"file",
"."
] | python | train | 32.282353 |
pyusb/pyusb | usb/core.py | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/core.py#L1081-L1091 | def attach_kernel_driver(self, interface):
r"""Re-attach an interface's kernel driver, which was previously
detached using detach_kernel_driver().
The interface parameter is the device interface number to attach the
driver to.
"""
self._ctx.managed_open()
self._c... | [
"def",
"attach_kernel_driver",
"(",
"self",
",",
"interface",
")",
":",
"self",
".",
"_ctx",
".",
"managed_open",
"(",
")",
"self",
".",
"_ctx",
".",
"backend",
".",
"attach_kernel_driver",
"(",
"self",
".",
"_ctx",
".",
"handle",
",",
"interface",
")"
] | r"""Re-attach an interface's kernel driver, which was previously
detached using detach_kernel_driver().
The interface parameter is the device interface number to attach the
driver to. | [
"r",
"Re",
"-",
"attach",
"an",
"interface",
"s",
"kernel",
"driver",
"which",
"was",
"previously",
"detached",
"using",
"detach_kernel_driver",
"()",
"."
] | python | train | 35.909091 |
mozilla-releng/scriptworker | scriptworker/ed25519.py | https://github.com/mozilla-releng/scriptworker/blob/8e97bbd83b9b578565ec57904c966dd6ae4ef0ae/scriptworker/ed25519.py#L86-L100 | def ed25519_private_key_to_string(key):
"""Convert an ed25519 private key to a base64-encoded string.
Args:
key (Ed25519PrivateKey): the key to write to the file.
Returns:
str: the key representation as a str
"""
return base64.b64encode(key.private_bytes(
encoding=serializ... | [
"def",
"ed25519_private_key_to_string",
"(",
"key",
")",
":",
"return",
"base64",
".",
"b64encode",
"(",
"key",
".",
"private_bytes",
"(",
"encoding",
"=",
"serialization",
".",
"Encoding",
".",
"Raw",
",",
"format",
"=",
"serialization",
".",
"PrivateFormat",
... | Convert an ed25519 private key to a base64-encoded string.
Args:
key (Ed25519PrivateKey): the key to write to the file.
Returns:
str: the key representation as a str | [
"Convert",
"an",
"ed25519",
"private",
"key",
"to",
"a",
"base64",
"-",
"encoded",
"string",
"."
] | python | train | 30.666667 |
saltstack/salt | salt/utils/network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L606-L627 | def cidr_to_ipv4_netmask(cidr_bits):
'''
Returns an IPv4 netmask
'''
try:
cidr_bits = int(cidr_bits)
if not 1 <= cidr_bits <= 32:
return ''
except ValueError:
return ''
netmask = ''
for idx in range(4):
if idx:
netmask += '.'
i... | [
"def",
"cidr_to_ipv4_netmask",
"(",
"cidr_bits",
")",
":",
"try",
":",
"cidr_bits",
"=",
"int",
"(",
"cidr_bits",
")",
"if",
"not",
"1",
"<=",
"cidr_bits",
"<=",
"32",
":",
"return",
"''",
"except",
"ValueError",
":",
"return",
"''",
"netmask",
"=",
"''"... | Returns an IPv4 netmask | [
"Returns",
"an",
"IPv4",
"netmask"
] | python | train | 22.681818 |
neo4j-contrib/neomodel | neomodel/cardinality.py | https://github.com/neo4j-contrib/neomodel/blob/cca5de4c4e90998293558b871b1b529095c91a38/neomodel/cardinality.py#L72-L80 | def disconnect(self, node):
"""
Disconnect node
:param node:
:return:
"""
if super(OneOrMore, self).__len__() < 2:
raise AttemptedCardinalityViolation("One or more expected")
return super(OneOrMore, self).disconnect(node) | [
"def",
"disconnect",
"(",
"self",
",",
"node",
")",
":",
"if",
"super",
"(",
"OneOrMore",
",",
"self",
")",
".",
"__len__",
"(",
")",
"<",
"2",
":",
"raise",
"AttemptedCardinalityViolation",
"(",
"\"One or more expected\"",
")",
"return",
"super",
"(",
"On... | Disconnect node
:param node:
:return: | [
"Disconnect",
"node",
":",
"param",
"node",
":",
":",
"return",
":"
] | python | train | 31.222222 |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L2239-L2249 | def do_filesize(self, line):
"""filesize FILE
Prints the size of the file, in bytes. This function is primarily
for testing.
"""
if len(line) == 0:
print_err("Must provide a filename")
return
filename = resolve_path(line)
self.print(... | [
"def",
"do_filesize",
"(",
"self",
",",
"line",
")",
":",
"if",
"len",
"(",
"line",
")",
"==",
"0",
":",
"print_err",
"(",
"\"Must provide a filename\"",
")",
"return",
"filename",
"=",
"resolve_path",
"(",
"line",
")",
"self",
".",
"print",
"(",
"auto",... | filesize FILE
Prints the size of the file, in bytes. This function is primarily
for testing. | [
"filesize",
"FILE"
] | python | train | 30.818182 |
Pythonity/icon-font-to-png | icon_font_to_png/icon_font.py | https://github.com/Pythonity/icon-font-to-png/blob/4851fe15c077402749f843d43fbc10d28f6c655d/icon_font_to_png/icon_font.py#L78-L175 | def export_icon(self, icon, size, color='black', scale='auto',
filename=None, export_dir='exported'):
"""
Exports given icon with provided parameters.
If the desired icon size is less than 150x150 pixels, we will first
create a 150x150 pixels image and then scale it ... | [
"def",
"export_icon",
"(",
"self",
",",
"icon",
",",
"size",
",",
"color",
"=",
"'black'",
",",
"scale",
"=",
"'auto'",
",",
"filename",
"=",
"None",
",",
"export_dir",
"=",
"'exported'",
")",
":",
"org_size",
"=",
"size",
"size",
"=",
"max",
"(",
"1... | Exports given icon with provided parameters.
If the desired icon size is less than 150x150 pixels, we will first
create a 150x150 pixels image and then scale it down, so that
it's much less likely that the edges of the icon end up cropped.
:param icon: valid icon name
:param fi... | [
"Exports",
"given",
"icon",
"with",
"provided",
"parameters",
"."
] | python | train | 35.908163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.