repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
grundic/yagocd | yagocd/client.py | https://github.com/grundic/yagocd/blob/4c75336ae6f107c8723d37b15e52169151822127/yagocd/client.py#L221-L229 | def info(self):
"""
Property for accessing :class:`InfoManager` instance, which is used to general server info.
:rtype: yagocd.resources.info.InfoManager
"""
if self._info_manager is None:
self._info_manager = InfoManager(session=self._session)
return self._i... | [
"def",
"info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_info_manager",
"is",
"None",
":",
"self",
".",
"_info_manager",
"=",
"InfoManager",
"(",
"session",
"=",
"self",
".",
"_session",
")",
"return",
"self",
".",
"_info_manager"
] | Property for accessing :class:`InfoManager` instance, which is used to general server info.
:rtype: yagocd.resources.info.InfoManager | [
"Property",
"for",
"accessing",
":",
"class",
":",
"InfoManager",
"instance",
"which",
"is",
"used",
"to",
"general",
"server",
"info",
"."
] | python | train | 35.888889 |
Skyscanner/pycfmodel | pycfmodel/model/resources/properties/policy_document.py | https://github.com/Skyscanner/pycfmodel/blob/e3da4db96f59c0a5dba06ae66ad25645775e5500/pycfmodel/model/resources/properties/policy_document.py#L176-L189 | def wildcard_allowed_actions(self, pattern=None):
"""
Find statements which allow wildcard actions.
A pattern can be specified for the wildcard action
"""
wildcard_allowed = []
for statement in self.statements:
if statement.wildcard_actions(pattern) and sta... | [
"def",
"wildcard_allowed_actions",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"wildcard_allowed",
"=",
"[",
"]",
"for",
"statement",
"in",
"self",
".",
"statements",
":",
"if",
"statement",
".",
"wildcard_actions",
"(",
"pattern",
")",
"and",
"state... | Find statements which allow wildcard actions.
A pattern can be specified for the wildcard action | [
"Find",
"statements",
"which",
"allow",
"wildcard",
"actions",
"."
] | python | train | 29.714286 |
lambdamusic/Ontospy | ontospy/extras/hacks/sketch.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/sketch.py#L149-L166 | def omnigraffle(self):
""" tries to open an export directly in omnigraffle """
temp = self.rdf_source("dot")
try: # try to put in the user/tmp folder
from os.path import expanduser
home = expanduser("~")
filename = home + "/tmp/turtle_sketch.dot"
f = open(filename, "w")
except:
filename = "turt... | [
"def",
"omnigraffle",
"(",
"self",
")",
":",
"temp",
"=",
"self",
".",
"rdf_source",
"(",
"\"dot\"",
")",
"try",
":",
"# try to put in the user/tmp folder",
"from",
"os",
".",
"path",
"import",
"expanduser",
"home",
"=",
"expanduser",
"(",
"\"~\"",
")",
"fil... | tries to open an export directly in omnigraffle | [
"tries",
"to",
"open",
"an",
"export",
"directly",
"in",
"omnigraffle"
] | python | train | 25.333333 |
CalebBell/ht | ht/conv_plate.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_plate.py#L51-L147 | def Nu_plate_Kumar(Re, Pr, chevron_angle, mu=None, mu_wall=None):
r'''Calculates Nusselt number for single-phase flow in a
**well-designed** Chevron-style plate heat exchanger according to [1]_.
The data is believed to have been developed by APV International Limited,
since acquired by SPX Corporation.... | [
"def",
"Nu_plate_Kumar",
"(",
"Re",
",",
"Pr",
",",
"chevron_angle",
",",
"mu",
"=",
"None",
",",
"mu_wall",
"=",
"None",
")",
":",
"# Uses the standard diameter as characteristic diameter",
"beta_list_len",
"=",
"len",
"(",
"Kumar_beta_list",
")",
"for",
"i",
"... | r'''Calculates Nusselt number for single-phase flow in a
**well-designed** Chevron-style plate heat exchanger according to [1]_.
The data is believed to have been developed by APV International Limited,
since acquired by SPX Corporation. This uses a curve fit of that data
published in [2]_.
..... | [
"r",
"Calculates",
"Nusselt",
"number",
"for",
"single",
"-",
"phase",
"flow",
"in",
"a",
"**",
"well",
"-",
"designed",
"**",
"Chevron",
"-",
"style",
"plate",
"heat",
"exchanger",
"according",
"to",
"[",
"1",
"]",
"_",
".",
"The",
"data",
"is",
"beli... | python | train | 38.505155 |
e7dal/bubble3 | behave4cmd0/command_steps.py | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/behave4cmd0/command_steps.py#L198-L210 | def step_it_should_fail_with(context):
'''
EXAMPLE:
...
when I run "behave ..."
then it should fail with:
"""
TEXT
"""
'''
assert context.text is not None, "ENSURE: multiline text is provided."
step_command_output_should_contain(context)
... | [
"def",
"step_it_should_fail_with",
"(",
"context",
")",
":",
"assert",
"context",
".",
"text",
"is",
"not",
"None",
",",
"\"ENSURE: multiline text is provided.\"",
"step_command_output_should_contain",
"(",
"context",
")",
"assert_that",
"(",
"context",
".",
"command_re... | EXAMPLE:
...
when I run "behave ..."
then it should fail with:
"""
TEXT
""" | [
"EXAMPLE",
":",
"...",
"when",
"I",
"run",
"behave",
"...",
"then",
"it",
"should",
"fail",
"with",
":",
"TEXT"
] | python | train | 29 |
neurosynth/neurosynth | neurosynth/analysis/decode.py | https://github.com/neurosynth/neurosynth/blob/948ce7edce15d7df693446e76834e0c23bfe8f11/neurosynth/analysis/decode.py#L216-L219 | def _dot_product(self, imgs_to_decode):
""" Decoding using the dot product.
"""
return np.dot(imgs_to_decode.T, self.feature_images).T | [
"def",
"_dot_product",
"(",
"self",
",",
"imgs_to_decode",
")",
":",
"return",
"np",
".",
"dot",
"(",
"imgs_to_decode",
".",
"T",
",",
"self",
".",
"feature_images",
")",
".",
"T"
] | Decoding using the dot product. | [
"Decoding",
"using",
"the",
"dot",
"product",
"."
] | python | test | 38.75 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/MessageDecoder.py | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/MessageDecoder.py#L84-L104 | def decode_sent_msg(pref, message, pretty=False):
"""decode_sent_msg: Return a string of the decoded message
"""
newline = "\n" if pretty else " "
indent = " " if pretty else ""
start = newline + indent
out = []
out.append("%s%s{%sSEQNUM: %d," % (pref, newline, start, message[Const.W_SEQ... | [
"def",
"decode_sent_msg",
"(",
"pref",
",",
"message",
",",
"pretty",
"=",
"False",
")",
":",
"newline",
"=",
"\"\\n\"",
"if",
"pretty",
"else",
"\" \"",
"indent",
"=",
"\" \"",
"if",
"pretty",
"else",
"\"\"",
"start",
"=",
"newline",
"+",
"indent",
"... | decode_sent_msg: Return a string of the decoded message | [
"decode_sent_msg",
":",
"Return",
"a",
"string",
"of",
"the",
"decoded",
"message"
] | python | train | 59.47619 |
JinnLynn/genpac | genpac/publicsuffixlist/__init__.py | https://github.com/JinnLynn/genpac/blob/2f466d28f403a9a5624e02edcd538475fe475fc8/genpac/publicsuffixlist/__init__.py#L249-L260 | def privateparts(self, domain):
""" Return tuple of labels and the private suffix. """
s = self.privatesuffix(domain)
if s is None:
return None
else:
# I know the domain is valid and ends with private suffix
pre = domain[0:-(len(s)+1)]
if p... | [
"def",
"privateparts",
"(",
"self",
",",
"domain",
")",
":",
"s",
"=",
"self",
".",
"privatesuffix",
"(",
"domain",
")",
"if",
"s",
"is",
"None",
":",
"return",
"None",
"else",
":",
"# I know the domain is valid and ends with private suffix",
"pre",
"=",
"doma... | Return tuple of labels and the private suffix. | [
"Return",
"tuple",
"of",
"labels",
"and",
"the",
"private",
"suffix",
"."
] | python | train | 34.583333 |
mcs07/CIRpy | cirpy.py | https://github.com/mcs07/CIRpy/blob/fee2bbbb08eb39bbbe003f835d64e8c0c1688904/cirpy.py#L259-L286 | def download(input, filename, representation, overwrite=False, resolvers=None, get3d=False, **kwargs):
"""Convenience function to save a CIR response as a file.
This is just a simple wrapper around the resolve function.
:param string input: Chemical identifier to resolve
:param string filename: File p... | [
"def",
"download",
"(",
"input",
",",
"filename",
",",
"representation",
",",
"overwrite",
"=",
"False",
",",
"resolvers",
"=",
"None",
",",
"get3d",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"resolve",
"(",
"input",
",",
"represe... | Convenience function to save a CIR response as a file.
This is just a simple wrapper around the resolve function.
:param string input: Chemical identifier to resolve
:param string filename: File path to save to
:param string representation: Desired output representation
:param bool overwrite: (Opt... | [
"Convenience",
"function",
"to",
"save",
"a",
"CIR",
"response",
"as",
"a",
"file",
"."
] | python | train | 48.857143 |
mattharrison/rst2odp | odplib/preso.py | https://github.com/mattharrison/rst2odp/blob/4adbf29b28c8207ec882f792ded07e98b1d3e7d0/odplib/preso.py#L92-L113 | def cwd_decorator(func):
"""
decorator to change cwd to directory containing rst for this function
"""
def wrapper(*args, **kw):
cur_dir = os.getcwd()
found = False
for arg in sys.argv:
if arg.endswith(".rst"):
found = arg
break
... | [
"def",
"cwd_decorator",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"cur_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"found",
"=",
"False",
"for",
"arg",
"in",
"sys",
".",
"argv",
":",
"if",
"arg",
".... | decorator to change cwd to directory containing rst for this function | [
"decorator",
"to",
"change",
"cwd",
"to",
"directory",
"containing",
"rst",
"for",
"this",
"function"
] | python | train | 23.590909 |
zbanks/shmooze | shmooze/lib/database.py | https://github.com/zbanks/shmooze/blob/7ae615e172c174d6fe184a8bf90f8ad075bf58ed/shmooze/lib/database.py#L72-L120 | def create_top_schema(self):
"""
(Category --->) Item <---> Module <---> LogEntry
<---> is a many-to-many relationship
---> is a foreign key relationship
(- Category: represents a group of Items which form a top list)
- Item: something that can be played multiple time... | [
"def",
"create_top_schema",
"(",
"self",
")",
":",
"self",
".",
"execute",
"(",
"\"\"\"CREATE TABLE IF NOT EXISTS top_module (\n uuid TEXT,\n add_timestamp DATETIME\n );\"\"\"",
")",
"self",
".",
"execute",
"(",
"\"\"\"CREATE TABLE IF NOT EXISTS top_categ... | (Category --->) Item <---> Module <---> LogEntry
<---> is a many-to-many relationship
---> is a foreign key relationship
(- Category: represents a group of Items which form a top list)
- Item: something that can be played multiple times and is grouped by to build a top list
... | [
"(",
"Category",
"---",
">",
")",
"Item",
"<",
"---",
">",
"Module",
"<",
"---",
">",
"LogEntry"
] | python | train | 33.959184 |
Jajcus/pyxmpp2 | pyxmpp2/ext/muc/muc.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/muc/muc.py#L923-L941 | def __groupchat_message(self,stanza):
"""Process a groupchat message from a MUC room.
:Parameters:
- `stanza`: the stanza received.
:Types:
- `stanza`: `Message`
:return: `True` if the message was properly recognized as directed to
one of the managed... | [
"def",
"__groupchat_message",
"(",
"self",
",",
"stanza",
")",
":",
"fr",
"=",
"stanza",
".",
"get_from",
"(",
")",
"key",
"=",
"fr",
".",
"bare",
"(",
")",
".",
"as_unicode",
"(",
")",
"rs",
"=",
"self",
".",
"rooms",
".",
"get",
"(",
"key",
")"... | Process a groupchat message from a MUC room.
:Parameters:
- `stanza`: the stanza received.
:Types:
- `stanza`: `Message`
:return: `True` if the message was properly recognized as directed to
one of the managed rooms, `False` otherwise.
:returntype: `... | [
"Process",
"a",
"groupchat",
"message",
"from",
"a",
"MUC",
"room",
"."
] | python | valid | 33.473684 |
datastore/datastore | datastore/core/basic.py | https://github.com/datastore/datastore/blob/7ccf0cd4748001d3dbf5e6dda369b0f63e0269d3/datastore/core/basic.py#L1056-L1059 | def put(self, key, value):
'''Stores the object in all underlying datastores.'''
for store in self._stores:
store.put(key, value) | [
"def",
"put",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"for",
"store",
"in",
"self",
".",
"_stores",
":",
"store",
".",
"put",
"(",
"key",
",",
"value",
")"
] | Stores the object in all underlying datastores. | [
"Stores",
"the",
"object",
"in",
"all",
"underlying",
"datastores",
"."
] | python | train | 35 |
teepark/junction | junction/client.py | https://github.com/teepark/junction/blob/481d135d9e53acb55c72686e2eb4483432f35fa6/junction/client.py#L133-L165 | def send_rpc(self, service, routing_id, method, args=None, kwargs=None,
broadcast=False):
'''Send out an RPC request
:param service: the service name (the routing top level)
:type service: anything hash-able
:param routing_id:
The id used for routing within the r... | [
"def",
"send_rpc",
"(",
"self",
",",
"service",
",",
"routing_id",
",",
"method",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"broadcast",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_peer",
".",
"up",
":",
"raise",
"errors",
... | Send out an RPC request
:param service: the service name (the routing top level)
:type service: anything hash-able
:param routing_id:
The id used for routing within the registered handlers of the
service.
:type routing_id: int
:param method: the method na... | [
"Send",
"out",
"an",
"RPC",
"request"
] | python | train | 38.151515 |
aws/chalice | chalice/utils.py | https://github.com/aws/chalice/blob/10d7fb52e68bd1c52aae251c97e3939fc0190412/chalice/utils.py#L30-L46 | def to_cfn_resource_name(name):
# type: (str) -> str
"""Transform a name to a valid cfn name.
This will convert the provided name to a CamelCase name.
It's possible that the conversion to a CFN resource name
can result in name collisions. It's up to the caller
to handle name collisions appropr... | [
"def",
"to_cfn_resource_name",
"(",
"name",
")",
":",
"# type: (str) -> str",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"\"Invalid name: %r\"",
"%",
"name",
")",
"word_separators",
"=",
"[",
"'-'",
",",
"'_'",
"]",
"for",
"word_separator",
"in",
"w... | Transform a name to a valid cfn name.
This will convert the provided name to a CamelCase name.
It's possible that the conversion to a CFN resource name
can result in name collisions. It's up to the caller
to handle name collisions appropriately. | [
"Transform",
"a",
"name",
"to",
"a",
"valid",
"cfn",
"name",
"."
] | python | train | 37.882353 |
deanmalmgren/textract | textract/parsers/utils.py | https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/utils.py#L35-L48 | def process(self, filename, encoding, **kwargs):
"""Process ``filename`` and encode byte-string with ``encoding``. This
method is called by :func:`textract.parsers.process` and wraps
the :meth:`.BaseParser.extract` method in `a delicious unicode
sandwich <http://nedbatchelder.com/text/un... | [
"def",
"process",
"(",
"self",
",",
"filename",
",",
"encoding",
",",
"*",
"*",
"kwargs",
")",
":",
"# make a \"unicode sandwich\" to handle dealing with unknown",
"# input byte strings and converting them to a predictable",
"# output encoding",
"# http://nedbatchelder.com/text/uni... | Process ``filename`` and encode byte-string with ``encoding``. This
method is called by :func:`textract.parsers.process` and wraps
the :meth:`.BaseParser.extract` method in `a delicious unicode
sandwich <http://nedbatchelder.com/text/unipain.html>`_. | [
"Process",
"filename",
"and",
"encode",
"byte",
"-",
"string",
"with",
"encoding",
".",
"This",
"method",
"is",
"called",
"by",
":",
"func",
":",
"textract",
".",
"parsers",
".",
"process",
"and",
"wraps",
"the",
":",
"meth",
":",
".",
"BaseParser",
".",... | python | train | 51.071429 |
snipsco/snipsmanagercore | snipsmanagercore/intent_parser.py | https://github.com/snipsco/snipsmanagercore/blob/93eaaa665887f790a30ba86af5ffee394bfd8ede/snipsmanagercore/intent_parser.py#L59-L133 | def get_slot_value(payload, slot_name):
""" Return the parsed value of a slot. An intent has the form:
{
"text": "brew me a cappuccino with 3 sugars tomorrow",
"slots": [
{"value": {"slotName": "coffee_type", "value": "cappuccino"}},
... | [
"def",
"get_slot_value",
"(",
"payload",
",",
"slot_name",
")",
":",
"if",
"not",
"'slots'",
"in",
"payload",
":",
"return",
"[",
"]",
"slots",
"=",
"[",
"]",
"for",
"candidate",
"in",
"payload",
"[",
"'slots'",
"]",
":",
"if",
"'slotName'",
"in",
"can... | Return the parsed value of a slot. An intent has the form:
{
"text": "brew me a cappuccino with 3 sugars tomorrow",
"slots": [
{"value": {"slotName": "coffee_type", "value": "cappuccino"}},
...
]
}
... | [
"Return",
"the",
"parsed",
"value",
"of",
"a",
"slot",
".",
"An",
"intent",
"has",
"the",
"form",
":"
] | python | train | 33.4 |
IBM/pyxcli | pyxcli/events/events.py | https://github.com/IBM/pyxcli/blob/7d8ece1dcc16f50246740a447aa81b94a0dbced4/pyxcli/events/events.py#L71-L124 | def send_event(self, action, properties, event_severity=EVENT_SEVERITY):
"""
send css_event and if fails send custom_event instead
Args:
action (ACTIONS): the action causing the event
properties (dict): the action additional properties
event_severity (string):... | [
"def",
"send_event",
"(",
"self",
",",
"action",
",",
"properties",
",",
"event_severity",
"=",
"EVENT_SEVERITY",
")",
":",
"# verify properties",
"event_properties",
"=",
"dict",
"(",
")",
"if",
"(",
"properties",
"is",
"None",
")",
"else",
"properties",
"if"... | send css_event and if fails send custom_event instead
Args:
action (ACTIONS): the action causing the event
properties (dict): the action additional properties
event_severity (string): the event severity
Raises:
XCLIError: if the xcli.cmd.custom_event faile... | [
"send",
"css_event",
"and",
"if",
"fails",
"send",
"custom_event",
"instead",
"Args",
":",
"action",
"(",
"ACTIONS",
")",
":",
"the",
"action",
"causing",
"the",
"event",
"properties",
"(",
"dict",
")",
":",
"the",
"action",
"additional",
"properties",
"even... | python | train | 46.518519 |
LionelAuroux/pyrser | pyrser/parsing/node.py | https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L389-L396 | def values(self):
"""
in order
"""
tmp = self
while tmp is not None:
yield tmp.data
tmp = tmp.next | [
"def",
"values",
"(",
"self",
")",
":",
"tmp",
"=",
"self",
"while",
"tmp",
"is",
"not",
"None",
":",
"yield",
"tmp",
".",
"data",
"tmp",
"=",
"tmp",
".",
"next"
] | in order | [
"in",
"order"
] | python | test | 19.375 |
idlesign/django-sitemessage | sitemessage/messages/base.py | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L188-L214 | def _get_url(cls, name, message_model, dispatch_model):
"""Returns a common pattern sitemessage URL.
:param str name: URL name
:param Message message_model:
:param Dispatch|None dispatch_model:
:return:
"""
global APP_URLS_ATTACHED
url = ''
if d... | [
"def",
"_get_url",
"(",
"cls",
",",
"name",
",",
"message_model",
",",
"dispatch_model",
")",
":",
"global",
"APP_URLS_ATTACHED",
"url",
"=",
"''",
"if",
"dispatch_model",
"is",
"None",
":",
"return",
"url",
"if",
"APP_URLS_ATTACHED",
"!=",
"False",
":",
"# ... | Returns a common pattern sitemessage URL.
:param str name: URL name
:param Message message_model:
:param Dispatch|None dispatch_model:
:return: | [
"Returns",
"a",
"common",
"pattern",
"sitemessage",
"URL",
"."
] | python | train | 28.666667 |
pantsbuild/pants | src/python/pants/pantsd/service/pants_service.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/service/pants_service.py#L190-L196 | def mark_running(self):
"""Moves the service to the Running state.
Raises if the service is not currently in the Paused state.
"""
with self._lock:
self._set_state(self._RUNNING, self._PAUSED) | [
"def",
"mark_running",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"_set_state",
"(",
"self",
".",
"_RUNNING",
",",
"self",
".",
"_PAUSED",
")"
] | Moves the service to the Running state.
Raises if the service is not currently in the Paused state. | [
"Moves",
"the",
"service",
"to",
"the",
"Running",
"state",
"."
] | python | train | 29.857143 |
ultrabug/py3status | py3status/modules/i3block.py | https://github.com/ultrabug/py3status/blob/4c105f1b44f7384ca4f7da5f821a47e468c7dee2/py3status/modules/i3block.py#L158-L225 | def _persist(self):
"""
Run the command inside a thread so that we can catch output for each
line as it comes in and display it.
"""
# run the block/command
for command in self.commands:
try:
process = Popen(
[command],
... | [
"def",
"_persist",
"(",
"self",
")",
":",
"# run the block/command",
"for",
"command",
"in",
"self",
".",
"commands",
":",
"try",
":",
"process",
"=",
"Popen",
"(",
"[",
"command",
"]",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
",",
"univ... | Run the command inside a thread so that we can catch output for each
line as it comes in and display it. | [
"Run",
"the",
"command",
"inside",
"a",
"thread",
"so",
"that",
"we",
"can",
"catch",
"output",
"for",
"each",
"line",
"as",
"it",
"comes",
"in",
"and",
"display",
"it",
"."
] | python | train | 41.514706 |
misli/django-cms-articles | cms_articles/api.py | https://github.com/misli/django-cms-articles/blob/d96ac77e049022deb4c70d268e4eab74d175145c/cms_articles/api.py#L26-L100 | def create_article(tree, template, title, language, slug=None, description=None,
page_title=None, menu_title=None, meta_description=None,
created_by=None, image=None, publication_date=None, publication_end_date=None,
published=False, login_required=False, creatio... | [
"def",
"create_article",
"(",
"tree",
",",
"template",
",",
"title",
",",
"language",
",",
"slug",
"=",
"None",
",",
"description",
"=",
"None",
",",
"page_title",
"=",
"None",
",",
"menu_title",
"=",
"None",
",",
"meta_description",
"=",
"None",
",",
"c... | Create a CMS Article and it's title for the given language | [
"Create",
"a",
"CMS",
"Article",
"and",
"it",
"s",
"title",
"for",
"the",
"given",
"language"
] | python | train | 30.92 |
bspaans/python-mingus | mingus/containers/track.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/track.py#L89-L127 | def from_chords(self, chords, duration=1):
"""Add chords to the Track.
The given chords should be a list of shorthand strings or list of
list of shorthand strings, etc.
Each sublist divides the value by 2.
If a tuning is set, chords will be expanded so they have a proper
... | [
"def",
"from_chords",
"(",
"self",
",",
"chords",
",",
"duration",
"=",
"1",
")",
":",
"tun",
"=",
"self",
".",
"get_tuning",
"(",
")",
"def",
"add_chord",
"(",
"chord",
",",
"duration",
")",
":",
"if",
"type",
"(",
"chord",
")",
"==",
"list",
":",... | Add chords to the Track.
The given chords should be a list of shorthand strings or list of
list of shorthand strings, etc.
Each sublist divides the value by 2.
If a tuning is set, chords will be expanded so they have a proper
fingering.
Example:
>>> t = Track(... | [
"Add",
"chords",
"to",
"the",
"Track",
"."
] | python | train | 34.307692 |
benoitkugler/abstractDataLibrary | pyDLib/GUI/common.py | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/common.py#L346-L369 | def cree_widgets(self):
"""Create widgets and store them in self.widgets"""
for t in self.FIELDS:
if type(t) is str:
attr, kwargs = t, {}
else:
attr, kwargs = t[0], t[1].copy()
self.champs.append(attr)
is_editable = kwargs.p... | [
"def",
"cree_widgets",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"FIELDS",
":",
"if",
"type",
"(",
"t",
")",
"is",
"str",
":",
"attr",
",",
"kwargs",
"=",
"t",
",",
"{",
"}",
"else",
":",
"attr",
",",
"kwargs",
"=",
"t",
"[",
"0",... | Create widgets and store them in self.widgets | [
"Create",
"widgets",
"and",
"store",
"them",
"in",
"self",
".",
"widgets"
] | python | train | 35.541667 |
briancappello/flask-unchained | flask_mail.py | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_mail.py#L691-L704 | def init_app(self, app):
"""Initializes your mail settings from the application settings.
You can use this if you want to set up your Mail instance
at configuration time.
:param app: Flask application instance
"""
state = self.init_mail(app.config, app.debug, app.testin... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"state",
"=",
"self",
".",
"init_mail",
"(",
"app",
".",
"config",
",",
"app",
".",
"debug",
",",
"app",
".",
"testing",
")",
"# register extension with app",
"app",
".",
"extensions",
"=",
"getattr",... | Initializes your mail settings from the application settings.
You can use this if you want to set up your Mail instance
at configuration time.
:param app: Flask application instance | [
"Initializes",
"your",
"mail",
"settings",
"from",
"the",
"application",
"settings",
"."
] | python | train | 33.142857 |
ga4gh/ga4gh-client | ga4gh/client/cli.py | https://github.com/ga4gh/ga4gh-client/blob/d23b00b89112ef0930d45ee75aa3c6de3db615c5/ga4gh/client/cli.py#L501-L521 | def _textOutput(self, gaObjects):
"""
Prints out the specified Variant objects in a VCF-like form.
"""
for variant in gaObjects:
print(
variant.id, variant.variant_set_id, variant.names,
variant.reference_name, variant.start, variant.end,
... | [
"def",
"_textOutput",
"(",
"self",
",",
"gaObjects",
")",
":",
"for",
"variant",
"in",
"gaObjects",
":",
"print",
"(",
"variant",
".",
"id",
",",
"variant",
".",
"variant_set_id",
",",
"variant",
".",
"names",
",",
"variant",
".",
"reference_name",
",",
... | Prints out the specified Variant objects in a VCF-like form. | [
"Prints",
"out",
"the",
"specified",
"Variant",
"objects",
"in",
"a",
"VCF",
"-",
"like",
"form",
"."
] | python | train | 41.619048 |
zyga/json-schema-validator | json_schema_validator/schema.py | https://github.com/zyga/json-schema-validator/blob/0504605da5c0a9a5b5b05c41b37661aec9652144/json_schema_validator/schema.py#L145-L153 | def requires(self):
"""Additional object or objects required by this object."""
# NOTE: spec says this can also be a list of strings
value = self._schema.get("requires", {})
if not isinstance(value, (basestring, dict)):
raise SchemaError(
"requires value {0!r}... | [
"def",
"requires",
"(",
"self",
")",
":",
"# NOTE: spec says this can also be a list of strings",
"value",
"=",
"self",
".",
"_schema",
".",
"get",
"(",
"\"requires\"",
",",
"{",
"}",
")",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"basestring",
",",
... | Additional object or objects required by this object. | [
"Additional",
"object",
"or",
"objects",
"required",
"by",
"this",
"object",
"."
] | python | train | 44.666667 |
CityOfZion/neo-python | neo/Wallets/NEP5Token.py | https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Wallets/NEP5Token.py#L310-L318 | def Deserialize(self, reader):
"""
Read serialized data from byte stream
Args:
reader (neocore.IO.BinaryReader): reader to read byte data from
"""
self.name = reader.ReadVarString().decode('utf-8')
self.symbol = reader.ReadVarString().decode('utf-8')
s... | [
"def",
"Deserialize",
"(",
"self",
",",
"reader",
")",
":",
"self",
".",
"name",
"=",
"reader",
".",
"ReadVarString",
"(",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"self",
".",
"symbol",
"=",
"reader",
".",
"ReadVarString",
"(",
")",
".",
"decode",
"... | Read serialized data from byte stream
Args:
reader (neocore.IO.BinaryReader): reader to read byte data from | [
"Read",
"serialized",
"data",
"from",
"byte",
"stream",
"Args",
":",
"reader",
"(",
"neocore",
".",
"IO",
".",
"BinaryReader",
")",
":",
"reader",
"to",
"read",
"byte",
"data",
"from"
] | python | train | 38.333333 |
wbond/oscrypto | oscrypto/_osx/util.py | https://github.com/wbond/oscrypto/blob/af778bf1c88bf6c4a7342f5353b130686a5bbe1c/oscrypto/_osx/util.py#L42-L60 | def _extract_error():
"""
Extracts the last OS error message into a python unicode string
:return:
A unicode string error message
"""
error_num = errno()
try:
error_string = os.strerror(error_num)
except (ValueError):
return str_cls(error_num)
if isinstance(er... | [
"def",
"_extract_error",
"(",
")",
":",
"error_num",
"=",
"errno",
"(",
")",
"try",
":",
"error_string",
"=",
"os",
".",
"strerror",
"(",
"error_num",
")",
"except",
"(",
"ValueError",
")",
":",
"return",
"str_cls",
"(",
"error_num",
")",
"if",
"isinstan... | Extracts the last OS error message into a python unicode string
:return:
A unicode string error message | [
"Extracts",
"the",
"last",
"OS",
"error",
"message",
"into",
"a",
"python",
"unicode",
"string"
] | python | valid | 20.473684 |
NuGrid/NuGridPy | nugridpy/ppn.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/ppn.py#L545-L607 | def getColData(self, attri, fname, numtype='cycNum'):
"""
In this method a column of data for the associated column
attribute is returned.
Parameters
----------
attri : string
The name of the attribute we are looking for.
fname : string
Th... | [
"def",
"getColData",
"(",
"self",
",",
"attri",
",",
"fname",
",",
"numtype",
"=",
"'cycNum'",
")",
":",
"fname",
"=",
"self",
".",
"findFile",
"(",
"fname",
",",
"numtype",
")",
"f",
"=",
"open",
"(",
"fname",
",",
"'r'",
")",
"for",
"i",
"in",
... | In this method a column of data for the associated column
attribute is returned.
Parameters
----------
attri : string
The name of the attribute we are looking for.
fname : string
The name of the file we are getting the data from or the
cycle n... | [
"In",
"this",
"method",
"a",
"column",
"of",
"data",
"for",
"the",
"associated",
"column",
"attribute",
"is",
"returned",
"."
] | python | train | 34.31746 |
awslabs/serverless-application-model | samtranslator/plugins/application/serverless_app_plugin.py | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/application/serverless_app_plugin.py#L300-L315 | def _handle_get_cfn_template_response(self, response, application_id, template_id):
"""
Handles the response from the SAR service call
:param dict response: the response dictionary from the app repo
:param string application_id: the ApplicationId
:param string template_id: the u... | [
"def",
"_handle_get_cfn_template_response",
"(",
"self",
",",
"response",
",",
"application_id",
",",
"template_id",
")",
":",
"status",
"=",
"response",
"[",
"'Status'",
"]",
"if",
"status",
"!=",
"\"ACTIVE\"",
":",
"# Other options are PREPARING and EXPIRED.",
"if",... | Handles the response from the SAR service call
:param dict response: the response dictionary from the app repo
:param string application_id: the ApplicationId
:param string template_id: the unique TemplateId for this application | [
"Handles",
"the",
"response",
"from",
"the",
"SAR",
"service",
"call"
] | python | train | 53.0625 |
daviddrysdale/python-phonenumbers | python/phonenumbers/unicode_util.py | https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/unicode_util.py#L397-L405 | def digit(uni_char, default_value=None):
"""Returns the digit value assigned to the Unicode character uni_char as
integer. If no such value is defined, default is returned, or, if not
given, ValueError is raised."""
uni_char = unicod(uni_char) # Force to Unicode.
if default_value is not None:
... | [
"def",
"digit",
"(",
"uni_char",
",",
"default_value",
"=",
"None",
")",
":",
"uni_char",
"=",
"unicod",
"(",
"uni_char",
")",
"# Force to Unicode.",
"if",
"default_value",
"is",
"not",
"None",
":",
"return",
"unicodedata",
".",
"digit",
"(",
"uni_char",
","... | Returns the digit value assigned to the Unicode character uni_char as
integer. If no such value is defined, default is returned, or, if not
given, ValueError is raised. | [
"Returns",
"the",
"digit",
"value",
"assigned",
"to",
"the",
"Unicode",
"character",
"uni_char",
"as",
"integer",
".",
"If",
"no",
"such",
"value",
"is",
"defined",
"default",
"is",
"returned",
"or",
"if",
"not",
"given",
"ValueError",
"is",
"raised",
"."
] | python | train | 46.333333 |
bitesofcode/projexui | projexui/widgets/xorbbrowserwidget/xcardwidget.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbbrowserwidget/xcardwidget.py#L75-L92 | def setRecord( self, record ):
"""
Sets the record that is linked with this widget.
:param record | <orb.Table>
"""
super(XBasicCardWidget, self).setRecord(record)
browser = self.browserWidget()
if ( not browser ):
retu... | [
"def",
"setRecord",
"(",
"self",
",",
"record",
")",
":",
"super",
"(",
"XBasicCardWidget",
",",
"self",
")",
".",
"setRecord",
"(",
"record",
")",
"browser",
"=",
"self",
".",
"browserWidget",
"(",
")",
"if",
"(",
"not",
"browser",
")",
":",
"return",... | Sets the record that is linked with this widget.
:param record | <orb.Table> | [
"Sets",
"the",
"record",
"that",
"is",
"linked",
"with",
"this",
"widget",
".",
":",
"param",
"record",
"|",
"<orb",
".",
"Table",
">"
] | python | train | 30.111111 |
jtwhite79/pyemu | pyemu/logger.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/logger.py#L64-L92 | def log(self,phrase):
"""log something that happened. The first time phrase is passed the
start time is saved. The second time the phrase is logged, the
elapsed time is written
Parameters
----------
phrase : str
the thing that happened
"""
... | [
"def",
"log",
"(",
"self",
",",
"phrase",
")",
":",
"pass",
"t",
"=",
"datetime",
".",
"now",
"(",
")",
"if",
"phrase",
"in",
"self",
".",
"items",
".",
"keys",
"(",
")",
":",
"s",
"=",
"str",
"(",
"t",
")",
"+",
"' finished: '",
"+",
"str",
... | log something that happened. The first time phrase is passed the
start time is saved. The second time the phrase is logged, the
elapsed time is written
Parameters
----------
phrase : str
the thing that happened | [
"log",
"something",
"that",
"happened",
".",
"The",
"first",
"time",
"phrase",
"is",
"passed",
"the",
"start",
"time",
"is",
"saved",
".",
"The",
"second",
"time",
"the",
"phrase",
"is",
"logged",
"the",
"elapsed",
"time",
"is",
"written"
] | python | train | 32.793103 |
saltstack/salt | salt/runners/vault.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/vault.py#L192-L239 | def _expand_pattern_lists(pattern, **mappings):
'''
Expands the pattern for any list-valued mappings, such that for any list of
length N in the mappings present in the pattern, N copies of the pattern are
returned, each with an element of the list substituted.
pattern:
A pattern to expand, ... | [
"def",
"_expand_pattern_lists",
"(",
"pattern",
",",
"*",
"*",
"mappings",
")",
":",
"expanded_patterns",
"=",
"[",
"]",
"f",
"=",
"string",
".",
"Formatter",
"(",
")",
"'''\n This function uses a string.Formatter to get all the formatting tokens from\n the pattern, t... | Expands the pattern for any list-valued mappings, such that for any list of
length N in the mappings present in the pattern, N copies of the pattern are
returned, each with an element of the list substituted.
pattern:
A pattern to expand, for example ``by-role/{grains[roles]}``
mappings:
... | [
"Expands",
"the",
"pattern",
"for",
"any",
"list",
"-",
"valued",
"mappings",
"such",
"that",
"for",
"any",
"list",
"of",
"length",
"N",
"in",
"the",
"mappings",
"present",
"in",
"the",
"pattern",
"N",
"copies",
"of",
"the",
"pattern",
"are",
"returned",
... | python | train | 37.666667 |
OSLL/jabba | jabba/file_index.py | https://github.com/OSLL/jabba/blob/71c1d008ab497020fba6ffa12a600721eb3f5ef7/jabba/file_index.py#L66-L78 | def add_file(self, path, yaml):
"""
Adds given file to the file index
"""
if is_job_config(yaml):
name = self.get_job_name(yaml)
file_data = FileData(path=path, yaml=yaml)
self.files[path] = file_data
self.jobs[name] = file_data
e... | [
"def",
"add_file",
"(",
"self",
",",
"path",
",",
"yaml",
")",
":",
"if",
"is_job_config",
"(",
"yaml",
")",
":",
"name",
"=",
"self",
".",
"get_job_name",
"(",
"yaml",
")",
"file_data",
"=",
"FileData",
"(",
"path",
"=",
"path",
",",
"yaml",
"=",
... | Adds given file to the file index | [
"Adds",
"given",
"file",
"to",
"the",
"file",
"index"
] | python | train | 28.769231 |
pypa/pipenv | pipenv/vendor/pexpect/spawnbase.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/spawnbase.py#L157-L180 | def read_nonblocking(self, size=1, timeout=None):
"""This reads data from the file descriptor.
This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
The timeout parameter is ignored.
"""
try:
s = os.read(sel... | [
"def",
"read_nonblocking",
"(",
"self",
",",
"size",
"=",
"1",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"s",
"=",
"os",
".",
"read",
"(",
"self",
".",
"child_fd",
",",
"size",
")",
"except",
"OSError",
"as",
"err",
":",
"if",
"err",
"."... | This reads data from the file descriptor.
This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
The timeout parameter is ignored. | [
"This",
"reads",
"data",
"from",
"the",
"file",
"descriptor",
"."
] | python | train | 33.333333 |
NiklasRosenstein/py-bundler | bundler/nativedeps/windll.py | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L60-L94 | def get_dependency_walker():
"""
Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
and extracted to a temporary directory. Note that the file will not be
deleted afterwards.
Returns the path to the Dependency Walker executable.
"""
for dirname in os.getenv('PATH', '').split(os... | [
"def",
"get_dependency_walker",
"(",
")",
":",
"for",
"dirname",
"in",
"os",
".",
"getenv",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"'de... | Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
and extracted to a temporary directory. Note that the file will not be
deleted afterwards.
Returns the path to the Dependency Walker executable. | [
"Checks",
"if",
"depends",
".",
"exe",
"is",
"in",
"the",
"system",
"PATH",
".",
"If",
"not",
"it",
"will",
"be",
"downloaded",
"and",
"extracted",
"to",
"a",
"temporary",
"directory",
".",
"Note",
"that",
"the",
"file",
"will",
"not",
"be",
"deleted",
... | python | train | 35.685714 |
yangl1996/libpagure | libpagure/libpagure.py | https://github.com/yangl1996/libpagure/blob/dd96ed29142407463790c66ed321984a6ea7465a/libpagure/libpagure.py#L138-L151 | def list_tags(self, pattern=None):
"""
List all tags made on this project.
:param pattern: filters the starting letters of the return value
:return:
"""
request_url = "{}tags".format(self.create_basic_url())
params = None
if pattern:
params = ... | [
"def",
"list_tags",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"request_url",
"=",
"\"{}tags\"",
".",
"format",
"(",
"self",
".",
"create_basic_url",
"(",
")",
")",
"params",
"=",
"None",
"if",
"pattern",
":",
"params",
"=",
"{",
"'pattern'",
... | List all tags made on this project.
:param pattern: filters the starting letters of the return value
:return: | [
"List",
"all",
"tags",
"made",
"on",
"this",
"project",
".",
":",
"param",
"pattern",
":",
"filters",
"the",
"starting",
"letters",
"of",
"the",
"return",
"value",
":",
"return",
":"
] | python | train | 30.714286 |
openp2pdesign/makerlabs | makerlabs/techshop_ws.py | https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/techshop_ws.py#L50-L191 | def get_labs(format):
"""Gets Techshop data from techshop.ws."""
techshops_soup = data_from_techshop_ws(techshop_us_url)
techshops = {}
# Load all the TechShops
# By first parsing the html
data = techshops_soup.findAll('div', attrs={'id': 'main-content'})
for element in data:
link... | [
"def",
"get_labs",
"(",
"format",
")",
":",
"techshops_soup",
"=",
"data_from_techshop_ws",
"(",
"techshop_us_url",
")",
"techshops",
"=",
"{",
"}",
"# Load all the TechShops",
"# By first parsing the html",
"data",
"=",
"techshops_soup",
".",
"findAll",
"(",
"'div'",... | Gets Techshop data from techshop.ws. | [
"Gets",
"Techshop",
"data",
"from",
"techshop",
".",
"ws",
"."
] | python | train | 39.725352 |
noahbenson/neuropythy | neuropythy/util/core.py | https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/util/core.py#L222-L266 | def to_affine(aff, dims=None):
'''
to_affine(None) yields None.
to_affine(data) yields an affine transformation matrix equivalent to that given in data. Such a
matrix may be specified either as (matrix, offset_vector), as an (n+1)x(n+1) matrix, or, as an
n x (n+1) matrix.
to_affine(data, dim... | [
"def",
"to_affine",
"(",
"aff",
",",
"dims",
"=",
"None",
")",
":",
"if",
"aff",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"aff",
",",
"_tuple_type",
")",
":",
"# allowed to be (mtx, offset)",
"if",
"(",
"len",
"(",
"aff",
")",
"!="... | to_affine(None) yields None.
to_affine(data) yields an affine transformation matrix equivalent to that given in data. Such a
matrix may be specified either as (matrix, offset_vector), as an (n+1)x(n+1) matrix, or, as an
n x (n+1) matrix.
to_affine(data, dims) additionally requires that the dimension... | [
"to_affine",
"(",
"None",
")",
"yields",
"None",
".",
"to_affine",
"(",
"data",
")",
"yields",
"an",
"affine",
"transformation",
"matrix",
"equivalent",
"to",
"that",
"given",
"in",
"data",
".",
"Such",
"a",
"matrix",
"may",
"be",
"specified",
"either",
"a... | python | train | 46.2 |
tanghaibao/jcvi | jcvi/utils/orderedcollections.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/orderedcollections.py#L386-L392 | def find_ge(self, item):
'Return first item with a key >= equal to item. Raise ValueError if not found'
k = self._key(item)
i = bisect_left(self._keys, k)
if i != len(self):
return self._items[i]
raise ValueError('No item found with key at or above: %r' % (k,)) | [
"def",
"find_ge",
"(",
"self",
",",
"item",
")",
":",
"k",
"=",
"self",
".",
"_key",
"(",
"item",
")",
"i",
"=",
"bisect_left",
"(",
"self",
".",
"_keys",
",",
"k",
")",
"if",
"i",
"!=",
"len",
"(",
"self",
")",
":",
"return",
"self",
".",
"_... | Return first item with a key >= equal to item. Raise ValueError if not found | [
"Return",
"first",
"item",
"with",
"a",
"key",
">",
"=",
"equal",
"to",
"item",
".",
"Raise",
"ValueError",
"if",
"not",
"found"
] | python | train | 44 |
OpenKMIP/PyKMIP | kmip/core/messages/payloads/archive.py | https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/core/messages/payloads/archive.py#L230-L258 | def write(self, output_stream, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Archive response payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearraySt... | [
"def",
"write",
"(",
"self",
",",
"output_stream",
",",
"kmip_version",
"=",
"enums",
".",
"KMIPVersion",
".",
"KMIP_1_0",
")",
":",
"local_stream",
"=",
"utils",
".",
"BytearrayStream",
"(",
")",
"if",
"self",
".",
"_unique_identifier",
":",
"self",
".",
... | Write the data encoding the Archive response payload to a stream.
Args:
output_stream (stream): A data stream in which to encode object
data, supporting a write method; usually a BytearrayStream
object.
kmip_version (KMIPVersion): An enumeration defining ... | [
"Write",
"the",
"data",
"encoding",
"the",
"Archive",
"response",
"payload",
"to",
"a",
"stream",
"."
] | python | test | 35.689655 |
manns/pyspread | pyspread/src/lib/vlc.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L243-L248 | def _Cobject(cls, ctype):
"""(INTERNAL) New instance from ctypes.
"""
o = object.__new__(cls)
o._as_parameter_ = ctype
return o | [
"def",
"_Cobject",
"(",
"cls",
",",
"ctype",
")",
":",
"o",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"o",
".",
"_as_parameter_",
"=",
"ctype",
"return",
"o"
] | (INTERNAL) New instance from ctypes. | [
"(",
"INTERNAL",
")",
"New",
"instance",
"from",
"ctypes",
"."
] | python | train | 23.666667 |
ladybug-tools/ladybug | ladybug/designday.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/designday.py#L1341-L1355 | def radiation_values(self, location, timestep=1):
"""Lists of driect normal, diffuse horiz, and global horiz rad at each timestep.
"""
# create sunpath and get altitude at every timestep of the design day
sp = Sunpath.from_location(location)
altitudes = []
dates = self._g... | [
"def",
"radiation_values",
"(",
"self",
",",
"location",
",",
"timestep",
"=",
"1",
")",
":",
"# create sunpath and get altitude at every timestep of the design day",
"sp",
"=",
"Sunpath",
".",
"from_location",
"(",
"location",
")",
"altitudes",
"=",
"[",
"]",
"date... | Lists of driect normal, diffuse horiz, and global horiz rad at each timestep. | [
"Lists",
"of",
"driect",
"normal",
"diffuse",
"horiz",
"and",
"global",
"horiz",
"rad",
"at",
"each",
"timestep",
"."
] | python | train | 50.066667 |
siemens/django-dingos | dingos/templatetags/dingos_tags.py | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/templatetags/dingos_tags.py#L36-L161 | def node_indent(elt_name, node_id, fact_term, attribute, highlight_node=None):
"""
This tag uses a table structure to display indentation
of fact terms based on the information contained in the
node identifier.
This tag and the closing 'node_indent_end' tag must
enclose the value to be displaye... | [
"def",
"node_indent",
"(",
"elt_name",
",",
"node_id",
",",
"fact_term",
",",
"attribute",
",",
"highlight_node",
"=",
"None",
")",
":",
"# Some colors to chose from:",
"color_dict",
"=",
"{",
"0",
":",
"{",
"0",
":",
"'#004C80'",
",",
"# blueish",
"1",
":",... | This tag uses a table structure to display indentation
of fact terms based on the information contained in the
node identifier.
This tag and the closing 'node_indent_end' tag must
enclose the value to be displayed after the display
of the fact term. | [
"This",
"tag",
"uses",
"a",
"table",
"structure",
"to",
"display",
"indentation",
"of",
"fact",
"terms",
"based",
"on",
"the",
"information",
"contained",
"in",
"the",
"node",
"identifier",
"."
] | python | train | 33.706349 |
hollenstein/maspy | maspy/core.py | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/core.py#L741-L757 | def jsonHook(encoded):
"""Custom JSON decoder that allows construction of a new ``Ci`` instance
from a decoded JSON object.
:param encoded: a JSON decoded object literal (a dict)
:returns: "encoded" or one of the these objects: :class:`Ci`,
:class:`MzmlProduct`, :class:`Mzm... | [
"def",
"jsonHook",
"(",
"encoded",
")",
":",
"if",
"'__Ci__'",
"in",
"encoded",
":",
"return",
"Ci",
".",
"_fromJSON",
"(",
"encoded",
"[",
"'__Ci__'",
"]",
")",
"elif",
"'__MzmlProduct__'",
"in",
"encoded",
":",
"return",
"MzmlProduct",
".",
"_fromJSON",
... | Custom JSON decoder that allows construction of a new ``Ci`` instance
from a decoded JSON object.
:param encoded: a JSON decoded object literal (a dict)
:returns: "encoded" or one of the these objects: :class:`Ci`,
:class:`MzmlProduct`, :class:`MzmlPrecursor` | [
"Custom",
"JSON",
"decoder",
"that",
"allows",
"construction",
"of",
"a",
"new",
"Ci",
"instance",
"from",
"a",
"decoded",
"JSON",
"object",
"."
] | python | train | 40.058824 |
aws/aws-xray-sdk-python | aws_xray_sdk/core/lambda_launcher.py | https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/lambda_launcher.py#L125-L146 | def _initialize_context(self, trace_header):
"""
Create a facade segment based on environment variables
set by AWS Lambda and initialize storage for subsegments.
"""
sampled = None
if not global_sdk_config.sdk_enabled():
# Force subsequent subsegments to be di... | [
"def",
"_initialize_context",
"(",
"self",
",",
"trace_header",
")",
":",
"sampled",
"=",
"None",
"if",
"not",
"global_sdk_config",
".",
"sdk_enabled",
"(",
")",
":",
"# Force subsequent subsegments to be disabled and turned into DummySegments.",
"sampled",
"=",
"False",
... | Create a facade segment based on environment variables
set by AWS Lambda and initialize storage for subsegments. | [
"Create",
"a",
"facade",
"segment",
"based",
"on",
"environment",
"variables",
"set",
"by",
"AWS",
"Lambda",
"and",
"initialize",
"storage",
"for",
"subsegments",
"."
] | python | train | 35.181818 |
theno/fabsetup | fabsetup/fabfile/setup/revealjs.py | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/revealjs.py#L50-L90 | def revealjs(basedir=None, title=None, subtitle=None, description=None,
github_user=None, github_repo=None):
'''Set up or update a reveals.js presentation with slides written in markdown.
Several reveal.js plugins will be set up, too.
More info:
Demo: https://theno.github.io/revealjs_te... | [
"def",
"revealjs",
"(",
"basedir",
"=",
"None",
",",
"title",
"=",
"None",
",",
"subtitle",
"=",
"None",
",",
"description",
"=",
"None",
",",
"github_user",
"=",
"None",
",",
"github_repo",
"=",
"None",
")",
":",
"basedir",
"=",
"basedir",
"or",
"quer... | Set up or update a reveals.js presentation with slides written in markdown.
Several reveal.js plugins will be set up, too.
More info:
Demo: https://theno.github.io/revealjs_template
http://lab.hakim.se/reveal-js/
https://github.com/hakimel/reveal.js
plugins:
https://github.com/... | [
"Set",
"up",
"or",
"update",
"a",
"reveals",
".",
"js",
"presentation",
"with",
"slides",
"written",
"in",
"markdown",
"."
] | python | train | 42.170732 |
shoebot/shoebot | lib/colors/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1241-L1247 | def reverse(self):
"""
Returns a reversed copy of the list.
"""
colors = ColorList.copy(self)
_list.reverse(colors)
return colors | [
"def",
"reverse",
"(",
"self",
")",
":",
"colors",
"=",
"ColorList",
".",
"copy",
"(",
"self",
")",
"_list",
".",
"reverse",
"(",
"colors",
")",
"return",
"colors"
] | Returns a reversed copy of the list. | [
"Returns",
"a",
"reversed",
"copy",
"of",
"the",
"list",
"."
] | python | valid | 24.428571 |
loli/medpy | medpy/metric/binary.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L34-L81 | def dc(result, reference):
r"""
Dice coefficient
Computes the Dice coefficient (also known as Sorensen index) between the binary
objects in two images.
The metric is defined as
.. math::
DC=\frac{2|A\cap B|}{|A|+|B|}
, where :math:`A` is the first and... | [
"def",
"dc",
"(",
"result",
",",
"reference",
")",
":",
"result",
"=",
"numpy",
".",
"atleast_1d",
"(",
"result",
".",
"astype",
"(",
"numpy",
".",
"bool",
")",
")",
"reference",
"=",
"numpy",
".",
"atleast_1d",
"(",
"reference",
".",
"astype",
"(",
... | r"""
Dice coefficient
Computes the Dice coefficient (also known as Sorensen index) between the binary
objects in two images.
The metric is defined as
.. math::
DC=\frac{2|A\cap B|}{|A|+|B|}
, where :math:`A` is the first and :math:`B` the second set of sa... | [
"r",
"Dice",
"coefficient",
"Computes",
"the",
"Dice",
"coefficient",
"(",
"also",
"known",
"as",
"Sorensen",
"index",
")",
"between",
"the",
"binary",
"objects",
"in",
"two",
"images",
".",
"The",
"metric",
"is",
"defined",
"as",
"..",
"math",
"::",
"DC",... | python | train | 30.208333 |
saltstack/salt | salt/modules/lxc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/lxc.py#L2440-L2481 | def stop(name, kill=False, path=None, use_vt=None):
'''
Stop the named container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
kill: False
Do not wait for the container to stop, kill all tasks in the container.
... | [
"def",
"stop",
"(",
"name",
",",
"kill",
"=",
"False",
",",
"path",
"=",
"None",
",",
"use_vt",
"=",
"None",
")",
":",
"_ensure_exists",
"(",
"name",
",",
"path",
"=",
"path",
")",
"orig_state",
"=",
"state",
"(",
"name",
",",
"path",
"=",
"path",
... | Stop the named container
path
path to the container parent directory
default: /var/lib/lxc (system)
.. versionadded:: 2015.8.0
kill: False
Do not wait for the container to stop, kill all tasks in the container.
Older LXC versions will stop containers like this irrespec... | [
"Stop",
"the",
"named",
"container"
] | python | train | 27.857143 |
apache/spark | python/pyspark/broadcast.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/broadcast.py#L162-L175 | def destroy(self, blocking=False):
"""
Destroy all data and metadata related to this broadcast variable.
Use this with caution; once a broadcast variable has been destroyed,
it cannot be used again.
.. versionchanged:: 3.0.0
Added optional argument `blocking` to speci... | [
"def",
"destroy",
"(",
"self",
",",
"blocking",
"=",
"False",
")",
":",
"if",
"self",
".",
"_jbroadcast",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Broadcast can only be destroyed in driver\"",
")",
"self",
".",
"_jbroadcast",
".",
"destroy",
"(",
"bloc... | Destroy all data and metadata related to this broadcast variable.
Use this with caution; once a broadcast variable has been destroyed,
it cannot be used again.
.. versionchanged:: 3.0.0
Added optional argument `blocking` to specify whether to block until all
blocks are del... | [
"Destroy",
"all",
"data",
"and",
"metadata",
"related",
"to",
"this",
"broadcast",
"variable",
".",
"Use",
"this",
"with",
"caution",
";",
"once",
"a",
"broadcast",
"variable",
"has",
"been",
"destroyed",
"it",
"cannot",
"be",
"used",
"again",
"."
] | python | train | 40.142857 |
tanghaibao/goatools | goatools/anno/init/reader_gaf.py | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L173-L192 | def get_gafvals(self, line):
"""Convert fields from string to preferred format for GAF ver 2.1 and 2.0."""
flds = line.split('\t')
flds[3] = self._get_qualifier(flds[3]) # 3 Qualifier
flds[5] = self._get_set(flds[5]) # 5 DB_Reference
flds[7] = self._get_set(flds[7]) #... | [
"def",
"get_gafvals",
"(",
"self",
",",
"line",
")",
":",
"flds",
"=",
"line",
".",
"split",
"(",
"'\\t'",
")",
"flds",
"[",
"3",
"]",
"=",
"self",
".",
"_get_qualifier",
"(",
"flds",
"[",
"3",
"]",
")",
"# 3 Qualifier",
"flds",
"[",
"5",
"]",
"... | Convert fields from string to preferred format for GAF ver 2.1 and 2.0. | [
"Convert",
"fields",
"from",
"string",
"to",
"preferred",
"format",
"for",
"GAF",
"ver",
"2",
".",
"1",
"and",
"2",
".",
"0",
"."
] | python | train | 51.2 |
pmacosta/pexdoc | pexdoc/exh.py | https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L260-L305 | def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None):
r"""
Return global exception handler if set, otherwise create a new one and return it.
:param full_cname: Flag that indicates whether fully qualified
function/method/class property names are obtained for... | [
"def",
"get_or_create_exh_obj",
"(",
"full_cname",
"=",
"False",
",",
"exclude",
"=",
"None",
",",
"callables_fname",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"__builtin__",
",",
"\"_EXH\"",
")",
":",
"set_exh_obj",
"(",
"ExHandle",
"(",
"full_cna... | r"""
Return global exception handler if set, otherwise create a new one and return it.
:param full_cname: Flag that indicates whether fully qualified
function/method/class property names are obtained for
functions/methods/class properties that use the
... | [
"r",
"Return",
"global",
"exception",
"handler",
"if",
"set",
"otherwise",
"create",
"a",
"new",
"one",
"and",
"return",
"it",
"."
] | python | train | 41.913043 |
virtuald/pygi-composite-templates | gi_composites.py | https://github.com/virtuald/pygi-composite-templates/blob/a22be54ea95b8125b36deaa3ce7171e84158d486/gi_composites.py#L104-L136 | def _init_template(self, cls, base_init_template):
'''This would be better as an override for Gtk.Widget'''
# TODO: could disallow using a metaclass.. but this is good enough
# .. if you disagree, feel free to fix it and issue a PR :)
if self.__class__ is not cls:
raise TypeError("Inheritance f... | [
"def",
"_init_template",
"(",
"self",
",",
"cls",
",",
"base_init_template",
")",
":",
"# TODO: could disallow using a metaclass.. but this is good enough",
"# .. if you disagree, feel free to fix it and issue a PR :)",
"if",
"self",
".",
"__class__",
"is",
"not",
"cls",
":",
... | This would be better as an override for Gtk.Widget | [
"This",
"would",
"be",
"better",
"as",
"an",
"override",
"for",
"Gtk",
".",
"Widget"
] | python | train | 47.242424 |
xaptum/xtt-python | xtt/_utils.py | https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/xtt/_utils.py#L21-L31 | def to_bytes(s, encoding="utf-8"):
"""
Converts the string to a bytes type, if not already.
:s: the string to convert to bytes
:returns: `str` on Python2 and `bytes` on Python3.
"""
if isinstance(s, six.binary_type):
return s
else:
return six.text_type(s).encode(encoding) | [
"def",
"to_bytes",
"(",
"s",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"binary_type",
")",
":",
"return",
"s",
"else",
":",
"return",
"six",
".",
"text_type",
"(",
"s",
")",
".",
"encode",
"(",
"enc... | Converts the string to a bytes type, if not already.
:s: the string to convert to bytes
:returns: `str` on Python2 and `bytes` on Python3. | [
"Converts",
"the",
"string",
"to",
"a",
"bytes",
"type",
"if",
"not",
"already",
"."
] | python | train | 27.909091 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L968-L979 | def get_vmpolicy_macaddr_input_datacenter(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr")
config = get_vmpolicy_macaddr
input = ET.SubElement(get_vmpolicy_macaddr, "input")
datacen... | [
"def",
"get_vmpolicy_macaddr_input_datacenter",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_vmpolicy_macaddr",
"=",
"ET",
".",
"Element",
"(",
"\"get_vmpolicy_macaddr\"",
")",
"config",
"=",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 40.916667 |
reingart/gui2py | gui/dialog.py | https://github.com/reingart/gui2py/blob/aca0a05f6fcde55c94ad7cc058671a06608b01a4/gui/dialog.py#L127-L131 | def find(default='', whole_words=0, case_sensitive=0, parent=None):
"Shows a find text dialog"
result = dialogs.findDialog(parent, default, whole_words, case_sensitive)
return {'text': result.searchText, 'whole_words': result.wholeWordsOnly,
'case_sensitive': result.caseSensitive} | [
"def",
"find",
"(",
"default",
"=",
"''",
",",
"whole_words",
"=",
"0",
",",
"case_sensitive",
"=",
"0",
",",
"parent",
"=",
"None",
")",
":",
"result",
"=",
"dialogs",
".",
"findDialog",
"(",
"parent",
",",
"default",
",",
"whole_words",
",",
"case_se... | Shows a find text dialog | [
"Shows",
"a",
"find",
"text",
"dialog"
] | python | test | 61 |
fakedrake/overlay_parse | overlay_parse/matchers.py | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L50-L66 | def offset_overlays(self, text, offset=0, **kw):
"""
Generate overlays after offset.
:param text: The text to be searched.
:param offset: Match starting that index. If none just search.
:returns: An overlay or None
"""
# This may be a bit slower but overlayedtext... | [
"def",
"offset_overlays",
"(",
"self",
",",
"text",
",",
"offset",
"=",
"0",
",",
"*",
"*",
"kw",
")",
":",
"# This may be a bit slower but overlayedtext takes care of",
"# unicode issues.",
"if",
"not",
"isinstance",
"(",
"text",
",",
"OverlayedText",
")",
":",
... | Generate overlays after offset.
:param text: The text to be searched.
:param offset: Match starting that index. If none just search.
:returns: An overlay or None | [
"Generate",
"overlays",
"after",
"offset",
".",
":",
"param",
"text",
":",
"The",
"text",
"to",
"be",
"searched",
".",
":",
"param",
"offset",
":",
"Match",
"starting",
"that",
"index",
".",
"If",
"none",
"just",
"search",
".",
":",
"returns",
":",
"An... | python | train | 39.117647 |
hobson/aima | aima/search.py | https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/search.py#L601-L606 | def random_boggle(n=4):
"""Return a random Boggle board of size n x n.
We represent a board as a linear list of letters."""
cubes = [cubes16[i % 16] for i in range(n*n)]
random.shuffle(cubes)
return map(random.choice, cubes) | [
"def",
"random_boggle",
"(",
"n",
"=",
"4",
")",
":",
"cubes",
"=",
"[",
"cubes16",
"[",
"i",
"%",
"16",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
"*",
"n",
")",
"]",
"random",
".",
"shuffle",
"(",
"cubes",
")",
"return",
"map",
"(",
"random",
... | Return a random Boggle board of size n x n.
We represent a board as a linear list of letters. | [
"Return",
"a",
"random",
"Boggle",
"board",
"of",
"size",
"n",
"x",
"n",
".",
"We",
"represent",
"a",
"board",
"as",
"a",
"linear",
"list",
"of",
"letters",
"."
] | python | valid | 39.833333 |
llazzaro/analyzerdam | analyzerdam/hbaseDAM.py | https://github.com/llazzaro/analyzerdam/blob/c5bc7483dae23bd2e14bbf36147b7a43a0067bc0/analyzerdam/hbaseDAM.py#L44-L48 | def readQuotes(self, start, end):
''' read quotes '''
rows = self.__hbase.scanTable(self.tableName(HBaseDAM.QUOTE), [HBaseDAM.QUOTE], start, end)
return [self.__rowResultToQuote(row) for row in rows] | [
"def",
"readQuotes",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"rows",
"=",
"self",
".",
"__hbase",
".",
"scanTable",
"(",
"self",
".",
"tableName",
"(",
"HBaseDAM",
".",
"QUOTE",
")",
",",
"[",
"HBaseDAM",
".",
"QUOTE",
"]",
",",
"start",
"... | read quotes | [
"read",
"quotes"
] | python | train | 44.8 |
codelv/enaml-native | src/enamlnative/android/http.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/http.py#L276-L285 | def _fetch(self, request):
""" Fetch using the OkHttpClient """
client = self.client
#: Dispatch the async call
call = Call(__id__=client.newCall(request.request))
call.enqueue(request.handler)
#: Save the call reference
request.call = call | [
"def",
"_fetch",
"(",
"self",
",",
"request",
")",
":",
"client",
"=",
"self",
".",
"client",
"#: Dispatch the async call",
"call",
"=",
"Call",
"(",
"__id__",
"=",
"client",
".",
"newCall",
"(",
"request",
".",
"request",
")",
")",
"call",
".",
"enqueue... | Fetch using the OkHttpClient | [
"Fetch",
"using",
"the",
"OkHttpClient"
] | python | train | 28.9 |
charlesthomas/proauth2 | proauth2/async_proauth2.py | https://github.com/charlesthomas/proauth2/blob/f88c8df966a1802414047ed304d02df1dd520097/proauth2/async_proauth2.py#L123-L128 | def revoke_token(self, token, callback):
'''
revoke_token removes the access token from the data_store
'''
yield Task(self.data_store.remove, 'tokens', token=token)
callback() | [
"def",
"revoke_token",
"(",
"self",
",",
"token",
",",
"callback",
")",
":",
"yield",
"Task",
"(",
"self",
".",
"data_store",
".",
"remove",
",",
"'tokens'",
",",
"token",
"=",
"token",
")",
"callback",
"(",
")"
] | revoke_token removes the access token from the data_store | [
"revoke_token",
"removes",
"the",
"access",
"token",
"from",
"the",
"data_store"
] | python | valid | 35 |
AnalogJ/lexicon | lexicon/providers/hetzner.py | https://github.com/AnalogJ/lexicon/blob/9330b871988753cad44fe2876a217b4c67b1fa0e/lexicon/providers/hetzner.py#L648-L675 | def _get_domain_id(self, domain):
"""
Pulls all domains managed by authenticated Hetzner account, extracts their IDs
and returns the ID for the current domain, if exists. Otherwise raises error.
"""
api = self.api[self.account]['domain_id']
qdomain = dns.name.from_text(do... | [
"def",
"_get_domain_id",
"(",
"self",
",",
"domain",
")",
":",
"api",
"=",
"self",
".",
"api",
"[",
"self",
".",
"account",
"]",
"[",
"'domain_id'",
"]",
"qdomain",
"=",
"dns",
".",
"name",
".",
"from_text",
"(",
"domain",
")",
".",
"to_unicode",
"("... | Pulls all domains managed by authenticated Hetzner account, extracts their IDs
and returns the ID for the current domain, if exists. Otherwise raises error. | [
"Pulls",
"all",
"domains",
"managed",
"by",
"authenticated",
"Hetzner",
"account",
"extracts",
"their",
"IDs",
"and",
"returns",
"the",
"ID",
"for",
"the",
"current",
"domain",
"if",
"exists",
".",
"Otherwise",
"raises",
"error",
"."
] | python | train | 54.392857 |
last-partizan/pytils | pytils/numeral.py | https://github.com/last-partizan/pytils/blob/1c570a32b15e564bc68587b8207e32d464e61d08/pytils/numeral.py#L126-L157 | def choose_plural(amount, variants):
"""
Choose proper case depending on amount
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode... | [
"def",
"choose_plural",
"(",
"amount",
",",
"variants",
")",
":",
"if",
"isinstance",
"(",
"variants",
",",
"six",
".",
"text_type",
")",
":",
"variants",
"=",
"split_values",
"(",
"variants",
")",
"check_length",
"(",
"variants",
",",
"3",
")",
"amount",
... | Choose proper case depending on amount
@param amount: amount of objects
@type amount: C{integer types}
@param variants: variants (forms) of object in such form:
(1 object, 2 objects, 5 objects).
@type variants: 3-element C{sequence} of C{unicode}
or C{unicode} (three variants with deli... | [
"Choose",
"proper",
"case",
"depending",
"on",
"amount"
] | python | train | 27.21875 |
bitcraze/crazyflie-lib-python | cflib/crazyflie/mem.py | https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/crazyflie/mem.py#L928-L934 | def ow_search(self, vid=0xBC, pid=None, name=None):
"""Search for specific memory id/name and return it"""
for m in self.get_mems(MemoryElement.TYPE_1W):
if pid and m.pid == pid or name and m.name == name:
return m
return None | [
"def",
"ow_search",
"(",
"self",
",",
"vid",
"=",
"0xBC",
",",
"pid",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"for",
"m",
"in",
"self",
".",
"get_mems",
"(",
"MemoryElement",
".",
"TYPE_1W",
")",
":",
"if",
"pid",
"and",
"m",
".",
"pid",... | Search for specific memory id/name and return it | [
"Search",
"for",
"specific",
"memory",
"id",
"/",
"name",
"and",
"return",
"it"
] | python | train | 39 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1412-L1450 | def compile_fund(workbook, sheet, row, col):
"""
Compile funding entries. Iter both rows at the same time. Keep adding entries until both cells are empty.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list of dict: l
"""
logger_excel.info("enter compi... | [
"def",
"compile_fund",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter compile_fund\"",
")",
"l",
"=",
"[",
"]",
"temp_sheet",
"=",
"workbook",
".",
"sheet_by_name",
"(",
"sheet",
")",
"while",
... | Compile funding entries. Iter both rows at the same time. Keep adding entries until both cells are empty.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list of dict: l | [
"Compile",
"funding",
"entries",
".",
"Iter",
"both",
"rows",
"at",
"the",
"same",
"time",
".",
"Keep",
"adding",
"entries",
"until",
"both",
"cells",
"are",
"empty",
".",
":",
"param",
"obj",
"workbook",
":",
":",
"param",
"str",
"sheet",
":",
":",
"p... | python | train | 39.615385 |
trendels/rhino | rhino/request.py | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/request.py#L91-L105 | def get(self, key, default=None, type=None):
"""Returns the first value for a key.
If `type` is not None, the value will be converted by calling
`type` with the value as argument. If type() raises `ValueError`, it
will be treated as if the value didn't exist, and `default` will be
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"type",
"=",
"None",
")",
":",
"try",
":",
"value",
"=",
"self",
"[",
"key",
"]",
"if",
"type",
"is",
"not",
"None",
":",
"return",
"type",
"(",
"value",
")",
"return",
"v... | Returns the first value for a key.
If `type` is not None, the value will be converted by calling
`type` with the value as argument. If type() raises `ValueError`, it
will be treated as if the value didn't exist, and `default` will be
returned instead. | [
"Returns",
"the",
"first",
"value",
"for",
"a",
"key",
"."
] | python | train | 36 |
klen/makesite | makesite/site.py | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L24-L31 | def get_info(self, full=False):
" Return printable information about current site. "
if full:
context = self.as_dict()
return "".join("{0:<25} = {1}\n".format(
key, context[key]) for key in sorted(context.iterkeys()))
return "%s [%s]" % (self.g... | [
"def",
"get_info",
"(",
"self",
",",
"full",
"=",
"False",
")",
":",
"if",
"full",
":",
"context",
"=",
"self",
".",
"as_dict",
"(",
")",
"return",
"\"\"",
".",
"join",
"(",
"\"{0:<25} = {1}\\n\"",
".",
"format",
"(",
"key",
",",
"context",
"[",
"key... | Return printable information about current site. | [
"Return",
"printable",
"information",
"about",
"current",
"site",
"."
] | python | train | 42.25 |
CivicSpleen/ambry | ambry/library/search_backends/postgres_backend.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/postgres_backend.py#L515-L523 | def is_indexed(self, partition):
""" Returns True if partition is already indexed. Otherwise returns False. """
query = text("""
SELECT vid
FROM partition_index
WHERE vid = :vid;
""")
result = self.execute(query, vid=partition.vid)
return bool(... | [
"def",
"is_indexed",
"(",
"self",
",",
"partition",
")",
":",
"query",
"=",
"text",
"(",
"\"\"\"\n SELECT vid\n FROM partition_index\n WHERE vid = :vid;\n \"\"\"",
")",
"result",
"=",
"self",
".",
"execute",
"(",
"query",
",",
"vid"... | Returns True if partition is already indexed. Otherwise returns False. | [
"Returns",
"True",
"if",
"partition",
"is",
"already",
"indexed",
".",
"Otherwise",
"returns",
"False",
"."
] | python | train | 36.666667 |
RedHatInsights/insights-core | insights/client/collection_rules.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/collection_rules.py#L160-L167 | def write_collection_data(self, path, data):
"""
Write collections rules to disk
"""
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
fd = os.open(path, flags, 0o600)
with os.fdopen(fd, 'w') as dyn_conf_file:
dyn_conf_file.write(data) | [
"def",
"write_collection_data",
"(",
"self",
",",
"path",
",",
"data",
")",
":",
"flags",
"=",
"os",
".",
"O_WRONLY",
"|",
"os",
".",
"O_CREAT",
"|",
"os",
".",
"O_TRUNC",
"fd",
"=",
"os",
".",
"open",
"(",
"path",
",",
"flags",
",",
"0o600",
")",
... | Write collections rules to disk | [
"Write",
"collections",
"rules",
"to",
"disk"
] | python | train | 35.5 |
python-openxml/python-docx | docx/oxml/xmlchemy.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/xmlchemy.py#L469-L477 | def _prop_name(self):
"""
Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
"""
if ':' in self._nsptagname:
start = self._nsptagname.index(':') + 1
else:
start = 0
return self._nsptagname[start:] | [
"def",
"_prop_name",
"(",
"self",
")",
":",
"if",
"':'",
"in",
"self",
".",
"_nsptagname",
":",
"start",
"=",
"self",
".",
"_nsptagname",
".",
"index",
"(",
"':'",
")",
"+",
"1",
"else",
":",
"start",
"=",
"0",
"return",
"self",
".",
"_nsptagname",
... | Calculate property name from tag name, e.g. a:schemeClr -> schemeClr. | [
"Calculate",
"property",
"name",
"from",
"tag",
"name",
"e",
".",
"g",
".",
"a",
":",
"schemeClr",
"-",
">",
"schemeClr",
"."
] | python | train | 31 |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/settings/settings_client.py | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/settings/settings_client.py#L60-L74 | def set_entries(self, entries, user_scope):
"""SetEntries.
[Preview API] Set the specified setting entry values for the given user/all-users scope
:param {object} entries: The entries to set
:param str user_scope: User-Scope at which to set the values. Should be "me" for the current user... | [
"def",
"set_entries",
"(",
"self",
",",
"entries",
",",
"user_scope",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"user_scope",
"is",
"not",
"None",
":",
"route_values",
"[",
"'userScope'",
"]",
"=",
"self",
".",
"_serialize",
".",
"url",
"(",
"'user_... | SetEntries.
[Preview API] Set the specified setting entry values for the given user/all-users scope
:param {object} entries: The entries to set
:param str user_scope: User-Scope at which to set the values. Should be "me" for the current user or "host" for all users. | [
"SetEntries",
".",
"[",
"Preview",
"API",
"]",
"Set",
"the",
"specified",
"setting",
"entry",
"values",
"for",
"the",
"given",
"user",
"/",
"all",
"-",
"users",
"scope",
":",
"param",
"{",
"object",
"}",
"entries",
":",
"The",
"entries",
"to",
"set",
"... | python | train | 52.933333 |
saltstack/salt | salt/runners/venafiapi.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/venafiapi.py#L87-L167 | def gen_key(minion_id, dns_name=None, zone='default', password=None):
'''
Generate and return an private_key. If a ``dns_name`` is passed in, the
private_key will be cached under that name. The type of key and the
parameters used to generate the key are based on the default certificate
use policy as... | [
"def",
"gen_key",
"(",
"minion_id",
",",
"dns_name",
"=",
"None",
",",
"zone",
"=",
"'default'",
",",
"password",
"=",
"None",
")",
":",
"# Get the default certificate use policy associated with the zone",
"# so we can generate keys that conform with policy",
"# The /v1/zones... | Generate and return an private_key. If a ``dns_name`` is passed in, the
private_key will be cached under that name. The type of key and the
parameters used to generate the key are based on the default certificate
use policy associated with the specified zone.
CLI Example:
.. code-block:: bash
... | [
"Generate",
"and",
"return",
"an",
"private_key",
".",
"If",
"a",
"dns_name",
"is",
"passed",
"in",
"the",
"private_key",
"will",
"be",
"cached",
"under",
"that",
"name",
".",
"The",
"type",
"of",
"key",
"and",
"the",
"parameters",
"used",
"to",
"generate"... | python | train | 34.419753 |
StackStorm/pybind | pybind/slxos/v17s_1_02/interface/ethernet/switchport/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/interface/ethernet/switchport/__init__.py#L147-L170 | def _set_port_security(self, v, load=False):
"""
Setter method for port_security, mapped from YANG variable /interface/ethernet/switchport/port_security (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_security is considered as a private
method. Backe... | [
"def",
"_set_port_security",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"... | Setter method for port_security, mapped from YANG variable /interface/ethernet/switchport/port_security (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_port_security is considered as a private
method. Backends looking to populate this variable should
do so vi... | [
"Setter",
"method",
"for",
"port_security",
"mapped",
"from",
"YANG",
"variable",
"/",
"interface",
"/",
"ethernet",
"/",
"switchport",
"/",
"port_security",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"fal... | python | train | 75.291667 |
iotile/coretools | iotilecore/iotile/core/utilities/schema_verify/dict_verify.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/schema_verify/dict_verify.py#L43-L63 | def key_rule(self, regex, verifier):
"""Add a rule with a pattern that should apply to all keys.
Any key not explicitly listed in an add_required or add_optional rule
must match ONE OF the rules given in a call to key_rule().
So these rules are all OR'ed together.
In this case ... | [
"def",
"key_rule",
"(",
"self",
",",
"regex",
",",
"verifier",
")",
":",
"if",
"regex",
"is",
"not",
"None",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"regex",
")",
"self",
".",
"_additional_key_rules",
".",
"append",
"(",
"(",
"regex",
",",
"ver... | Add a rule with a pattern that should apply to all keys.
Any key not explicitly listed in an add_required or add_optional rule
must match ONE OF the rules given in a call to key_rule().
So these rules are all OR'ed together.
In this case you should pass a raw string specifying a regex ... | [
"Add",
"a",
"rule",
"with",
"a",
"pattern",
"that",
"should",
"apply",
"to",
"all",
"keys",
"."
] | python | train | 36.190476 |
hannes-brt/cudnn-python-wrappers | libcudnn.py | https://github.com/hannes-brt/cudnn-python-wrappers/blob/55aab1242924c2fd43db150cf2ccc2a3df958dd5/libcudnn.py#L804-L822 | def cudnnCreateConvolutionDescriptor():
""""
Create a convolution descriptor.
This function creates a convolution descriptor object by allocating the memory needed to
hold its opaque structure.
Returns
-------
convDesc : cudnnConvolutionDescriptor
Handle to newly allocated convolut... | [
"def",
"cudnnCreateConvolutionDescriptor",
"(",
")",
":",
"convDesc",
"=",
"ctypes",
".",
"c_void_p",
"(",
")",
"status",
"=",
"_libcudnn",
".",
"cudnnCreateConvolutionDescriptor",
"(",
"ctypes",
".",
"byref",
"(",
"convDesc",
")",
")",
"cudnnCheckStatus",
"(",
... | Create a convolution descriptor.
This function creates a convolution descriptor object by allocating the memory needed to
hold its opaque structure.
Returns
-------
convDesc : cudnnConvolutionDescriptor
Handle to newly allocated convolution descriptor. | [
"Create",
"a",
"convolution",
"descriptor",
"."
] | python | train | 26.105263 |
rackerlabs/simpl | simpl/git.py | https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/git.py#L240-L259 | def git_list_refs(repo_dir):
"""List references available in the local repo with commit ids.
This is similar to ls-remote, but shows the *local* refs.
Return format:
.. code-block:: python
{<ref1>: <commit_hash1>,
<ref2>: <commit_hash2>,
...,
<refN>: <commit_hashN>... | [
"def",
"git_list_refs",
"(",
"repo_dir",
")",
":",
"command",
"=",
"[",
"'git'",
",",
"'show-ref'",
",",
"'--dereference'",
",",
"'--head'",
"]",
"raw",
"=",
"execute_git_command",
"(",
"command",
",",
"repo_dir",
"=",
"repo_dir",
")",
".",
"splitlines",
"("... | List references available in the local repo with commit ids.
This is similar to ls-remote, but shows the *local* refs.
Return format:
.. code-block:: python
{<ref1>: <commit_hash1>,
<ref2>: <commit_hash2>,
...,
<refN>: <commit_hashN>,
} | [
"List",
"references",
"available",
"in",
"the",
"local",
"repo",
"with",
"commit",
"ids",
"."
] | python | train | 30.2 |
DistrictDataLabs/yellowbrick | yellowbrick/cluster/elbow.py | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/cluster/elbow.py#L48-L107 | def distortion_score(X, labels, metric='euclidean'):
"""
Compute the mean distortion of all samples.
The distortion is computed as the the sum of the squared distances between
each observation and its closest centroid. Logically, this is the metric
that K-Means attempts to minimize as it is fitting... | [
"def",
"distortion_score",
"(",
"X",
",",
"labels",
",",
"metric",
"=",
"'euclidean'",
")",
":",
"# Encode labels to get unique centers and groups",
"le",
"=",
"LabelEncoder",
"(",
")",
"labels",
"=",
"le",
".",
"fit_transform",
"(",
"labels",
")",
"unique_labels"... | Compute the mean distortion of all samples.
The distortion is computed as the the sum of the squared distances between
each observation and its closest centroid. Logically, this is the metric
that K-Means attempts to minimize as it is fitting the model.
.. seealso:: http://kldavenport.com/the-cost-fun... | [
"Compute",
"the",
"mean",
"distortion",
"of",
"all",
"samples",
"."
] | python | train | 40.016667 |
minio/minio-py | minio/helpers.py | https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/helpers.py#L308-L327 | def is_virtual_host(endpoint_url, bucket_name):
"""
Check to see if the ``bucket_name`` can be part of virtual host
style.
:param endpoint_url: Endpoint url which will be used for virtual host.
:param bucket_name: Bucket name to be validated against.
"""
is_valid_bucket_name(bucket_name)
... | [
"def",
"is_virtual_host",
"(",
"endpoint_url",
",",
"bucket_name",
")",
":",
"is_valid_bucket_name",
"(",
"bucket_name",
")",
"parsed_url",
"=",
"urlsplit",
"(",
"endpoint_url",
")",
"# bucket_name can be valid but '.' in the hostname will fail",
"# SSL certificate validation. ... | Check to see if the ``bucket_name`` can be part of virtual host
style.
:param endpoint_url: Endpoint url which will be used for virtual host.
:param bucket_name: Bucket name to be validated against. | [
"Check",
"to",
"see",
"if",
"the",
"bucket_name",
"can",
"be",
"part",
"of",
"virtual",
"host",
"style",
"."
] | python | train | 35.05 |
KrzyHonk/bpmn-python | bpmn_python/bpmn_diagram_import.py | https://github.com/KrzyHonk/bpmn-python/blob/6e5e28e3d656dbf5bd3d85d78fe8e3f2fb462629/bpmn_python/bpmn_diagram_import.py#L262-L297 | def import_lane_element(lane_element, plane_element):
"""
Method for importing 'laneSet' element from diagram file.
:param lane_element: XML document element,
:param plane_element: object representing a BPMN XML 'plane' element.
"""
lane_id = lane_element.getAttribute(co... | [
"def",
"import_lane_element",
"(",
"lane_element",
",",
"plane_element",
")",
":",
"lane_id",
"=",
"lane_element",
".",
"getAttribute",
"(",
"consts",
".",
"Consts",
".",
"id",
")",
"lane_name",
"=",
"lane_element",
".",
"getAttribute",
"(",
"consts",
".",
"Co... | Method for importing 'laneSet' element from diagram file.
:param lane_element: XML document element,
:param plane_element: object representing a BPMN XML 'plane' element. | [
"Method",
"for",
"importing",
"laneSet",
"element",
"from",
"diagram",
"file",
"."
] | python | train | 58 |
earwig/mwparserfromhell | mwparserfromhell/wikicode.py | https://github.com/earwig/mwparserfromhell/blob/98dc30902d35c714a70aca8e6616f49d71cb24cc/mwparserfromhell/wikicode.py#L334-L367 | def get_ancestors(self, obj):
"""Return a list of all ancestor nodes of the :class:`.Node` *obj*.
The list is ordered from the most shallow ancestor (greatest great-
grandparent) to the direct parent. The node itself is not included in
the list. For example::
>>> text = "{{... | [
"def",
"get_ancestors",
"(",
"self",
",",
"obj",
")",
":",
"def",
"_get_ancestors",
"(",
"code",
",",
"needle",
")",
":",
"for",
"node",
"in",
"code",
".",
"nodes",
":",
"if",
"node",
"is",
"needle",
":",
"return",
"[",
"]",
"for",
"code",
"in",
"n... | Return a list of all ancestor nodes of the :class:`.Node` *obj*.
The list is ordered from the most shallow ancestor (greatest great-
grandparent) to the direct parent. The node itself is not included in
the list. For example::
>>> text = "{{a|{{b|{{c|{{d}}}}}}}}"
>>> co... | [
"Return",
"a",
"list",
"of",
"all",
"ancestor",
"nodes",
"of",
"the",
":",
"class",
":",
".",
"Node",
"*",
"obj",
"*",
"."
] | python | train | 39.5 |
hydraplatform/hydra-base | hydra_base/lib/template.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/template.py#L2147-L2176 | def get_etree_layout_as_dict(layout_tree):
"""
Convert something that looks like this:
<layout>
<item>
<name>color</name>
<value>red</value>
</item>
<item>
<name>shapefile</name>
<value>blah.shp</value>
</item>
</layout>
... | [
"def",
"get_etree_layout_as_dict",
"(",
"layout_tree",
")",
":",
"layout_dict",
"=",
"dict",
"(",
")",
"for",
"item",
"in",
"layout_tree",
".",
"findall",
"(",
"'item'",
")",
":",
"name",
"=",
"item",
".",
"find",
"(",
"'name'",
")",
".",
"text",
"val_el... | Convert something that looks like this:
<layout>
<item>
<name>color</name>
<value>red</value>
</item>
<item>
<name>shapefile</name>
<value>blah.shp</value>
</item>
</layout>
Into something that looks like this:
{
'co... | [
"Convert",
"something",
"that",
"looks",
"like",
"this",
":",
"<layout",
">",
"<item",
">",
"<name",
">",
"color<",
"/",
"name",
">",
"<value",
">",
"red<",
"/",
"value",
">",
"<",
"/",
"item",
">",
"<item",
">",
"<name",
">",
"shapefile<",
"/",
"nam... | python | train | 27.3 |
joke2k/django-faker | django_faker/guessers.py | https://github.com/joke2k/django-faker/blob/345e3eebcf636e2566d9890ae7b35788ebdb5173/django_faker/guessers.py#L10-L33 | def guessFormat(self, name):
"""
:param name:
:type name: str
"""
name = name.lower()
generator = self.generator
if re.findall(r'^is[_A-Z]', name): return lambda x:generator.boolean()
if re.findall(r'(_a|A)t$', name): return lambda x:generator.dateTime()
... | [
"def",
"guessFormat",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"lower",
"(",
")",
"generator",
"=",
"self",
".",
"generator",
"if",
"re",
".",
"findall",
"(",
"r'^is[_A-Z]'",
",",
"name",
")",
":",
"return",
"lambda",
"x",
":",
... | :param name:
:type name: str | [
":",
"param",
"name",
":",
":",
"type",
"name",
":",
"str"
] | python | train | 54.625 |
GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/boto/boto_config.py#L66-L89 | def _CreateConfig(self, project_id):
"""Create the boto config to support standalone GSUtil.
Args:
project_id: string, the project ID to use in the config file.
"""
project_id = project_id or self._GetNumericProjectId()
# Our project doesn't support service accounts.
if not project_id:
... | [
"def",
"_CreateConfig",
"(",
"self",
",",
"project_id",
")",
":",
"project_id",
"=",
"project_id",
"or",
"self",
".",
"_GetNumericProjectId",
"(",
")",
"# Our project doesn't support service accounts.",
"if",
"not",
"project_id",
":",
"return",
"self",
".",
"boto_co... | Create the boto config to support standalone GSUtil.
Args:
project_id: string, the project ID to use in the config file. | [
"Create",
"the",
"boto",
"config",
"to",
"support",
"standalone",
"GSUtil",
"."
] | python | train | 37.583333 |
PyMySQL/PyMySQL | pymysql/protocol.py | https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L94-L98 | def rewind(self, position=0):
"""Set the position of the data buffer cursor to 'position'."""
if position < 0 or position > len(self._data):
raise Exception("Invalid position to rewind cursor to: %s." % position)
self._position = position | [
"def",
"rewind",
"(",
"self",
",",
"position",
"=",
"0",
")",
":",
"if",
"position",
"<",
"0",
"or",
"position",
">",
"len",
"(",
"self",
".",
"_data",
")",
":",
"raise",
"Exception",
"(",
"\"Invalid position to rewind cursor to: %s.\"",
"%",
"position",
"... | Set the position of the data buffer cursor to 'position'. | [
"Set",
"the",
"position",
"of",
"the",
"data",
"buffer",
"cursor",
"to",
"position",
"."
] | python | train | 54 |
luckydonald/pytgbot | code_generation/code_generator_online.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_online.py#L508-L512 | def calc_path_and_create_folders(folder, import_path):
""" calculate the path and create the needed folders """
file_path = abspath(path_join(folder, import_path[:import_path.rfind(".")].replace(".", folder_seperator) + ".py"))
mkdir_p(dirname(file_path))
return file_path | [
"def",
"calc_path_and_create_folders",
"(",
"folder",
",",
"import_path",
")",
":",
"file_path",
"=",
"abspath",
"(",
"path_join",
"(",
"folder",
",",
"import_path",
"[",
":",
"import_path",
".",
"rfind",
"(",
"\".\"",
")",
"]",
".",
"replace",
"(",
"\".\"",... | calculate the path and create the needed folders | [
"calculate",
"the",
"path",
"and",
"create",
"the",
"needed",
"folders"
] | python | train | 56.8 |
log2timeline/plaso | plaso/engine/extractors.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/extractors.py#L481-L546 | def _ExtractPathSpecsFromDirectory(self, file_entry, depth=0):
"""Extracts path specification from a directory.
Args:
file_entry (dfvfs.FileEntry): file entry that refers to the directory.
depth (Optional[int]): current depth where 0 represents the file system
root.
Yields:
dfv... | [
"def",
"_ExtractPathSpecsFromDirectory",
"(",
"self",
",",
"file_entry",
",",
"depth",
"=",
"0",
")",
":",
"if",
"depth",
">=",
"self",
".",
"_MAXIMUM_DEPTH",
":",
"raise",
"errors",
".",
"MaximumRecursionDepth",
"(",
"'Maximum recursion depth reached.'",
")",
"# ... | Extracts path specification from a directory.
Args:
file_entry (dfvfs.FileEntry): file entry that refers to the directory.
depth (Optional[int]): current depth where 0 represents the file system
root.
Yields:
dfvfs.PathSpec: path specification of a file entry found in the directory... | [
"Extracts",
"path",
"specification",
"from",
"a",
"directory",
"."
] | python | train | 37.560606 |
Azure/azure-cli-extensions | src/express-route/azext_express_route/vendored_sdks/network_management_client.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/express-route/azext_express_route/vendored_sdks/network_management_client.py#L2058-L2071 | def service_endpoint_policy_definitions(self):
"""Instance depends on the API version:
* 2018-07-01: :class:`ServiceEndpointPolicyDefinitionsOperations<azure.mgmt.network.v2018_07_01.operations.ServiceEndpointPolicyDefinitionsOperations>`
* 2018-08-01: :class:`ServiceEndpointPolicyDefinit... | [
"def",
"service_endpoint_policy_definitions",
"(",
"self",
")",
":",
"api_version",
"=",
"self",
".",
"_get_api_version",
"(",
"'service_endpoint_policy_definitions'",
")",
"if",
"api_version",
"==",
"'2018-07-01'",
":",
"from",
".",
"v2018_07_01",
".",
"operations",
... | Instance depends on the API version:
* 2018-07-01: :class:`ServiceEndpointPolicyDefinitionsOperations<azure.mgmt.network.v2018_07_01.operations.ServiceEndpointPolicyDefinitionsOperations>`
* 2018-08-01: :class:`ServiceEndpointPolicyDefinitionsOperations<azure.mgmt.network.v2018_08_01.operations.S... | [
"Instance",
"depends",
"on",
"the",
"API",
"version",
":"
] | python | train | 75.428571 |
pyvisa/pyvisa | pyvisa/ctwrapper/functions.py | https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1510-L1523 | def poke_8(library, session, address, data):
"""Write an 8-bit value from the specified address.
Corresponds to viPoke8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read t... | [
"def",
"poke_8",
"(",
"library",
",",
"session",
",",
"address",
",",
"data",
")",
":",
"return",
"library",
".",
"viPoke8",
"(",
"session",
",",
"address",
",",
"data",
")"
] | Write an 8-bit value from the specified address.
Corresponds to viPoke8 function of the VISA library.
:param library: the visa library wrapped by ctypes.
:param session: Unique logical identifier to a session.
:param address: Source address to read the value.
:param data: value to be written to th... | [
"Write",
"an",
"8",
"-",
"bit",
"value",
"from",
"the",
"specified",
"address",
"."
] | python | train | 39.5 |
spotify/docker_interface | docker_interface/util.py | https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L114-L136 | def pop_value(instance, path, ref=None):
"""
Pop the value from `instance` at the given `path`.
Parameters
----------
instance : dict or list
instance from which to retrieve a value
path : str
path to retrieve a value from
ref : str or None
reference path if `path` i... | [
"def",
"pop_value",
"(",
"instance",
",",
"path",
",",
"ref",
"=",
"None",
")",
":",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"abspath",
"(",
"path",
",",
"ref",
")",
")",
"instance",
"=",
"get_value",
"(",
"instance",
",",
... | Pop the value from `instance` at the given `path`.
Parameters
----------
instance : dict or list
instance from which to retrieve a value
path : str
path to retrieve a value from
ref : str or None
reference path if `path` is relative
Returns
-------
value :
... | [
"Pop",
"the",
"value",
"from",
"instance",
"at",
"the",
"given",
"path",
"."
] | python | train | 24.913043 |
FlorianRhiem/pyGLFW | glfw/__init__.py | https://github.com/FlorianRhiem/pyGLFW/blob/87767dfbe15ba15d2a8338cdfddf6afc6a25dff5/glfw/__init__.py#L744-L756 | def get_monitor_physical_size(monitor):
"""
Returns the physical size of the monitor.
Wrapper for:
void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
"""
width_value = ctypes.c_int(0)
width = ctypes.pointer(width_value)
height_value = ctypes.c_int(0)
... | [
"def",
"get_monitor_physical_size",
"(",
"monitor",
")",
":",
"width_value",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"width",
"=",
"ctypes",
".",
"pointer",
"(",
"width_value",
")",
"height_value",
"=",
"ctypes",
".",
"c_int",
"(",
"0",
")",
"height",
... | Returns the physical size of the monitor.
Wrapper for:
void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); | [
"Returns",
"the",
"physical",
"size",
"of",
"the",
"monitor",
"."
] | python | train | 35.076923 |
Metatab/metapack | metapack/cli/build.py | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/build.py#L34-L126 | def build(subparsers):
"""
Build source packages.
The mp build program runs all of the resources listed in a Metatab file and
produces one or more Metapack packages with those resources localized. It
will always try to produce a Filesystem package, and may optionally produce
Excel, Zip and CSV ... | [
"def",
"build",
"(",
"subparsers",
")",
":",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'build'",
",",
"help",
"=",
"'Build derived packages'",
",",
"description",
"=",
"build",
".",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescr... | Build source packages.
The mp build program runs all of the resources listed in a Metatab file and
produces one or more Metapack packages with those resources localized. It
will always try to produce a Filesystem package, and may optionally produce
Excel, Zip and CSV packages.
Typical usage is to ... | [
"Build",
"source",
"packages",
"."
] | python | train | 38.344086 |
nicolargo/glances | glances/plugins/glances_now.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_now.py#L48-L58 | def update(self):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# Add the time zone (issue #1249 and issue #1337)
if 'tmzone' in localtime():
self.stats... | [
"def",
"update",
"(",
"self",
")",
":",
"# Had to convert it to string because datetime is not JSON serializable",
"self",
".",
"stats",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"# Add the time zone (issue #1249 and issue #133... | Update current date/time. | [
"Update",
"current",
"date",
"/",
"time",
"."
] | python | train | 41.272727 |
kinegratii/borax | borax/calendars/lunardate.py | https://github.com/kinegratii/borax/blob/921649f9277e3f657b6dea5a80e67de9ee5567f6/borax/calendars/lunardate.py#L84-L98 | def _iter_year_month(year_info):
""" Iter the month days in a lunar year.
"""
# info => month, days, leap
leap_month, leap_days = _parse_leap(year_info)
months = [(i, 0) for i in range(1, 13)]
if leap_month > 0:
months.insert(leap_month, (leap_month, 1))
for month, leap in months:
... | [
"def",
"_iter_year_month",
"(",
"year_info",
")",
":",
"# info => month, days, leap",
"leap_month",
",",
"leap_days",
"=",
"_parse_leap",
"(",
"year_info",
")",
"months",
"=",
"[",
"(",
"i",
",",
"0",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"13",
... | Iter the month days in a lunar year. | [
"Iter",
"the",
"month",
"days",
"in",
"a",
"lunar",
"year",
"."
] | python | train | 30.133333 |
empymod/empymod | empymod/utils.py | https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/utils.py#L1895-L1903 | def _prnt_min_max_val(var, text, verb):
r"""Print variable; if more than three, just min/max, unless verb > 3."""
if var.size > 3:
print(text, _strvar(var.min()), "-", _strvar(var.max()),
":", _strvar(var.size), " [min-max; #]")
if verb > 3:
print(" : ... | [
"def",
"_prnt_min_max_val",
"(",
"var",
",",
"text",
",",
"verb",
")",
":",
"if",
"var",
".",
"size",
">",
"3",
":",
"print",
"(",
"text",
",",
"_strvar",
"(",
"var",
".",
"min",
"(",
")",
")",
",",
"\"-\"",
",",
"_strvar",
"(",
"var",
".",
"ma... | r"""Print variable; if more than three, just min/max, unless verb > 3. | [
"r",
"Print",
"variable",
";",
"if",
"more",
"than",
"three",
"just",
"min",
"/",
"max",
"unless",
"verb",
">",
"3",
"."
] | python | train | 43 |
ThreatConnect-Inc/tcex | tcex/tcex.py | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L822-L858 | def results_tc(self, key, value):
"""Write data to results_tc file in TcEX specified directory.
The TcEx platform support persistent values between executions of the App. This
method will store the values for TC to read and put into the Database.
Args:
key (string): The da... | [
"def",
"results_tc",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"os",
".",
"access",
"(",
"self",
".",
"default_args",
".",
"tc_out_path",
",",
"os",
".",
"W_OK",
")",
":",
"results_file",
"=",
"'{}/results.tc'",
".",
"format",
"(",
"self",... | Write data to results_tc file in TcEX specified directory.
The TcEx platform support persistent values between executions of the App. This
method will store the values for TC to read and put into the Database.
Args:
key (string): The data key to be stored.
value (strin... | [
"Write",
"data",
"to",
"results_tc",
"file",
"in",
"TcEX",
"specified",
"directory",
"."
] | python | train | 39.351351 |
qacafe/cdrouter.py | cdrouter/filters.py | https://github.com/qacafe/cdrouter.py/blob/aacf2c6ab0b987250f7b1892f4bba14bb2b7dbe5/cdrouter/filters.py#L137-L147 | def ge(self, value):
"""Construct a greater than or equal to (``>=``) filter.
:param value: Filter value
:return: :class:`filters.Field <filters.Field>` object
:rtype: filters.Field
"""
self.op = '>='
self.negate_op = '<'
self.value = self._value(value)
... | [
"def",
"ge",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"op",
"=",
"'>='",
"self",
".",
"negate_op",
"=",
"'<'",
"self",
".",
"value",
"=",
"self",
".",
"_value",
"(",
"value",
")",
"return",
"self"
] | Construct a greater than or equal to (``>=``) filter.
:param value: Filter value
:return: :class:`filters.Field <filters.Field>` object
:rtype: filters.Field | [
"Construct",
"a",
"greater",
"than",
"or",
"equal",
"to",
"(",
">",
"=",
")",
"filter",
"."
] | python | train | 29.818182 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.