repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
pystorm/pystorm | pystorm/component.py | https://github.com/pystorm/pystorm/blob/0f853e007c79e03cefdb4a0794423f84dce4c2f3/pystorm/component.py#L406-L478 | def emit(
self,
tup,
tup_id=None,
stream=None,
anchors=None,
direct_task=None,
need_task_ids=False,
):
"""Emit a new Tuple to a stream.
:param tup: the Tuple payload to send to Storm, should contain only
JSON-serializable d... | [
"def",
"emit",
"(",
"self",
",",
"tup",
",",
"tup_id",
"=",
"None",
",",
"stream",
"=",
"None",
",",
"anchors",
"=",
"None",
",",
"direct_task",
"=",
"None",
",",
"need_task_ids",
"=",
"False",
",",
")",
":",
"if",
"not",
"isinstance",
"(",
"tup",
... | Emit a new Tuple to a stream.
:param tup: the Tuple payload to send to Storm, should contain only
JSON-serializable data.
:type tup: :class:`list` or :class:`pystorm.component.Tuple`
:param tup_id: the ID for the Tuple. If omitted by a
:class:`pystorm.... | [
"Emit",
"a",
"new",
"Tuple",
"to",
"a",
"stream",
"."
] | python | train |
diffeo/rejester | rejester/_task_master.py | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L869-L878 | def num_pending(self, work_spec_name):
'''Get the number of pending work units for some work spec.
These are work units that some worker is currently working on
(hopefully; it could include work units assigned to workers that
died and that have not yet expired).
'''
ret... | [
"def",
"num_pending",
"(",
"self",
",",
"work_spec_name",
")",
":",
"return",
"self",
".",
"registry",
".",
"len",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"priority_min",
"=",
"time",
".",
"time",
"(",
")",
")"
] | Get the number of pending work units for some work spec.
These are work units that some worker is currently working on
(hopefully; it could include work units assigned to workers that
died and that have not yet expired). | [
"Get",
"the",
"number",
"of",
"pending",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | python | train |
SuperCowPowers/workbench | workbench/workers/yara_sigs.py | https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/yara_sigs.py#L9-L21 | def get_rules_from_disk():
''' Recursively traverse the yara/rules directory for rules '''
# Try to find the yara rules directory relative to the worker
my_dir = os.path.dirname(os.path.realpath(__file__))
yara_rule_path = os.path.join(my_dir, 'yara/rules')
if not os.path.exists(yara_rule_path):
... | [
"def",
"get_rules_from_disk",
"(",
")",
":",
"# Try to find the yara rules directory relative to the worker",
"my_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"yara_rule_path",
"=",
"os",
".",
... | Recursively traverse the yara/rules directory for rules | [
"Recursively",
"traverse",
"the",
"yara",
"/",
"rules",
"directory",
"for",
"rules"
] | python | train |
mikedh/trimesh | trimesh/collision.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/collision.py#L373-L439 | def in_collision_other(self, other_manager,
return_names=False, return_data=False):
"""
Check if any object from this manager collides with any object
from another manager.
Parameters
-------------------
other_manager : CollisionManager
... | [
"def",
"in_collision_other",
"(",
"self",
",",
"other_manager",
",",
"return_names",
"=",
"False",
",",
"return_data",
"=",
"False",
")",
":",
"cdata",
"=",
"fcl",
".",
"CollisionData",
"(",
")",
"if",
"return_names",
"or",
"return_data",
":",
"cdata",
"=",
... | Check if any object from this manager collides with any object
from another manager.
Parameters
-------------------
other_manager : CollisionManager
Another collision manager object
return_names : bool
If true, a set is returned containing the names
... | [
"Check",
"if",
"any",
"object",
"from",
"this",
"manager",
"collides",
"with",
"any",
"object",
"from",
"another",
"manager",
"."
] | python | train |
saltstack/salt | salt/fileclient.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L870-L886 | def file_list(self, saltenv='base', prefix=''):
'''
Return a list of files in the given environment
with optional relative prefix path to limit directory traversal
'''
ret = []
prefix = prefix.strip('/')
for path in self.opts['pillar_roots'].get(saltenv, []):
... | [
"def",
"file_list",
"(",
"self",
",",
"saltenv",
"=",
"'base'",
",",
"prefix",
"=",
"''",
")",
":",
"ret",
"=",
"[",
"]",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
"'/'",
")",
"for",
"path",
"in",
"self",
".",
"opts",
"[",
"'pillar_roots'",
"]",
... | Return a list of files in the given environment
with optional relative prefix path to limit directory traversal | [
"Return",
"a",
"list",
"of",
"files",
"in",
"the",
"given",
"environment",
"with",
"optional",
"relative",
"prefix",
"path",
"to",
"limit",
"directory",
"traversal"
] | python | train |
wilson-eft/wilson | wilson/classes.py | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/classes.py#L281-L308 | def plotdata(self, key, part='re', scale='log', steps=50):
"""Return a tuple of arrays x, y that can be fed to plt.plot,
where x is the scale in GeV and y is the parameter of interest.
Parameters:
- key: dicionary key of the parameter to be plotted (e.g. a WCxf
coefficient na... | [
"def",
"plotdata",
"(",
"self",
",",
"key",
",",
"part",
"=",
"'re'",
",",
"scale",
"=",
"'log'",
",",
"steps",
"=",
"50",
")",
":",
"if",
"scale",
"==",
"'log'",
":",
"x",
"=",
"np",
".",
"logspace",
"(",
"log",
"(",
"self",
".",
"scale_min",
... | Return a tuple of arrays x, y that can be fed to plt.plot,
where x is the scale in GeV and y is the parameter of interest.
Parameters:
- key: dicionary key of the parameter to be plotted (e.g. a WCxf
coefficient name or a SM parameter like 'g')
- part: plot the real part 're'... | [
"Return",
"a",
"tuple",
"of",
"arrays",
"x",
"y",
"that",
"can",
"be",
"fed",
"to",
"plt",
".",
"plot",
"where",
"x",
"is",
"the",
"scale",
"in",
"GeV",
"and",
"y",
"is",
"the",
"parameter",
"of",
"interest",
"."
] | python | train |
ryanvarley/ExoData | exodata/equations.py | https://github.com/ryanvarley/ExoData/blob/e0d3652117214d2377a707d6778f93b7eb201a41/exodata/equations.py#L768-L787 | def ratioTerminatorToStar(H_p, R_p, R_s): # TODO add into planet class
r"""Calculates the ratio of the terminator to the star assuming 5 scale
heights large. If you dont know all of the input try
:py:func:`calcRatioTerminatorToStar`
.. math::
\Delta F = \frac{10 H R_p + 25 H^2}{R_\star^2}
... | [
"def",
"ratioTerminatorToStar",
"(",
"H_p",
",",
"R_p",
",",
"R_s",
")",
":",
"# TODO add into planet class",
"deltaF",
"=",
"(",
"(",
"10",
"*",
"H_p",
"*",
"R_p",
")",
"+",
"(",
"25",
"*",
"H_p",
"**",
"2",
")",
")",
"/",
"(",
"R_s",
"**",
"2",
... | r"""Calculates the ratio of the terminator to the star assuming 5 scale
heights large. If you dont know all of the input try
:py:func:`calcRatioTerminatorToStar`
.. math::
\Delta F = \frac{10 H R_p + 25 H^2}{R_\star^2}
Where :math:`\Delta F` is the ration of the terminator to the star,
H s... | [
"r",
"Calculates",
"the",
"ratio",
"of",
"the",
"terminator",
"to",
"the",
"star",
"assuming",
"5",
"scale",
"heights",
"large",
".",
"If",
"you",
"dont",
"know",
"all",
"of",
"the",
"input",
"try",
":",
"py",
":",
"func",
":",
"calcRatioTerminatorToStar"
... | python | train |
senaite/senaite.core | bika/lims/browser/worksheet/views/add_duplicate.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/worksheet/views/add_duplicate.py#L142-L153 | def get_container_mapping(self):
"""Returns a mapping of container -> postition
"""
layout = self.context.getLayout()
container_mapping = {}
for slot in layout:
if slot["type"] != "a":
continue
position = slot["position"]
contai... | [
"def",
"get_container_mapping",
"(",
"self",
")",
":",
"layout",
"=",
"self",
".",
"context",
".",
"getLayout",
"(",
")",
"container_mapping",
"=",
"{",
"}",
"for",
"slot",
"in",
"layout",
":",
"if",
"slot",
"[",
"\"type\"",
"]",
"!=",
"\"a\"",
":",
"c... | Returns a mapping of container -> postition | [
"Returns",
"a",
"mapping",
"of",
"container",
"-",
">",
"postition"
] | python | train |
icometrix/dicom2nifti | dicom2nifti/common.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L333-L343 | def get_is_value(tag):
"""
Getters for data that also work with implicit transfersyntax
:param tag: the tag to read
"""
# data is int formatted as string so convert te string first and cast to int
if tag.VR == 'OB' or tag.VR == 'UN':
value = int(tag.value.decode("ascii").replace(" ", ""... | [
"def",
"get_is_value",
"(",
"tag",
")",
":",
"# data is int formatted as string so convert te string first and cast to int",
"if",
"tag",
".",
"VR",
"==",
"'OB'",
"or",
"tag",
".",
"VR",
"==",
"'UN'",
":",
"value",
"=",
"int",
"(",
"tag",
".",
"value",
".",
"d... | Getters for data that also work with implicit transfersyntax
:param tag: the tag to read | [
"Getters",
"for",
"data",
"that",
"also",
"work",
"with",
"implicit",
"transfersyntax"
] | python | train |
mdsol/rwslib | rwslib/extras/rwscmd/data_scrambler.py | https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/extras/rwscmd/data_scrambler.py#L106-L124 | def scramble_value(self, value):
"""Duck-type value and scramble appropriately"""
try:
type, format = typeof_rave_data(value)
if type == 'float':
i, f = value.split('.')
return self.scramble_float(len(value) - 1, len(f))
elif type == 'i... | [
"def",
"scramble_value",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"type",
",",
"format",
"=",
"typeof_rave_data",
"(",
"value",
")",
"if",
"type",
"==",
"'float'",
":",
"i",
",",
"f",
"=",
"value",
".",
"split",
"(",
"'.'",
")",
"return",
"... | Duck-type value and scramble appropriately | [
"Duck",
"-",
"type",
"value",
"and",
"scramble",
"appropriately"
] | python | train |
mosesschwartz/scrypture | scrypture/webapi.py | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/webapi.py#L40-L46 | def radio_field(*args, **kwargs):
'''
Get a password
'''
radio_field = wtforms.RadioField(*args, **kwargs)
radio_field.input_type = 'radio_field'
return radio_field | [
"def",
"radio_field",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"radio_field",
"=",
"wtforms",
".",
"RadioField",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"radio_field",
".",
"input_type",
"=",
"'radio_field'",
"return",
"radio_field"
] | Get a password | [
"Get",
"a",
"password"
] | python | train |
ming060/robotframework-uiautomatorlibrary | uiautomatorlibrary/Mobile.py | https://github.com/ming060/robotframework-uiautomatorlibrary/blob/b70202b6a8aa68b4efd9d029c2845407fb33451a/uiautomatorlibrary/Mobile.py#L772-L776 | def set_text(self, input_text, *args, **selectors):
"""
Set *input_text* to the UI object with *selectors*
"""
self.device(**selectors).set_text(input_text) | [
"def",
"set_text",
"(",
"self",
",",
"input_text",
",",
"*",
"args",
",",
"*",
"*",
"selectors",
")",
":",
"self",
".",
"device",
"(",
"*",
"*",
"selectors",
")",
".",
"set_text",
"(",
"input_text",
")"
] | Set *input_text* to the UI object with *selectors* | [
"Set",
"*",
"input_text",
"*",
"to",
"the",
"UI",
"object",
"with",
"*",
"selectors",
"*"
] | python | train |
mdiener/grace | grace/py27/slimit/parser.py | https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/slimit/parser.py#L311-L324 | def p_property_assignment(self, p):
"""property_assignment \
: property_name COLON assignment_expr
| GETPROP property_name LPAREN RPAREN LBRACE function_body RBRACE
| SETPROP property_name LPAREN formal_parameter_list RPAREN \
LBRACE function_body RBRACE... | [
"def",
"p_property_assignment",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Assign",
"(",
"left",
"=",
"p",
"[",
"1",
"]",
",",
"op",
"=",
"p",
"[",
"2",
"]",
",",
"ri... | property_assignment \
: property_name COLON assignment_expr
| GETPROP property_name LPAREN RPAREN LBRACE function_body RBRACE
| SETPROP property_name LPAREN formal_parameter_list RPAREN \
LBRACE function_body RBRACE | [
"property_assignment",
"\\",
":",
"property_name",
"COLON",
"assignment_expr",
"|",
"GETPROP",
"property_name",
"LPAREN",
"RPAREN",
"LBRACE",
"function_body",
"RBRACE",
"|",
"SETPROP",
"property_name",
"LPAREN",
"formal_parameter_list",
"RPAREN",
"\\",
"LBRACE",
"function... | python | train |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/productreleases_api.py | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/productreleases_api.py#L504-L527 | def get_all_support_level(self, **kwargs):
"""
Gets all Product Releases Support Level
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>... | [
"def",
"get_all_support_level",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_all_support_level_with_http_info",
... | Gets all Product Releases Support Level
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(respo... | [
"Gets",
"all",
"Product",
"Releases",
"Support",
"Level",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
"function",
"to",
"be"... | python | train |
GNS3/gns3-server | gns3server/controller/compute.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L604-L614 | def forward(self, method, type, path, data=None):
"""
Forward a call to the emulator on compute
"""
try:
action = "/{}/{}".format(type, path)
res = yield from self.http_query(method, action, data=data, timeout=None)
except aiohttp.ServerDisconnectedError:
... | [
"def",
"forward",
"(",
"self",
",",
"method",
",",
"type",
",",
"path",
",",
"data",
"=",
"None",
")",
":",
"try",
":",
"action",
"=",
"\"/{}/{}\"",
".",
"format",
"(",
"type",
",",
"path",
")",
"res",
"=",
"yield",
"from",
"self",
".",
"http_query... | Forward a call to the emulator on compute | [
"Forward",
"a",
"call",
"to",
"the",
"emulator",
"on",
"compute"
] | python | train |
OCHA-DAP/hdx-python-utilities | src/hdx/utilities/compare.py | https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/compare.py#L24-L38 | def assert_files_same(path1, path2):
# type: (str, str) -> None
"""Asserts that two files are the same and returns delta using
-, ?, + format if not
Args:
path1 (str): Path to first file
path2 (str): Path to second file
Returns:
None
"""
difflines = compare_files(p... | [
"def",
"assert_files_same",
"(",
"path1",
",",
"path2",
")",
":",
"# type: (str, str) -> None",
"difflines",
"=",
"compare_files",
"(",
"path1",
",",
"path2",
")",
"assert",
"len",
"(",
"difflines",
")",
"==",
"0",
",",
"''",
".",
"join",
"(",
"[",
"'\\n'"... | Asserts that two files are the same and returns delta using
-, ?, + format if not
Args:
path1 (str): Path to first file
path2 (str): Path to second file
Returns:
None | [
"Asserts",
"that",
"two",
"files",
"are",
"the",
"same",
"and",
"returns",
"delta",
"using",
"-",
"?",
"+",
"format",
"if",
"not"
] | python | train |
Esri/ArcREST | src/arcrest/common/geometry.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/geometry.py#L563-L582 | def asDictionary(self):
""" returns the envelope as a dictionary """
template = {
"xmin" : self._xmin,
"ymin" : self._ymin,
"xmax" : self._xmax,
"ymax" : self._ymax,
"spatialReference" : self.spatialReference
}
if self._zmax is ... | [
"def",
"asDictionary",
"(",
"self",
")",
":",
"template",
"=",
"{",
"\"xmin\"",
":",
"self",
".",
"_xmin",
",",
"\"ymin\"",
":",
"self",
".",
"_ymin",
",",
"\"xmax\"",
":",
"self",
".",
"_xmax",
",",
"\"ymax\"",
":",
"self",
".",
"_ymax",
",",
"\"spa... | returns the envelope as a dictionary | [
"returns",
"the",
"envelope",
"as",
"a",
"dictionary"
] | python | train |
apache/incubator-heron | heron/tools/admin/src/python/standalone.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/admin/src/python/standalone.py#L840-L858 | def get_hostname(ip_addr, cl_args):
'''
get host name of remote host
'''
if is_self(ip_addr):
return get_self_hostname()
cmd = "hostname"
ssh_cmd = ssh_remote_execute(cmd, ip_addr, cl_args)
pid = subprocess.Popen(ssh_cmd,
shell=True,
stdout=subprocess.... | [
"def",
"get_hostname",
"(",
"ip_addr",
",",
"cl_args",
")",
":",
"if",
"is_self",
"(",
"ip_addr",
")",
":",
"return",
"get_self_hostname",
"(",
")",
"cmd",
"=",
"\"hostname\"",
"ssh_cmd",
"=",
"ssh_remote_execute",
"(",
"cmd",
",",
"ip_addr",
",",
"cl_args",... | get host name of remote host | [
"get",
"host",
"name",
"of",
"remote",
"host"
] | python | valid |
Contraz/demosys-py | demosys/resources/base.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/resources/base.py#L121-L129 | def load_pool(self):
"""
Loads all the data files using the configured finders.
"""
for meta in self._resources:
resource = self.load(meta)
yield meta, resource
self._resources = [] | [
"def",
"load_pool",
"(",
"self",
")",
":",
"for",
"meta",
"in",
"self",
".",
"_resources",
":",
"resource",
"=",
"self",
".",
"load",
"(",
"meta",
")",
"yield",
"meta",
",",
"resource",
"self",
".",
"_resources",
"=",
"[",
"]"
] | Loads all the data files using the configured finders. | [
"Loads",
"all",
"the",
"data",
"files",
"using",
"the",
"configured",
"finders",
"."
] | python | valid |
bitcraft/pyscroll | pyscroll/group.py | https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/group.py#L34-L56 | def draw(self, surface):
""" Draw all sprites and map onto the surface
:param surface: pygame surface to draw to
:type surface: pygame.surface.Surface
"""
ox, oy = self._map_layer.get_center_offset()
new_surfaces = list()
spritedict = self.spritedict
gl ... | [
"def",
"draw",
"(",
"self",
",",
"surface",
")",
":",
"ox",
",",
"oy",
"=",
"self",
".",
"_map_layer",
".",
"get_center_offset",
"(",
")",
"new_surfaces",
"=",
"list",
"(",
")",
"spritedict",
"=",
"self",
".",
"spritedict",
"gl",
"=",
"self",
".",
"g... | Draw all sprites and map onto the surface
:param surface: pygame surface to draw to
:type surface: pygame.surface.Surface | [
"Draw",
"all",
"sprites",
"and",
"map",
"onto",
"the",
"surface"
] | python | train |
LIVVkit/LIVVkit | livvkit/components/performance.py | https://github.com/LIVVkit/LIVVkit/blob/680120cd437e408673e62e535fc0a246c7fc17db/livvkit/components/performance.py#L150-L174 | def _summarize_result(result, config):
""" Trim out some data to return for the index page """
timing_var = config['scaling_var']
summary = LIVVDict()
for size, res in result.items():
proc_counts = []
bench_times = []
model_times = []
for proc, data in res.items():
... | [
"def",
"_summarize_result",
"(",
"result",
",",
"config",
")",
":",
"timing_var",
"=",
"config",
"[",
"'scaling_var'",
"]",
"summary",
"=",
"LIVVDict",
"(",
")",
"for",
"size",
",",
"res",
"in",
"result",
".",
"items",
"(",
")",
":",
"proc_counts",
"=",
... | Trim out some data to return for the index page | [
"Trim",
"out",
"some",
"data",
"to",
"return",
"for",
"the",
"index",
"page"
] | python | train |
NateFerrero/oauth2lib | oauth2lib/provider.py | https://github.com/NateFerrero/oauth2lib/blob/d161b010f8a596826050a09e5e94d59443cc12d9/oauth2lib/provider.py#L573-L586 | def get_authorization(self):
"""Get authorization object representing status of authentication."""
auth = self.authorization_class()
header = self.get_authorization_header()
if not header or not header.split:
return auth
header = header.split()
if len(header) ... | [
"def",
"get_authorization",
"(",
"self",
")",
":",
"auth",
"=",
"self",
".",
"authorization_class",
"(",
")",
"header",
"=",
"self",
".",
"get_authorization_header",
"(",
")",
"if",
"not",
"header",
"or",
"not",
"header",
".",
"split",
":",
"return",
"auth... | Get authorization object representing status of authentication. | [
"Get",
"authorization",
"object",
"representing",
"status",
"of",
"authentication",
"."
] | python | test |
trombastic/PyScada | pyscada/utils/scheduler.py | https://github.com/trombastic/PyScada/blob/c5fc348a25f0df1340336f694ee9bc1aea62516a/pyscada/utils/scheduler.py#L142-L207 | def demonize(self):
"""
do the double fork magic
"""
# check if a process is already running
if access(self.pid_file_name, F_OK):
# read the pid file
pid = self.read_pid()
try:
kill(pid, 0) # check if process is running
... | [
"def",
"demonize",
"(",
"self",
")",
":",
"# check if a process is already running",
"if",
"access",
"(",
"self",
".",
"pid_file_name",
",",
"F_OK",
")",
":",
"# read the pid file",
"pid",
"=",
"self",
".",
"read_pid",
"(",
")",
"try",
":",
"kill",
"(",
"pid... | do the double fork magic | [
"do",
"the",
"double",
"fork",
"magic"
] | python | train |
Kozea/pygal | pygal/graph/histogram.py | https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/histogram.py#L64-L88 | def _bar(self, serie, parent, x0, x1, y, i, zero, secondary=False):
"""Internal bar drawing function"""
x, y = self.view((x0, y))
x1, _ = self.view((x1, y))
width = x1 - x
height = self.view.y(zero) - y
series_margin = width * self._series_margin
x += series_margi... | [
"def",
"_bar",
"(",
"self",
",",
"serie",
",",
"parent",
",",
"x0",
",",
"x1",
",",
"y",
",",
"i",
",",
"zero",
",",
"secondary",
"=",
"False",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"view",
"(",
"(",
"x0",
",",
"y",
")",
")",
"x1",
"... | Internal bar drawing function | [
"Internal",
"bar",
"drawing",
"function"
] | python | train |
lancekrogers/edgerdb | edgerdb/helper_functions.py | https://github.com/lancekrogers/edgerdb/blob/ed6f37af40f95588db94ba27a5a27d73da59e485/edgerdb/helper_functions.py#L165-L183 | def retrieve_document(file_path, directory='sec_filings'):
'''
This function takes a file path beginning with edgar and stores the form in a directory.
The default directory is sec_filings but can be changed through a keyword argument.
'''
ftp = FTP('ftp.sec.gov', timeout=None)
ftp.login... | [
"def",
"retrieve_document",
"(",
"file_path",
",",
"directory",
"=",
"'sec_filings'",
")",
":",
"ftp",
"=",
"FTP",
"(",
"'ftp.sec.gov'",
",",
"timeout",
"=",
"None",
")",
"ftp",
".",
"login",
"(",
")",
"name",
"=",
"file_path",
".",
"replace",
"(",
"'/'"... | This function takes a file path beginning with edgar and stores the form in a directory.
The default directory is sec_filings but can be changed through a keyword argument. | [
"This",
"function",
"takes",
"a",
"file",
"path",
"beginning",
"with",
"edgar",
"and",
"stores",
"the",
"form",
"in",
"a",
"directory",
".",
"The",
"default",
"directory",
"is",
"sec_filings",
"but",
"can",
"be",
"changed",
"through",
"a",
"keyword",
"argume... | python | valid |
saltstack/salt | salt/modules/bridge.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bridge.py#L103-L109 | def _linux_brdel(br):
'''
Internal, deletes the bridge
'''
brctl = _tool_path('brctl')
return __salt__['cmd.run']('{0} delbr {1}'.format(brctl, br),
python_shell=False) | [
"def",
"_linux_brdel",
"(",
"br",
")",
":",
"brctl",
"=",
"_tool_path",
"(",
"'brctl'",
")",
"return",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'{0} delbr {1}'",
".",
"format",
"(",
"brctl",
",",
"br",
")",
",",
"python_shell",
"=",
"False",
")"
] | Internal, deletes the bridge | [
"Internal",
"deletes",
"the",
"bridge"
] | python | train |
firecat53/urlscan | urlscan/urlchoose.py | https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L357-L371 | def _digits(self):
""" 0-9 """
self.number += self.key
try:
if self.compact is False:
self.top.body.focus_position = \
self.items.index(self.items_com[max(int(self.number) - 1, 0)])
else:
self.top.body.focus_position = \... | [
"def",
"_digits",
"(",
"self",
")",
":",
"self",
".",
"number",
"+=",
"self",
".",
"key",
"try",
":",
"if",
"self",
".",
"compact",
"is",
"False",
":",
"self",
".",
"top",
".",
"body",
".",
"focus_position",
"=",
"self",
".",
"items",
".",
"index",... | 0-9 | [
"0",
"-",
"9"
] | python | train |
MacHu-GWU/rolex-project | rolex/math.py | https://github.com/MacHu-GWU/rolex-project/blob/a1111b410ed04b4b6eddd81df110fa2dacfa6537/rolex/math.py#L135-L165 | def add_years(datetime_like_object, n, return_date=False):
"""
Returns a time that n years after a time.
:param datetimestr: a datetime object or a datetime str
:param n: number of years, value can be negative
:param return_date: returns a date object instead of datetime
**中文文档**
返回给定日期N年... | [
"def",
"add_years",
"(",
"datetime_like_object",
",",
"n",
",",
"return_date",
"=",
"False",
")",
":",
"a_datetime",
"=",
"parser",
".",
"parse_datetime",
"(",
"datetime_like_object",
")",
"# try assign year, month, day",
"try",
":",
"a_datetime",
"=",
"datetime",
... | Returns a time that n years after a time.
:param datetimestr: a datetime object or a datetime str
:param n: number of years, value can be negative
:param return_date: returns a date object instead of datetime
**中文文档**
返回给定日期N年之后的时间。 | [
"Returns",
"a",
"time",
"that",
"n",
"years",
"after",
"a",
"time",
"."
] | python | train |
vertexproject/synapse | synapse/lib/task.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/task.py#L130-L141 | async def executor(func, *args, **kwargs):
'''
Execute a function in an executor thread.
Args:
todo ((func,args,kwargs)): A todo tuple.
'''
def syncfunc():
return func(*args, **kwargs)
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, syncfunc) | [
"async",
"def",
"executor",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"syncfunc",
"(",
")",
":",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"loop",
"=",
"asyncio",
".",
"get_running_loop",
"(",
... | Execute a function in an executor thread.
Args:
todo ((func,args,kwargs)): A todo tuple. | [
"Execute",
"a",
"function",
"in",
"an",
"executor",
"thread",
"."
] | python | train |
manns/pyspread | pyspread/src/gui/_gui_interfaces.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L189-L208 | def get_print_setup(self, print_data):
"""Opens print setup dialog and returns print_data"""
psd = wx.PageSetupDialogData(print_data)
# psd.EnablePrinter(False)
psd.CalculatePaperSizeFromId()
dlg = wx.PageSetupDialog(self.main_window, psd)
dlg.ShowModal()
# this... | [
"def",
"get_print_setup",
"(",
"self",
",",
"print_data",
")",
":",
"psd",
"=",
"wx",
".",
"PageSetupDialogData",
"(",
"print_data",
")",
"# psd.EnablePrinter(False)",
"psd",
".",
"CalculatePaperSizeFromId",
"(",
")",
"dlg",
"=",
"wx",
".",
"PageSetupDialog",
"(... | Opens print setup dialog and returns print_data | [
"Opens",
"print",
"setup",
"dialog",
"and",
"returns",
"print_data"
] | python | train |
Nukesor/pueue | pueue/daemon/daemon.py | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L462-L486 | def stash(self, payload):
"""Stash the specified processes."""
succeeded = []
failed = []
for key in payload['keys']:
if self.queue.get(key) is not None:
if self.queue[key]['status'] == 'queued':
self.queue[key]['status'] = 'stashed'
... | [
"def",
"stash",
"(",
"self",
",",
"payload",
")",
":",
"succeeded",
"=",
"[",
"]",
"failed",
"=",
"[",
"]",
"for",
"key",
"in",
"payload",
"[",
"'keys'",
"]",
":",
"if",
"self",
".",
"queue",
".",
"get",
"(",
"key",
")",
"is",
"not",
"None",
":... | Stash the specified processes. | [
"Stash",
"the",
"specified",
"processes",
"."
] | python | train |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L831-L848 | def _instantiateFont(self, path):
""" Return a instance of a font object with all the given subclasses"""
try:
return self.fontClass(path,
layerClass=self.layerClass,
libClass=self.libClass,
kerningClass=self.kerningClass,
group... | [
"def",
"_instantiateFont",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"self",
".",
"fontClass",
"(",
"path",
",",
"layerClass",
"=",
"self",
".",
"layerClass",
",",
"libClass",
"=",
"self",
".",
"libClass",
",",
"kerningClass",
"=",
"self"... | Return a instance of a font object with all the given subclasses | [
"Return",
"a",
"instance",
"of",
"a",
"font",
"object",
"with",
"all",
"the",
"given",
"subclasses"
] | python | train |
moluwole/Bast | bast/validator/rules.py | https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/validator/rules.py#L159-L170 | def run(self, value):
""" Determines if value character length equal self.length.
Keyword arguments:
value str -- the value of the associated field to compare
"""
if self.pass_ and not value.strip():
return True
if len((value.strip() if self.strip else value)... | [
"def",
"run",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"pass_",
"and",
"not",
"value",
".",
"strip",
"(",
")",
":",
"return",
"True",
"if",
"len",
"(",
"(",
"value",
".",
"strip",
"(",
")",
"if",
"self",
".",
"strip",
"else",
"va... | Determines if value character length equal self.length.
Keyword arguments:
value str -- the value of the associated field to compare | [
"Determines",
"if",
"value",
"character",
"length",
"equal",
"self",
".",
"length",
".",
"Keyword",
"arguments",
":",
"value",
"str",
"--",
"the",
"value",
"of",
"the",
"associated",
"field",
"to",
"compare"
] | python | train |
peri-source/peri | peri/runner.py | https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/runner.py#L35-L96 | def locate_spheres(image, feature_rad, dofilter=False, order=(3 ,3, 3),
trim_edge=True, **kwargs):
"""
Get an initial featuring of sphere positions in an image.
Parameters
-----------
image : :class:`peri.util.Image` object
Image object which defines the image file as we... | [
"def",
"locate_spheres",
"(",
"image",
",",
"feature_rad",
",",
"dofilter",
"=",
"False",
",",
"order",
"=",
"(",
"3",
",",
"3",
",",
"3",
")",
",",
"trim_edge",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# We just want a smoothed field model of the ... | Get an initial featuring of sphere positions in an image.
Parameters
-----------
image : :class:`peri.util.Image` object
Image object which defines the image file as well as the region.
feature_rad : float
Radius of objects to find, in pixels. This is a featuring radius
and not... | [
"Get",
"an",
"initial",
"featuring",
"of",
"sphere",
"positions",
"in",
"an",
"image",
"."
] | python | valid |
google/grr | grr/server/grr_response_server/gui/http_api.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/http_api.py#L370-L396 | def _BuildStreamingResponse(self, binary_stream, method_name=None):
"""Builds HTTPResponse object for streaming."""
precondition.AssertType(method_name, Text)
# We get a first chunk of the output stream. This way the likelihood
# of catching an exception that may happen during response generation
#... | [
"def",
"_BuildStreamingResponse",
"(",
"self",
",",
"binary_stream",
",",
"method_name",
"=",
"None",
")",
":",
"precondition",
".",
"AssertType",
"(",
"method_name",
",",
"Text",
")",
"# We get a first chunk of the output stream. This way the likelihood",
"# of catching an... | Builds HTTPResponse object for streaming. | [
"Builds",
"HTTPResponse",
"object",
"for",
"streaming",
"."
] | python | train |
wavefrontHQ/python-client | wavefront_api_client/api/event_api.py | https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/event_api.py#L626-L646 | def get_event_tags(self, id, **kwargs): # noqa: E501
"""Get all tags associated with a specific event # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_even... | [
"def",
"get_event_tags",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"get_event_tag... | Get all tags associated with a specific event # noqa: E501
# noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_event_tags(id, async_req=True)
>>> result = thread.get()
... | [
"Get",
"all",
"tags",
"associated",
"with",
"a",
"specific",
"event",
"#",
"noqa",
":",
"E501"
] | python | train |
rbarrois/confutils | confutils/configfile.py | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L397-L402 | def handle_line(self, line):
"""Read one line."""
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line) | [
"def",
"handle_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
".",
"kind",
"==",
"ConfigLine",
".",
"KIND_HEADER",
":",
"self",
".",
"enter_block",
"(",
"line",
".",
"header",
")",
"else",
":",
"self",
".",
"insert_line",
"(",
"line",
")"
] | Read one line. | [
"Read",
"one",
"line",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/helpers/state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/helpers/state.py#L147-L230 | def create_new_state_from_state_with_type(source_state, target_state_class):
"""The function duplicates/transforms a state to a new state type. If the source state type and the new state
type both are ContainerStates the new state will have not transitions to force the user to explicitly re-order
the logica... | [
"def",
"create_new_state_from_state_with_type",
"(",
"source_state",
",",
"target_state_class",
")",
":",
"current_state_is_container",
"=",
"isinstance",
"(",
"source_state",
",",
"ContainerState",
")",
"new_state_is_container",
"=",
"issubclass",
"(",
"target_state_class",
... | The function duplicates/transforms a state to a new state type. If the source state type and the new state
type both are ContainerStates the new state will have not transitions to force the user to explicitly re-order
the logical flow according the paradigm of the new state type.
:param source_state: previ... | [
"The",
"function",
"duplicates",
"/",
"transforms",
"a",
"state",
"to",
"a",
"new",
"state",
"type",
".",
"If",
"the",
"source",
"state",
"type",
"and",
"the",
"new",
"state",
"type",
"both",
"are",
"ContainerStates",
"the",
"new",
"state",
"will",
"have",... | python | train |
pantsbuild/pants | build-support/bin/check_header_helper.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/build-support/bin/check_header_helper.py#L71-L82 | def check_dir(directory, newly_created_files):
"""Returns list of files that fail the check."""
header_parse_failures = []
for root, dirs, files in os.walk(directory):
for f in files:
if f.endswith('.py') and os.path.basename(f) != '__init__.py':
filename = os.path.join(root, f)
try:
... | [
"def",
"check_dir",
"(",
"directory",
",",
"newly_created_files",
")",
":",
"header_parse_failures",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"directory",
")",
":",
"for",
"f",
"in",
"files",
":",
"if",
"f"... | Returns list of files that fail the check. | [
"Returns",
"list",
"of",
"files",
"that",
"fail",
"the",
"check",
"."
] | python | train |
dmerejkowsky/replacer | replacer.py | https://github.com/dmerejkowsky/replacer/blob/8dc16f297d0ff3a6ee2fa3c0d77789a6859b0f6a/replacer.py#L110-L133 | def walk_files(args, root, directory, action):
"""
Recusively go do the subdirectories of the directory,
calling the action on each file
"""
for entry in os.listdir(directory):
if is_hidden(args, entry):
continue
if is_excluded_directory(args, entry):
continu... | [
"def",
"walk_files",
"(",
"args",
",",
"root",
",",
"directory",
",",
"action",
")",
":",
"for",
"entry",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"if",
"is_hidden",
"(",
"args",
",",
"entry",
")",
":",
"continue",
"if",
"is_excluded_dir... | Recusively go do the subdirectories of the directory,
calling the action on each file | [
"Recusively",
"go",
"do",
"the",
"subdirectories",
"of",
"the",
"directory",
"calling",
"the",
"action",
"on",
"each",
"file"
] | python | train |
odlgroup/odl | odl/space/npy_tensors.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/space/npy_tensors.py#L2279-L2298 | def dist(self, x1, x2):
"""Return the weighted distance between ``x1`` and ``x2``.
Parameters
----------
x1, x2 : `NumpyTensor`
Tensors whose mutual distance is calculated.
Returns
-------
dist : float
The distance between the tensors.
... | [
"def",
"dist",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"if",
"self",
".",
"exponent",
"==",
"2.0",
":",
"return",
"float",
"(",
"np",
".",
"sqrt",
"(",
"self",
".",
"const",
")",
"*",
"_norm_default",
"(",
"x1",
"-",
"x2",
")",
")",
"elif"... | Return the weighted distance between ``x1`` and ``x2``.
Parameters
----------
x1, x2 : `NumpyTensor`
Tensors whose mutual distance is calculated.
Returns
-------
dist : float
The distance between the tensors. | [
"Return",
"the",
"weighted",
"distance",
"between",
"x1",
"and",
"x2",
"."
] | python | train |
inveniosoftware/invenio-access | invenio_access/alembic/2069a982633b_add_on_delete_cascade_constraint.py | https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/invenio_access/alembic/2069a982633b_add_on_delete_cascade_constraint.py#L38-L53 | def downgrade():
"""Downgrade database."""
op.drop_constraint(op.f('fk_access_actionsusers_user_id_accounts_user'),
'access_actionsusers', type_='foreignkey')
op.drop_index(op.f('ix_access_actionsusers_user_id'),
table_name='access_actionsusers')
op.create_foreig... | [
"def",
"downgrade",
"(",
")",
":",
"op",
".",
"drop_constraint",
"(",
"op",
".",
"f",
"(",
"'fk_access_actionsusers_user_id_accounts_user'",
")",
",",
"'access_actionsusers'",
",",
"type_",
"=",
"'foreignkey'",
")",
"op",
".",
"drop_index",
"(",
"op",
".",
"f"... | Downgrade database. | [
"Downgrade",
"database",
"."
] | python | train |
msmbuilder/msmbuilder | msmbuilder/msm/bayesmsm.py | https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/msm/bayesmsm.py#L307-L327 | def all_timescales_(self):
"""Implied relaxation timescales each sample in the ensemble
Returns
-------
timescales : array-like, shape = (n_samples, n_timescales,)
The longest implied relaxation timescales of the each sample in
the ensemble of transition matrices... | [
"def",
"all_timescales_",
"(",
"self",
")",
":",
"us",
",",
"lvs",
",",
"rvs",
"=",
"self",
".",
"_get_eigensystem",
"(",
")",
"# make sure to leave off equilibrium distribution",
"timescales",
"=",
"-",
"self",
".",
"lag_time",
"/",
"np",
".",
"log",
"(",
"... | Implied relaxation timescales each sample in the ensemble
Returns
-------
timescales : array-like, shape = (n_samples, n_timescales,)
The longest implied relaxation timescales of the each sample in
the ensemble of transition matrices, expressed in units of
ti... | [
"Implied",
"relaxation",
"timescales",
"each",
"sample",
"in",
"the",
"ensemble"
] | python | train |
pgjones/quart | quart/app.py | https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1123-L1143 | def after_serving(self, func: Callable) -> Callable:
"""Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: pytho... | [
"def",
"after_serving",
"(",
"self",
",",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"handler",
"=",
"ensure_coroutine",
"(",
"func",
")",
"self",
".",
"after_serving_funcs",
".",
"append",
"(",
"handler",
")",
"return",
"func"
] | Add a after serving function.
This will allow the function provided to be called once after
anything is served (after last byte is sent).
This is designed to be used as a decorator. An example usage,
.. code-block:: python
@app.after_serving
def func():
... | [
"Add",
"a",
"after",
"serving",
"function",
"."
] | python | train |
hyperledger/indy-plenum | plenum/server/replica.py | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L555-L568 | def generateName(nodeName: str, instId: int):
"""
Create and return the name for a replica using its nodeName and
instanceId.
Ex: Alpha:1
"""
if isinstance(nodeName, str):
# Because sometimes it is bytes (why?)
if ":" in nodeName:
... | [
"def",
"generateName",
"(",
"nodeName",
":",
"str",
",",
"instId",
":",
"int",
")",
":",
"if",
"isinstance",
"(",
"nodeName",
",",
"str",
")",
":",
"# Because sometimes it is bytes (why?)",
"if",
"\":\"",
"in",
"nodeName",
":",
"# Because in some cases (for reques... | Create and return the name for a replica using its nodeName and
instanceId.
Ex: Alpha:1 | [
"Create",
"and",
"return",
"the",
"name",
"for",
"a",
"replica",
"using",
"its",
"nodeName",
"and",
"instanceId",
".",
"Ex",
":",
"Alpha",
":",
"1"
] | python | train |
bcbio/bcbio-nextgen | bcbio/provenance/do.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/do.py#L60-L72 | def _normalize_cmd_args(cmd):
"""Normalize subprocess arguments to handle list commands, string and pipes.
Piped commands set pipefail and require use of bash to help with debugging
intermediate errors.
"""
if isinstance(cmd, six.string_types):
# check for standard or anonymous named pipes
... | [
"def",
"_normalize_cmd_args",
"(",
"cmd",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"six",
".",
"string_types",
")",
":",
"# check for standard or anonymous named pipes",
"if",
"cmd",
".",
"find",
"(",
"\" | \"",
")",
">",
"0",
"or",
"cmd",
".",
"find",... | Normalize subprocess arguments to handle list commands, string and pipes.
Piped commands set pipefail and require use of bash to help with debugging
intermediate errors. | [
"Normalize",
"subprocess",
"arguments",
"to",
"handle",
"list",
"commands",
"string",
"and",
"pipes",
".",
"Piped",
"commands",
"set",
"pipefail",
"and",
"require",
"use",
"of",
"bash",
"to",
"help",
"with",
"debugging",
"intermediate",
"errors",
"."
] | python | train |
OCR-D/core | ocrd/ocrd/cli/workspace.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd/ocrd/cli/workspace.py#L276-L282 | def workspace_backup_list(ctx):
"""
List backups
"""
backup_manager = WorkspaceBackupManager(Workspace(ctx.resolver, directory=ctx.directory, mets_basename=ctx.mets_basename, automatic_backup=ctx.automatic_backup))
for b in backup_manager.list():
print(b) | [
"def",
"workspace_backup_list",
"(",
"ctx",
")",
":",
"backup_manager",
"=",
"WorkspaceBackupManager",
"(",
"Workspace",
"(",
"ctx",
".",
"resolver",
",",
"directory",
"=",
"ctx",
".",
"directory",
",",
"mets_basename",
"=",
"ctx",
".",
"mets_basename",
",",
"... | List backups | [
"List",
"backups"
] | python | train |
nerdvegas/rez | src/build_utils/virtualenv/virtualenv.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/build_utils/virtualenv/virtualenv.py#L618-L624 | def get_environ_vars(self, prefix='VIRTUALENV_'):
"""
Returns a generator with all environmental vars with prefix VIRTUALENV
"""
for key, val in os.environ.items():
if key.startswith(prefix):
yield (key.replace(prefix, '').lower(), val) | [
"def",
"get_environ_vars",
"(",
"self",
",",
"prefix",
"=",
"'VIRTUALENV_'",
")",
":",
"for",
"key",
",",
"val",
"in",
"os",
".",
"environ",
".",
"items",
"(",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"prefix",
")",
":",
"yield",
"(",
"key",
... | Returns a generator with all environmental vars with prefix VIRTUALENV | [
"Returns",
"a",
"generator",
"with",
"all",
"environmental",
"vars",
"with",
"prefix",
"VIRTUALENV"
] | python | train |
marrow/web.db | web/ext/db.py | https://github.com/marrow/web.db/blob/c755fbff7028a5edc223d6a631b8421858274fc4/web/ext/db.py#L52-L57 | def _handle_event(self, event, *args, **kw):
"""Broadcast an event to the database connections registered."""
for engine in self.engines.values():
if hasattr(engine, event):
getattr(engine, event)(*args, **kw) | [
"def",
"_handle_event",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"for",
"engine",
"in",
"self",
".",
"engines",
".",
"values",
"(",
")",
":",
"if",
"hasattr",
"(",
"engine",
",",
"event",
")",
":",
"getattr",
"(... | Broadcast an event to the database connections registered. | [
"Broadcast",
"an",
"event",
"to",
"the",
"database",
"connections",
"registered",
"."
] | python | test |
markovmodel/PyEMMA | pyemma/plots/plots2d.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/plots/plots2d.py#L63-L108 | def scatter_contour(
x, y, z, ncontours=50, colorbar=True, fig=None,
ax=None, cmap=None, outfile=None):
"""Contour plot on scattered data (x,y,z) and
plots the positions of the points (x,y) on top.
Parameters
----------
x : ndarray(T)
x-coordinates
y : ndarray(T)
... | [
"def",
"scatter_contour",
"(",
"x",
",",
"y",
",",
"z",
",",
"ncontours",
"=",
"50",
",",
"colorbar",
"=",
"True",
",",
"fig",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"outfile",
"=",
"None",
")",
":",
"_warn",
"(",
"... | Contour plot on scattered data (x,y,z) and
plots the positions of the points (x,y) on top.
Parameters
----------
x : ndarray(T)
x-coordinates
y : ndarray(T)
y-coordinates
z : ndarray(T)
z-coordinates
ncontours : int, optional, default=50
number of contour lev... | [
"Contour",
"plot",
"on",
"scattered",
"data",
"(",
"x",
"y",
"z",
")",
"and",
"plots",
"the",
"positions",
"of",
"the",
"points",
"(",
"x",
"y",
")",
"on",
"top",
"."
] | python | train |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/message.py | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/message.py#L279-L288 | def add_string(self, s):
"""
Add a string to the stream.
:param str s: string to add
"""
s = asbytes(s)
self.add_size(len(s))
self.packet.write(s)
return self | [
"def",
"add_string",
"(",
"self",
",",
"s",
")",
":",
"s",
"=",
"asbytes",
"(",
"s",
")",
"self",
".",
"add_size",
"(",
"len",
"(",
"s",
")",
")",
"self",
".",
"packet",
".",
"write",
"(",
"s",
")",
"return",
"self"
] | Add a string to the stream.
:param str s: string to add | [
"Add",
"a",
"string",
"to",
"the",
"stream",
".",
":",
"param",
"str",
"s",
":",
"string",
"to",
"add"
] | python | train |
alvinwan/TexSoup | TexSoup/reader.py | https://github.com/alvinwan/TexSoup/blob/63323ed71510fd2351102b8c36660a3b7703cead/TexSoup/reader.py#L72-L85 | def tokenize(text):
r"""Generator for LaTeX tokens on text, ignoring comments.
:param Union[str,iterator,Buffer] text: LaTeX to process
>>> print(*tokenize(r'\textbf{Do play \textit{nice}.}'))
\textbf { Do play \textit { nice } . }
>>> print(*tokenize(r'\begin{tabular} 0 & 1 \\ 2 & 0 \end{tabular... | [
"def",
"tokenize",
"(",
"text",
")",
":",
"current_token",
"=",
"next_token",
"(",
"text",
")",
"while",
"current_token",
"is",
"not",
"None",
":",
"yield",
"current_token",
"current_token",
"=",
"next_token",
"(",
"text",
")"
] | r"""Generator for LaTeX tokens on text, ignoring comments.
:param Union[str,iterator,Buffer] text: LaTeX to process
>>> print(*tokenize(r'\textbf{Do play \textit{nice}.}'))
\textbf { Do play \textit { nice } . }
>>> print(*tokenize(r'\begin{tabular} 0 & 1 \\ 2 & 0 \end{tabular}'))
\begin { tabula... | [
"r",
"Generator",
"for",
"LaTeX",
"tokens",
"on",
"text",
"ignoring",
"comments",
"."
] | python | train |
istresearch/scrapy-cluster | utils/scutils/stats_collector.py | https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/utils/scutils/stats_collector.py#L70-L87 | def get_rolling_time_window(self, redis_conn=None, host='localhost',
port=6379, key='rolling_time_window_counter',
cycle_time=5, window=SECONDS_1_HOUR):
'''
Generate a new RollingTimeWindow
Useful for collect data about the number o... | [
"def",
"get_rolling_time_window",
"(",
"self",
",",
"redis_conn",
"=",
"None",
",",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"6379",
",",
"key",
"=",
"'rolling_time_window_counter'",
",",
"cycle_time",
"=",
"5",
",",
"window",
"=",
"SECONDS_1_HOUR",
")",
... | Generate a new RollingTimeWindow
Useful for collect data about the number of hits in the past X seconds
@param redis_conn: A premade redis connection (overrides host and port)
@param host: the redis host
@param port: the redis port
@param key: the key for your stats collection
... | [
"Generate",
"a",
"new",
"RollingTimeWindow",
"Useful",
"for",
"collect",
"data",
"about",
"the",
"number",
"of",
"hits",
"in",
"the",
"past",
"X",
"seconds"
] | python | train |
ARMmbed/icetea | icetea_lib/tools/file/FileUtils.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/tools/file/FileUtils.py#L55-L76 | def remove_file(filename, path=None):
"""
Remove file filename from path.
:param filename: Name of file to remove
:param path: Path where file is located
:return: True if successfull
:raises OSError if chdir or remove fails.
"""
cwd = os.getcwd()
try:
if path:
os... | [
"def",
"remove_file",
"(",
"filename",
",",
"path",
"=",
"None",
")",
":",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"if",
"path",
":",
"os",
".",
"chdir",
"(",
"path",
")",
"except",
"OSError",
":",
"raise",
"try",
":",
"os",
".",
... | Remove file filename from path.
:param filename: Name of file to remove
:param path: Path where file is located
:return: True if successfull
:raises OSError if chdir or remove fails. | [
"Remove",
"file",
"filename",
"from",
"path",
"."
] | python | train |
KnowledgeLinks/rdfframework | rdfframework/rdfclass/rdfproperty.py | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L588-L599 | def unique_append(self, value):
""" function for only appending unique items to a list.
#! consider the possibility of item using this to a set
"""
if value not in self:
try:
super(self.__class__, self).append(Uri(value))
except AttributeError as err:
if isinstanc... | [
"def",
"unique_append",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"not",
"in",
"self",
":",
"try",
":",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"append",
"(",
"Uri",
"(",
"value",
")",
")",
"except",
"AttributeError",... | function for only appending unique items to a list.
#! consider the possibility of item using this to a set | [
"function",
"for",
"only",
"appending",
"unique",
"items",
"to",
"a",
"list",
".",
"#!",
"consider",
"the",
"possibility",
"of",
"item",
"using",
"this",
"to",
"a",
"set"
] | python | train |
rollbar/pyrollbar | rollbar/__init__.py | https://github.com/rollbar/pyrollbar/blob/33ef2e723a33d09dd6302f978f4a3908be95b9d2/rollbar/__init__.py#L436-L479 | def send_payload(payload, access_token):
"""
Sends a payload object, (the result of calling _build_payload() + _serialize_payload()).
Uses the configured handler from SETTINGS['handler']
Available handlers:
- 'blocking': calls _send_payload() (which makes an HTTP request) immediately, blocks on it
... | [
"def",
"send_payload",
"(",
"payload",
",",
"access_token",
")",
":",
"payload",
"=",
"events",
".",
"on_payload",
"(",
"payload",
")",
"if",
"payload",
"is",
"False",
":",
"return",
"payload_str",
"=",
"_serialize_payload",
"(",
"payload",
")",
"handler",
"... | Sends a payload object, (the result of calling _build_payload() + _serialize_payload()).
Uses the configured handler from SETTINGS['handler']
Available handlers:
- 'blocking': calls _send_payload() (which makes an HTTP request) immediately, blocks on it
- 'thread': starts a single-use thread that will ... | [
"Sends",
"a",
"payload",
"object",
"(",
"the",
"result",
"of",
"calling",
"_build_payload",
"()",
"+",
"_serialize_payload",
"()",
")",
".",
"Uses",
"the",
"configured",
"handler",
"from",
"SETTINGS",
"[",
"handler",
"]"
] | python | test |
singnet/snet-cli | snet_cli/utils_ipfs.py | https://github.com/singnet/snet-cli/blob/1b5ac98cb9a64211c861ead9fcfe6208f2749032/snet_cli/utils_ipfs.py#L35-L63 | def get_from_ipfs_and_checkhash(ipfs_client, ipfs_hash_base58, validate=True):
"""
Get file from ipfs
We must check the hash becasue we cannot believe that ipfs_client wasn't been compromise
"""
if validate:
from snet_cli.resources.proto.unixfs_pb2 import Data
from snet_cli.resources... | [
"def",
"get_from_ipfs_and_checkhash",
"(",
"ipfs_client",
",",
"ipfs_hash_base58",
",",
"validate",
"=",
"True",
")",
":",
"if",
"validate",
":",
"from",
"snet_cli",
".",
"resources",
".",
"proto",
".",
"unixfs_pb2",
"import",
"Data",
"from",
"snet_cli",
".",
... | Get file from ipfs
We must check the hash becasue we cannot believe that ipfs_client wasn't been compromise | [
"Get",
"file",
"from",
"ipfs",
"We",
"must",
"check",
"the",
"hash",
"becasue",
"we",
"cannot",
"believe",
"that",
"ipfs_client",
"wasn",
"t",
"been",
"compromise"
] | python | train |
AnthonyBloomer/daftlistings | daftlistings/daft.py | https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L64-L69 | def set_max_lease(self, max_lease):
"""
Set the maximum lease period in months.
:param max_lease: int
"""
self._query_params += str(QueryParam.MAX_LEASE) + str(max_lease) | [
"def",
"set_max_lease",
"(",
"self",
",",
"max_lease",
")",
":",
"self",
".",
"_query_params",
"+=",
"str",
"(",
"QueryParam",
".",
"MAX_LEASE",
")",
"+",
"str",
"(",
"max_lease",
")"
] | Set the maximum lease period in months.
:param max_lease: int | [
"Set",
"the",
"maximum",
"lease",
"period",
"in",
"months",
".",
":",
"param",
"max_lease",
":",
"int"
] | python | train |
tanghaibao/goatools | goatools/grouper/wrxlsx.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/wrxlsx.py#L41-L47 | def wr_xlsx_gos(self, fout_xlsx, **kws_usr):
"""Write an Excel spreadsheet with user GO ids, grouped under broader GO terms."""
# Keyword arguments: control content
desc2nts = self.sortobj.get_desc2nts(**kws_usr)
# Keyword arguments: control xlsx format
self.wr_xlsx_nts(fout_xlsx... | [
"def",
"wr_xlsx_gos",
"(",
"self",
",",
"fout_xlsx",
",",
"*",
"*",
"kws_usr",
")",
":",
"# Keyword arguments: control content",
"desc2nts",
"=",
"self",
".",
"sortobj",
".",
"get_desc2nts",
"(",
"*",
"*",
"kws_usr",
")",
"# Keyword arguments: control xlsx format",
... | Write an Excel spreadsheet with user GO ids, grouped under broader GO terms. | [
"Write",
"an",
"Excel",
"spreadsheet",
"with",
"user",
"GO",
"ids",
"grouped",
"under",
"broader",
"GO",
"terms",
"."
] | python | train |
inveniosoftware/invenio-formatter | invenio_formatter/filters/datetime.py | https://github.com/inveniosoftware/invenio-formatter/blob/aa25f36742e809f05e116b52e8255cdb362e5642/invenio_formatter/filters/datetime.py#L16-L26 | def from_isodate(value, strict=False):
"""Convert an ISO formatted date into a Date object.
:param value: The ISO formatted date.
:param strict: If value is ``None``, then if strict is ``True`` it returns
the Date object of today, otherwise it returns ``None``.
(Default: ``False``)
:ret... | [
"def",
"from_isodate",
"(",
"value",
",",
"strict",
"=",
"False",
")",
":",
"if",
"value",
"or",
"strict",
":",
"return",
"arrow",
".",
"get",
"(",
"value",
")",
".",
"date",
"(",
")"
] | Convert an ISO formatted date into a Date object.
:param value: The ISO formatted date.
:param strict: If value is ``None``, then if strict is ``True`` it returns
the Date object of today, otherwise it returns ``None``.
(Default: ``False``)
:returns: The Date object or ``None``. | [
"Convert",
"an",
"ISO",
"formatted",
"date",
"into",
"a",
"Date",
"object",
"."
] | python | train |
horazont/aioxmpp | aioxmpp/ibb/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/ibb/service.py#L232-L250 | def write(self, data):
"""
Send `data` over the IBB. If `data` is larger than the block size
is is chunked and sent in chunks.
Chunks from one call of :meth:`write` will always be sent in
series.
"""
if self.is_closing():
return
self._write_... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"is_closing",
"(",
")",
":",
"return",
"self",
".",
"_write_buffer",
"+=",
"data",
"if",
"len",
"(",
"self",
".",
"_write_buffer",
")",
">=",
"self",
".",
"_output_buffer_limit_high",... | Send `data` over the IBB. If `data` is larger than the block size
is is chunked and sent in chunks.
Chunks from one call of :meth:`write` will always be sent in
series. | [
"Send",
"data",
"over",
"the",
"IBB",
".",
"If",
"data",
"is",
"larger",
"than",
"the",
"block",
"size",
"is",
"is",
"chunked",
"and",
"sent",
"in",
"chunks",
"."
] | python | train |
eddiejessup/spatious | spatious/vector.py | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L343-L347 | def smallest_signed_angle(source, target):
"""Find the smallest angle going from angle `source` to angle `target`."""
dth = target - source
dth = (dth + np.pi) % (2.0 * np.pi) - np.pi
return dth | [
"def",
"smallest_signed_angle",
"(",
"source",
",",
"target",
")",
":",
"dth",
"=",
"target",
"-",
"source",
"dth",
"=",
"(",
"dth",
"+",
"np",
".",
"pi",
")",
"%",
"(",
"2.0",
"*",
"np",
".",
"pi",
")",
"-",
"np",
".",
"pi",
"return",
"dth"
] | Find the smallest angle going from angle `source` to angle `target`. | [
"Find",
"the",
"smallest",
"angle",
"going",
"from",
"angle",
"source",
"to",
"angle",
"target",
"."
] | python | train |
mithro/python-datetime-tz | datetime_tz/__init__.py | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/__init__.py#L855-L875 | def _wrap_method(name):
"""Wrap a method.
Patch a method which might return a datetime.datetime to return a
datetime_tz.datetime_tz instead.
Args:
name: The name of the method to patch
"""
method = getattr(datetime.datetime, name)
# Have to give the second argument as method has no __module__ optio... | [
"def",
"_wrap_method",
"(",
"name",
")",
":",
"method",
"=",
"getattr",
"(",
"datetime",
".",
"datetime",
",",
"name",
")",
"# Have to give the second argument as method has no __module__ option.",
"@",
"functools",
".",
"wraps",
"(",
"method",
",",
"(",
"\"__name__... | Wrap a method.
Patch a method which might return a datetime.datetime to return a
datetime_tz.datetime_tz instead.
Args:
name: The name of the method to patch | [
"Wrap",
"a",
"method",
"."
] | python | train |
mfcovington/pubmed-lookup | pubmed_lookup/pubmed_lookup.py | https://github.com/mfcovington/pubmed-lookup/blob/b0aa2945b354f0945db73da22dd15ea628212da8/pubmed_lookup/pubmed_lookup.py#L60-L90 | def cite(self, max_authors=5):
"""
Return string with a citation for the record, formatted as:
'{authors} ({year}). {title} {journal} {volume}({issue}): {pages}.'
"""
citation_data = {
'title': self.title,
'authors': self.authors_et_al(max_authors),
... | [
"def",
"cite",
"(",
"self",
",",
"max_authors",
"=",
"5",
")",
":",
"citation_data",
"=",
"{",
"'title'",
":",
"self",
".",
"title",
",",
"'authors'",
":",
"self",
".",
"authors_et_al",
"(",
"max_authors",
")",
",",
"'year'",
":",
"self",
".",
"year",
... | Return string with a citation for the record, formatted as:
'{authors} ({year}). {title} {journal} {volume}({issue}): {pages}.' | [
"Return",
"string",
"with",
"a",
"citation",
"for",
"the",
"record",
"formatted",
"as",
":",
"{",
"authors",
"}",
"(",
"{",
"year",
"}",
")",
".",
"{",
"title",
"}",
"{",
"journal",
"}",
"{",
"volume",
"}",
"(",
"{",
"issue",
"}",
")",
":",
"{",
... | python | train |
edublancas/sklearn-evaluation | sklearn_evaluation/util.py | https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/util.py#L37-L51 | def _group_by(data, criteria):
"""
Group objects in data using a function or a key
"""
if isinstance(criteria, str):
criteria_str = criteria
def criteria(x):
return x[criteria_str]
res = defaultdict(list)
for element in data:
key = criteria(element)
... | [
"def",
"_group_by",
"(",
"data",
",",
"criteria",
")",
":",
"if",
"isinstance",
"(",
"criteria",
",",
"str",
")",
":",
"criteria_str",
"=",
"criteria",
"def",
"criteria",
"(",
"x",
")",
":",
"return",
"x",
"[",
"criteria_str",
"]",
"res",
"=",
"default... | Group objects in data using a function or a key | [
"Group",
"objects",
"in",
"data",
"using",
"a",
"function",
"or",
"a",
"key"
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/profile/profile_plugin.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/profile/profile_plugin.py#L351-L409 | def data_impl(self, request):
"""Retrieves and processes the tool data for a run and a host.
Args:
request: XMLHttpRequest
Returns:
A string that can be served to the frontend tool or None if tool,
run or host is invalid.
"""
run = request.args.get('run')
tool = request.arg... | [
"def",
"data_impl",
"(",
"self",
",",
"request",
")",
":",
"run",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'run'",
")",
"tool",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'tag'",
")",
"host",
"=",
"request",
".",
"args",
".",
"get",
"("... | Retrieves and processes the tool data for a run and a host.
Args:
request: XMLHttpRequest
Returns:
A string that can be served to the frontend tool or None if tool,
run or host is invalid. | [
"Retrieves",
"and",
"processes",
"the",
"tool",
"data",
"for",
"a",
"run",
"and",
"a",
"host",
"."
] | python | train |
datastore/datastore | datastore/core/key.py | https://github.com/datastore/datastore/blob/7ccf0cd4748001d3dbf5e6dda369b0f63e0269d3/datastore/core/key.py#L147-L157 | def isAncestorOf(self, other):
'''Returns whether this Key is an ancestor of `other`.
>>> john = Key('/Comedy/MontyPython/Actor:JohnCleese')
>>> Key('/Comedy').isAncestorOf(john)
True
'''
if isinstance(other, Key):
return other._string.startswith(self._string + '/')
raise... | [
"def",
"isAncestorOf",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Key",
")",
":",
"return",
"other",
".",
"_string",
".",
"startswith",
"(",
"self",
".",
"_string",
"+",
"'/'",
")",
"raise",
"TypeError",
"(",
"'%s is n... | Returns whether this Key is an ancestor of `other`.
>>> john = Key('/Comedy/MontyPython/Actor:JohnCleese')
>>> Key('/Comedy').isAncestorOf(john)
True | [
"Returns",
"whether",
"this",
"Key",
"is",
"an",
"ancestor",
"of",
"other",
"."
] | python | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/logs.py | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/logs.py#L38-L82 | def config_logging(no_log_file, log_to, log_level, silent, verbosity):
"""
Configures and generates a Logger object, 'openaccess_epub' based on common
parameters used for console interface script execution in OpenAccess_EPUB.
These parameters are:
no_log_file
Boolean. Disables logging t... | [
"def",
"config_logging",
"(",
"no_log_file",
",",
"log_to",
",",
"log_level",
",",
"silent",
",",
"verbosity",
")",
":",
"log_level",
"=",
"get_level",
"(",
"log_level",
")",
"console_level",
"=",
"get_level",
"(",
"verbosity",
")",
"#We want to configure our open... | Configures and generates a Logger object, 'openaccess_epub' based on common
parameters used for console interface script execution in OpenAccess_EPUB.
These parameters are:
no_log_file
Boolean. Disables logging to file. If set to True, log_to and
log_level become irrelevant.
log... | [
"Configures",
"and",
"generates",
"a",
"Logger",
"object",
"openaccess_epub",
"based",
"on",
"common",
"parameters",
"used",
"for",
"console",
"interface",
"script",
"execution",
"in",
"OpenAccess_EPUB",
"."
] | python | train |
mbedmicro/pyOCD | pyocd/gdbserver/context_facade.py | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L60-L76 | def get_register_context(self):
"""
return hexadecimal dump of registers as expected by GDB
"""
logging.debug("GDB getting register context")
resp = b''
reg_num_list = [reg.reg_num for reg in self._register_list]
vals = self._context.read_core_registers_raw(reg_nu... | [
"def",
"get_register_context",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"GDB getting register context\"",
")",
"resp",
"=",
"b''",
"reg_num_list",
"=",
"[",
"reg",
".",
"reg_num",
"for",
"reg",
"in",
"self",
".",
"_register_list",
"]",
"vals",
... | return hexadecimal dump of registers as expected by GDB | [
"return",
"hexadecimal",
"dump",
"of",
"registers",
"as",
"expected",
"by",
"GDB"
] | python | train |
yamins81/tabular | tabular/web.py | https://github.com/yamins81/tabular/blob/1caf091c8c395960a9ad7078f95158b533cc52dd/tabular/web.py#L22-L318 | def tabular2html(fname=None, X=None, fin=None, title=None, printheader=False,
split=True, usecss=None, writecss=None, SERVERNAME=None,
SERVER_FROM_CURDIR='../', ROWS_PER_PAGE=1000,
returnstring = False, **kwargs):
"""
Creates an html representation of tabula... | [
"def",
"tabular2html",
"(",
"fname",
"=",
"None",
",",
"X",
"=",
"None",
",",
"fin",
"=",
"None",
",",
"title",
"=",
"None",
",",
"printheader",
"=",
"False",
",",
"split",
"=",
"True",
",",
"usecss",
"=",
"None",
",",
"writecss",
"=",
"None",
",",... | Creates an html representation of tabular data, either from a tabarray or
an externa file (`including ``.hsv``, ``.csv``, ``.tsv``). If no data is
directly provided by passing a tabarray to `X`, then a tabarray is
constructed using :func:`tabular.tabarray.tabarray.__new__`.
**Parameters**
... | [
"Creates",
"an",
"html",
"representation",
"of",
"tabular",
"data",
"either",
"from",
"a",
"tabarray",
"or",
"an",
"externa",
"file",
"(",
"including",
".",
"hsv",
".",
"csv",
".",
"tsv",
")",
".",
"If",
"no",
"data",
"is",
"directly",
"provided",
"by",
... | python | train |
MinchinWeb/minchin.releaser | minchin/releaser/util.py | https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/util.py#L35-L61 | def check_existence(to_check, name, config_key=None, relative_to=None,
allow_undefined=False, allow_not_existing=False,
base_key='releaser'):
"""Determine whether a file or folder actually exists."""
if allow_undefined and (to_check is None or to_check.lower() == 'none'):... | [
"def",
"check_existence",
"(",
"to_check",
",",
"name",
",",
"config_key",
"=",
"None",
",",
"relative_to",
"=",
"None",
",",
"allow_undefined",
"=",
"False",
",",
"allow_not_existing",
"=",
"False",
",",
"base_key",
"=",
"'releaser'",
")",
":",
"if",
"allow... | Determine whether a file or folder actually exists. | [
"Determine",
"whether",
"a",
"file",
"or",
"folder",
"actually",
"exists",
"."
] | python | train |
bigchaindb/bigchaindb | bigchaindb/common/transaction.py | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L161-L185 | def _fulfillment_to_details(fulfillment):
"""Encode a fulfillment as a details dictionary
Args:
fulfillment: Crypto-conditions Fulfillment object
"""
if fulfillment.type_name == 'ed25519-sha-256':
return {
'type': 'ed25519-sha-256',
'public_key': base58.b58encod... | [
"def",
"_fulfillment_to_details",
"(",
"fulfillment",
")",
":",
"if",
"fulfillment",
".",
"type_name",
"==",
"'ed25519-sha-256'",
":",
"return",
"{",
"'type'",
":",
"'ed25519-sha-256'",
",",
"'public_key'",
":",
"base58",
".",
"b58encode",
"(",
"fulfillment",
".",... | Encode a fulfillment as a details dictionary
Args:
fulfillment: Crypto-conditions Fulfillment object | [
"Encode",
"a",
"fulfillment",
"as",
"a",
"details",
"dictionary"
] | python | train |
Metatab/metapack | metapack/cli/metaaws.py | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/metaaws.py#L349-L375 | def bucket_policy_to_dict(policy):
"""Produce a dictionary of read, write permissions for an existing bucket policy document"""
import json
if not isinstance(policy, dict):
policy = json.loads(policy)
statements = {s['Sid']: s for s in policy['Statement']}
d = {}
for rw in ('Read', '... | [
"def",
"bucket_policy_to_dict",
"(",
"policy",
")",
":",
"import",
"json",
"if",
"not",
"isinstance",
"(",
"policy",
",",
"dict",
")",
":",
"policy",
"=",
"json",
".",
"loads",
"(",
"policy",
")",
"statements",
"=",
"{",
"s",
"[",
"'Sid'",
"]",
":",
... | Produce a dictionary of read, write permissions for an existing bucket policy document | [
"Produce",
"a",
"dictionary",
"of",
"read",
"write",
"permissions",
"for",
"an",
"existing",
"bucket",
"policy",
"document"
] | python | train |
etal/biocma | biocma/cma.py | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L374-L389 | def consensus2block(record, level=0, name=None):
"""Convert a Biopython SeqRecord to a esbglib.cma block.
Ungapping is handled here.
"""
cons_ungap = str(record.seq).replace('-', '').replace('.', '').upper()
record.seq = cons_ungap
return dict(
level=level, #record.annotations.get('... | [
"def",
"consensus2block",
"(",
"record",
",",
"level",
"=",
"0",
",",
"name",
"=",
"None",
")",
":",
"cons_ungap",
"=",
"str",
"(",
"record",
".",
"seq",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
".",
"replace",
"(",
"'.'",
",",
"''",
")",... | Convert a Biopython SeqRecord to a esbglib.cma block.
Ungapping is handled here. | [
"Convert",
"a",
"Biopython",
"SeqRecord",
"to",
"a",
"esbglib",
".",
"cma",
"block",
"."
] | python | train |
cloudmesh-cmd3/cmd3 | cmd3/plugins/info.py | https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/info.py#L22-L42 | def do_info(self, arg, arguments):
"""
::
Usage:
info [--all]
Options:
--all -a more extensive information
Prints some internal information about the shell
"""
if arguments["--all"]:
Console.ok(... | [
"def",
"do_info",
"(",
"self",
",",
"arg",
",",
"arguments",
")",
":",
"if",
"arguments",
"[",
"\"--all\"",
"]",
":",
"Console",
".",
"ok",
"(",
"70",
"*",
"\"-\"",
")",
"Console",
".",
"ok",
"(",
"'DIR'",
")",
"Console",
".",
"ok",
"(",
"70",
"*... | ::
Usage:
info [--all]
Options:
--all -a more extensive information
Prints some internal information about the shell | [
"::"
] | python | train |
shoebot/shoebot | shoebot/sbio/shell.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L325-L332 | def do_EOF(self, line):
"""
Exit shell and shoebot
Alias for exit.
"""
print(self.response_prompt, file=self.stdout)
return self.do_exit(line) | [
"def",
"do_EOF",
"(",
"self",
",",
"line",
")",
":",
"print",
"(",
"self",
".",
"response_prompt",
",",
"file",
"=",
"self",
".",
"stdout",
")",
"return",
"self",
".",
"do_exit",
"(",
"line",
")"
] | Exit shell and shoebot
Alias for exit. | [
"Exit",
"shell",
"and",
"shoebot"
] | python | valid |
yyuu/botornado | boto/s3/bucket.py | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/s3/bucket.py#L1289-L1352 | def initiate_multipart_upload(self, key_name, headers=None,
reduced_redundancy=False,
metadata=None, encrypt_key=False):
"""
Start a multipart upload operation.
:type key_name: string
:param key_name: The name of the ke... | [
"def",
"initiate_multipart_upload",
"(",
"self",
",",
"key_name",
",",
"headers",
"=",
"None",
",",
"reduced_redundancy",
"=",
"False",
",",
"metadata",
"=",
"None",
",",
"encrypt_key",
"=",
"False",
")",
":",
"query_args",
"=",
"'uploads'",
"provider",
"=",
... | Start a multipart upload operation.
:type key_name: string
:param key_name: The name of the key that will ultimately result from
this multipart upload operation. This will be exactly
as the key appears in the bucket after the upload
... | [
"Start",
"a",
"multipart",
"upload",
"operation",
"."
] | python | train |
SheffieldML/GPy | GPy/likelihoods/bernoulli.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/likelihoods/bernoulli.py#L251-L258 | def predictive_quantiles(self, mu, var, quantiles, Y_metadata=None):
"""
Get the "quantiles" of the binary labels (Bernoulli draws). all the
quantiles must be either 0 or 1, since those are the only values the
draw can take!
"""
p = self.predictive_mean(mu, var)
r... | [
"def",
"predictive_quantiles",
"(",
"self",
",",
"mu",
",",
"var",
",",
"quantiles",
",",
"Y_metadata",
"=",
"None",
")",
":",
"p",
"=",
"self",
".",
"predictive_mean",
"(",
"mu",
",",
"var",
")",
"return",
"[",
"np",
".",
"asarray",
"(",
"p",
">",
... | Get the "quantiles" of the binary labels (Bernoulli draws). all the
quantiles must be either 0 or 1, since those are the only values the
draw can take! | [
"Get",
"the",
"quantiles",
"of",
"the",
"binary",
"labels",
"(",
"Bernoulli",
"draws",
")",
".",
"all",
"the",
"quantiles",
"must",
"be",
"either",
"0",
"or",
"1",
"since",
"those",
"are",
"the",
"only",
"values",
"the",
"draw",
"can",
"take!"
] | python | train |
obilaniu/Nauka | src/nauka/exp/experiment.py | https://github.com/obilaniu/Nauka/blob/1492a4f9d204a868c1a8a1d327bd108490b856b4/src/nauka/exp/experiment.py#L163-L199 | def purge (self,
strategy = "klogn",
keep = None,
deleteNonSnapshots = False,
**kwargs):
"""Purge snapshot directory of snapshots according to some strategy,
preserving ... | [
"def",
"purge",
"(",
"self",
",",
"strategy",
"=",
"\"klogn\"",
",",
"keep",
"=",
"None",
",",
"deleteNonSnapshots",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"(",
"isinstance",
"(",
"keep",
",",
"(",
"list",
",",
"set",
")",
")",
... | Purge snapshot directory of snapshots according to some strategy,
preserving however a given "keep" list or set of snapshot numbers.
Available strategies are:
"lastk": Keep last k snapshots (Default: k=10)
"klogn": Keep every snapshot in the last k, 2k snapshots in
the last k**2, 3k... | [
"Purge",
"snapshot",
"directory",
"of",
"snapshots",
"according",
"to",
"some",
"strategy",
"preserving",
"however",
"a",
"given",
"keep",
"list",
"or",
"set",
"of",
"snapshot",
"numbers",
".",
"Available",
"strategies",
"are",
":",
"lastk",
":",
"Keep",
"last... | python | train |
kalefranz/auxlib | auxlib/configuration.py | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/configuration.py#L146-L150 | def unset_env(self, key):
"""Removes an environment variable using the prepended app_name convention with `key`."""
os.environ.pop(make_env_key(self.appname, key), None)
self._registered_env_keys.discard(key)
self._clear_memoization() | [
"def",
"unset_env",
"(",
"self",
",",
"key",
")",
":",
"os",
".",
"environ",
".",
"pop",
"(",
"make_env_key",
"(",
"self",
".",
"appname",
",",
"key",
")",
",",
"None",
")",
"self",
".",
"_registered_env_keys",
".",
"discard",
"(",
"key",
")",
"self"... | Removes an environment variable using the prepended app_name convention with `key`. | [
"Removes",
"an",
"environment",
"variable",
"using",
"the",
"prepended",
"app_name",
"convention",
"with",
"key",
"."
] | python | train |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L278-L315 | def _definition_from_example(example):
"""Generates a swagger definition json from a given example
Works only for simple types in the dict
Args:
example: The example for which we want a definition
Type is DICT
Returns:
A dict that is the ... | [
"def",
"_definition_from_example",
"(",
"example",
")",
":",
"assert",
"isinstance",
"(",
"example",
",",
"dict",
")",
"def",
"_has_simple_type",
"(",
"value",
")",
":",
"accepted",
"=",
"(",
"str",
",",
"int",
",",
"float",
",",
"bool",
")",
"return",
"... | Generates a swagger definition json from a given example
Works only for simple types in the dict
Args:
example: The example for which we want a definition
Type is DICT
Returns:
A dict that is the swagger definition json | [
"Generates",
"a",
"swagger",
"definition",
"json",
"from",
"a",
"given",
"example",
"Works",
"only",
"for",
"simple",
"types",
"in",
"the",
"dict"
] | python | train |
TkTech/Jawa | jawa/fields.py | https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/fields.py#L98-L102 | def find_and_remove(self, f: Callable):
"""
Removes any and all fields for which `f(field)` returns `True`.
"""
self._table = [fld for fld in self._table if not f(fld)] | [
"def",
"find_and_remove",
"(",
"self",
",",
"f",
":",
"Callable",
")",
":",
"self",
".",
"_table",
"=",
"[",
"fld",
"for",
"fld",
"in",
"self",
".",
"_table",
"if",
"not",
"f",
"(",
"fld",
")",
"]"
] | Removes any and all fields for which `f(field)` returns `True`. | [
"Removes",
"any",
"and",
"all",
"fields",
"for",
"which",
"f",
"(",
"field",
")",
"returns",
"True",
"."
] | python | train |
msmbuilder/msmbuilder | msmbuilder/msm/msm.py | https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/msm/msm.py#L212-L281 | def eigtransform(self, sequences, right=True, mode='clip'):
r"""Transform a list of sequences by projecting the sequences onto
the first `n_timescales` dynamical eigenvectors.
Parameters
----------
sequences : list of array-like
List of sequences, or a single sequenc... | [
"def",
"eigtransform",
"(",
"self",
",",
"sequences",
",",
"right",
"=",
"True",
",",
"mode",
"=",
"'clip'",
")",
":",
"result",
"=",
"[",
"]",
"for",
"y",
"in",
"self",
".",
"transform",
"(",
"sequences",
",",
"mode",
"=",
"mode",
")",
":",
"if",
... | r"""Transform a list of sequences by projecting the sequences onto
the first `n_timescales` dynamical eigenvectors.
Parameters
----------
sequences : list of array-like
List of sequences, or a single sequence. Each sequence should be a
1D iterable of state labels... | [
"r",
"Transform",
"a",
"list",
"of",
"sequences",
"by",
"projecting",
"the",
"sequences",
"onto",
"the",
"first",
"n_timescales",
"dynamical",
"eigenvectors",
"."
] | python | train |
chromy/essence | src/essence/world.py | https://github.com/chromy/essence/blob/6cd18821ec91edf022619d9f0c0878f38c22a763/src/essence/world.py#L56-L72 | def add_component(self, entity, component):
"""Add component to entity.
Long-hand for :func:`essence.Entity.add`.
:param entity: entity to associate
:type entity: :class:`essence.Entity`
:param component: component to add to the entity
:type component: :class:`essence.C... | [
"def",
"add_component",
"(",
"self",
",",
"entity",
",",
"component",
")",
":",
"component_type",
"=",
"type",
"(",
"component",
")",
"relation",
"=",
"self",
".",
"_get_relation",
"(",
"component_type",
")",
"if",
"entity",
"in",
"relation",
":",
"# PYTHON2... | Add component to entity.
Long-hand for :func:`essence.Entity.add`.
:param entity: entity to associate
:type entity: :class:`essence.Entity`
:param component: component to add to the entity
:type component: :class:`essence.Component` | [
"Add",
"component",
"to",
"entity",
"."
] | python | train |
AndresMWeber/Nomenclate | nomenclate/core/configurator.py | https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/configurator.py#L160-L174 | def _get_path_entry_from_string(self, query_string, first_found=True, full_path=False):
""" Parses a string to form a list of strings that represents a possible config entry header
:param query_string: str, query string we are looking for
:param first_found: bool, return first found entry or en... | [
"def",
"_get_path_entry_from_string",
"(",
"self",
",",
"query_string",
",",
"first_found",
"=",
"True",
",",
"full_path",
"=",
"False",
")",
":",
"iter_matches",
"=",
"gen_dict_key_matches",
"(",
"query_string",
",",
"self",
".",
"config_file_contents",
",",
"ful... | Parses a string to form a list of strings that represents a possible config entry header
:param query_string: str, query string we are looking for
:param first_found: bool, return first found entry or entire list
:param full_path: bool, whether to return each entry with their corresponding conf... | [
"Parses",
"a",
"string",
"to",
"form",
"a",
"list",
"of",
"strings",
"that",
"represents",
"a",
"possible",
"config",
"entry",
"header"
] | python | train |
ultrabug/py3status | py3status/composite.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/composite.py#L58-L72 | def append(self, item):
"""
Add an item to the Composite. Item can be a Composite, list etc
"""
if isinstance(item, Composite):
self._content += item.get_content()
elif isinstance(item, list):
self._content += item
elif isinstance(item, dict):
... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"Composite",
")",
":",
"self",
".",
"_content",
"+=",
"item",
".",
"get_content",
"(",
")",
"elif",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"self",
... | Add an item to the Composite. Item can be a Composite, list etc | [
"Add",
"an",
"item",
"to",
"the",
"Composite",
".",
"Item",
"can",
"be",
"a",
"Composite",
"list",
"etc"
] | python | train |
chaoss/grimoirelab-perceval | perceval/backends/core/groupsio.py | https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/groupsio.py#L259-L268 | def _pre_init(self):
"""Initialize mailing lists directory path"""
if not self.parsed_args.mboxes_path:
base_path = os.path.expanduser('~/.perceval/mailinglists/')
dirpath = os.path.join(base_path, GROUPSIO_URL, 'g', self.parsed_args.group_name)
else:
dirpath... | [
"def",
"_pre_init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parsed_args",
".",
"mboxes_path",
":",
"base_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.perceval/mailinglists/'",
")",
"dirpath",
"=",
"os",
".",
"path",
".",
"join",
... | Initialize mailing lists directory path | [
"Initialize",
"mailing",
"lists",
"directory",
"path"
] | python | test |
mar10/wsgidav | wsgidav/dav_provider.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/dav_provider.py#L582-L716 | def get_property_value(self, name):
"""Return the value of a property.
name:
the property name in Clark notation.
return value:
may have different types, depending on the status:
- string or unicode: for standard property values.
- lxml.etree.Ele... | [
"def",
"get_property_value",
"(",
"self",
",",
"name",
")",
":",
"refUrl",
"=",
"self",
".",
"get_ref_url",
"(",
")",
"# lock properties",
"lm",
"=",
"self",
".",
"provider",
".",
"lock_manager",
"if",
"lm",
"and",
"name",
"==",
"\"{DAV:}lockdiscovery\"",
":... | Return the value of a property.
name:
the property name in Clark notation.
return value:
may have different types, depending on the status:
- string or unicode: for standard property values.
- lxml.etree.Element: for complex values.
If the p... | [
"Return",
"the",
"value",
"of",
"a",
"property",
"."
] | python | valid |
singularityhub/singularity-cli | spython/image/cmd/create.py | https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/image/cmd/create.py#L11-L34 | def create(self,image_path, size=1024, sudo=False):
'''create will create a a new image
Parameters
==========
image_path: full path to image
size: image sizein MiB, default is 1024MiB
filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3
'''
f... | [
"def",
"create",
"(",
"self",
",",
"image_path",
",",
"size",
"=",
"1024",
",",
"sudo",
"=",
"False",
")",
":",
"from",
"spython",
".",
"utils",
"import",
"check_install",
"check_install",
"(",
")",
"cmd",
"=",
"self",
".",
"init_command",
"(",
"'image.c... | create will create a a new image
Parameters
==========
image_path: full path to image
size: image sizein MiB, default is 1024MiB
filesystem: supported file systems ext3/ext4 (ext[2/3]: default ext3 | [
"create",
"will",
"create",
"a",
"a",
"new",
"image"
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L14781-L14794 | def delete_guest_property(self, name):
"""Deletes an entry from the machine's guest property store.
in name of type str
The name of the property to delete.
raises :class:`VBoxErrorInvalidVmState`
Machine session is not open.
"""
if not isinstanc... | [
"def",
"delete_guest_property",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"name can only be an instance of type basestring\"",
")",
"self",
".",
"_call",
"(",
"\"deleteGues... | Deletes an entry from the machine's guest property store.
in name of type str
The name of the property to delete.
raises :class:`VBoxErrorInvalidVmState`
Machine session is not open. | [
"Deletes",
"an",
"entry",
"from",
"the",
"machine",
"s",
"guest",
"property",
"store",
"."
] | python | train |
pandas-dev/pandas | pandas/core/groupby/groupby.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1984-L2088 | def _get_cythonized_result(self, how, grouper, aggregate=False,
cython_dtype=None, needs_values=False,
needs_mask=False, needs_ngroups=False,
result_is_index=False,
pre_processing=None, post_proce... | [
"def",
"_get_cythonized_result",
"(",
"self",
",",
"how",
",",
"grouper",
",",
"aggregate",
"=",
"False",
",",
"cython_dtype",
"=",
"None",
",",
"needs_values",
"=",
"False",
",",
"needs_mask",
"=",
"False",
",",
"needs_ngroups",
"=",
"False",
",",
"result_i... | Get result for Cythonized functions.
Parameters
----------
how : str, Cythonized function name to be called
grouper : Grouper object containing pertinent group info
aggregate : bool, default False
Whether the result should be aggregated to match the number of
... | [
"Get",
"result",
"for",
"Cythonized",
"functions",
"."
] | python | train |
saltstack/salt | salt/modules/salt_version.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_version.py#L151-L170 | def _check_release_cmp(name):
'''
Helper function to compare release codename versions to the minion's current
Salt version.
If release codename isn't found, the function returns None. Otherwise, it
returns the results of the version comparison as documented by the
``versions_cmp`` function in ... | [
"def",
"_check_release_cmp",
"(",
"name",
")",
":",
"map_version",
"=",
"get_release_number",
"(",
"name",
")",
"if",
"map_version",
"is",
"None",
":",
"log",
".",
"info",
"(",
"'Release codename %s was not found.'",
",",
"name",
")",
"return",
"None",
"current_... | Helper function to compare release codename versions to the minion's current
Salt version.
If release codename isn't found, the function returns None. Otherwise, it
returns the results of the version comparison as documented by the
``versions_cmp`` function in ``salt.utils.versions.py``. | [
"Helper",
"function",
"to",
"compare",
"release",
"codename",
"versions",
"to",
"the",
"minion",
"s",
"current",
"Salt",
"version",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_lag.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_lag.py#L327-L338 | def get_port_channel_detail_output_has_more(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_port_channel_detail = ET.Element("get_port_channel_detail")
config = get_port_channel_detail
output = ET.SubElement(get_port_channel_detail, "output")... | [
"def",
"get_port_channel_detail_output_has_more",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_port_channel_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_port_channel_detail\"",
")",
"config",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
callowayproject/Transmogrify | transmogrify/geometry.py | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/geometry.py#L130-L156 | def translate(self, val1, val2=None):
"""
Move to new (x + dx, y + dy).
accepts Point, (x, y), [x, y], int, float
"""
error = "Point.translate only accepts a Point, a tuple, a list, ints or floats."
if val1 and val2:
if isinstance(val1, (int, float)) and isin... | [
"def",
"translate",
"(",
"self",
",",
"val1",
",",
"val2",
"=",
"None",
")",
":",
"error",
"=",
"\"Point.translate only accepts a Point, a tuple, a list, ints or floats.\"",
"if",
"val1",
"and",
"val2",
":",
"if",
"isinstance",
"(",
"val1",
",",
"(",
"int",
",",... | Move to new (x + dx, y + dy).
accepts Point, (x, y), [x, y], int, float | [
"Move",
"to",
"new",
"(",
"x",
"+",
"dx",
"y",
"+",
"dy",
")",
"."
] | python | train |
HydraChain/hydrachain | hydrachain/native_contracts.py | https://github.com/HydraChain/hydrachain/blob/6c0919b0575dc8aa481f3a8c703e1a7f0575ecc3/hydrachain/native_contracts.py#L215-L219 | def abi_encode_args(method, args):
"encode args for method: method_id|data"
assert issubclass(method.im_class, NativeABIContract), method.im_class
m_abi = method.im_class._get_method_abi(method)
return zpad(encode_int(m_abi['id']), 4) + abi.encode_abi(m_abi['arg_types'], args) | [
"def",
"abi_encode_args",
"(",
"method",
",",
"args",
")",
":",
"assert",
"issubclass",
"(",
"method",
".",
"im_class",
",",
"NativeABIContract",
")",
",",
"method",
".",
"im_class",
"m_abi",
"=",
"method",
".",
"im_class",
".",
"_get_method_abi",
"(",
"meth... | encode args for method: method_id|data | [
"encode",
"args",
"for",
"method",
":",
"method_id|data"
] | python | test |
ambitioninc/django-entity | entity/sync.py | https://github.com/ambitioninc/django-entity/blob/ebc61f34313c52f4ef5819eb1da25b2ad837e80c/entity/sync.py#L59-L91 | def defer_entity_syncing(wrapped, instance, args, kwargs):
"""
A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening
"""
# Defer... | [
"def",
"defer_entity_syncing",
"(",
"wrapped",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"# Defer entity syncing while we run our method",
"sync_entities",
".",
"defer",
"=",
"True",
"# Run the method",
"try",
":",
"return",
"wrapped",
"(",
"*",
"args",... | A decorator that can be used to defer the syncing of entities until after the method has been run
This is being introduced to help avoid deadlocks in the meantime as we attempt to better understand
why they are happening | [
"A",
"decorator",
"that",
"can",
"be",
"used",
"to",
"defer",
"the",
"syncing",
"of",
"entities",
"until",
"after",
"the",
"method",
"has",
"been",
"run",
"This",
"is",
"being",
"introduced",
"to",
"help",
"avoid",
"deadlocks",
"in",
"the",
"meantime",
"as... | python | train |
i3visio/entify | entify/lib/patterns/dni.py | https://github.com/i3visio/entify/blob/51c5b89cebee3a39d44d0918e2798739361f337c/entify/lib/patterns/dni.py#L42-L71 | def isValidExp(self, exp):
'''
Method to verify if a given expression is correct just in case the used regular expression needs additional processing to verify this fact.$
This method will be overwritten when necessary.
:param exp: Expression to verify.
... | [
"def",
"isValidExp",
"(",
"self",
",",
"exp",
")",
":",
"# order of the letters depending on which is the mod of the number",
"# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23",
"order",
"=",
"[",
"'T'",
",",
... | Method to verify if a given expression is correct just in case the used regular expression needs additional processing to verify this fact.$
This method will be overwritten when necessary.
:param exp: Expression to verify.
:return: True | False | [
"Method",
"to",
"verify",
"if",
"a",
"given",
"expression",
"is",
"correct",
"just",
"in",
"case",
"the",
"used",
"regular",
"expression",
"needs",
"additional",
"processing",
"to",
"verify",
"this",
"fact",
".",
"$",
"This",
"method",
"will",
"be",
"overwri... | python | train |
Falkonry/falkonry-python-client | falkonryclient/service/falkonry.py | https://github.com/Falkonry/falkonry-python-client/blob/0aeb2b00293ee94944f1634e9667401b03da29c1/falkonryclient/service/falkonry.py#L37-L45 | def get_datastreams(self):
"""
To get list of Datastream
"""
datastreams = []
response = self.http.get('/Datastream')
for datastream in response:
datastreams.append(Schemas.Datastream(datastream=datastream))
return datastreams | [
"def",
"get_datastreams",
"(",
"self",
")",
":",
"datastreams",
"=",
"[",
"]",
"response",
"=",
"self",
".",
"http",
".",
"get",
"(",
"'/Datastream'",
")",
"for",
"datastream",
"in",
"response",
":",
"datastreams",
".",
"append",
"(",
"Schemas",
".",
"Da... | To get list of Datastream | [
"To",
"get",
"list",
"of",
"Datastream"
] | python | train |
markovmodel/PyEMMA | pyemma/coordinates/data/util/traj_info_backends.py | https://github.com/markovmodel/PyEMMA/blob/5c3124398217de05ba5ce9c8fb01519222481ab8/pyemma/coordinates/data/util/traj_info_backends.py#L259-L288 | def _update_time_stamp(self, hash_value):
""" timestamps are being stored distributed over several lru databases.
The timestamp is a time.time() snapshot (float), which are seconds since epoch."""
db_name = self._database_from_key(hash_value)
if not db_name:
db_name=':memory:... | [
"def",
"_update_time_stamp",
"(",
"self",
",",
"hash_value",
")",
":",
"db_name",
"=",
"self",
".",
"_database_from_key",
"(",
"hash_value",
")",
"if",
"not",
"db_name",
":",
"db_name",
"=",
"':memory:'",
"def",
"_update",
"(",
")",
":",
"import",
"sqlite3",... | timestamps are being stored distributed over several lru databases.
The timestamp is a time.time() snapshot (float), which are seconds since epoch. | [
"timestamps",
"are",
"being",
"stored",
"distributed",
"over",
"several",
"lru",
"databases",
".",
"The",
"timestamp",
"is",
"a",
"time",
".",
"time",
"()",
"snapshot",
"(",
"float",
")",
"which",
"are",
"seconds",
"since",
"epoch",
"."
] | python | train |
exa-analytics/exa | exa/core/editor.py | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L435-L452 | def lines_from_file(path, as_interned=False, encoding=None):
"""
Create a list of file lines from a given filepath.
Args:
path (str): File path
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list
"""
lines = None
wi... | [
"def",
"lines_from_file",
"(",
"path",
",",
"as_interned",
"=",
"False",
",",
"encoding",
"=",
"None",
")",
":",
"lines",
"=",
"None",
"with",
"io",
".",
"open",
"(",
"path",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"if",
"as_interned",
... | Create a list of file lines from a given filepath.
Args:
path (str): File path
as_interned (bool): List of "interned" strings (default False)
Returns:
strings (list): File line list | [
"Create",
"a",
"list",
"of",
"file",
"lines",
"from",
"a",
"given",
"filepath",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.