id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,200 | Pixelapse/pyglass | pyglass/sketch/export.py | export_cmd | def export_cmd(cmd, src_path, dest_dir=None, item_id=None, export_format=None, scale=None):
''' Executes a `sketchtool export` command and returns formatted output
:src_path: File to export. :type <str>
:dest_dir: Items are exported at /dest_dir/name@scale.export_format e.g. `~/Desktop/Page 1@2x.png`
:param ex... | python | def export_cmd(cmd, src_path, dest_dir=None, item_id=None, export_format=None, scale=None):
''' Executes a `sketchtool export` command and returns formatted output
:src_path: File to export. :type <str>
:dest_dir: Items are exported at /dest_dir/name@scale.export_format e.g. `~/Desktop/Page 1@2x.png`
:param ex... | [
"def",
"export_cmd",
"(",
"cmd",
",",
"src_path",
",",
"dest_dir",
"=",
"None",
",",
"item_id",
"=",
"None",
",",
"export_format",
"=",
"None",
",",
"scale",
"=",
"None",
")",
":",
"cmd",
".",
"extend",
"(",
"[",
"src_path",
"]",
")",
"if",
"not",
... | Executes a `sketchtool export` command and returns formatted output
:src_path: File to export. :type <str>
:dest_dir: Items are exported at /dest_dir/name@scale.export_format e.g. `~/Desktop/Page 1@2x.png`
:param export_format: 'png', 'pdf' etc. :type <ExportFormat>
:param scale: Specify as 1.0, 2.0 etc. :type... | [
"Executes",
"a",
"sketchtool",
"export",
"command",
"and",
"returns",
"formatted",
"output"
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/sketch/export.py#L19-L54 |
52,201 | RI-imaging/qpsphere | qpsphere/models/_bhfield/fetch.py | get_binaries | def get_binaries():
"""Download and return paths of all platform-specific binaries"""
paths = []
for arp in [False, True]:
paths.append(get_binary(arp=arp))
return paths | python | def get_binaries():
"""Download and return paths of all platform-specific binaries"""
paths = []
for arp in [False, True]:
paths.append(get_binary(arp=arp))
return paths | [
"def",
"get_binaries",
"(",
")",
":",
"paths",
"=",
"[",
"]",
"for",
"arp",
"in",
"[",
"False",
",",
"True",
"]",
":",
"paths",
".",
"append",
"(",
"get_binary",
"(",
"arp",
"=",
"arp",
")",
")",
"return",
"paths"
] | Download and return paths of all platform-specific binaries | [
"Download",
"and",
"return",
"paths",
"of",
"all",
"platform",
"-",
"specific",
"binaries"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/_bhfield/fetch.py#L111-L116 |
52,202 | zengbin93/zb | zb/algorithms/nn_one_hidden.py | backward_propagation | def backward_propagation(parameters, cache, X, Y):
"""
Implement the backward propagation using the instructions above.
Arguments:
parameters -- python dictionary containing our parameters
cache -- a dictionary containing "Z1", "A1", "Z2" and "A2".
X -- input data of shape (2, number of example... | python | def backward_propagation(parameters, cache, X, Y):
"""
Implement the backward propagation using the instructions above.
Arguments:
parameters -- python dictionary containing our parameters
cache -- a dictionary containing "Z1", "A1", "Z2" and "A2".
X -- input data of shape (2, number of example... | [
"def",
"backward_propagation",
"(",
"parameters",
",",
"cache",
",",
"X",
",",
"Y",
")",
":",
"m",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"# First, retrieve W1 and W2 from the dictionary \"parameters\".",
"W1",
"=",
"parameters",
"[",
"\"W1\"",
"]",
"W2",
"=",... | Implement the backward propagation using the instructions above.
Arguments:
parameters -- python dictionary containing our parameters
cache -- a dictionary containing "Z1", "A1", "Z2" and "A2".
X -- input data of shape (2, number of examples)
Y -- "true" labels vector of shape (1, number of example... | [
"Implement",
"the",
"backward",
"propagation",
"using",
"the",
"instructions",
"above",
"."
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/nn_one_hidden.py#L134-L170 |
52,203 | zengbin93/zb | zb/algorithms/nn_one_hidden.py | update_parameters | def update_parameters(parameters, grads, learning_rate=1.2):
"""
Updates parameters using the gradient descent update rule given above
Arguments:
parameters -- python dictionary containing your parameters
grads -- python dictionary containing your gradients
Returns:
parameters -- python di... | python | def update_parameters(parameters, grads, learning_rate=1.2):
"""
Updates parameters using the gradient descent update rule given above
Arguments:
parameters -- python dictionary containing your parameters
grads -- python dictionary containing your gradients
Returns:
parameters -- python di... | [
"def",
"update_parameters",
"(",
"parameters",
",",
"grads",
",",
"learning_rate",
"=",
"1.2",
")",
":",
"# Retrieve each parameter from the dictionary \"parameters\"",
"W1",
"=",
"parameters",
"[",
"\"W1\"",
"]",
"b1",
"=",
"parameters",
"[",
"\"b1\"",
"]",
"W2",
... | Updates parameters using the gradient descent update rule given above
Arguments:
parameters -- python dictionary containing your parameters
grads -- python dictionary containing your gradients
Returns:
parameters -- python dictionary containing your updated parameters | [
"Updates",
"parameters",
"using",
"the",
"gradient",
"descent",
"update",
"rule",
"given",
"above"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/nn_one_hidden.py#L173-L207 |
52,204 | zengbin93/zb | zb/algorithms/nn_one_hidden.py | predict | def predict(parameters, X):
"""
Using the learned parameters, predicts a class for each example in X
Arguments:
parameters -- python dictionary containing your parameters
X -- input data of size (n_x, m)
Returns
predictions -- vector of predictions of our model (red: 0 / blue: 1)
"""
... | python | def predict(parameters, X):
"""
Using the learned parameters, predicts a class for each example in X
Arguments:
parameters -- python dictionary containing your parameters
X -- input data of size (n_x, m)
Returns
predictions -- vector of predictions of our model (red: 0 / blue: 1)
"""
... | [
"def",
"predict",
"(",
"parameters",
",",
"X",
")",
":",
"# Computes probabilities using forward propagation,",
"# and classifies to 0/1 using 0.5 as the threshold.",
"A2",
",",
"cache",
"=",
"forward_propagation",
"(",
"X",
",",
"parameters",
")",
"predictions",
"=",
"np... | Using the learned parameters, predicts a class for each example in X
Arguments:
parameters -- python dictionary containing your parameters
X -- input data of size (n_x, m)
Returns
predictions -- vector of predictions of our model (red: 0 / blue: 1) | [
"Using",
"the",
"learned",
"parameters",
"predicts",
"a",
"class",
"for",
"each",
"example",
"in",
"X"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/nn_one_hidden.py#L258-L275 |
52,205 | zengbin93/zb | zb/tools/sms.py | send_email | def send_email(sender, pw, to, subject, content, files=None, service='163'):
"""send email, recommended use 163 mailbox service, as it is tested.
:param sender: str
email address of sender
:param pw: str
password for sender
:param to: str
email addressee
:param subject: str
... | python | def send_email(sender, pw, to, subject, content, files=None, service='163'):
"""send email, recommended use 163 mailbox service, as it is tested.
:param sender: str
email address of sender
:param pw: str
password for sender
:param to: str
email addressee
:param subject: str
... | [
"def",
"send_email",
"(",
"sender",
",",
"pw",
",",
"to",
",",
"subject",
",",
"content",
",",
"files",
"=",
"None",
",",
"service",
"=",
"'163'",
")",
":",
"se",
"=",
"EmailSender",
"(",
"from_",
"=",
"sender",
",",
"pw",
"=",
"pw",
",",
"service"... | send email, recommended use 163 mailbox service, as it is tested.
:param sender: str
email address of sender
:param pw: str
password for sender
:param to: str
email addressee
:param subject: str
subject of email
:param content: str
content of email
:param... | [
"send",
"email",
"recommended",
"use",
"163",
"mailbox",
"service",
"as",
"it",
"is",
"tested",
"."
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/tools/sms.py#L130-L151 |
52,206 | winstonwolff/expectorant | expectorant/spec.py | Suite.nodes | def nodes(self, node=None):
'''walks through tree and yields each node'''
if node is None:
for root in self.stack:
yield from self.nodes(root)
else:
yield node
if node.is_container():
for child in node.children:
... | python | def nodes(self, node=None):
'''walks through tree and yields each node'''
if node is None:
for root in self.stack:
yield from self.nodes(root)
else:
yield node
if node.is_container():
for child in node.children:
... | [
"def",
"nodes",
"(",
"self",
",",
"node",
"=",
"None",
")",
":",
"if",
"node",
"is",
"None",
":",
"for",
"root",
"in",
"self",
".",
"stack",
":",
"yield",
"from",
"self",
".",
"nodes",
"(",
"root",
")",
"else",
":",
"yield",
"node",
"if",
"node",... | walks through tree and yields each node | [
"walks",
"through",
"tree",
"and",
"yields",
"each",
"node"
] | cb9e4c1656d7c1f4394f0b0fbeb968a833030031 | https://github.com/winstonwolff/expectorant/blob/cb9e4c1656d7c1f4394f0b0fbeb968a833030031/expectorant/spec.py#L111-L120 |
52,207 | winstonwolff/expectorant | expectorant/spec.py | Suite.context | def context(self, message):
'''
Function decorator which adds "context" around a group of TestCases and may have
a `before` and `after` func.
>>> s = Suite()
>>> @s.context('context 1')
... def _():
... @s.before
... def _(): p... | python | def context(self, message):
'''
Function decorator which adds "context" around a group of TestCases and may have
a `before` and `after` func.
>>> s = Suite()
>>> @s.context('context 1')
... def _():
... @s.before
... def _(): p... | [
"def",
"context",
"(",
"self",
",",
"message",
")",
":",
"def",
"decorator",
"(",
"context_func",
")",
":",
"self",
".",
"push_container",
"(",
"message",
")",
"context_func",
"(",
")",
"self",
".",
"pop_container",
"(",
")",
"return",
"decorator"
] | Function decorator which adds "context" around a group of TestCases and may have
a `before` and `after` func.
>>> s = Suite()
>>> @s.context('context 1')
... def _():
... @s.before
... def _(): print('before 1 called.')
... @s.... | [
"Function",
"decorator",
"which",
"adds",
"context",
"around",
"a",
"group",
"of",
"TestCases",
"and",
"may",
"have",
"a",
"before",
"and",
"after",
"func",
"."
] | cb9e4c1656d7c1f4394f0b0fbeb968a833030031 | https://github.com/winstonwolff/expectorant/blob/cb9e4c1656d7c1f4394f0b0fbeb968a833030031/expectorant/spec.py#L134-L165 |
52,208 | winstonwolff/expectorant | expectorant/spec.py | Suite.it | def it(self, message, repeat=None):
'''
Function decorator which adds a TestCase to the Suite
>>> s = Suite()
>>> @s.it('always passes')
... def _(): pass
>>> list(s.nodes())
[<Container: root>, <TestCase: always passes>]
`repeat` w... | python | def it(self, message, repeat=None):
'''
Function decorator which adds a TestCase to the Suite
>>> s = Suite()
>>> @s.it('always passes')
... def _(): pass
>>> list(s.nodes())
[<Container: root>, <TestCase: always passes>]
`repeat` w... | [
"def",
"it",
"(",
"self",
",",
"message",
",",
"repeat",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"test_func",
")",
":",
"if",
"repeat",
":",
"for",
"set_of_args",
"in",
"repeat",
":",
"self",
".",
"add_test",
"(",
"message",
",",
"test_func",
... | Function decorator which adds a TestCase to the Suite
>>> s = Suite()
>>> @s.it('always passes')
... def _(): pass
>>> list(s.nodes())
[<Container: root>, <TestCase: always passes>]
`repeat` will add multiple test cases with extra parameters.
... | [
"Function",
"decorator",
"which",
"adds",
"a",
"TestCase",
"to",
"the",
"Suite"
] | cb9e4c1656d7c1f4394f0b0fbeb968a833030031 | https://github.com/winstonwolff/expectorant/blob/cb9e4c1656d7c1f4394f0b0fbeb968a833030031/expectorant/spec.py#L169-L194 |
52,209 | leandroarndt/djangospam | djangospam/cookie/views.py | spammer_view | def spammer_view(request):
"""View for setting cookies on spammers."""
# Permits use of CSRF middleware
context = RequestContext(request, {})
template = Template("")
response = HttpResponse(template.render(context))
# Sets a cookie with a 10 years lifetime, accessible only via HTTP:
respon... | python | def spammer_view(request):
"""View for setting cookies on spammers."""
# Permits use of CSRF middleware
context = RequestContext(request, {})
template = Template("")
response = HttpResponse(template.render(context))
# Sets a cookie with a 10 years lifetime, accessible only via HTTP:
respon... | [
"def",
"spammer_view",
"(",
"request",
")",
":",
"# Permits use of CSRF middleware",
"context",
"=",
"RequestContext",
"(",
"request",
",",
"{",
"}",
")",
"template",
"=",
"Template",
"(",
"\"\"",
")",
"response",
"=",
"HttpResponse",
"(",
"template",
".",
"re... | View for setting cookies on spammers. | [
"View",
"for",
"setting",
"cookies",
"on",
"spammers",
"."
] | 57fa9cfbf54a40f0e0652d0155dbb3451c14b69d | https://github.com/leandroarndt/djangospam/blob/57fa9cfbf54a40f0e0652d0155dbb3451c14b69d/djangospam/cookie/views.py#L9-L25 |
52,210 | uw-it-cte/uw-ems-client | ems_client/__init__.py | load_object_by_name | def load_object_by_name(object_name):
"""Load an object from a module by name"""
mod_name, attr = object_name.rsplit('.', 1)
mod = import_module(mod_name)
return getattr(mod, attr) | python | def load_object_by_name(object_name):
"""Load an object from a module by name"""
mod_name, attr = object_name.rsplit('.', 1)
mod = import_module(mod_name)
return getattr(mod, attr) | [
"def",
"load_object_by_name",
"(",
"object_name",
")",
":",
"mod_name",
",",
"attr",
"=",
"object_name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"mod",
"=",
"import_module",
"(",
"mod_name",
")",
"return",
"getattr",
"(",
"mod",
",",
"attr",
")"
] | Load an object from a module by name | [
"Load",
"an",
"object",
"from",
"a",
"module",
"by",
"name"
] | db1aed689e79f193f3268d9dd4817da3072d282c | https://github.com/uw-it-cte/uw-ems-client/blob/db1aed689e79f193f3268d9dd4817da3072d282c/ems_client/__init__.py#L21-L25 |
52,211 | agile4you/SchemaFactory | benchmarks.py | bench_serpy | def bench_serpy():
"""Beanchmark for 1000 objects with 2 fields.
"""
class FooSerializer(serpy.DictSerializer):
"""The serializer schema definition."""
# Use a Field subclass like IntField if you need more validation.
attr_2 = serpy.IntField()
attr_1 = serpy.StrField()
... | python | def bench_serpy():
"""Beanchmark for 1000 objects with 2 fields.
"""
class FooSerializer(serpy.DictSerializer):
"""The serializer schema definition."""
# Use a Field subclass like IntField if you need more validation.
attr_2 = serpy.IntField()
attr_1 = serpy.StrField()
... | [
"def",
"bench_serpy",
"(",
")",
":",
"class",
"FooSerializer",
"(",
"serpy",
".",
"DictSerializer",
")",
":",
"\"\"\"The serializer schema definition.\"\"\"",
"# Use a Field subclass like IntField if you need more validation.",
"attr_2",
"=",
"serpy",
".",
"IntField",
"(",
... | Beanchmark for 1000 objects with 2 fields. | [
"Beanchmark",
"for",
"1000",
"objects",
"with",
"2",
"fields",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/benchmarks.py#L75-L85 |
52,212 | dcaune/perseus-lib-python-common | majormode/perseus/model/locale.py | Locale.decompose_locale | def decompose_locale(locale, strict=True):
"""
Return the decomposition of the specified locale into a language code
and a country code.
@param locale: a string representation of a locale, i.e., a ISO 639-3
alpha-3 code (or alpha-2 code), optionally followed by a dash
... | python | def decompose_locale(locale, strict=True):
"""
Return the decomposition of the specified locale into a language code
and a country code.
@param locale: a string representation of a locale, i.e., a ISO 639-3
alpha-3 code (or alpha-2 code), optionally followed by a dash
... | [
"def",
"decompose_locale",
"(",
"locale",
",",
"strict",
"=",
"True",
")",
":",
"if",
"locale",
"is",
"None",
":",
"return",
"(",
"'eng'",
",",
"None",
")",
"match",
"=",
"REGEX_LOCALE",
".",
"match",
"(",
"locale",
")",
"if",
"match",
"is",
"None",
... | Return the decomposition of the specified locale into a language code
and a country code.
@param locale: a string representation of a locale, i.e., a ISO 639-3
alpha-3 code (or alpha-2 code), optionally followed by a dash
character ``-`` and a ISO 3166-1 alpha-2 code. If ``Non... | [
"Return",
"the",
"decomposition",
"of",
"the",
"specified",
"locale",
"into",
"a",
"language",
"code",
"and",
"a",
"country",
"code",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/locale.py#L254-L288 |
52,213 | zh012/flask-dropin | flask_dropin/__init__.py | BaseDropsLoader.load_drops | def load_drops(self, dropin):
"""Load `drops` from the given dropin.
Args:
dropin (string): path of a dropin, e.g. dropin.auth
Returns:
An iterable contains the drops object in the given dropin
This method load drops object by some sort of convension. For examp... | python | def load_drops(self, dropin):
"""Load `drops` from the given dropin.
Args:
dropin (string): path of a dropin, e.g. dropin.auth
Returns:
An iterable contains the drops object in the given dropin
This method load drops object by some sort of convension. For examp... | [
"def",
"load_drops",
"(",
"self",
",",
"dropin",
")",
":",
"obj",
"=",
"load_object",
"(",
"dropin",
")",
"try",
":",
"drops",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"drops_type",
")",
"except",
"AttributeError",
":",
"try",
":",
"drops",
"=",
... | Load `drops` from the given dropin.
Args:
dropin (string): path of a dropin, e.g. dropin.auth
Returns:
An iterable contains the drops object in the given dropin
This method load drops object by some sort of convension. For example, assuming
we want to load drop... | [
"Load",
"drops",
"from",
"the",
"given",
"dropin",
"."
] | a0ef6c4088ac8542d1c33dcfd75d9a7edf1f6cac | https://github.com/zh012/flask-dropin/blob/a0ef6c4088ac8542d1c33dcfd75d9a7edf1f6cac/flask_dropin/__init__.py#L31-L74 |
52,214 | zh012/flask-dropin | flask_dropin/__init__.py | BaseDropsLoader.register_drops | def register_drops(self, dropin):
"""Register the `drops` in given `dropin` to a flask app.
Args:
app (Flask): the flask app to be initialized
dropin (string): path of a python module or object, e.g. dropin.auth
This is the only method that a drops loader **must** impl... | python | def register_drops(self, dropin):
"""Register the `drops` in given `dropin` to a flask app.
Args:
app (Flask): the flask app to be initialized
dropin (string): path of a python module or object, e.g. dropin.auth
This is the only method that a drops loader **must** impl... | [
"def",
"register_drops",
"(",
"self",
",",
"dropin",
")",
":",
"drops",
"=",
"self",
".",
"app",
".",
"extensions",
"[",
"'dropin'",
"]",
".",
"setdefault",
"(",
"self",
".",
"drops_type",
",",
"[",
"]",
")",
"drops",
".",
"extend",
"(",
"self",
".",... | Register the `drops` in given `dropin` to a flask app.
Args:
app (Flask): the flask app to be initialized
dropin (string): path of a python module or object, e.g. dropin.auth
This is the only method that a drops loader **must** implment. The default
behavior in the bas... | [
"Register",
"the",
"drops",
"in",
"given",
"dropin",
"to",
"a",
"flask",
"app",
"."
] | a0ef6c4088ac8542d1c33dcfd75d9a7edf1f6cac | https://github.com/zh012/flask-dropin/blob/a0ef6c4088ac8542d1c33dcfd75d9a7edf1f6cac/flask_dropin/__init__.py#L76-L103 |
52,215 | GaretJax/coolfig | coolfig/schema.py | Settings.merge | def merge(cls, *others):
"""
Merge the `others` schema into this instance.
The values will all be read from the provider of the original object.
"""
for other in others:
for k, v in other:
setattr(cls, k, BoundValue(cls, k, v.value)) | python | def merge(cls, *others):
"""
Merge the `others` schema into this instance.
The values will all be read from the provider of the original object.
"""
for other in others:
for k, v in other:
setattr(cls, k, BoundValue(cls, k, v.value)) | [
"def",
"merge",
"(",
"cls",
",",
"*",
"others",
")",
":",
"for",
"other",
"in",
"others",
":",
"for",
"k",
",",
"v",
"in",
"other",
":",
"setattr",
"(",
"cls",
",",
"k",
",",
"BoundValue",
"(",
"cls",
",",
"k",
",",
"v",
".",
"value",
")",
")... | Merge the `others` schema into this instance.
The values will all be read from the provider of the original object. | [
"Merge",
"the",
"others",
"schema",
"into",
"this",
"instance",
"."
] | 6952aabc6ad2c9684d5d98dc470313f8f13fe636 | https://github.com/GaretJax/coolfig/blob/6952aabc6ad2c9684d5d98dc470313f8f13fe636/coolfig/schema.py#L166-L174 |
52,216 | agile4you/SchemaFactory | schema_factory/nodes.py | BaseNode.field_value | def field_value(self, value):
"""Validate against NodeType.
"""
if not self.is_array:
return self.field_type(value)
if isinstance(value, (list, tuple, set)):
return [self.field_type(item) for item in value]
return self.field_type(value) | python | def field_value(self, value):
"""Validate against NodeType.
"""
if not self.is_array:
return self.field_type(value)
if isinstance(value, (list, tuple, set)):
return [self.field_type(item) for item in value]
return self.field_type(value) | [
"def",
"field_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"is_array",
":",
"return",
"self",
".",
"field_type",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
",",
"set",
")",
")",
":... | Validate against NodeType. | [
"Validate",
"against",
"NodeType",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/nodes.py#L131-L139 |
52,217 | agile4you/SchemaFactory | schema_factory/nodes.py | BaseNode.is_valid | def is_valid(self, value):
"""Validate value before actual instance setting based on type.
Args:
value (object): The value object for validation.
Returns:
True if value validation succeeds else False.
"""
if not self.is_array:
return self._va... | python | def is_valid(self, value):
"""Validate value before actual instance setting based on type.
Args:
value (object): The value object for validation.
Returns:
True if value validation succeeds else False.
"""
if not self.is_array:
return self._va... | [
"def",
"is_valid",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"is_array",
":",
"return",
"self",
".",
"_valid",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"set",
",",
"tuple",
")",
")",
":",
"r... | Validate value before actual instance setting based on type.
Args:
value (object): The value object for validation.
Returns:
True if value validation succeeds else False. | [
"Validate",
"value",
"before",
"actual",
"instance",
"setting",
"based",
"on",
"type",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/nodes.py#L141-L156 |
52,218 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._attr_data_ | def _attr_data_(self):
"Special property containing the memoized data."
try:
return self.__attr_data
except AttributeError:
self.__attr_data = type(
''.join([type(self).__name__, 'EmptyData']),
(),
{
'__... | python | def _attr_data_(self):
"Special property containing the memoized data."
try:
return self.__attr_data
except AttributeError:
self.__attr_data = type(
''.join([type(self).__name__, 'EmptyData']),
(),
{
'__... | [
"def",
"_attr_data_",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"__attr_data",
"except",
"AttributeError",
":",
"self",
".",
"__attr_data",
"=",
"type",
"(",
"''",
".",
"join",
"(",
"[",
"type",
"(",
"self",
")",
".",
"__name__",
",",
... | Special property containing the memoized data. | [
"Special",
"property",
"containing",
"the",
"memoized",
"data",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L288-L302 |
52,219 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._attr_func_ | def _attr_func_(self):
"Special property containing functions to be lazily-evaluated."
try:
return self.__attr_func
except AttributeError:
self.__attr_func = type(
''.join([type(self).__name__, 'EmptyFuncs']),
(),
{
... | python | def _attr_func_(self):
"Special property containing functions to be lazily-evaluated."
try:
return self.__attr_func
except AttributeError:
self.__attr_func = type(
''.join([type(self).__name__, 'EmptyFuncs']),
(),
{
... | [
"def",
"_attr_func_",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"__attr_func",
"except",
"AttributeError",
":",
"self",
".",
"__attr_func",
"=",
"type",
"(",
"''",
".",
"join",
"(",
"[",
"type",
"(",
"self",
")",
".",
"__name__",
",",
... | Special property containing functions to be lazily-evaluated. | [
"Special",
"property",
"containing",
"functions",
"to",
"be",
"lazily",
"-",
"evaluated",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L320-L335 |
52,220 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._loadable_get_ | def _loadable_get_(name, self):
"Used to lazily-evaluate & memoize an attribute."
func = getattr(self._attr_func_, name)
ret = func()
setattr(self._attr_data_, name, ret)
setattr(
type(self),
name,
property(
functools.partial(s... | python | def _loadable_get_(name, self):
"Used to lazily-evaluate & memoize an attribute."
func = getattr(self._attr_func_, name)
ret = func()
setattr(self._attr_data_, name, ret)
setattr(
type(self),
name,
property(
functools.partial(s... | [
"def",
"_loadable_get_",
"(",
"name",
",",
"self",
")",
":",
"func",
"=",
"getattr",
"(",
"self",
".",
"_attr_func_",
",",
"name",
")",
"ret",
"=",
"func",
"(",
")",
"setattr",
"(",
"self",
".",
"_attr_data_",
",",
"name",
",",
"ret",
")",
"setattr",... | Used to lazily-evaluate & memoize an attribute. | [
"Used",
"to",
"lazily",
"-",
"evaluate",
"&",
"memoize",
"an",
"attribute",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L360-L374 |
52,221 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._setable_get_ | def _setable_get_(name, self):
"Used to raise an exception for attributes unable to be evaluated yet."
raise AttributeError(
"'{typename}' object has no attribute '{name}'".format(
typename=type(self).__name__,
name=name
)
) | python | def _setable_get_(name, self):
"Used to raise an exception for attributes unable to be evaluated yet."
raise AttributeError(
"'{typename}' object has no attribute '{name}'".format(
typename=type(self).__name__,
name=name
)
) | [
"def",
"_setable_get_",
"(",
"name",
",",
"self",
")",
":",
"raise",
"AttributeError",
"(",
"\"'{typename}' object has no attribute '{name}'\"",
".",
"format",
"(",
"typename",
"=",
"type",
"(",
"self",
")",
".",
"__name__",
",",
"name",
"=",
"name",
")",
")"
... | Used to raise an exception for attributes unable to be evaluated yet. | [
"Used",
"to",
"raise",
"an",
"exception",
"for",
"attributes",
"unable",
"to",
"be",
"evaluated",
"yet",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L377-L385 |
52,222 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._setable_set_ | def _setable_set_(name, self, func):
"Used to set the attribute a single time using the given function."
setattr(self._attr_data_, name, func())
if hasattr(self._attr_func_, name):
delattr(self._attr_func_, name)
setattr(
type(self),
name,
... | python | def _setable_set_(name, self, func):
"Used to set the attribute a single time using the given function."
setattr(self._attr_data_, name, func())
if hasattr(self._attr_func_, name):
delattr(self._attr_func_, name)
setattr(
type(self),
name,
... | [
"def",
"_setable_set_",
"(",
"name",
",",
"self",
",",
"func",
")",
":",
"setattr",
"(",
"self",
".",
"_attr_data_",
",",
"name",
",",
"func",
"(",
")",
")",
"if",
"hasattr",
"(",
"self",
".",
"_attr_func_",
",",
"name",
")",
":",
"delattr",
"(",
"... | Used to set the attribute a single time using the given function. | [
"Used",
"to",
"set",
"the",
"attribute",
"a",
"single",
"time",
"using",
"the",
"given",
"function",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L388-L402 |
52,223 | xlorepdarkhelm/config | xdh/_config.py | BaseConfig._set_attr | def _set_attr(self, name, doc=None, preload=False):
"Initially sets up an attribute."
if doc is None:
doc = 'The {name} attribute.'.format(name=name)
if not hasattr(self._attr_func_, name):
attr_prop = property(
functools.partial(self._setable_get_, name... | python | def _set_attr(self, name, doc=None, preload=False):
"Initially sets up an attribute."
if doc is None:
doc = 'The {name} attribute.'.format(name=name)
if not hasattr(self._attr_func_, name):
attr_prop = property(
functools.partial(self._setable_get_, name... | [
"def",
"_set_attr",
"(",
"self",
",",
"name",
",",
"doc",
"=",
"None",
",",
"preload",
"=",
"False",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc",
"=",
"'The {name} attribute.'",
".",
"format",
"(",
"name",
"=",
"name",
")",
"if",
"not",
"hasattr"... | Initially sets up an attribute. | [
"Initially",
"sets",
"up",
"an",
"attribute",
"."
] | c973d02f6500c7719441e016bc9c3df84104e392 | https://github.com/xlorepdarkhelm/config/blob/c973d02f6500c7719441e016bc9c3df84104e392/xdh/_config.py#L404-L432 |
52,224 | sci-bots/pygtkhelpers | pygtkhelpers/ui/dialogs.py | simple | def simple(type, short, long=None,
parent=None, buttons=gtk.BUTTONS_OK, default=None, **kw):
"""A simple dialog
:param type: The type of dialog
:param short: The short description
:param long: The long description
:param parent: The parent Window to make this dialog transient to
:par... | python | def simple(type, short, long=None,
parent=None, buttons=gtk.BUTTONS_OK, default=None, **kw):
"""A simple dialog
:param type: The type of dialog
:param short: The short description
:param long: The long description
:param parent: The parent Window to make this dialog transient to
:par... | [
"def",
"simple",
"(",
"type",
",",
"short",
",",
"long",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"buttons",
"=",
"gtk",
".",
"BUTTONS_OK",
",",
"default",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"buttons",
"==",
"gtk",
".",
"BUTTO... | A simple dialog
:param type: The type of dialog
:param short: The short description
:param long: The long description
:param parent: The parent Window to make this dialog transient to
:param buttons: A buttons enum
:param default: A default response | [
"A",
"simple",
"dialog"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/dialogs.py#L184-L198 |
52,225 | sci-bots/pygtkhelpers | pygtkhelpers/ui/dialogs.py | open_filechooser | def open_filechooser(title, parent=None, patterns=None,
folder=None, filter=None, multiple=False,
_before_run=None, action=None):
"""An open dialog.
:param parent: window or None
:param patterns: file match patterns
:param folder: initial folder
:param filt... | python | def open_filechooser(title, parent=None, patterns=None,
folder=None, filter=None, multiple=False,
_before_run=None, action=None):
"""An open dialog.
:param parent: window or None
:param patterns: file match patterns
:param folder: initial folder
:param filt... | [
"def",
"open_filechooser",
"(",
"title",
",",
"parent",
"=",
"None",
",",
"patterns",
"=",
"None",
",",
"folder",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"multiple",
"=",
"False",
",",
"_before_run",
"=",
"None",
",",
"action",
"=",
"None",
")",
... | An open dialog.
:param parent: window or None
:param patterns: file match patterns
:param folder: initial folder
:param filter: file filter
Use of filter and patterns at the same time is invalid. | [
"An",
"open",
"dialog",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/dialogs.py#L201-L253 |
52,226 | sci-bots/pygtkhelpers | pygtkhelpers/ui/dialogs.py | save | def save(title='Save', parent=None, current_name='', folder=None,
_before_run=None, _before_overwrite=None):
"""Displays a save dialog."""
filechooser = gtk.FileChooserDialog(title, parent,
gtk.FILE_CHOOSER_ACTION_SAVE,
(gt... | python | def save(title='Save', parent=None, current_name='', folder=None,
_before_run=None, _before_overwrite=None):
"""Displays a save dialog."""
filechooser = gtk.FileChooserDialog(title, parent,
gtk.FILE_CHOOSER_ACTION_SAVE,
(gt... | [
"def",
"save",
"(",
"title",
"=",
"'Save'",
",",
"parent",
"=",
"None",
",",
"current_name",
"=",
"''",
",",
"folder",
"=",
"None",
",",
"_before_run",
"=",
"None",
",",
"_before_overwrite",
"=",
"None",
")",
":",
"filechooser",
"=",
"gtk",
".",
"FileC... | Displays a save dialog. | [
"Displays",
"a",
"save",
"dialog",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/dialogs.py#L267-L299 |
52,227 | zengbin93/zb | zb/data/nan.py | count_nans | def count_nans(df):
"""
Count the total number of NaNs in every column
Parameters
--------------------
df pd.DataFrame
Returns
--------------------
nas_df pd.DataFrame
"""
cols = df.columns
res = []
for col in cols:
length = len(df[col])
n... | python | def count_nans(df):
"""
Count the total number of NaNs in every column
Parameters
--------------------
df pd.DataFrame
Returns
--------------------
nas_df pd.DataFrame
"""
cols = df.columns
res = []
for col in cols:
length = len(df[col])
n... | [
"def",
"count_nans",
"(",
"df",
")",
":",
"cols",
"=",
"df",
".",
"columns",
"res",
"=",
"[",
"]",
"for",
"col",
"in",
"cols",
":",
"length",
"=",
"len",
"(",
"df",
"[",
"col",
"]",
")",
"not_nas",
"=",
"len",
"(",
"df",
"[",
"col",
"]",
".",... | Count the total number of NaNs in every column
Parameters
--------------------
df pd.DataFrame
Returns
--------------------
nas_df pd.DataFrame | [
"Count",
"the",
"total",
"number",
"of",
"NaNs",
"in",
"every",
"column"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/data/nan.py#L6-L32 |
52,228 | armstrong/armstrong.cli | armstrong/cli/main.py | find_project_dir | def find_project_dir(path=os.getcwd()):
"""Attempt to find the project root, returns None if not found"""
path_split = os.path.split(path)
while path_split[1]:
if in_armstrong_project(path):
return path
path = path_split[0]
path_split = os.path.split(path)
# we ran ou... | python | def find_project_dir(path=os.getcwd()):
"""Attempt to find the project root, returns None if not found"""
path_split = os.path.split(path)
while path_split[1]:
if in_armstrong_project(path):
return path
path = path_split[0]
path_split = os.path.split(path)
# we ran ou... | [
"def",
"find_project_dir",
"(",
"path",
"=",
"os",
".",
"getcwd",
"(",
")",
")",
":",
"path_split",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"while",
"path_split",
"[",
"1",
"]",
":",
"if",
"in_armstrong_project",
"(",
"path",
")",
":"... | Attempt to find the project root, returns None if not found | [
"Attempt",
"to",
"find",
"the",
"project",
"root",
"returns",
"None",
"if",
"not",
"found"
] | aaf433030be229cbbf241b14059dbe6613d0edc9 | https://github.com/armstrong/armstrong.cli/blob/aaf433030be229cbbf241b14059dbe6613d0edc9/armstrong/cli/main.py#L20-L29 |
52,229 | sci-bots/pygtkhelpers | pygtkhelpers/debug/console.py | _commonprefix | def _commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m:
return ''
prefix = m[0]
for item in m:
for i in range(len(prefix)):
if prefix[:i+1] != item[:i+1]:
prefix = prefix[:i]
if i == 0:
... | python | def _commonprefix(m):
"Given a list of pathnames, returns the longest common leading component"
if not m:
return ''
prefix = m[0]
for item in m:
for i in range(len(prefix)):
if prefix[:i+1] != item[:i+1]:
prefix = prefix[:i]
if i == 0:
... | [
"def",
"_commonprefix",
"(",
"m",
")",
":",
"if",
"not",
"m",
":",
"return",
"''",
"prefix",
"=",
"m",
"[",
"0",
"]",
"for",
"item",
"in",
"m",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"prefix",
")",
")",
":",
"if",
"prefix",
"[",
":"... | Given a list of pathnames, returns the longest common leading component | [
"Given",
"a",
"list",
"of",
"pathnames",
"returns",
"the",
"longest",
"common",
"leading",
"component"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/debug/console.py#L56-L68 |
52,230 | the01/python-floscraper | floscraper/cache.py | Cache.prepare_headers | def prepare_headers(self, headers, cache_info=None):
"""
Prepare headers object for request (add cache information
:param headers: Headers object
:type headers: dict
:param cache_info: Cache information to add
:type cache_info: floscraper.models.CacheInfo
:return... | python | def prepare_headers(self, headers, cache_info=None):
"""
Prepare headers object for request (add cache information
:param headers: Headers object
:type headers: dict
:param cache_info: Cache information to add
:type cache_info: floscraper.models.CacheInfo
:return... | [
"def",
"prepare_headers",
"(",
"self",
",",
"headers",
",",
"cache_info",
"=",
"None",
")",
":",
"if",
"self",
".",
"use_advanced",
"and",
"cache_info",
":",
"hkeys",
"=",
"headers",
".",
"keys",
"(",
")",
"if",
"cache_info",
".",
"access_time",
"and",
"... | Prepare headers object for request (add cache information
:param headers: Headers object
:type headers: dict
:param cache_info: Cache information to add
:type cache_info: floscraper.models.CacheInfo
:return: Prepared headers
:rtype: dict | [
"Prepare",
"headers",
"object",
"for",
"request",
"(",
"add",
"cache",
"information"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/cache.py#L74-L93 |
52,231 | the01/python-floscraper | floscraper/cache.py | Cache.get | def get(self, url, ignore_access_time=False):
"""
Try to retrieve url from cache if available
:param url: Url to retrieve
:type url: str | unicode
:param ignore_access_time: Should ignore the access time
:type ignore_access_time: bool
:return: (data, CacheInfo)
... | python | def get(self, url, ignore_access_time=False):
"""
Try to retrieve url from cache if available
:param url: Url to retrieve
:type url: str | unicode
:param ignore_access_time: Should ignore the access time
:type ignore_access_time: bool
:return: (data, CacheInfo)
... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"ignore_access_time",
"=",
"False",
")",
":",
"key",
"=",
"hashlib",
".",
"md5",
"(",
"url",
")",
".",
"hexdigest",
"(",
")",
"accessed",
"=",
"self",
".",
"_cache_meta_get",
"(",
"key",
")",
"if",
"not",
... | Try to retrieve url from cache if available
:param url: Url to retrieve
:type url: str | unicode
:param ignore_access_time: Should ignore the access time
:type ignore_access_time: bool
:return: (data, CacheInfo)
None, None -> not found in cache
None, Cach... | [
"Try",
"to",
"retrieve",
"url",
"from",
"cache",
"if",
"available"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/cache.py#L111-L150 |
52,232 | the01/python-floscraper | floscraper/cache.py | Cache.update | def update(self, url, cache_info=None):
"""
Update cache information for url
:param url: Update for this url
:type url: str | unicode
:param cache_info: Cache info
:type cache_info: floscraper.models.CacheInfo
:rtype: None
"""
key = hashlib.md5(ur... | python | def update(self, url, cache_info=None):
"""
Update cache information for url
:param url: Update for this url
:type url: str | unicode
:param cache_info: Cache info
:type cache_info: floscraper.models.CacheInfo
:rtype: None
"""
key = hashlib.md5(ur... | [
"def",
"update",
"(",
"self",
",",
"url",
",",
"cache_info",
"=",
"None",
")",
":",
"key",
"=",
"hashlib",
".",
"md5",
"(",
"url",
")",
".",
"hexdigest",
"(",
")",
"access_time",
"=",
"None",
"if",
"not",
"cache_info",
":",
"cache_info",
"=",
"CacheI... | Update cache information for url
:param url: Update for this url
:type url: str | unicode
:param cache_info: Cache info
:type cache_info: floscraper.models.CacheInfo
:rtype: None | [
"Update",
"cache",
"information",
"for",
"url"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/cache.py#L152-L168 |
52,233 | the01/python-floscraper | floscraper/cache.py | Cache.put | def put(self, url, html, cache_info=None):
"""
Put response into cache
:param url: Url to cache
:type url: str | unicode
:param html: HTML content of url
:type html: str | unicode
:param cache_info: Cache Info (default: None)
:type cache_info: floscraper.... | python | def put(self, url, html, cache_info=None):
"""
Put response into cache
:param url: Url to cache
:type url: str | unicode
:param html: HTML content of url
:type html: str | unicode
:param cache_info: Cache Info (default: None)
:type cache_info: floscraper.... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"html",
",",
"cache_info",
"=",
"None",
")",
":",
"key",
"=",
"hashlib",
".",
"md5",
"(",
"url",
")",
".",
"hexdigest",
"(",
")",
"try",
":",
"self",
".",
"_cache_set",
"(",
"key",
",",
"html",
")",
"... | Put response into cache
:param url: Url to cache
:type url: str | unicode
:param html: HTML content of url
:type html: str | unicode
:param cache_info: Cache Info (default: None)
:type cache_info: floscraper.models.CacheInfo
:rtype: None | [
"Put",
"response",
"into",
"cache"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/cache.py#L170-L189 |
52,234 | AbletonAG/abl.vpath | abl/vpath/base/uriparse.py | urisplit | def urisplit(uri):
"""
Basic URI Parser according to STD66 aka RFC3986
>>> urisplit("scheme://authority/path?query#fragment")
('scheme', 'authority', 'path', 'query', 'fragment')
"""
inner_part = re.compile(r'\(\(.*?\)\)')
m = inner_part.search(uri)
inner_value = ''
if m i... | python | def urisplit(uri):
"""
Basic URI Parser according to STD66 aka RFC3986
>>> urisplit("scheme://authority/path?query#fragment")
('scheme', 'authority', 'path', 'query', 'fragment')
"""
inner_part = re.compile(r'\(\(.*?\)\)')
m = inner_part.search(uri)
inner_value = ''
if m i... | [
"def",
"urisplit",
"(",
"uri",
")",
":",
"inner_part",
"=",
"re",
".",
"compile",
"(",
"r'\\(\\(.*?\\)\\)'",
")",
"m",
"=",
"inner_part",
".",
"search",
"(",
"uri",
")",
"inner_value",
"=",
"''",
"if",
"m",
"is",
"not",
"None",
":",
"inner_value",
"=",... | Basic URI Parser according to STD66 aka RFC3986
>>> urisplit("scheme://authority/path?query#fragment")
('scheme', 'authority', 'path', 'query', 'fragment') | [
"Basic",
"URI",
"Parser",
"according",
"to",
"STD66",
"aka",
"RFC3986"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/uriparse.py#L60-L89 |
52,235 | AbletonAG/abl.vpath | abl/vpath/base/uriparse.py | split_authority | def split_authority(authority):
"""
Basic authority parser that splits authority into component parts
>>> split_authority("user:password@host:port")
('user', 'password', 'host', 'port')
"""
if '@' in authority:
userinfo, hostport = authority.split('@', 1)
else:
use... | python | def split_authority(authority):
"""
Basic authority parser that splits authority into component parts
>>> split_authority("user:password@host:port")
('user', 'password', 'host', 'port')
"""
if '@' in authority:
userinfo, hostport = authority.split('@', 1)
else:
use... | [
"def",
"split_authority",
"(",
"authority",
")",
":",
"if",
"'@'",
"in",
"authority",
":",
"userinfo",
",",
"hostport",
"=",
"authority",
".",
"split",
"(",
"'@'",
",",
"1",
")",
"else",
":",
"userinfo",
",",
"hostport",
"=",
"None",
",",
"authority",
... | Basic authority parser that splits authority into component parts
>>> split_authority("user:password@host:port")
('user', 'password', 'host', 'port') | [
"Basic",
"authority",
"parser",
"that",
"splits",
"authority",
"into",
"component",
"parts"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/uriparse.py#L114-L136 |
52,236 | AbletonAG/abl.vpath | abl/vpath/base/uriparse.py | URIParser.parse | def parse(self, uri, defaults=None):
"""Parse the URI.
uri is the uri to parse.
defaults is a scheme-dependent list of values to use if there
is no value for that part in the supplied URI.
The return value is a tuple of scheme-dependent length.
"""
return tuple(... | python | def parse(self, uri, defaults=None):
"""Parse the URI.
uri is the uri to parse.
defaults is a scheme-dependent list of values to use if there
is no value for that part in the supplied URI.
The return value is a tuple of scheme-dependent length.
"""
return tuple(... | [
"def",
"parse",
"(",
"self",
",",
"uri",
",",
"defaults",
"=",
"None",
")",
":",
"return",
"tuple",
"(",
"[",
"self",
".",
"scheme_of",
"(",
"uri",
")",
"]",
"+",
"list",
"(",
"self",
".",
"parser_for",
"(",
"uri",
")",
"(",
"defaults",
")",
".",... | Parse the URI.
uri is the uri to parse.
defaults is a scheme-dependent list of values to use if there
is no value for that part in the supplied URI.
The return value is a tuple of scheme-dependent length. | [
"Parse",
"the",
"URI",
"."
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/uriparse.py#L300-L309 |
52,237 | AbletonAG/abl.vpath | abl/vpath/base/uriparse.py | URIParser.unparse | def unparse(self, pieces, defaults=None):
"""Join the parts of a URI back together to form a valid URI.
pieces is a tuble of URI pieces. The scheme must be in pieces[0] so that
the rest of the pieces can be interpreted.
"""
return self.parser_for(pieces[0])(defaults).unparse(p... | python | def unparse(self, pieces, defaults=None):
"""Join the parts of a URI back together to form a valid URI.
pieces is a tuble of URI pieces. The scheme must be in pieces[0] so that
the rest of the pieces can be interpreted.
"""
return self.parser_for(pieces[0])(defaults).unparse(p... | [
"def",
"unparse",
"(",
"self",
",",
"pieces",
",",
"defaults",
"=",
"None",
")",
":",
"return",
"self",
".",
"parser_for",
"(",
"pieces",
"[",
"0",
"]",
")",
"(",
"defaults",
")",
".",
"unparse",
"(",
"pieces",
")"
] | Join the parts of a URI back together to form a valid URI.
pieces is a tuble of URI pieces. The scheme must be in pieces[0] so that
the rest of the pieces can be interpreted. | [
"Join",
"the",
"parts",
"of",
"a",
"URI",
"back",
"together",
"to",
"form",
"a",
"valid",
"URI",
"."
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/uriparse.py#L311-L318 |
52,238 | AbletonAG/abl.vpath | abl/vpath/base/uriparse.py | URIParser.parser_for | def parser_for(self, uri):
"""Return the Parser object used to parse a particular URI.
Parser objects are required to have only 'parse' and 'unparse' methods.
"""
return self._parsers.get(self.scheme_of(uri), DefaultURIParser) | python | def parser_for(self, uri):
"""Return the Parser object used to parse a particular URI.
Parser objects are required to have only 'parse' and 'unparse' methods.
"""
return self._parsers.get(self.scheme_of(uri), DefaultURIParser) | [
"def",
"parser_for",
"(",
"self",
",",
"uri",
")",
":",
"return",
"self",
".",
"_parsers",
".",
"get",
"(",
"self",
".",
"scheme_of",
"(",
"uri",
")",
",",
"DefaultURIParser",
")"
] | Return the Parser object used to parse a particular URI.
Parser objects are required to have only 'parse' and 'unparse' methods. | [
"Return",
"the",
"Parser",
"object",
"used",
"to",
"parse",
"a",
"particular",
"URI",
"."
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/uriparse.py#L329-L335 |
52,239 | RI-imaging/qpsphere | qpsphere/models/_bhfield/wrap.py | clear_temp | def clear_temp(wdir, rmdir=True):
"""Remove all files in wdir"""
wdir = pathlib.Path(wdir)
extensions = ["*.log", "*.dat", "*.txt"]
for ext in extensions:
for ff in wdir.glob(ext):
ff.unlink()
if rmdir:
wdir.rmdir() | python | def clear_temp(wdir, rmdir=True):
"""Remove all files in wdir"""
wdir = pathlib.Path(wdir)
extensions = ["*.log", "*.dat", "*.txt"]
for ext in extensions:
for ff in wdir.glob(ext):
ff.unlink()
if rmdir:
wdir.rmdir() | [
"def",
"clear_temp",
"(",
"wdir",
",",
"rmdir",
"=",
"True",
")",
":",
"wdir",
"=",
"pathlib",
".",
"Path",
"(",
"wdir",
")",
"extensions",
"=",
"[",
"\"*.log\"",
",",
"\"*.dat\"",
",",
"\"*.txt\"",
"]",
"for",
"ext",
"in",
"extensions",
":",
"for",
... | Remove all files in wdir | [
"Remove",
"all",
"files",
"in",
"wdir"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/_bhfield/wrap.py#L18-L28 |
52,240 | RI-imaging/qpsphere | qpsphere/models/_bhfield/wrap.py | load_field | def load_field(wdir, shape_grid):
"""Extract electric field from simulation file "V_0Ereim.dat"
Parameters
----------
wdir: str or pathlib.Path
path to the working directory
shape_grid: tuple of ints
the shape of the simulation data grid
Notes
-----
These are the files ... | python | def load_field(wdir, shape_grid):
"""Extract electric field from simulation file "V_0Ereim.dat"
Parameters
----------
wdir: str or pathlib.Path
path to the working directory
shape_grid: tuple of ints
the shape of the simulation data grid
Notes
-----
These are the files ... | [
"def",
"load_field",
"(",
"wdir",
",",
"shape_grid",
")",
":",
"wdir",
"=",
"pathlib",
".",
"Path",
"(",
"wdir",
")",
"check_simulation",
"(",
"wdir",
")",
"field_file",
"=",
"wdir",
"/",
"\"V_0Ereim.dat\"",
"a",
"=",
"np",
".",
"loadtxt",
"(",
"field_fi... | Extract electric field from simulation file "V_0Ereim.dat"
Parameters
----------
wdir: str or pathlib.Path
path to the working directory
shape_grid: tuple of ints
the shape of the simulation data grid
Notes
-----
These are the files present in the working directory
bhf... | [
"Extract",
"electric",
"field",
"from",
"simulation",
"file",
"V_0Ereim",
".",
"dat"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/_bhfield/wrap.py#L31-L118 |
52,241 | RI-imaging/qpsphere | qpsphere/models/_bhfield/wrap.py | check_simulation | def check_simulation(wdir):
"""
Check bhdebug.txt to make sure that you specify enough digits to
overcome roundoff errors.
"""
wdir = pathlib.Path(wdir)
field = wdir / "V_0Ereim.dat"
if not (field.exists() and
field.stat().st_size > 130):
msg = "Output {} does not exist o... | python | def check_simulation(wdir):
"""
Check bhdebug.txt to make sure that you specify enough digits to
overcome roundoff errors.
"""
wdir = pathlib.Path(wdir)
field = wdir / "V_0Ereim.dat"
if not (field.exists() and
field.stat().st_size > 130):
msg = "Output {} does not exist o... | [
"def",
"check_simulation",
"(",
"wdir",
")",
":",
"wdir",
"=",
"pathlib",
".",
"Path",
"(",
"wdir",
")",
"field",
"=",
"wdir",
"/",
"\"V_0Ereim.dat\"",
"if",
"not",
"(",
"field",
".",
"exists",
"(",
")",
"and",
"field",
".",
"stat",
"(",
")",
".",
... | Check bhdebug.txt to make sure that you specify enough digits to
overcome roundoff errors. | [
"Check",
"bhdebug",
".",
"txt",
"to",
"make",
"sure",
"that",
"you",
"specify",
"enough",
"digits",
"to",
"overcome",
"roundoff",
"errors",
"."
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/_bhfield/wrap.py#L306-L316 |
52,242 | Pixelapse/pyglass | pyglass/sketch/api.py | slices | def slices(src_path):
''' Return slices as a flat list '''
pages = list_slices(src_path)
slices = []
for page in pages:
slices.extend(page.slices)
return slices | python | def slices(src_path):
''' Return slices as a flat list '''
pages = list_slices(src_path)
slices = []
for page in pages:
slices.extend(page.slices)
return slices | [
"def",
"slices",
"(",
"src_path",
")",
":",
"pages",
"=",
"list_slices",
"(",
"src_path",
")",
"slices",
"=",
"[",
"]",
"for",
"page",
"in",
"pages",
":",
"slices",
".",
"extend",
"(",
"page",
".",
"slices",
")",
"return",
"slices"
] | Return slices as a flat list | [
"Return",
"slices",
"as",
"a",
"flat",
"list"
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/sketch/api.py#L67-L73 |
52,243 | Pixelapse/pyglass | pyglass/sketch/api.py | artboards | def artboards(src_path):
''' Return artboards as a flat list '''
pages = list_artboards(src_path)
artboards = []
for page in pages:
artboards.extend(page.artboards)
return artboards | python | def artboards(src_path):
''' Return artboards as a flat list '''
pages = list_artboards(src_path)
artboards = []
for page in pages:
artboards.extend(page.artboards)
return artboards | [
"def",
"artboards",
"(",
"src_path",
")",
":",
"pages",
"=",
"list_artboards",
"(",
"src_path",
")",
"artboards",
"=",
"[",
"]",
"for",
"page",
"in",
"pages",
":",
"artboards",
".",
"extend",
"(",
"page",
".",
"artboards",
")",
"return",
"artboards"
] | Return artboards as a flat list | [
"Return",
"artboards",
"as",
"a",
"flat",
"list"
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/sketch/api.py#L76-L82 |
52,244 | boris-savic/python-mbills | python_mbills/base.py | MBillsBase.verify_response | def verify_response(self, response_json, signed_id_name='transactionid'):
"""
Verify the response message.
:param response_json:
:param signed_id_name:
:return:
"""
auth_json = response_json.get('auth', {})
nonce = auth_json.get('nonce', '')
t... | python | def verify_response(self, response_json, signed_id_name='transactionid'):
"""
Verify the response message.
:param response_json:
:param signed_id_name:
:return:
"""
auth_json = response_json.get('auth', {})
nonce = auth_json.get('nonce', '')
t... | [
"def",
"verify_response",
"(",
"self",
",",
"response_json",
",",
"signed_id_name",
"=",
"'transactionid'",
")",
":",
"auth_json",
"=",
"response_json",
".",
"get",
"(",
"'auth'",
",",
"{",
"}",
")",
"nonce",
"=",
"auth_json",
".",
"get",
"(",
"'nonce'",
"... | Verify the response message.
:param response_json:
:param signed_id_name:
:return: | [
"Verify",
"the",
"response",
"message",
"."
] | a2147810c8c54b9242d9bcc2218622f1e19f9ac3 | https://github.com/boris-savic/python-mbills/blob/a2147810c8c54b9242d9bcc2218622f1e19f9ac3/python_mbills/base.py#L69-L85 |
52,245 | oksome/Tumulus | tumulus/element.py | Element.soup | def soup(self):
'''
Returns HTML as a BeautifulSoup element.
'''
components_soup = Tag(name=self.tagname, builder=BUILDER)
components_soup.attrs = self.attributes
for c in flatten(self.components):
if hasattr(c, 'soup'):
components_soup.app... | python | def soup(self):
'''
Returns HTML as a BeautifulSoup element.
'''
components_soup = Tag(name=self.tagname, builder=BUILDER)
components_soup.attrs = self.attributes
for c in flatten(self.components):
if hasattr(c, 'soup'):
components_soup.app... | [
"def",
"soup",
"(",
"self",
")",
":",
"components_soup",
"=",
"Tag",
"(",
"name",
"=",
"self",
".",
"tagname",
",",
"builder",
"=",
"BUILDER",
")",
"components_soup",
".",
"attrs",
"=",
"self",
".",
"attributes",
"for",
"c",
"in",
"flatten",
"(",
"self... | Returns HTML as a BeautifulSoup element. | [
"Returns",
"HTML",
"as",
"a",
"BeautifulSoup",
"element",
"."
] | 20fca0e251d6f1825c33e61a8d497b62a8cbc0da | https://github.com/oksome/Tumulus/blob/20fca0e251d6f1825c33e61a8d497b62a8cbc0da/tumulus/element.py#L42-L57 |
52,246 | oksome/Tumulus | tumulus/element.py | Element.plugins | def plugins(self, deduplicate=False):
'''
Returns a flattened list of all plugins used by page components.
'''
plugins = []
for c in self.components:
if hasattr(c, 'plugins'):
plugins += c.plugins()
elif isinstance(c, Lib):
... | python | def plugins(self, deduplicate=False):
'''
Returns a flattened list of all plugins used by page components.
'''
plugins = []
for c in self.components:
if hasattr(c, 'plugins'):
plugins += c.plugins()
elif isinstance(c, Lib):
... | [
"def",
"plugins",
"(",
"self",
",",
"deduplicate",
"=",
"False",
")",
":",
"plugins",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"components",
":",
"if",
"hasattr",
"(",
"c",
",",
"'plugins'",
")",
":",
"plugins",
"+=",
"c",
".",
"plugins",
"(",... | Returns a flattened list of all plugins used by page components. | [
"Returns",
"a",
"flattened",
"list",
"of",
"all",
"plugins",
"used",
"by",
"page",
"components",
"."
] | 20fca0e251d6f1825c33e61a8d497b62a8cbc0da | https://github.com/oksome/Tumulus/blob/20fca0e251d6f1825c33e61a8d497b62a8cbc0da/tumulus/element.py#L62-L77 |
52,247 | oksome/Tumulus | tumulus/element.py | HTMLElement.soup | def soup(self):
'''
Running plugins and adding an HTML doctype to the
generated Tag HTML.
'''
dom = BeautifulSoup('<!DOCTYPE html>')
# BeautifulSoup behaves differently if lxml is installed or not,
# and will create a basic HTML structure if lxml is insta... | python | def soup(self):
'''
Running plugins and adding an HTML doctype to the
generated Tag HTML.
'''
dom = BeautifulSoup('<!DOCTYPE html>')
# BeautifulSoup behaves differently if lxml is installed or not,
# and will create a basic HTML structure if lxml is insta... | [
"def",
"soup",
"(",
"self",
")",
":",
"dom",
"=",
"BeautifulSoup",
"(",
"'<!DOCTYPE html>'",
")",
"# BeautifulSoup behaves differently if lxml is installed or not,",
"# and will create a basic HTML structure if lxml is installed.",
"if",
"len",
"(",
"dom",
")",
">",
"1",
":... | Running plugins and adding an HTML doctype to the
generated Tag HTML. | [
"Running",
"plugins",
"and",
"adding",
"an",
"HTML",
"doctype",
"to",
"the",
"generated",
"Tag",
"HTML",
"."
] | 20fca0e251d6f1825c33e61a8d497b62a8cbc0da | https://github.com/oksome/Tumulus/blob/20fca0e251d6f1825c33e61a8d497b62a8cbc0da/tumulus/element.py#L86-L104 |
52,248 | dcaune/perseus-lib-python-common | majormode/perseus/model/place.py | Place._eq__ | def _eq__(self, other):
"""
Compare the current place object to another passed to the comparison
method. The two place objects must have the same identification, even
if some of their attributes might be different.
@param other: a ``Place`` instance to compare with the current ... | python | def _eq__(self, other):
"""
Compare the current place object to another passed to the comparison
method. The two place objects must have the same identification, even
if some of their attributes might be different.
@param other: a ``Place`` instance to compare with the current ... | [
"def",
"_eq__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"place_id",
"and",
"other",
".",
"place_id",
"and",
"self",
".",
"place_id",
"==",
"other",
".",
"place_id"
] | Compare the current place object to another passed to the comparison
method. The two place objects must have the same identification, even
if some of their attributes might be different.
@param other: a ``Place`` instance to compare with the current place
object.
@return: ... | [
"Compare",
"the",
"current",
"place",
"object",
"to",
"another",
"passed",
"to",
"the",
"comparison",
"method",
".",
"The",
"two",
"place",
"objects",
"must",
"have",
"the",
"same",
"identification",
"even",
"if",
"some",
"of",
"their",
"attributes",
"might",
... | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/place.py#L138-L151 |
52,249 | dcaune/perseus-lib-python-common | majormode/perseus/model/place.py | Place.from_json | def from_json(payload):
"""
Build a ``Place`` instance from the specified JSON object.
@param payload: JSON representation of a place::
{
"area_id": string,
"address": {
component_type: string,
...
... | python | def from_json(payload):
"""
Build a ``Place`` instance from the specified JSON object.
@param payload: JSON representation of a place::
{
"area_id": string,
"address": {
component_type: string,
...
... | [
"def",
"from_json",
"(",
"payload",
")",
":",
"return",
"payload",
"and",
"Place",
"(",
"[",
"(",
"float",
"(",
"lon",
")",
",",
"float",
"(",
"lat",
")",
",",
"float",
"(",
"alt",
")",
")",
"for",
"(",
"lon",
",",
"lat",
",",
"alt",
")",
"in",... | Build a ``Place`` instance from the specified JSON object.
@param payload: JSON representation of a place::
{
"area_id": string,
"address": {
component_type: string,
...
} \ [
{
... | [
"Build",
"a",
"Place",
"instance",
"from",
"the",
"specified",
"JSON",
"object",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/place.py#L323-L490 |
52,250 | andreacioni/pycommon | pycommon/dynamo.py | load_classes | def load_classes(package_str):
'''Load all classes from modules of a given `package_str`. All class instances are stored in a case-insensitive `dict`
and returned. If a package doesn't contain any class `None` is returned'''
_logger.debug('Loading all modules from %s', package_str)
package = importlib.... | python | def load_classes(package_str):
'''Load all classes from modules of a given `package_str`. All class instances are stored in a case-insensitive `dict`
and returned. If a package doesn't contain any class `None` is returned'''
_logger.debug('Loading all modules from %s', package_str)
package = importlib.... | [
"def",
"load_classes",
"(",
"package_str",
")",
":",
"_logger",
".",
"debug",
"(",
"'Loading all modules from %s'",
",",
"package_str",
")",
"package",
"=",
"importlib",
".",
"import_module",
"(",
"package_str",
")",
"package_path",
"=",
"package",
".",
"__path__"... | Load all classes from modules of a given `package_str`. All class instances are stored in a case-insensitive `dict`
and returned. If a package doesn't contain any class `None` is returned | [
"Load",
"all",
"classes",
"from",
"modules",
"of",
"a",
"given",
"package_str",
".",
"All",
"class",
"instances",
"are",
"stored",
"in",
"a",
"case",
"-",
"insensitive",
"dict",
"and",
"returned",
".",
"If",
"a",
"package",
"doesn",
"t",
"contain",
"any",
... | b98c5c2815d25e5e79c2edb51ac76ad600510213 | https://github.com/andreacioni/pycommon/blob/b98c5c2815d25e5e79c2edb51ac76ad600510213/pycommon/dynamo.py#L14-L47 |
52,251 | andreacioni/pycommon | pycommon/dynamo.py | get | def get(package_str, classname):
'''Retrieve from the internal cache a class instance. All arguments are case-insensitive'''
if (package_str in _dynamo_cache) and (classname in _dynamo_cache[package_str]):
return _dynamo_cache[package_str][classname]
return None | python | def get(package_str, classname):
'''Retrieve from the internal cache a class instance. All arguments are case-insensitive'''
if (package_str in _dynamo_cache) and (classname in _dynamo_cache[package_str]):
return _dynamo_cache[package_str][classname]
return None | [
"def",
"get",
"(",
"package_str",
",",
"classname",
")",
":",
"if",
"(",
"package_str",
"in",
"_dynamo_cache",
")",
"and",
"(",
"classname",
"in",
"_dynamo_cache",
"[",
"package_str",
"]",
")",
":",
"return",
"_dynamo_cache",
"[",
"package_str",
"]",
"[",
... | Retrieve from the internal cache a class instance. All arguments are case-insensitive | [
"Retrieve",
"from",
"the",
"internal",
"cache",
"a",
"class",
"instance",
".",
"All",
"arguments",
"are",
"case",
"-",
"insensitive"
] | b98c5c2815d25e5e79c2edb51ac76ad600510213 | https://github.com/andreacioni/pycommon/blob/b98c5c2815d25e5e79c2edb51ac76ad600510213/pycommon/dynamo.py#L56-L60 |
52,252 | Josef-Friedrich/tmep | tmep/template.py | ex_literal | def ex_literal(val):
"""An int, float, long, bool, string, or None literal with the given
value.
"""
if val is None:
return ast.Name('None', ast.Load())
elif isinstance(val, int):
return ast.Num(val)
elif isinstance(val, bool):
return ast.Name(bytes(val), ast.Load())
... | python | def ex_literal(val):
"""An int, float, long, bool, string, or None literal with the given
value.
"""
if val is None:
return ast.Name('None', ast.Load())
elif isinstance(val, int):
return ast.Num(val)
elif isinstance(val, bool):
return ast.Name(bytes(val), ast.Load())
... | [
"def",
"ex_literal",
"(",
"val",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"ast",
".",
"Name",
"(",
"'None'",
",",
"ast",
".",
"Load",
"(",
")",
")",
"elif",
"isinstance",
"(",
"val",
",",
"int",
")",
":",
"return",
"ast",
".",
"Num",
... | An int, float, long, bool, string, or None literal with the given
value. | [
"An",
"int",
"float",
"long",
"bool",
"string",
"or",
"None",
"literal",
"with",
"the",
"given",
"value",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L69-L81 |
52,253 | Josef-Friedrich/tmep | tmep/template.py | ex_varassign | def ex_varassign(name, expr):
"""Assign an expression into a single variable. The expression may
either be an `ast.expr` object or a value to be used as a literal.
"""
if not isinstance(expr, ast.expr):
expr = ex_literal(expr)
return ast.Assign([ex_lvalue(name)], expr) | python | def ex_varassign(name, expr):
"""Assign an expression into a single variable. The expression may
either be an `ast.expr` object or a value to be used as a literal.
"""
if not isinstance(expr, ast.expr):
expr = ex_literal(expr)
return ast.Assign([ex_lvalue(name)], expr) | [
"def",
"ex_varassign",
"(",
"name",
",",
"expr",
")",
":",
"if",
"not",
"isinstance",
"(",
"expr",
",",
"ast",
".",
"expr",
")",
":",
"expr",
"=",
"ex_literal",
"(",
"expr",
")",
"return",
"ast",
".",
"Assign",
"(",
"[",
"ex_lvalue",
"(",
"name",
"... | Assign an expression into a single variable. The expression may
either be an `ast.expr` object or a value to be used as a literal. | [
"Assign",
"an",
"expression",
"into",
"a",
"single",
"variable",
".",
"The",
"expression",
"may",
"either",
"be",
"an",
"ast",
".",
"expr",
"object",
"or",
"a",
"value",
"to",
"be",
"used",
"as",
"a",
"literal",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L84-L90 |
52,254 | Josef-Friedrich/tmep | tmep/template.py | ex_call | def ex_call(func, args):
"""A function-call expression with only positional parameters. The
function may be an expression or the name of a function. Each
argument may be an expression or a value to be used as a literal.
"""
if isinstance(func, str):
func = ex_rvalue(func)
args = list(ar... | python | def ex_call(func, args):
"""A function-call expression with only positional parameters. The
function may be an expression or the name of a function. Each
argument may be an expression or a value to be used as a literal.
"""
if isinstance(func, str):
func = ex_rvalue(func)
args = list(ar... | [
"def",
"ex_call",
"(",
"func",
",",
"args",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"str",
")",
":",
"func",
"=",
"ex_rvalue",
"(",
"func",
")",
"args",
"=",
"list",
"(",
"args",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"args",
... | A function-call expression with only positional parameters. The
function may be an expression or the name of a function. Each
argument may be an expression or a value to be used as a literal. | [
"A",
"function",
"-",
"call",
"expression",
"with",
"only",
"positional",
"parameters",
".",
"The",
"function",
"may",
"be",
"an",
"expression",
"or",
"the",
"name",
"of",
"a",
"function",
".",
"Each",
"argument",
"may",
"be",
"an",
"expression",
"or",
"a"... | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L93-L109 |
52,255 | Josef-Friedrich/tmep | tmep/template.py | compile_func | def compile_func(arg_names, statements, name='_the_func', debug=False):
"""Compile a list of statements as the body of a function and return
the resulting Python function. If `debug`, then print out the
bytecode of the compiled function.
"""
func_def = ast.FunctionDef(
name=name,
arg... | python | def compile_func(arg_names, statements, name='_the_func', debug=False):
"""Compile a list of statements as the body of a function and return
the resulting Python function. If `debug`, then print out the
bytecode of the compiled function.
"""
func_def = ast.FunctionDef(
name=name,
arg... | [
"def",
"compile_func",
"(",
"arg_names",
",",
"statements",
",",
"name",
"=",
"'_the_func'",
",",
"debug",
"=",
"False",
")",
":",
"func_def",
"=",
"ast",
".",
"FunctionDef",
"(",
"name",
"=",
"name",
",",
"args",
"=",
"ast",
".",
"arguments",
"(",
"ar... | Compile a list of statements as the body of a function and return
the resulting Python function. If `debug`, then print out the
bytecode of the compiled function. | [
"Compile",
"a",
"list",
"of",
"statements",
"as",
"the",
"body",
"of",
"a",
"function",
"and",
"return",
"the",
"resulting",
"Python",
"function",
".",
"If",
"debug",
"then",
"print",
"out",
"the",
"bytecode",
"of",
"the",
"compiled",
"function",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L112-L143 |
52,256 | Josef-Friedrich/tmep | tmep/template.py | _parse | def _parse(template):
"""Parse a top-level template string Expression. Any extraneous text
is considered literal text.
"""
parser = Parser(template)
parser.parse_expression()
parts = parser.parts
remainder = parser.string[parser.pos:]
if remainder:
parts.append(remainder)
re... | python | def _parse(template):
"""Parse a top-level template string Expression. Any extraneous text
is considered literal text.
"""
parser = Parser(template)
parser.parse_expression()
parts = parser.parts
remainder = parser.string[parser.pos:]
if remainder:
parts.append(remainder)
re... | [
"def",
"_parse",
"(",
"template",
")",
":",
"parser",
"=",
"Parser",
"(",
"template",
")",
"parser",
".",
"parse_expression",
"(",
")",
"parts",
"=",
"parser",
".",
"parts",
"remainder",
"=",
"parser",
".",
"string",
"[",
"parser",
".",
"pos",
":",
"]"... | Parse a top-level template string Expression. Any extraneous text
is considered literal text. | [
"Parse",
"a",
"top",
"-",
"level",
"template",
"string",
"Expression",
".",
"Any",
"extraneous",
"text",
"is",
"considered",
"literal",
"text",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L515-L526 |
52,257 | Josef-Friedrich/tmep | tmep/template.py | Symbol.evaluate | def evaluate(self, env):
"""Evaluate the symbol in the environment, returning a Unicode
string.
"""
if self.ident in env.values:
# Substitute for a value.
return env.values[self.ident]
else:
# Keep original text.
return self.origina... | python | def evaluate(self, env):
"""Evaluate the symbol in the environment, returning a Unicode
string.
"""
if self.ident in env.values:
# Substitute for a value.
return env.values[self.ident]
else:
# Keep original text.
return self.origina... | [
"def",
"evaluate",
"(",
"self",
",",
"env",
")",
":",
"if",
"self",
".",
"ident",
"in",
"env",
".",
"values",
":",
"# Substitute for a value.",
"return",
"env",
".",
"values",
"[",
"self",
".",
"ident",
"]",
"else",
":",
"# Keep original text.",
"return",
... | Evaluate the symbol in the environment, returning a Unicode
string. | [
"Evaluate",
"the",
"symbol",
"in",
"the",
"environment",
"returning",
"a",
"Unicode",
"string",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L157-L166 |
52,258 | Josef-Friedrich/tmep | tmep/template.py | Symbol.translate | def translate(self):
"""Compile the variable lookup."""
ident = self.ident
expr = ex_rvalue(VARIABLE_PREFIX + ident)
return [expr], set([ident]), set() | python | def translate(self):
"""Compile the variable lookup."""
ident = self.ident
expr = ex_rvalue(VARIABLE_PREFIX + ident)
return [expr], set([ident]), set() | [
"def",
"translate",
"(",
"self",
")",
":",
"ident",
"=",
"self",
".",
"ident",
"expr",
"=",
"ex_rvalue",
"(",
"VARIABLE_PREFIX",
"+",
"ident",
")",
"return",
"[",
"expr",
"]",
",",
"set",
"(",
"[",
"ident",
"]",
")",
",",
"set",
"(",
")"
] | Compile the variable lookup. | [
"Compile",
"the",
"variable",
"lookup",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L168-L172 |
52,259 | Josef-Friedrich/tmep | tmep/template.py | Call.evaluate | def evaluate(self, env):
"""Evaluate the function call in the environment, returning a
Unicode string.
"""
if self.ident in env.functions:
arg_vals = [expr.evaluate(env) for expr in self.args]
try:
out = env.functions[self.ident](*arg_vals)
... | python | def evaluate(self, env):
"""Evaluate the function call in the environment, returning a
Unicode string.
"""
if self.ident in env.functions:
arg_vals = [expr.evaluate(env) for expr in self.args]
try:
out = env.functions[self.ident](*arg_vals)
... | [
"def",
"evaluate",
"(",
"self",
",",
"env",
")",
":",
"if",
"self",
".",
"ident",
"in",
"env",
".",
"functions",
":",
"arg_vals",
"=",
"[",
"expr",
".",
"evaluate",
"(",
"env",
")",
"for",
"expr",
"in",
"self",
".",
"args",
"]",
"try",
":",
"out"... | Evaluate the function call in the environment, returning a
Unicode string. | [
"Evaluate",
"the",
"function",
"call",
"in",
"the",
"environment",
"returning",
"a",
"Unicode",
"string",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L186-L200 |
52,260 | Josef-Friedrich/tmep | tmep/template.py | Call.translate | def translate(self):
"""Compile the function call."""
varnames = set()
ident = self.ident
funcnames = set([ident])
arg_exprs = []
for arg in self.args:
subexprs, subvars, subfuncs = arg.translate()
varnames.update(subvars)
funcnames.up... | python | def translate(self):
"""Compile the function call."""
varnames = set()
ident = self.ident
funcnames = set([ident])
arg_exprs = []
for arg in self.args:
subexprs, subvars, subfuncs = arg.translate()
varnames.update(subvars)
funcnames.up... | [
"def",
"translate",
"(",
"self",
")",
":",
"varnames",
"=",
"set",
"(",
")",
"ident",
"=",
"self",
".",
"ident",
"funcnames",
"=",
"set",
"(",
"[",
"ident",
"]",
")",
"arg_exprs",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"sube... | Compile the function call. | [
"Compile",
"the",
"function",
"call",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L202-L231 |
52,261 | Josef-Friedrich/tmep | tmep/template.py | Expression.evaluate | def evaluate(self, env):
"""Evaluate the entire expression in the environment, returning
a Unicode string.
"""
out = []
for part in self.parts:
if isinstance(part, str):
out.append(part)
else:
out.append(part.evaluate(env))
... | python | def evaluate(self, env):
"""Evaluate the entire expression in the environment, returning
a Unicode string.
"""
out = []
for part in self.parts:
if isinstance(part, str):
out.append(part)
else:
out.append(part.evaluate(env))
... | [
"def",
"evaluate",
"(",
"self",
",",
"env",
")",
":",
"out",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"if",
"isinstance",
"(",
"part",
",",
"str",
")",
":",
"out",
".",
"append",
"(",
"part",
")",
"else",
":",
"out",
".",
... | Evaluate the entire expression in the environment, returning
a Unicode string. | [
"Evaluate",
"the",
"entire",
"expression",
"in",
"the",
"environment",
"returning",
"a",
"Unicode",
"string",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L244-L254 |
52,262 | Josef-Friedrich/tmep | tmep/template.py | Expression.translate | def translate(self):
"""Compile the expression to a list of Python AST expressions, a
set of variable names used, and a set of function names.
"""
expressions = []
varnames = set()
funcnames = set()
for part in self.parts:
if isinstance(part, str):
... | python | def translate(self):
"""Compile the expression to a list of Python AST expressions, a
set of variable names used, and a set of function names.
"""
expressions = []
varnames = set()
funcnames = set()
for part in self.parts:
if isinstance(part, str):
... | [
"def",
"translate",
"(",
"self",
")",
":",
"expressions",
"=",
"[",
"]",
"varnames",
"=",
"set",
"(",
")",
"funcnames",
"=",
"set",
"(",
")",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"if",
"isinstance",
"(",
"part",
",",
"str",
")",
":",
"... | Compile the expression to a list of Python AST expressions, a
set of variable names used, and a set of function names. | [
"Compile",
"the",
"expression",
"to",
"a",
"list",
"of",
"Python",
"AST",
"expressions",
"a",
"set",
"of",
"variable",
"names",
"used",
"and",
"a",
"set",
"of",
"function",
"names",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L256-L271 |
52,263 | Josef-Friedrich/tmep | tmep/template.py | Parser.parse_argument_list | def parse_argument_list(self):
"""Parse a list of arguments starting at ``pos``, returning a
list of Expression objects. Does not modify ``parts``. Should
leave ``pos`` pointing to a } character or the end of the
string.
"""
# Try to parse a subexpression in a subparser.
... | python | def parse_argument_list(self):
"""Parse a list of arguments starting at ``pos``, returning a
list of Expression objects. Does not modify ``parts``. Should
leave ``pos`` pointing to a } character or the end of the
string.
"""
# Try to parse a subexpression in a subparser.
... | [
"def",
"parse_argument_list",
"(",
"self",
")",
":",
"# Try to parse a subexpression in a subparser.",
"expressions",
"=",
"[",
"]",
"while",
"self",
".",
"pos",
"<",
"len",
"(",
"self",
".",
"string",
")",
":",
"subparser",
"=",
"Parser",
"(",
"self",
".",
... | Parse a list of arguments starting at ``pos``, returning a
list of Expression objects. Does not modify ``parts``. Should
leave ``pos`` pointing to a } character or the end of the
string. | [
"Parse",
"a",
"list",
"of",
"arguments",
"starting",
"at",
"pos",
"returning",
"a",
"list",
"of",
"Expression",
"objects",
".",
"Does",
"not",
"modify",
"parts",
".",
"Should",
"leave",
"pos",
"pointing",
"to",
"a",
"}",
"character",
"or",
"the",
"end",
... | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L476-L503 |
52,264 | Josef-Friedrich/tmep | tmep/template.py | Template.substitute | def substitute(self, values={}, functions={}):
"""Evaluate the template given the values and functions.
"""
try:
res = self.compiled(values, functions)
except Exception: # Handle any exceptions thrown by compiled version.
res = self.interpret(values, functions)
... | python | def substitute(self, values={}, functions={}):
"""Evaluate the template given the values and functions.
"""
try:
res = self.compiled(values, functions)
except Exception: # Handle any exceptions thrown by compiled version.
res = self.interpret(values, functions)
... | [
"def",
"substitute",
"(",
"self",
",",
"values",
"=",
"{",
"}",
",",
"functions",
"=",
"{",
"}",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"compiled",
"(",
"values",
",",
"functions",
")",
"except",
"Exception",
":",
"# Handle any exceptions thrown ... | Evaluate the template given the values and functions. | [
"Evaluate",
"the",
"template",
"given",
"the",
"values",
"and",
"functions",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L550-L558 |
52,265 | Josef-Friedrich/tmep | tmep/template.py | Template.translate | def translate(self):
"""Compile the template to a Python function."""
expressions, varnames, funcnames = self.expr.translate()
argnames = []
for varname in varnames:
argnames.append(VARIABLE_PREFIX + varname)
for funcname in funcnames:
argnames.append(FUN... | python | def translate(self):
"""Compile the template to a Python function."""
expressions, varnames, funcnames = self.expr.translate()
argnames = []
for varname in varnames:
argnames.append(VARIABLE_PREFIX + varname)
for funcname in funcnames:
argnames.append(FUN... | [
"def",
"translate",
"(",
"self",
")",
":",
"expressions",
",",
"varnames",
",",
"funcnames",
"=",
"self",
".",
"expr",
".",
"translate",
"(",
")",
"argnames",
"=",
"[",
"]",
"for",
"varname",
"in",
"varnames",
":",
"argnames",
".",
"append",
"(",
"VARI... | Compile the template to a Python function. | [
"Compile",
"the",
"template",
"to",
"a",
"Python",
"function",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/template.py#L560-L584 |
52,266 | AbletonAG/abl.vpath | abl/vpath/base/simpleuri.py | uri_from_parts | def uri_from_parts(parts):
"simple function to merge three parts into an uri"
uri = "%s://%s%s" % (parts[0], parts[1], parts[2])
if parts[3]:
extra = '?'+urlencode(parts[3])
uri += extra
return uri | python | def uri_from_parts(parts):
"simple function to merge three parts into an uri"
uri = "%s://%s%s" % (parts[0], parts[1], parts[2])
if parts[3]:
extra = '?'+urlencode(parts[3])
uri += extra
return uri | [
"def",
"uri_from_parts",
"(",
"parts",
")",
":",
"uri",
"=",
"\"%s://%s%s\"",
"%",
"(",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
"]",
",",
"parts",
"[",
"2",
"]",
")",
"if",
"parts",
"[",
"3",
"]",
":",
"extra",
"=",
"'?'",
"+",
"urlenco... | simple function to merge three parts into an uri | [
"simple",
"function",
"to",
"merge",
"three",
"parts",
"into",
"an",
"uri"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/simpleuri.py#L173-L179 |
52,267 | AbletonAG/abl.vpath | abl/vpath/base/simpleuri.py | UriParse.as_list | def as_list(self):
"return some attributes as a list"
netloc = ''
if self.vpath_connector:
netloc = '(('+self.vpath_connector+'))'
elif self.authority:
netloc = self.authority
else:
netloc = self.netloc
return [
self.scheme,... | python | def as_list(self):
"return some attributes as a list"
netloc = ''
if self.vpath_connector:
netloc = '(('+self.vpath_connector+'))'
elif self.authority:
netloc = self.authority
else:
netloc = self.netloc
return [
self.scheme,... | [
"def",
"as_list",
"(",
"self",
")",
":",
"netloc",
"=",
"''",
"if",
"self",
".",
"vpath_connector",
":",
"netloc",
"=",
"'(('",
"+",
"self",
".",
"vpath_connector",
"+",
"'))'",
"elif",
"self",
".",
"authority",
":",
"netloc",
"=",
"self",
".",
"author... | return some attributes as a list | [
"return",
"some",
"attributes",
"as",
"a",
"list"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/simpleuri.py#L156-L171 |
52,268 | decryptus/sonicprobe | sonicprobe/helpers.py | is_print | def is_print(value, space = True, tab = False, crlf = False):
""" Returns True if is print or False otherwise """
if not isinstance(value, basestring):
return False
regex = r'\x00-\x08\x0B\x0C\x0E-\x1F\x7F'
if not space:
regex += r'\x20'
if tab:
regex += r'\x09'
if cr... | python | def is_print(value, space = True, tab = False, crlf = False):
""" Returns True if is print or False otherwise """
if not isinstance(value, basestring):
return False
regex = r'\x00-\x08\x0B\x0C\x0E-\x1F\x7F'
if not space:
regex += r'\x20'
if tab:
regex += r'\x09'
if cr... | [
"def",
"is_print",
"(",
"value",
",",
"space",
"=",
"True",
",",
"tab",
"=",
"False",
",",
"crlf",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"basestring",
")",
":",
"return",
"False",
"regex",
"=",
"r'\\x00-\\x08\\x0B\\x0C\\x0... | Returns True if is print or False otherwise | [
"Returns",
"True",
"if",
"is",
"print",
"or",
"False",
"otherwise"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/helpers.py#L56-L72 |
52,269 | decryptus/sonicprobe | sonicprobe/helpers.py | file_writelines_flush_sync | def file_writelines_flush_sync(path, lines):
"""
Fill file at @path with @lines then flush all buffers
(Python and system buffers)
"""
fp = open(path, 'w')
try:
fp.writelines(lines)
flush_sync_file_object(fp)
finally:
fp.close() | python | def file_writelines_flush_sync(path, lines):
"""
Fill file at @path with @lines then flush all buffers
(Python and system buffers)
"""
fp = open(path, 'w')
try:
fp.writelines(lines)
flush_sync_file_object(fp)
finally:
fp.close() | [
"def",
"file_writelines_flush_sync",
"(",
"path",
",",
"lines",
")",
":",
"fp",
"=",
"open",
"(",
"path",
",",
"'w'",
")",
"try",
":",
"fp",
".",
"writelines",
"(",
"lines",
")",
"flush_sync_file_object",
"(",
"fp",
")",
"finally",
":",
"fp",
".",
"clo... | Fill file at @path with @lines then flush all buffers
(Python and system buffers) | [
"Fill",
"file",
"at"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/helpers.py#L259-L269 |
52,270 | decryptus/sonicprobe | sonicprobe/helpers.py | file_w_create_directories | def file_w_create_directories(filepath):
"""
Recursively create some directories if needed so that the directory where
@filepath must be written exists, then open it in "w" mode and return the
file object.
"""
dirname = os.path.dirname(filepath)
if dirname and dirname != os.path.curdir and ... | python | def file_w_create_directories(filepath):
"""
Recursively create some directories if needed so that the directory where
@filepath must be written exists, then open it in "w" mode and return the
file object.
"""
dirname = os.path.dirname(filepath)
if dirname and dirname != os.path.curdir and ... | [
"def",
"file_w_create_directories",
"(",
"filepath",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filepath",
")",
"if",
"dirname",
"and",
"dirname",
"!=",
"os",
".",
"path",
".",
"curdir",
"and",
"not",
"os",
".",
"path",
".",
"is... | Recursively create some directories if needed so that the directory where
@filepath must be written exists, then open it in "w" mode and return the
file object. | [
"Recursively",
"create",
"some",
"directories",
"if",
"needed",
"so",
"that",
"the",
"directory",
"where"
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/helpers.py#L271-L282 |
52,271 | boris-savic/python-mbills | python_mbills/api.py | MBillsAPI.fetch_transaction_status | def fetch_transaction_status(self, transaction_id):
"""
Get the transaction current status.
:param transaction_id:
:return:
"""
url = "%s%s%s/status" % (self.api_endpoint, constants.TRANSACTION_STATUS_ENDPOINT, transaction_id)
username = self.base.get_usernam... | python | def fetch_transaction_status(self, transaction_id):
"""
Get the transaction current status.
:param transaction_id:
:return:
"""
url = "%s%s%s/status" % (self.api_endpoint, constants.TRANSACTION_STATUS_ENDPOINT, transaction_id)
username = self.base.get_usernam... | [
"def",
"fetch_transaction_status",
"(",
"self",
",",
"transaction_id",
")",
":",
"url",
"=",
"\"%s%s%s/status\"",
"%",
"(",
"self",
".",
"api_endpoint",
",",
"constants",
".",
"TRANSACTION_STATUS_ENDPOINT",
",",
"transaction_id",
")",
"username",
"=",
"self",
".",... | Get the transaction current status.
:param transaction_id:
:return: | [
"Get",
"the",
"transaction",
"current",
"status",
"."
] | a2147810c8c54b9242d9bcc2218622f1e19f9ac3 | https://github.com/boris-savic/python-mbills/blob/a2147810c8c54b9242d9bcc2218622f1e19f9ac3/python_mbills/api.py#L101-L121 |
52,272 | boris-savic/python-mbills | python_mbills/api.py | MBillsAPI.capture_sale | def capture_sale(self, transaction_id, capture_amount, message=None):
"""
Capture existing preauth.
:param transaction_id:
:param capture_amount:
:param message:
:return: status code
"""
request_data = {
"amount": self.base.convert_decimal_to_... | python | def capture_sale(self, transaction_id, capture_amount, message=None):
"""
Capture existing preauth.
:param transaction_id:
:param capture_amount:
:param message:
:return: status code
"""
request_data = {
"amount": self.base.convert_decimal_to_... | [
"def",
"capture_sale",
"(",
"self",
",",
"transaction_id",
",",
"capture_amount",
",",
"message",
"=",
"None",
")",
":",
"request_data",
"=",
"{",
"\"amount\"",
":",
"self",
".",
"base",
".",
"convert_decimal_to_hundreds",
"(",
"capture_amount",
")",
",",
"\"c... | Capture existing preauth.
:param transaction_id:
:param capture_amount:
:param message:
:return: status code | [
"Capture",
"existing",
"preauth",
"."
] | a2147810c8c54b9242d9bcc2218622f1e19f9ac3 | https://github.com/boris-savic/python-mbills/blob/a2147810c8c54b9242d9bcc2218622f1e19f9ac3/python_mbills/api.py#L123-L153 |
52,273 | tuxpiper/cloudcast | cloudcast/_utils.py | caller_folder | def caller_folder():
"""
Returns the folder where the code of the caller's caller lives
"""
import inspect
caller_file = inspect.stack()[2][1]
if os.path.exists(caller_file):
return os.path.abspath(os.path.dirname(caller_file))
else:
return os.path.abspath(os.getcwd()) | python | def caller_folder():
"""
Returns the folder where the code of the caller's caller lives
"""
import inspect
caller_file = inspect.stack()[2][1]
if os.path.exists(caller_file):
return os.path.abspath(os.path.dirname(caller_file))
else:
return os.path.abspath(os.getcwd()) | [
"def",
"caller_folder",
"(",
")",
":",
"import",
"inspect",
"caller_file",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"2",
"]",
"[",
"1",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"caller_file",
")",
":",
"return",
"os",
".",
"path",
".",... | Returns the folder where the code of the caller's caller lives | [
"Returns",
"the",
"folder",
"where",
"the",
"code",
"of",
"the",
"caller",
"s",
"caller",
"lives"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/_utils.py#L3-L12 |
52,274 | the01/python-floscraper | floscraper/models.py | Response.to_dict | def to_dict(self):
"""
Response as dict
:return: response
:rtype: dict
"""
cache_info = None
if self.cache_info:
cache_info = self.cache_info.to_dict()
return {
'cache_info': cache_info,
'html': self.html,
'... | python | def to_dict(self):
"""
Response as dict
:return: response
:rtype: dict
"""
cache_info = None
if self.cache_info:
cache_info = self.cache_info.to_dict()
return {
'cache_info': cache_info,
'html': self.html,
'... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"cache_info",
"=",
"None",
"if",
"self",
".",
"cache_info",
":",
"cache_info",
"=",
"self",
".",
"cache_info",
".",
"to_dict",
"(",
")",
"return",
"{",
"'cache_info'",
":",
"cache_info",
",",
"'html'",
":",
"self"... | Response as dict
:return: response
:rtype: dict | [
"Response",
"as",
"dict"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/models.py#L97-L112 |
52,275 | the01/python-floscraper | floscraper/models.py | Response.from_dict | def from_dict(d):
"""
Response from dict
:param d: Dict to load
:type d: dict
:return: response
:rtype: Response
"""
if d is None:
return None
return Response(
d.get('html'),
CacheInfo.from_dict(d.get('cache_inf... | python | def from_dict(d):
"""
Response from dict
:param d: Dict to load
:type d: dict
:return: response
:rtype: Response
"""
if d is None:
return None
return Response(
d.get('html'),
CacheInfo.from_dict(d.get('cache_inf... | [
"def",
"from_dict",
"(",
"d",
")",
":",
"if",
"d",
"is",
"None",
":",
"return",
"None",
"return",
"Response",
"(",
"d",
".",
"get",
"(",
"'html'",
")",
",",
"CacheInfo",
".",
"from_dict",
"(",
"d",
".",
"get",
"(",
"'cache_info'",
")",
")",
",",
... | Response from dict
:param d: Dict to load
:type d: dict
:return: response
:rtype: Response | [
"Response",
"from",
"dict"
] | d578cd3d6381070d9a07dade1e10387ae33e9a65 | https://github.com/the01/python-floscraper/blob/d578cd3d6381070d9a07dade1e10387ae33e9a65/floscraper/models.py#L115-L131 |
52,276 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._create_board_image_cv | def _create_board_image_cv(self, board=None):
"""Return a cv image of the board or empty board if not provided."""
board = board or base.Board() # empty board by default
tile_h, tile_w = self._TILE_SHAPE[0:2]
board_shape = tile_h * 8, tile_w * 8, 3
board_image = numpy.zeros(boar... | python | def _create_board_image_cv(self, board=None):
"""Return a cv image of the board or empty board if not provided."""
board = board or base.Board() # empty board by default
tile_h, tile_w = self._TILE_SHAPE[0:2]
board_shape = tile_h * 8, tile_w * 8, 3
board_image = numpy.zeros(boar... | [
"def",
"_create_board_image_cv",
"(",
"self",
",",
"board",
"=",
"None",
")",
":",
"board",
"=",
"board",
"or",
"base",
".",
"Board",
"(",
")",
"# empty board by default",
"tile_h",
",",
"tile_w",
"=",
"self",
".",
"_TILE_SHAPE",
"[",
"0",
":",
"2",
"]",... | Return a cv image of the board or empty board if not provided. | [
"Return",
"a",
"cv",
"image",
"of",
"the",
"board",
"or",
"empty",
"board",
"if",
"not",
"provided",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L118-L130 |
52,277 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._draw_swap_cv | def _draw_swap_cv(self, board_image, swap):
"""Add a white tile border to indicate the swap."""
tile_h, tile_w = self._TILE_SHAPE[0:2]
# get a single bounding box
(row_1, col_1), (row_2, col_2) = swap
t = tile_h * min(row_1, row_2)
b = tile_h * (1 + max(row_1, row_2))
... | python | def _draw_swap_cv(self, board_image, swap):
"""Add a white tile border to indicate the swap."""
tile_h, tile_w = self._TILE_SHAPE[0:2]
# get a single bounding box
(row_1, col_1), (row_2, col_2) = swap
t = tile_h * min(row_1, row_2)
b = tile_h * (1 + max(row_1, row_2))
... | [
"def",
"_draw_swap_cv",
"(",
"self",
",",
"board_image",
",",
"swap",
")",
":",
"tile_h",
",",
"tile_w",
"=",
"self",
".",
"_TILE_SHAPE",
"[",
"0",
":",
"2",
"]",
"# get a single bounding box",
"(",
"row_1",
",",
"col_1",
")",
",",
"(",
"row_2",
",",
"... | Add a white tile border to indicate the swap. | [
"Add",
"a",
"white",
"tile",
"border",
"to",
"indicate",
"the",
"swap",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L132-L144 |
52,278 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._convert_cv_to_tk | def _convert_cv_to_tk(self, image_cv):
"""Convert an OpenCV image to a tkinter PhotoImage"""
# convert BGR to RGB
image_cv_rgb = data.cv2.cvtColor(image_cv, data.cv2.COLOR_BGR2RGB)
# convert opencv to PIL
image_pil = PIL_Image.fromarray(image_cv_rgb)
# convert PIL to tkin... | python | def _convert_cv_to_tk(self, image_cv):
"""Convert an OpenCV image to a tkinter PhotoImage"""
# convert BGR to RGB
image_cv_rgb = data.cv2.cvtColor(image_cv, data.cv2.COLOR_BGR2RGB)
# convert opencv to PIL
image_pil = PIL_Image.fromarray(image_cv_rgb)
# convert PIL to tkin... | [
"def",
"_convert_cv_to_tk",
"(",
"self",
",",
"image_cv",
")",
":",
"# convert BGR to RGB",
"image_cv_rgb",
"=",
"data",
".",
"cv2",
".",
"cvtColor",
"(",
"image_cv",
",",
"data",
".",
"cv2",
".",
"COLOR_BGR2RGB",
")",
"# convert opencv to PIL",
"image_pil",
"="... | Convert an OpenCV image to a tkinter PhotoImage | [
"Convert",
"an",
"OpenCV",
"image",
"to",
"a",
"tkinter",
"PhotoImage"
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L146-L153 |
52,279 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._scheduled_check_for_summaries | def _scheduled_check_for_summaries(self):
"""Present the results if they have become available or timed out."""
if self._analysis_process is None:
return
# handle time out
timed_out = time.time() - self._analyze_start_time > self.time_limit
if timed_out:
s... | python | def _scheduled_check_for_summaries(self):
"""Present the results if they have become available or timed out."""
if self._analysis_process is None:
return
# handle time out
timed_out = time.time() - self._analyze_start_time > self.time_limit
if timed_out:
s... | [
"def",
"_scheduled_check_for_summaries",
"(",
"self",
")",
":",
"if",
"self",
".",
"_analysis_process",
"is",
"None",
":",
"return",
"# handle time out",
"timed_out",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_analyze_start_time",
">",
"self",
"."... | Present the results if they have become available or timed out. | [
"Present",
"the",
"results",
"if",
"they",
"have",
"become",
"available",
"or",
"timed",
"out",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L174-L196 |
52,280 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._next | def _next(self):
"""Get the next summary and present it."""
self.summaries.rotate(-1)
current_summary = self.summaries[0]
self._update_summary(current_summary) | python | def _next(self):
"""Get the next summary and present it."""
self.summaries.rotate(-1)
current_summary = self.summaries[0]
self._update_summary(current_summary) | [
"def",
"_next",
"(",
"self",
")",
":",
"self",
".",
"summaries",
".",
"rotate",
"(",
"-",
"1",
")",
"current_summary",
"=",
"self",
".",
"summaries",
"[",
"0",
"]",
"self",
".",
"_update_summary",
"(",
"current_summary",
")"
] | Get the next summary and present it. | [
"Get",
"the",
"next",
"summary",
"and",
"present",
"it",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L219-L223 |
52,281 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._previous | def _previous(self):
"""Get the previous summary and present it."""
self.summaries.rotate()
current_summary = self.summaries[0]
self._update_summary(current_summary) | python | def _previous(self):
"""Get the previous summary and present it."""
self.summaries.rotate()
current_summary = self.summaries[0]
self._update_summary(current_summary) | [
"def",
"_previous",
"(",
"self",
")",
":",
"self",
".",
"summaries",
".",
"rotate",
"(",
")",
"current_summary",
"=",
"self",
".",
"summaries",
"[",
"0",
"]",
"self",
".",
"_update_summary",
"(",
"current_summary",
")"
] | Get the previous summary and present it. | [
"Get",
"the",
"previous",
"summary",
"and",
"present",
"it",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L225-L229 |
52,282 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._update_notification | def _update_notification(self, message=None):
"""Update the message area with blank or a message."""
if message is None:
message = ''
message_label = self._parts['notification label']
message_label.config(text=message)
self._base.update() | python | def _update_notification(self, message=None):
"""Update the message area with blank or a message."""
if message is None:
message = ''
message_label = self._parts['notification label']
message_label.config(text=message)
self._base.update() | [
"def",
"_update_notification",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"''",
"message_label",
"=",
"self",
".",
"_parts",
"[",
"'notification label'",
"]",
"message_label",
".",
"config",
"(",
... | Update the message area with blank or a message. | [
"Update",
"the",
"message",
"area",
"with",
"blank",
"or",
"a",
"message",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L236-L242 |
52,283 | kobejohn/PQHelper | pqhelper/ui.py | _GenericGameGUI._update_summary | def _update_summary(self, summary=None):
"""Update all parts of the summary or clear when no summary."""
board_image_label = self._parts['board image label']
# get content for update or use blanks when no summary
if summary:
# make a board image with the swap drawn on it
... | python | def _update_summary(self, summary=None):
"""Update all parts of the summary or clear when no summary."""
board_image_label = self._parts['board image label']
# get content for update or use blanks when no summary
if summary:
# make a board image with the swap drawn on it
... | [
"def",
"_update_summary",
"(",
"self",
",",
"summary",
"=",
"None",
")",
":",
"board_image_label",
"=",
"self",
".",
"_parts",
"[",
"'board image label'",
"]",
"# get content for update or use blanks when no summary",
"if",
"summary",
":",
"# make a board image with the s... | Update all parts of the summary or clear when no summary. | [
"Update",
"all",
"parts",
"of",
"the",
"summary",
"or",
"clear",
"when",
"no",
"summary",
"."
] | d2b78a22dcb631794295e6a159b06f39c3f10db6 | https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/ui.py#L244-L273 |
52,284 | klmitch/requiem | requiem/request.py | HTTPRequest.send | def send(self):
"""Issue the request.
Uses httplib2.Http support for handling redirects. Returns an
httplib2.Response, which may be augmented by the
proc_response() method.
Note that the default implementation of proc_response() causes
an appropriate exception to be ra... | python | def send(self):
"""Issue the request.
Uses httplib2.Http support for handling redirects. Returns an
httplib2.Response, which may be augmented by the
proc_response() method.
Note that the default implementation of proc_response() causes
an appropriate exception to be ra... | [
"def",
"send",
"(",
"self",
")",
":",
"# Pre-process the request",
"try",
":",
"self",
".",
"procstack",
".",
"proc_request",
"(",
"self",
")",
"except",
"exc",
".",
"ShortCircuit",
",",
"e",
":",
"self",
".",
"_debug",
"(",
"\"Request pre-processing short-cir... | Issue the request.
Uses httplib2.Http support for handling redirects. Returns an
httplib2.Response, which may be augmented by the
proc_response() method.
Note that the default implementation of proc_response() causes
an appropriate exception to be raised if the response code i... | [
"Issue",
"the",
"request",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/request.py#L76-L122 |
52,285 | klmitch/requiem | requiem/request.py | HTTPRequest.proc_response | def proc_response(self, resp):
"""Process response hook.
Process non-redirect responses received by the send() method.
May augment the response. The default implementation causes
an exception to be raised if the response status code is >=
400.
"""
# Raise excep... | python | def proc_response(self, resp):
"""Process response hook.
Process non-redirect responses received by the send() method.
May augment the response. The default implementation causes
an exception to be raised if the response status code is >=
400.
"""
# Raise excep... | [
"def",
"proc_response",
"(",
"self",
",",
"resp",
")",
":",
"# Raise exceptions for error responses",
"if",
"resp",
".",
"status",
">=",
"400",
":",
"e",
"=",
"exc",
".",
"exception_map",
".",
"get",
"(",
"resp",
".",
"status",
",",
"exc",
".",
"HTTPExcept... | Process response hook.
Process non-redirect responses received by the send() method.
May augment the response. The default implementation causes
an exception to be raised if the response status code is >=
400. | [
"Process",
"response",
"hook",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/request.py#L124-L138 |
52,286 | bbengfort/commis | commis/labeled.py | LabelCommand.add_arguments | def add_arguments(self):
"""
Add the label argument by default, no need to specify it in args.
"""
super(LabelCommand, self).add_arguments()
self.parser.add_argument('labels', metavar=self.label, nargs="+") | python | def add_arguments(self):
"""
Add the label argument by default, no need to specify it in args.
"""
super(LabelCommand, self).add_arguments()
self.parser.add_argument('labels', metavar=self.label, nargs="+") | [
"def",
"add_arguments",
"(",
"self",
")",
":",
"super",
"(",
"LabelCommand",
",",
"self",
")",
".",
"add_arguments",
"(",
")",
"self",
".",
"parser",
".",
"add_argument",
"(",
"'labels'",
",",
"metavar",
"=",
"self",
".",
"label",
",",
"nargs",
"=",
"\... | Add the label argument by default, no need to specify it in args. | [
"Add",
"the",
"label",
"argument",
"by",
"default",
"no",
"need",
"to",
"specify",
"it",
"in",
"args",
"."
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/labeled.py#L45-L50 |
52,287 | dcaune/perseus-lib-python-common | majormode/perseus/model/enum.py | _comparator | def _comparator(func):
""" Decorator for EnumValue rich comparison methods. """
def comparator_wrapper(self, other):
try:
# [PATCH] The code was originally the following:
#
# assert self.enumtype == other.enumtype
# result = func(self.index, other.... | python | def _comparator(func):
""" Decorator for EnumValue rich comparison methods. """
def comparator_wrapper(self, other):
try:
# [PATCH] The code was originally the following:
#
# assert self.enumtype == other.enumtype
# result = func(self.index, other.... | [
"def",
"_comparator",
"(",
"func",
")",
":",
"def",
"comparator_wrapper",
"(",
"self",
",",
"other",
")",
":",
"try",
":",
"# [PATCH] The code was originally the following:",
"#",
"# assert self.enumtype == other.enumtype",
"# result = func(self.index, other.index)",
... | Decorator for EnumValue rich comparison methods. | [
"Decorator",
"for",
"EnumValue",
"rich",
"comparison",
"methods",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/enum.py#L111-L137 |
52,288 | dcaune/perseus-lib-python-common | majormode/perseus/model/enum.py | Enum.extend | def extend(self, *keys, **kwargs):
"""
Return a new enumeration object extended with the specified items.
"""
this = copy.deepcopy(self)
value_type = kwargs.get('value_type', EnumValue)
if not keys:
raise EnumEmptyError()
keys = tuple(keys)
... | python | def extend(self, *keys, **kwargs):
"""
Return a new enumeration object extended with the specified items.
"""
this = copy.deepcopy(self)
value_type = kwargs.get('value_type', EnumValue)
if not keys:
raise EnumEmptyError()
keys = tuple(keys)
... | [
"def",
"extend",
"(",
"self",
",",
"*",
"keys",
",",
"*",
"*",
"kwargs",
")",
":",
"this",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"value_type",
"=",
"kwargs",
".",
"get",
"(",
"'value_type'",
",",
"EnumValue",
")",
"if",
"not",
"keys",
":"... | Return a new enumeration object extended with the specified items. | [
"Return",
"a",
"new",
"enumeration",
"object",
"extended",
"with",
"the",
"specified",
"items",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/model/enum.py#L244-L269 |
52,289 | Pixelapse/pyglass | pyglass/quicklook/api.py | is_valid_preview | def is_valid_preview(preview):
''' Verifies that the preview is a valid filetype '''
if not preview:
return False
if mimetype(preview) not in [ExportMimeType.PNG, ExportMimeType.PDF]:
return False
return True | python | def is_valid_preview(preview):
''' Verifies that the preview is a valid filetype '''
if not preview:
return False
if mimetype(preview) not in [ExportMimeType.PNG, ExportMimeType.PDF]:
return False
return True | [
"def",
"is_valid_preview",
"(",
"preview",
")",
":",
"if",
"not",
"preview",
":",
"return",
"False",
"if",
"mimetype",
"(",
"preview",
")",
"not",
"in",
"[",
"ExportMimeType",
".",
"PNG",
",",
"ExportMimeType",
".",
"PDF",
"]",
":",
"return",
"False",
"r... | Verifies that the preview is a valid filetype | [
"Verifies",
"that",
"the",
"preview",
"is",
"a",
"valid",
"filetype"
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/quicklook/api.py#L13-L21 |
52,290 | tundish/turberfield-dialogue | turberfield/dialogue/matcher.py | Matcher.options | def options(self, data):
"""Generate folders to best match metadata.
The results will be a single, perfectly matched folder, or the two nearest
neighbours of an imperfect match.
:param dict data: metadata matching criteria.
This method is a generator. It yields
:py:cla... | python | def options(self, data):
"""Generate folders to best match metadata.
The results will be a single, perfectly matched folder, or the two nearest
neighbours of an imperfect match.
:param dict data: metadata matching criteria.
This method is a generator. It yields
:py:cla... | [
"def",
"options",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"mapping_key",
"(",
"data",
")",
"in",
"self",
".",
"keys",
":",
"yield",
"next",
"(",
"i",
"for",
"i",
"in",
"self",
".",
"folders",
"if",
"i",
".",
"metadata",
"==",
"data... | Generate folders to best match metadata.
The results will be a single, perfectly matched folder, or the two nearest
neighbours of an imperfect match.
:param dict data: metadata matching criteria.
This method is a generator. It yields
:py:class:`turberfield.dialogue.model.Scene... | [
"Generate",
"folders",
"to",
"best",
"match",
"metadata",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/matcher.py#L70-L87 |
52,291 | sci-bots/pygtkhelpers | pygtkhelpers/forms.py | widget_for | def widget_for(element):
"""Create a widget for a schema item
"""
view_type = _view_type_for_element(element)
if view_type is None:
raise KeyError('No view type for %r' % element)
builder = view_widgets.get(view_type)
if builder is None:
raise KeyError('No widget type for %r' % v... | python | def widget_for(element):
"""Create a widget for a schema item
"""
view_type = _view_type_for_element(element)
if view_type is None:
raise KeyError('No view type for %r' % element)
builder = view_widgets.get(view_type)
if builder is None:
raise KeyError('No widget type for %r' % v... | [
"def",
"widget_for",
"(",
"element",
")",
":",
"view_type",
"=",
"_view_type_for_element",
"(",
"element",
")",
"if",
"view_type",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'No view type for %r'",
"%",
"element",
")",
"builder",
"=",
"view_widgets",
".",
"... | Create a widget for a schema item | [
"Create",
"a",
"widget",
"for",
"a",
"schema",
"item"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/forms.py#L35-L44 |
52,292 | RI-imaging/qpsphere | qpsphere/models/mod_proj.py | projection | def projection(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5)):
"""Optical path difference projection of a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [... | python | def projection(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5)):
"""Optical path difference projection of a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [... | [
"def",
"projection",
"(",
"radius",
"=",
"5e-6",
",",
"sphere_index",
"=",
"1.339",
",",
"medium_index",
"=",
"1.333",
",",
"wavelength",
"=",
"550e-9",
",",
"pixel_size",
"=",
"1e-7",
",",
"grid_size",
"=",
"(",
"80",
",",
"80",
")",
",",
"center",
"=... | Optical path difference projection of a dielectric sphere
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index: float
Refractive index of the sphere
medium_index: float
Refractive index of the surrounding medium
wavelength: float
Vacuum wavel... | [
"Optical",
"path",
"difference",
"projection",
"of",
"a",
"dielectric",
"sphere"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_proj.py#L5-L55 |
52,293 | sci-bots/pygtkhelpers | pygtkhelpers/delegates.py | get_first_builder_window | def get_first_builder_window(builder):
"""Get the first toplevel widget in a gtk.Builder hierarchy.
This is mostly used for guessing purposes, and an explicit naming is
always going to be a better situation.
"""
for obj in builder.get_objects():
if isinstance(obj, gtk.Window):
#... | python | def get_first_builder_window(builder):
"""Get the first toplevel widget in a gtk.Builder hierarchy.
This is mostly used for guessing purposes, and an explicit naming is
always going to be a better situation.
"""
for obj in builder.get_objects():
if isinstance(obj, gtk.Window):
#... | [
"def",
"get_first_builder_window",
"(",
"builder",
")",
":",
"for",
"obj",
"in",
"builder",
".",
"get_objects",
"(",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"gtk",
".",
"Window",
")",
":",
"# first window",
"return",
"obj"
] | Get the first toplevel widget in a gtk.Builder hierarchy.
This is mostly used for guessing purposes, and an explicit naming is
always going to be a better situation. | [
"Get",
"the",
"first",
"toplevel",
"widget",
"in",
"a",
"gtk",
".",
"Builder",
"hierarchy",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/delegates.py#L23-L32 |
52,294 | sci-bots/pygtkhelpers | pygtkhelpers/delegates.py | ToplevelView.get_builder_toplevel | def get_builder_toplevel(self, builder):
"""Get the toplevel widget from a gtk.Builder file.
The main view implementation first searches for the widget named as
self.toplevel_name (which defaults to "main". If this is missing, or not
a gtk.Window, the first toplevel window found in the ... | python | def get_builder_toplevel(self, builder):
"""Get the toplevel widget from a gtk.Builder file.
The main view implementation first searches for the widget named as
self.toplevel_name (which defaults to "main". If this is missing, or not
a gtk.Window, the first toplevel window found in the ... | [
"def",
"get_builder_toplevel",
"(",
"self",
",",
"builder",
")",
":",
"toplevel",
"=",
"builder",
".",
"get_object",
"(",
"self",
".",
"toplevel_name",
")",
"if",
"not",
"gobject",
".",
"type_is_a",
"(",
"toplevel",
",",
"gtk",
".",
"Window",
")",
":",
"... | Get the toplevel widget from a gtk.Builder file.
The main view implementation first searches for the widget named as
self.toplevel_name (which defaults to "main". If this is missing, or not
a gtk.Window, the first toplevel window found in the gtk.Builder is
used. | [
"Get",
"the",
"toplevel",
"widget",
"from",
"a",
"gtk",
".",
"Builder",
"file",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/delegates.py#L269-L282 |
52,295 | mogproject/mog-commons-python | src/mog_commons/string.py | to_bytes | def to_bytes(s, encoding=None, errors='strict'):
"""Convert string to bytes."""
encoding = encoding or 'utf-8'
if is_unicode(s):
return s.encode(encoding, errors)
elif is_strlike(s):
return s
else:
if six.PY2:
return str(s)
else:
return str(s)... | python | def to_bytes(s, encoding=None, errors='strict'):
"""Convert string to bytes."""
encoding = encoding or 'utf-8'
if is_unicode(s):
return s.encode(encoding, errors)
elif is_strlike(s):
return s
else:
if six.PY2:
return str(s)
else:
return str(s)... | [
"def",
"to_bytes",
"(",
"s",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"encoding",
"=",
"encoding",
"or",
"'utf-8'",
"if",
"is_unicode",
"(",
"s",
")",
":",
"return",
"s",
".",
"encode",
"(",
"encoding",
",",
"errors",
"... | Convert string to bytes. | [
"Convert",
"string",
"to",
"bytes",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/string.py#L87-L99 |
52,296 | mogproject/mog-commons-python | src/mog_commons/string.py | unicode_left | def unicode_left(s, width):
"""Cut unicode string from left to fit a given width."""
i = 0
j = 0
for ch in s:
j += __unicode_width_mapping[east_asian_width(ch)]
if width < j:
break
i += 1
return s[:i] | python | def unicode_left(s, width):
"""Cut unicode string from left to fit a given width."""
i = 0
j = 0
for ch in s:
j += __unicode_width_mapping[east_asian_width(ch)]
if width < j:
break
i += 1
return s[:i] | [
"def",
"unicode_left",
"(",
"s",
",",
"width",
")",
":",
"i",
"=",
"0",
"j",
"=",
"0",
"for",
"ch",
"in",
"s",
":",
"j",
"+=",
"__unicode_width_mapping",
"[",
"east_asian_width",
"(",
"ch",
")",
"]",
"if",
"width",
"<",
"j",
":",
"break",
"i",
"+... | Cut unicode string from left to fit a given width. | [
"Cut",
"unicode",
"string",
"from",
"left",
"to",
"fit",
"a",
"given",
"width",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/string.py#L136-L145 |
52,297 | mogproject/mog-commons-python | src/mog_commons/string.py | unicode_right | def unicode_right(s, width):
"""Cut unicode string from right to fit a given width."""
i = len(s)
j = 0
for ch in reversed(s):
j += __unicode_width_mapping[east_asian_width(ch)]
if width < j:
break
i -= 1
return s[i:] | python | def unicode_right(s, width):
"""Cut unicode string from right to fit a given width."""
i = len(s)
j = 0
for ch in reversed(s):
j += __unicode_width_mapping[east_asian_width(ch)]
if width < j:
break
i -= 1
return s[i:] | [
"def",
"unicode_right",
"(",
"s",
",",
"width",
")",
":",
"i",
"=",
"len",
"(",
"s",
")",
"j",
"=",
"0",
"for",
"ch",
"in",
"reversed",
"(",
"s",
")",
":",
"j",
"+=",
"__unicode_width_mapping",
"[",
"east_asian_width",
"(",
"ch",
")",
"]",
"if",
... | Cut unicode string from right to fit a given width. | [
"Cut",
"unicode",
"string",
"from",
"right",
"to",
"fit",
"a",
"given",
"width",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/string.py#L149-L158 |
52,298 | agile4you/SchemaFactory | schema_factory/schema.py | schema_factory | def schema_factory(schema_name, **schema_nodes):
"""Schema Validation class factory.
Args:
schema_name(str): The namespace of the schema.
schema_nodes(dict): The attr_names / SchemaNodes mapping of schema.
Returns:
A Schema class.
Raises:
SchemaError, for bad attribute... | python | def schema_factory(schema_name, **schema_nodes):
"""Schema Validation class factory.
Args:
schema_name(str): The namespace of the schema.
schema_nodes(dict): The attr_names / SchemaNodes mapping of schema.
Returns:
A Schema class.
Raises:
SchemaError, for bad attribute... | [
"def",
"schema_factory",
"(",
"schema_name",
",",
"*",
"*",
"schema_nodes",
")",
":",
"schema_dict",
"=",
"dict",
"(",
")",
"schema_dict",
".",
"update",
"(",
"schema_nodes",
")",
"def",
"cls_repr",
"(",
"self",
")",
":",
"# pragma: no cover",
"return",
"\"<... | Schema Validation class factory.
Args:
schema_name(str): The namespace of the schema.
schema_nodes(dict): The attr_names / SchemaNodes mapping of schema.
Returns:
A Schema class.
Raises:
SchemaError, for bad attribute setting initialization.
Examples:
>>> fro... | [
"Schema",
"Validation",
"class",
"factory",
"."
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/schema.py#L108-L200 |
52,299 | agile4you/SchemaFactory | schema_factory/schema.py | BaseSchema.serialize | def serialize(self, *fields):
"""Serialize Nodes and attributes
"""
if fields:
if not set(fields).issubset(self.data_nodes):
raise SchemaError('Invalid field for serialization: {}'.format(set(fields).difference(self.data_nodes)))
return OrderedDict([(k, g... | python | def serialize(self, *fields):
"""Serialize Nodes and attributes
"""
if fields:
if not set(fields).issubset(self.data_nodes):
raise SchemaError('Invalid field for serialization: {}'.format(set(fields).difference(self.data_nodes)))
return OrderedDict([(k, g... | [
"def",
"serialize",
"(",
"self",
",",
"*",
"fields",
")",
":",
"if",
"fields",
":",
"if",
"not",
"set",
"(",
"fields",
")",
".",
"issubset",
"(",
"self",
".",
"data_nodes",
")",
":",
"raise",
"SchemaError",
"(",
"'Invalid field for serialization: {}'",
"."... | Serialize Nodes and attributes | [
"Serialize",
"Nodes",
"and",
"attributes"
] | 515e3fb84cddf70fc17e5d300c74c3a63539f223 | https://github.com/agile4you/SchemaFactory/blob/515e3fb84cddf70fc17e5d300c74c3a63539f223/schema_factory/schema.py#L96-L105 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.