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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
247,900 | artisanofcode/python-broadway | broadway/whitenoise.py | init_app | def init_app(application):
"""
Initialise an application
Set up whitenoise to handle static files.
"""
config = {k: v for k, v in application.config.items() if k in SCHEMA}
kwargs = {'autorefresh': application.debug}
kwargs.update((k[11:].lower(), v) for k, v in config.items())
insta... | python | def init_app(application):
"""
Initialise an application
Set up whitenoise to handle static files.
"""
config = {k: v for k, v in application.config.items() if k in SCHEMA}
kwargs = {'autorefresh': application.debug}
kwargs.update((k[11:].lower(), v) for k, v in config.items())
insta... | [
"def",
"init_app",
"(",
"application",
")",
":",
"config",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"application",
".",
"config",
".",
"items",
"(",
")",
"if",
"k",
"in",
"SCHEMA",
"}",
"kwargs",
"=",
"{",
"'autorefresh'",
":",
"applica... | Initialise an application
Set up whitenoise to handle static files. | [
"Initialise",
"an",
"application"
] | a051ca5a922ecb38a541df59e8740e2a047d9a4a | https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/broadway/whitenoise.py#L38-L59 |
247,901 | neuroticnerd/armory | armory/utils/__init__.py | env | def env(key, default=_NOT_PROVIDED, cast=str, force=False, **kwargs):
"""
Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in... | python | def env(key, default=_NOT_PROVIDED, cast=str, force=False, **kwargs):
"""
Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in... | [
"def",
"env",
"(",
"key",
",",
"default",
"=",
"_NOT_PROVIDED",
",",
"cast",
"=",
"str",
",",
"force",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"boolmap",
"=",
"kwargs",
".",
"get",
"(",
"'boolmap'",
",",
"None",
")",
"sticky",
"=",
"kwargs... | Retrieve environment variables and specify default and options.
:param key: (required) environment variable name to retrieve
:param default: value to use if the environment var doesn't exist
:param cast: values always come in as strings, cast to this type if needed
:param force: force casting of value ... | [
"Retrieve",
"environment",
"variables",
"and",
"specify",
"default",
"and",
"options",
"."
] | d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1 | https://github.com/neuroticnerd/armory/blob/d37c5ca1dbdd60dddb968e35f0bbe4bc1299dca1/armory/utils/__init__.py#L14-L48 |
247,902 | n8henrie/urlmon | urlmon/urlmon.py | main | def main(arguments):
"""Parse arguments, request the urls, notify if different."""
formatter_class = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=formatter_class)
parser.add_argument('infile', help="Inpu... | python | def main(arguments):
"""Parse arguments, request the urls, notify if different."""
formatter_class = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=formatter_class)
parser.add_argument('infile', help="Inpu... | [
"def",
"main",
"(",
"arguments",
")",
":",
"formatter_class",
"=",
"argparse",
".",
"ArgumentDefaultsHelpFormatter",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"formatter_class",
")",
"parser",
... | Parse arguments, request the urls, notify if different. | [
"Parse",
"arguments",
"request",
"the",
"urls",
"notify",
"if",
"different",
"."
] | ebd58358843d7414f708c818a5c5a96feadd176f | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L101-L148 |
247,903 | n8henrie/urlmon | urlmon/urlmon.py | Pushover.validate | def validate(self):
"""Validate the user and token, returns the Requests response."""
validate_url = "https://api.pushover.net/1/users/validate.json"
payload = {
'token': self.api_token,
'user': self.user,
}
return requests.post(validate_url, data=paylo... | python | def validate(self):
"""Validate the user and token, returns the Requests response."""
validate_url = "https://api.pushover.net/1/users/validate.json"
payload = {
'token': self.api_token,
'user': self.user,
}
return requests.post(validate_url, data=paylo... | [
"def",
"validate",
"(",
"self",
")",
":",
"validate_url",
"=",
"\"https://api.pushover.net/1/users/validate.json\"",
"payload",
"=",
"{",
"'token'",
":",
"self",
".",
"api_token",
",",
"'user'",
":",
"self",
".",
"user",
",",
"}",
"return",
"requests",
".",
"p... | Validate the user and token, returns the Requests response. | [
"Validate",
"the",
"user",
"and",
"token",
"returns",
"the",
"Requests",
"response",
"."
] | ebd58358843d7414f708c818a5c5a96feadd176f | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L42-L52 |
247,904 | n8henrie/urlmon | urlmon/urlmon.py | Pushover.push | def push(self, message, device=None, title=None, url=None, url_title=None,
priority=None, timestamp=None, sound=None):
"""Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's dev... | python | def push(self, message, device=None, title=None, url=None, url_title=None,
priority=None, timestamp=None, sound=None):
"""Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's dev... | [
"def",
"push",
"(",
"self",
",",
"message",
",",
"device",
"=",
"None",
",",
"title",
"=",
"None",
",",
"url",
"=",
"None",
",",
"url_title",
"=",
"None",
",",
"priority",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"sound",
"=",
"None",
")",
... | Pushes the notification, returns the Requests response.
Arguments:
message -- your message
Keyword arguments:
device -- your user's device name to send the message directly to
that device, rather than all of the user's devices
title -- your message's... | [
"Pushes",
"the",
"notification",
"returns",
"the",
"Requests",
"response",
"."
] | ebd58358843d7414f708c818a5c5a96feadd176f | https://github.com/n8henrie/urlmon/blob/ebd58358843d7414f708c818a5c5a96feadd176f/urlmon/urlmon.py#L54-L93 |
247,905 | cogniteev/docido-python-sdk | docido_sdk/toolbox/edsl.py | kwargsql._get_obj_attr | def _get_obj_attr(cls, obj, path, pos):
"""Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: p... | python | def _get_obj_attr(cls, obj, path, pos):
"""Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: p... | [
"def",
"_get_obj_attr",
"(",
"cls",
",",
"obj",
",",
"path",
",",
"pos",
")",
":",
"field",
"=",
"path",
"[",
"pos",
"]",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"dict",
",",
"Mapping",
")",
")",
":",
"return",
"obj",
"[",
"field",
"]",
",",
... | Resolve one kwargsql expression for a given object and returns
its result.
:param obj: the object to evaluate
:param path: the list of all kwargsql expression, including those
previously evaluated.
:param int pos: provides index of the expression to evaluate in the
... | [
"Resolve",
"one",
"kwargsql",
"expression",
"for",
"a",
"given",
"object",
"and",
"returns",
"its",
"result",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/edsl.py#L245-L271 |
247,906 | todddeluca/dones | dones.py | get | def get(ns, dburl=None):
'''
Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned.
'''
if dburl is None:
dburl = DONES_DB_URL
cache_key = (ns, dburl)
if ns not in DONES_CACHE:
dones_ns = 'dones_{}'.f... | python | def get(ns, dburl=None):
'''
Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned.
'''
if dburl is None:
dburl = DONES_DB_URL
cache_key = (ns, dburl)
if ns not in DONES_CACHE:
dones_ns = 'dones_{}'.f... | [
"def",
"get",
"(",
"ns",
",",
"dburl",
"=",
"None",
")",
":",
"if",
"dburl",
"is",
"None",
":",
"dburl",
"=",
"DONES_DB_URL",
"cache_key",
"=",
"(",
"ns",
",",
"dburl",
")",
"if",
"ns",
"not",
"in",
"DONES_CACHE",
":",
"dones_ns",
"=",
"'dones_{}'",
... | Get a default dones object for ns. If no dones object exists for ns yet,
a DbDones object will be created, cached, and returned. | [
"Get",
"a",
"default",
"dones",
"object",
"for",
"ns",
".",
"If",
"no",
"dones",
"object",
"exists",
"for",
"ns",
"yet",
"a",
"DbDones",
"object",
"will",
"be",
"created",
"cached",
"and",
"returned",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L26-L39 |
247,907 | todddeluca/dones | dones.py | open_conn | def open_conn(host, db, user, password, retries=0, sleep=0.5):
'''
Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this ma... | python | def open_conn(host, db, user, password, retries=0, sleep=0.5):
'''
Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this ma... | [
"def",
"open_conn",
"(",
"host",
",",
"db",
",",
"user",
",",
"password",
",",
"retries",
"=",
"0",
",",
"sleep",
"=",
"0.5",
")",
":",
"assert",
"retries",
">=",
"0",
"try",
":",
"return",
"MySQLdb",
".",
"connect",
"(",
"host",
"=",
"host",
",",
... | Return an open mysql db connection using the given credentials. Use
`retries` and `sleep` to be robust to the occassional transient connection
failure.
retries: if an exception when getting the connection, try again at most this many times.
sleep: pause between retries for this many seconds. a float ... | [
"Return",
"an",
"open",
"mysql",
"db",
"connection",
"using",
"the",
"given",
"credentials",
".",
"Use",
"retries",
"and",
"sleep",
"to",
"be",
"robust",
"to",
"the",
"occassional",
"transient",
"connection",
"failure",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L265-L283 |
247,908 | todddeluca/dones | dones.py | open_url | def open_url(url, retries=0, sleep=0.5):
'''
Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database"
'''
return open_conn(retries=retries, sleep=sleep,... | python | def open_url(url, retries=0, sleep=0.5):
'''
Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database"
'''
return open_conn(retries=retries, sleep=sleep,... | [
"def",
"open_url",
"(",
"url",
",",
"retries",
"=",
"0",
",",
"sleep",
"=",
"0.5",
")",
":",
"return",
"open_conn",
"(",
"retries",
"=",
"retries",
",",
"sleep",
"=",
"sleep",
",",
"*",
"*",
"parse_url",
"(",
"url",
")",
")"
] | Open a mysql connection to a url. Note that if your password has
punctuation characters, it might break the parsing of url.
url: A string in the form "mysql://username:password@host.domain/database" | [
"Open",
"a",
"mysql",
"connection",
"to",
"a",
"url",
".",
"Note",
"that",
"if",
"your",
"password",
"has",
"punctuation",
"characters",
"it",
"might",
"break",
"the",
"parsing",
"of",
"url",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L286-L293 |
247,909 | todddeluca/dones | dones.py | DbDones._get_k | def _get_k(self):
'''
Accessing self.k indirectly allows for creating the kvstore table
if necessary.
'''
if not self.ready:
self.k.create() # create table if it does not exist.
self.ready = True
return self.k | python | def _get_k(self):
'''
Accessing self.k indirectly allows for creating the kvstore table
if necessary.
'''
if not self.ready:
self.k.create() # create table if it does not exist.
self.ready = True
return self.k | [
"def",
"_get_k",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"ready",
":",
"self",
".",
"k",
".",
"create",
"(",
")",
"# create table if it does not exist.",
"self",
".",
"ready",
"=",
"True",
"return",
"self",
".",
"k"
] | Accessing self.k indirectly allows for creating the kvstore table
if necessary. | [
"Accessing",
"self",
".",
"k",
"indirectly",
"allows",
"for",
"creating",
"the",
"kvstore",
"table",
"if",
"necessary",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L64-L73 |
247,910 | todddeluca/dones | dones.py | FileJSONAppendDones.clear | def clear(self):
'''
Remove all existing done markers and the file used to store the dones.
'''
if os.path.exists(self.path):
os.remove(self.path) | python | def clear(self):
'''
Remove all existing done markers and the file used to store the dones.
'''
if os.path.exists(self.path):
os.remove(self.path) | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")"
] | Remove all existing done markers and the file used to store the dones. | [
"Remove",
"all",
"existing",
"done",
"markers",
"and",
"the",
"file",
"used",
"to",
"store",
"the",
"dones",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L170-L175 |
247,911 | todddeluca/dones | dones.py | FileJSONAppendDones.done | def done(self, key):
'''
return True iff key is marked done.
:param key: a json-serializable object.
'''
# key is not done b/c the file does not even exist yet
if not os.path.exists(self.path):
return False
is_done = False
done_line = self._d... | python | def done(self, key):
'''
return True iff key is marked done.
:param key: a json-serializable object.
'''
# key is not done b/c the file does not even exist yet
if not os.path.exists(self.path):
return False
is_done = False
done_line = self._d... | [
"def",
"done",
"(",
"self",
",",
"key",
")",
":",
"# key is not done b/c the file does not even exist yet",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"False",
"is_done",
"=",
"False",
"done_line",
"=",
"self... | return True iff key is marked done.
:param key: a json-serializable object. | [
"return",
"True",
"iff",
"key",
"is",
"marked",
"done",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L195-L215 |
247,912 | todddeluca/dones | dones.py | FileJSONAppendDones.are_done | def are_done(self, keys):
'''
Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serial... | python | def are_done(self, keys):
'''
Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serial... | [
"def",
"are_done",
"(",
"self",
",",
"keys",
")",
":",
"# No keys are done b/c the file does not even exist yet.",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"[",
"False",
"]",
"*",
"len",
"(",
"keys",
")",... | Return a list of boolean values corresponding to whether or not each
key in keys is marked done. This method can be faster than
individually checking each key, depending on how many keys you
want to check.
:param keys: a list of json-serializable keys | [
"Return",
"a",
"list",
"of",
"boolean",
"values",
"corresponding",
"to",
"whether",
"or",
"not",
"each",
"key",
"in",
"keys",
"is",
"marked",
"done",
".",
"This",
"method",
"can",
"be",
"faster",
"than",
"individually",
"checking",
"each",
"key",
"depending"... | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L217-L241 |
247,913 | todddeluca/dones | dones.py | KStore.add | def add(self, key):
'''
add key to the namespace. it is fine to add a key multiple times.
'''
encodedKey = json.dumps(key)
with self.connect() as conn:
with doTransaction(conn):
sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
... | python | def add(self, key):
'''
add key to the namespace. it is fine to add a key multiple times.
'''
encodedKey = json.dumps(key)
with self.connect() as conn:
with doTransaction(conn):
sql = 'INSERT IGNORE INTO ' + self.table + ' (name) VALUES (%s)'
... | [
"def",
"add",
"(",
"self",
",",
"key",
")",
":",
"encodedKey",
"=",
"json",
".",
"dumps",
"(",
"key",
")",
"with",
"self",
".",
"connect",
"(",
")",
"as",
"conn",
":",
"with",
"doTransaction",
"(",
"conn",
")",
":",
"sql",
"=",
"'INSERT IGNORE INTO '... | add key to the namespace. it is fine to add a key multiple times. | [
"add",
"key",
"to",
"the",
"namespace",
".",
"it",
"is",
"fine",
"to",
"add",
"a",
"key",
"multiple",
"times",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L458-L466 |
247,914 | todddeluca/dones | dones.py | KStore.remove | def remove(self, key):
'''
remove key from the namespace. it is fine to remove a key multiple times.
'''
encodedKey = json.dumps(key)
sql = 'DELETE FROM ' + self.table + ' WHERE name = %s'
with self.connect() as conn:
with doTransaction(conn):
... | python | def remove(self, key):
'''
remove key from the namespace. it is fine to remove a key multiple times.
'''
encodedKey = json.dumps(key)
sql = 'DELETE FROM ' + self.table + ' WHERE name = %s'
with self.connect() as conn:
with doTransaction(conn):
... | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"encodedKey",
"=",
"json",
".",
"dumps",
"(",
"key",
")",
"sql",
"=",
"'DELETE FROM '",
"+",
"self",
".",
"table",
"+",
"' WHERE name = %s'",
"with",
"self",
".",
"connect",
"(",
")",
"as",
"conn",
... | remove key from the namespace. it is fine to remove a key multiple times. | [
"remove",
"key",
"from",
"the",
"namespace",
".",
"it",
"is",
"fine",
"to",
"remove",
"a",
"key",
"multiple",
"times",
"."
] | 6ef56565556987e701fed797a405f0825fe2e15a | https://github.com/todddeluca/dones/blob/6ef56565556987e701fed797a405f0825fe2e15a/dones.py#L468-L476 |
247,915 | daknuett/py_register_machine2 | app/web/model.py | RMServer.load_machine | def load_machine(self, descriptor):
"""
Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values.
"""
def get_cfg(name):
if(name in descriptor):
return descriptor[name]
else:
return defaults[name]
self.processor = Processor(width = get_... | python | def load_machine(self, descriptor):
"""
Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values.
"""
def get_cfg(name):
if(name in descriptor):
return descriptor[name]
else:
return defaults[name]
self.processor = Processor(width = get_... | [
"def",
"load_machine",
"(",
"self",
",",
"descriptor",
")",
":",
"def",
"get_cfg",
"(",
"name",
")",
":",
"if",
"(",
"name",
"in",
"descriptor",
")",
":",
"return",
"descriptor",
"[",
"name",
"]",
"else",
":",
"return",
"defaults",
"[",
"name",
"]",
... | Load a complete register machine.
The descriptor is a map, unspecified values are loaded from the default values. | [
"Load",
"a",
"complete",
"register",
"machine",
".",
"The",
"descriptor",
"is",
"a",
"map",
"unspecified",
"values",
"are",
"loaded",
"from",
"the",
"default",
"values",
"."
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L67-L99 |
247,916 | daknuett/py_register_machine2 | app/web/model.py | RMServer.assemble_rom_code | def assemble_rom_code(self, asm):
"""
assemble the given code and program the ROM
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.rom.program(result)
return None, result | python | def assemble_rom_code(self, asm):
"""
assemble the given code and program the ROM
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.rom.program(result)
return None, result | [
"def",
"assemble_rom_code",
"(",
"self",
",",
"asm",
")",
":",
"stream",
"=",
"StringIO",
"(",
"asm",
")",
"worker",
"=",
"assembler",
".",
"Assembler",
"(",
"self",
".",
"processor",
",",
"stream",
")",
"try",
":",
"result",
"=",
"worker",
".",
"assem... | assemble the given code and program the ROM | [
"assemble",
"the",
"given",
"code",
"and",
"program",
"the",
"ROM"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L105-L116 |
247,917 | daknuett/py_register_machine2 | app/web/model.py | RMServer.assemble_flash_code | def assemble_flash_code(self, asm):
"""
assemble the given code and program the Flash
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.flash.program(result)
return None, result | python | def assemble_flash_code(self, asm):
"""
assemble the given code and program the Flash
"""
stream = StringIO(asm)
worker = assembler.Assembler(self.processor, stream)
try:
result = worker.assemble()
except BaseException as e:
return e, None
self.flash.program(result)
return None, result | [
"def",
"assemble_flash_code",
"(",
"self",
",",
"asm",
")",
":",
"stream",
"=",
"StringIO",
"(",
"asm",
")",
"worker",
"=",
"assembler",
".",
"Assembler",
"(",
"self",
".",
"processor",
",",
"stream",
")",
"try",
":",
"result",
"=",
"worker",
".",
"ass... | assemble the given code and program the Flash | [
"assemble",
"the",
"given",
"code",
"and",
"program",
"the",
"Flash"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L117-L128 |
247,918 | daknuett/py_register_machine2 | app/web/model.py | RMServer.flush_devices | def flush_devices(self):
"""
overwrite the complete memory with zeros
"""
self.rom.program([0 for i in range(self.rom.size)])
self.flash.program([0 for i in range(self.flash.size)])
for i in range(self.ram.size):
self.ram.write(i, 0) | python | def flush_devices(self):
"""
overwrite the complete memory with zeros
"""
self.rom.program([0 for i in range(self.rom.size)])
self.flash.program([0 for i in range(self.flash.size)])
for i in range(self.ram.size):
self.ram.write(i, 0) | [
"def",
"flush_devices",
"(",
"self",
")",
":",
"self",
".",
"rom",
".",
"program",
"(",
"[",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"rom",
".",
"size",
")",
"]",
")",
"self",
".",
"flash",
".",
"program",
"(",
"[",
"0",
"for",
"i",
... | overwrite the complete memory with zeros | [
"overwrite",
"the",
"complete",
"memory",
"with",
"zeros"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L153-L160 |
247,919 | daknuett/py_register_machine2 | app/web/model.py | RMServer.get_rom | def get_rom(self, format_ = "nl"):
"""
return a string representations of the rom
"""
rom = [self.rom.read(i) for i in range(self.rom.size)]
return self._format_mem(rom, format_) | python | def get_rom(self, format_ = "nl"):
"""
return a string representations of the rom
"""
rom = [self.rom.read(i) for i in range(self.rom.size)]
return self._format_mem(rom, format_) | [
"def",
"get_rom",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"rom",
"=",
"[",
"self",
".",
"rom",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"rom",
".",
"size",
")",
"]",
"return",
"self",
".",
"_format_... | return a string representations of the rom | [
"return",
"a",
"string",
"representations",
"of",
"the",
"rom"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L168-L173 |
247,920 | daknuett/py_register_machine2 | app/web/model.py | RMServer.get_ram | def get_ram(self, format_ = "nl"):
"""
return a string representations of the ram
"""
ram = [self.ram.read(i) for i in range(self.ram.size)]
return self._format_mem(ram, format_) | python | def get_ram(self, format_ = "nl"):
"""
return a string representations of the ram
"""
ram = [self.ram.read(i) for i in range(self.ram.size)]
return self._format_mem(ram, format_) | [
"def",
"get_ram",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"ram",
"=",
"[",
"self",
".",
"ram",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"ram",
".",
"size",
")",
"]",
"return",
"self",
".",
"_format_... | return a string representations of the ram | [
"return",
"a",
"string",
"representations",
"of",
"the",
"ram"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L174-L179 |
247,921 | daknuett/py_register_machine2 | app/web/model.py | RMServer.get_flash | def get_flash(self, format_ = "nl"):
"""
return a string representations of the flash
"""
flash = [self.flash.read(i) for i in range(self.flash.size)]
return self._format_mem(flash, format_) | python | def get_flash(self, format_ = "nl"):
"""
return a string representations of the flash
"""
flash = [self.flash.read(i) for i in range(self.flash.size)]
return self._format_mem(flash, format_) | [
"def",
"get_flash",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"flash",
"=",
"[",
"self",
".",
"flash",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"flash",
".",
"size",
")",
"]",
"return",
"self",
".",
"... | return a string representations of the flash | [
"return",
"a",
"string",
"representations",
"of",
"the",
"flash"
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L180-L185 |
247,922 | soasme/rio-client | rio_client/base.py | Client.emit | def emit(self, action, payload=None, retry=0):
"""Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict.
"""
payload = payload or {}
if retry:
... | python | def emit(self, action, payload=None, retry=0):
"""Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict.
"""
payload = payload or {}
if retry:
... | [
"def",
"emit",
"(",
"self",
",",
"action",
",",
"payload",
"=",
"None",
",",
"retry",
"=",
"0",
")",
":",
"payload",
"=",
"payload",
"or",
"{",
"}",
"if",
"retry",
":",
"_retry",
"=",
"self",
".",
"transport",
".",
"retry",
"(",
"retry",
")",
"em... | Emit action with payload.
:param action: an action slug
:param payload: data, default {}
:param retry: integer, default 0.
:return: information in form of dict. | [
"Emit",
"action",
"with",
"payload",
"."
] | c6d684c6f9deea5b43f2b05bcaf40714c48b5619 | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/base.py#L31-L47 |
247,923 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_upcoming_events | def get_upcoming_events(self):
"""
Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadR... | python | def get_upcoming_events(self):
"""
Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadR... | [
"def",
"get_upcoming_events",
"(",
"self",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'group_urlname'",
":",
"GROUP_URLNAME",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
"EVENTS_URL... | Get upcoming PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
ascending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse
* PythonKCMeetupsMeetupDown
... | [
"Get",
"upcoming",
"PythonKC",
"meetup",
"events",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L60-L84 |
247,924 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_past_events | def get_past_events(self):
"""
Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse... | python | def get_past_events(self):
"""
Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse... | [
"def",
"get_past_events",
"(",
"self",
")",
":",
"def",
"get_attendees",
"(",
"event",
")",
":",
"return",
"[",
"attendee",
"for",
"event_id",
",",
"attendee",
"in",
"events_attendees",
"if",
"event_id",
"==",
"event",
"[",
"'id'",
"]",
"]",
"def",
"get_ph... | Get past PythonKC meetup events.
Returns
-------
List of ``pythonkc_meetups.types.MeetupEvent``, ordered by event time,
descending.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCMeetupsBadResponse
* PythonKCMeetupsMeetupDown
* ... | [
"Get",
"past",
"PythonKC",
"meetup",
"events",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L86-L130 |
247,925 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_events_attendees | def get_events_attendees(self, event_ids):
"""
Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.Meetu... | python | def get_events_attendees(self, event_ids):
"""
Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.Meetu... | [
"def",
"get_events_attendees",
"(",
"self",
",",
"event_ids",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"','",
".",
"join",
"(",
"event_ids",
")",
"}",
")",
"url",
"=",
... | Get the attendees of the identified events.
Parameters
----------
event_ids
List of IDs of events to get attendees for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupMember``).
Exceptions
----------
* Py... | [
"Get",
"the",
"attendees",
"of",
"the",
"identified",
"events",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L132-L161 |
247,926 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_event_attendees | def get_event_attendees(self, event_id):
"""
Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
... | python | def get_event_attendees(self, event_id):
"""
Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
... | [
"def",
"get_event_attendees",
"(",
"self",
",",
"event_id",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"event_id",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
... | Get the attendees of the identified event.
Parameters
----------
event_id
ID of the event to get attendees for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupMember``.
Exceptions
----------
* PythonKCMeetupsBadJson
*... | [
"Get",
"the",
"attendees",
"of",
"the",
"identified",
"event",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L163-L191 |
247,927 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_events_photos | def get_events_photos(self, event_ids):
"""
Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
... | python | def get_events_photos(self, event_ids):
"""
Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
... | [
"def",
"get_events_photos",
"(",
"self",
",",
"event_ids",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"','",
".",
"join",
"(",
"event_ids",
")",
"}",
")",
"url",
"=",
"... | Get photos for the identified events.
Parameters
----------
event_ids
List of IDs of events to get photos for.
Returns
-------
List of tuples of (event id, ``pythonkc_meetups.types.MeetupPhoto``).
Exceptions
----------
* PythonKCMeet... | [
"Get",
"photos",
"for",
"the",
"identified",
"events",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L193-L221 |
247,928 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups.get_event_photos | def get_event_photos(self, event_id):
"""
Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
-----... | python | def get_event_photos(self, event_id):
"""
Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
-----... | [
"def",
"get_event_photos",
"(",
"self",
",",
"event_id",
")",
":",
"query",
"=",
"urllib",
".",
"urlencode",
"(",
"{",
"'key'",
":",
"self",
".",
"_api_key",
",",
"'event_id'",
":",
"event_id",
"}",
")",
"url",
"=",
"'{0}?{1}'",
".",
"format",
"(",
"PH... | Get photos for the identified event.
Parameters
----------
event_id
ID of the event to get photos for.
Returns
-------
List of ``pythonkc_meetups.types.MeetupPhoto``.
Exceptions
----------
* PythonKCMeetupsBadJson
* PythonKCM... | [
"Get",
"photos",
"for",
"the",
"identified",
"event",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L223-L250 |
247,929 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups._http_get_json | def _http_get_json(self, url):
"""
Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dicti... | python | def _http_get_json(self, url):
"""
Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dicti... | [
"def",
"_http_get_json",
"(",
"self",
",",
"url",
")",
":",
"response",
"=",
"self",
".",
"_http_get",
"(",
"url",
")",
"content_type",
"=",
"response",
".",
"headers",
"[",
"'content-type'",
"]",
"parsed_mimetype",
"=",
"mimeparse",
".",
"parse_mime_type",
... | Make an HTTP GET request to the specified URL, check that it returned a
JSON response, and returned the data parsed from that response.
Parameters
----------
url
The URL to GET.
Returns
-------
Dictionary of data parsed from a JSON HTTP response.
... | [
"Make",
"an",
"HTTP",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"check",
"that",
"it",
"returned",
"a",
"JSON",
"response",
"and",
"returned",
"the",
"data",
"parsed",
"from",
"that",
"response",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L252-L285 |
247,930 | pythonkc/pythonkc-meetups | pythonkc_meetups/client.py | PythonKCMeetups._http_get | def _http_get(self, url):
"""
Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 50... | python | def _http_get(self, url):
"""
Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 50... | [
"def",
"_http_get",
"(",
"self",
",",
"url",
")",
":",
"for",
"try_number",
"in",
"range",
"(",
"self",
".",
"_http_retries",
"+",
"1",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"timeout",
"=",
"self",
".",
"_http_timeout",
... | Make an HTTP GET request to the specified URL and return the response.
Retries
-------
The constructor of this class takes an argument specifying the number
of times to retry a GET. The statuses which are retried on are: 408,
500, 502, 503, and 504.
Returns
----... | [
"Make",
"an",
"HTTP",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"and",
"return",
"the",
"response",
"."
] | 54b5062b2825011c87c303256f59c6c13d395ee7 | https://github.com/pythonkc/pythonkc-meetups/blob/54b5062b2825011c87c303256f59c6c13d395ee7/pythonkc_meetups/client.py#L287-L325 |
247,931 | exekias/droplet | droplet/common.py | save | def save():
"""
Apply configuration changes on all the modules
"""
from .models import ModuleInfo
logger = logging.getLogger(__name__)
logger.info("Saving changes")
# Save + restart
for module in modules():
if module.enabled:
if module.changed:
modul... | python | def save():
"""
Apply configuration changes on all the modules
"""
from .models import ModuleInfo
logger = logging.getLogger(__name__)
logger.info("Saving changes")
# Save + restart
for module in modules():
if module.enabled:
if module.changed:
modul... | [
"def",
"save",
"(",
")",
":",
"from",
".",
"models",
"import",
"ModuleInfo",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"info",
"(",
"\"Saving changes\"",
")",
"# Save + restart",
"for",
"module",
"in",
"modules",
"(",
... | Apply configuration changes on all the modules | [
"Apply",
"configuration",
"changes",
"on",
"all",
"the",
"modules"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/common.py#L40-L66 |
247,932 | minhhoit/yacms | yacms/pages/fields.py | MenusField.get_default | def get_default(self):
"""
If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable.
"""
if self._overridden_default:
... | python | def get_default(self):
"""
If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable.
"""
if self._overridden_default:
... | [
"def",
"get_default",
"(",
"self",
")",
":",
"if",
"self",
".",
"_overridden_default",
":",
"# Even with user-provided default we'd rather not have it",
"# forced to text. Compare with Field.get_default().",
"if",
"callable",
"(",
"self",
".",
"default",
")",
":",
"default"... | If the user provided a default in the field definition, returns it,
otherwise determines the default menus based on available choices and
``PAGE_MENU_TEMPLATES_DEFAULT``. Ensures the default is not mutable. | [
"If",
"the",
"user",
"provided",
"a",
"default",
"in",
"the",
"field",
"definition",
"returns",
"it",
"otherwise",
"determines",
"the",
"default",
"menus",
"based",
"on",
"available",
"choices",
"and",
"PAGE_MENU_TEMPLATES_DEFAULT",
".",
"Ensures",
"the",
"default... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/fields.py#L26-L50 |
247,933 | minhhoit/yacms | yacms/pages/fields.py | MenusField._get_choices | def _get_choices(self):
"""
Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition.
"""
if self._overridden_choices:
# Note: choices is a property on Field bound to _get_choices().
return self._cho... | python | def _get_choices(self):
"""
Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition.
"""
if self._overridden_choices:
# Note: choices is a property on Field bound to _get_choices().
return self._cho... | [
"def",
"_get_choices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_overridden_choices",
":",
"# Note: choices is a property on Field bound to _get_choices().",
"return",
"self",
".",
"_choices",
"else",
":",
"menus",
"=",
"getattr",
"(",
"settings",
",",
"\"PAGE_MENU_... | Returns menus specified in ``PAGE_MENU_TEMPLATES`` unless you provide
some custom choices in the field definition. | [
"Returns",
"menus",
"specified",
"in",
"PAGE_MENU_TEMPLATES",
"unless",
"you",
"provide",
"some",
"custom",
"choices",
"in",
"the",
"field",
"definition",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/fields.py#L52-L62 |
247,934 | brutasse/rache | rache/__init__.py | job_details | def job_details(job_id, connection=None):
"""Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve."""
if connection is None:
connection = r
data = connection.hgetall(job_key(job_id))
job_data = {'id': job_id, 'schedule_at': int(connection.zscore(R... | python | def job_details(job_id, connection=None):
"""Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve."""
if connection is None:
connection = r
data = connection.hgetall(job_key(job_id))
job_data = {'id': job_id, 'schedule_at': int(connection.zscore(R... | [
"def",
"job_details",
"(",
"job_id",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"data",
"=",
"connection",
".",
"hgetall",
"(",
"job_key",
"(",
"job_id",
")",
")",
"job_data",
"=",
"{",
"'id... | Returns the job data with its scheduled timestamp.
:param job_id: the ID of the job to retrieve. | [
"Returns",
"the",
"job",
"data",
"with",
"its",
"scheduled",
"timestamp",
"."
] | fa9cf073376a8c731a13924b84fb8422a771a4ab | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L27-L45 |
247,935 | brutasse/rache | rache/__init__.py | schedule_job | def schedule_job(job_id, schedule_in, connection=None, **kwargs):
"""Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure... | python | def schedule_job(job_id, schedule_in, connection=None, **kwargs):
"""Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure... | [
"def",
"schedule_job",
"(",
"job_id",
",",
"schedule_in",
",",
"connection",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"schedule_in",
",",
"int",
")",
":",
"# assumed to be a timedelta",
"schedule_in",
"=",
"schedule_in",
... | Schedules a job.
:param job_id: unique identifier for this job
:param schedule_in: number of seconds from now in which to schedule the
job or timedelta object.
:param **kwargs: parameters to attach to the job, key-value structure.
>>> schedule_job('http://example.com/test', schedule_in=10, num_re... | [
"Schedules",
"a",
"job",
"."
] | fa9cf073376a8c731a13924b84fb8422a771a4ab | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L48-L87 |
247,936 | brutasse/rache | rache/__init__.py | pending_jobs | def pending_jobs(reschedule_in=None, limit=None, connection=None):
"""Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set ... | python | def pending_jobs(reschedule_in=None, limit=None, connection=None):
"""Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set ... | [
"def",
"pending_jobs",
"(",
"reschedule_in",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"start",
"=",
"None",
"if",
"limit",
"is",
"None",
"else",
"0"... | Gets the job needing execution.
:param reschedule_in: number of seconds in which returned jobs should be
auto-rescheduled. If set to None (default), jobs are not auto-rescheduled.
:param limit: max number of jobs to retrieve. If set to None (default),
retrieves all pending jobs with no limit. | [
"Gets",
"the",
"job",
"needing",
"execution",
"."
] | fa9cf073376a8c731a13924b84fb8422a771a4ab | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L105-L147 |
247,937 | brutasse/rache | rache/__init__.py | scheduled_jobs | def scheduled_jobs(with_times=False, connection=None):
"""Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings.
"""
if connection is None:
connection = r
jobs = connection.zrangebyscore(REDIS_KEY, 0, sys... | python | def scheduled_jobs(with_times=False, connection=None):
"""Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings.
"""
if connection is None:
connection = r
jobs = connection.zrangebyscore(REDIS_KEY, 0, sys... | [
"def",
"scheduled_jobs",
"(",
"with_times",
"=",
"False",
",",
"connection",
"=",
"None",
")",
":",
"if",
"connection",
"is",
"None",
":",
"connection",
"=",
"r",
"jobs",
"=",
"connection",
".",
"zrangebyscore",
"(",
"REDIS_KEY",
",",
"0",
",",
"sys",
".... | Gets all jobs in the scheduler.
:param with_times: whether to return tuples with (job_id, timestamp) or
just job_id as a list of strings. | [
"Gets",
"all",
"jobs",
"in",
"the",
"scheduler",
"."
] | fa9cf073376a8c731a13924b84fb8422a771a4ab | https://github.com/brutasse/rache/blob/fa9cf073376a8c731a13924b84fb8422a771a4ab/rache/__init__.py#L150-L164 |
247,938 | SmartDeveloperHub/agora-service-provider | agora/provider/server/base.py | AgoraApp.run | def run(self, host=None, port=None, debug=None, **options):
"""
Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields.
"""
tasks = options.get('tasks', [])
for task in tasks:
if task is not None and hasattr(task, '__call__'):
... | python | def run(self, host=None, port=None, debug=None, **options):
"""
Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields.
"""
tasks = options.get('tasks', [])
for task in tasks:
if task is not None and hasattr(task, '__call__'):
... | [
"def",
"run",
"(",
"self",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"debug",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"tasks",
"=",
"options",
".",
"get",
"(",
"'tasks'",
",",
"[",
"]",
")",
"for",
"task",
"in",
"tasks",... | Start the AgoraApp expecting the provided config to have at least REDIS and PORT fields. | [
"Start",
"the",
"AgoraApp",
"expecting",
"the",
"provided",
"config",
"to",
"have",
"at",
"least",
"REDIS",
"and",
"PORT",
"fields",
"."
] | 3962207e5701c659c74c8cfffcbc4b0a63eac4b4 | https://github.com/SmartDeveloperHub/agora-service-provider/blob/3962207e5701c659c74c8cfffcbc4b0a63eac4b4/agora/provider/server/base.py#L123-L142 |
247,939 | thomasvandoren/bugzscout-py | doc/example/src/celery_wsgi.py | _handle_exc | def _handle_exc(exception):
"""Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app
"""
# Set the des... | python | def _handle_exc(exception):
"""Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app
"""
# Set the des... | [
"def",
"_handle_exc",
"(",
"exception",
")",
":",
"# Set the description to a familiar string with the exception",
"# message. Add the stack trace to extra.",
"bugzscout",
".",
"ext",
".",
"celery_app",
".",
"submit_error",
".",
"delay",
"(",
"'http://fogbugz/scoutSubmit.asp'",
... | Record exception with stack trace to FogBugz via BugzScout,
asynchronously. Returns an empty string.
Note that this will not be reported to FogBugz until a celery worker
processes this task.
:param exception: uncaught exception thrown in app | [
"Record",
"exception",
"with",
"stack",
"trace",
"to",
"FogBugz",
"via",
"BugzScout",
"asynchronously",
".",
"Returns",
"an",
"empty",
"string",
"."
] | 514528e958a97e0e7b36870037c5c69661511824 | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/doc/example/src/celery_wsgi.py#L19-L39 |
247,940 | thomasvandoren/bugzscout-py | doc/example/src/celery_wsgi.py | app | def app(environ, start_response):
"""Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or... | python | def app(environ, start_response):
"""Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or... | [
"def",
"app",
"(",
"environ",
",",
"start_response",
")",
":",
"try",
":",
"if",
"environ",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'GET'",
":",
"start_response",
"(",
"'200 OK'",
",",
"[",
"(",
"'content-type'",
",",
"'text/html'",
")",
"]",
")",
"return",
... | Simple WSGI application. Returns 200 OK response with 'Hellow world!' in
the body for GET requests. Returns 405 Method Not Allowed for all other
methods.
Returns 500 Internal Server Error if an exception is thrown. The response
body will not include the error or any information about it. The error and
... | [
"Simple",
"WSGI",
"application",
".",
"Returns",
"200",
"OK",
"response",
"with",
"Hellow",
"world!",
"in",
"the",
"body",
"for",
"GET",
"requests",
".",
"Returns",
"405",
"Method",
"Not",
"Allowed",
"for",
"all",
"other",
"methods",
"."
] | 514528e958a97e0e7b36870037c5c69661511824 | https://github.com/thomasvandoren/bugzscout-py/blob/514528e958a97e0e7b36870037c5c69661511824/doc/example/src/celery_wsgi.py#L42-L71 |
247,941 | gmr/remy | remy/cli.py | add_cookbook_mgmt_options | def add_cookbook_mgmt_options(parser):
"""Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('cookbook', help='Invoke in a Jenkins job to '
'update a cookbook in '
... | python | def add_cookbook_mgmt_options(parser):
"""Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('cookbook', help='Invoke in a Jenkins job to '
'update a cookbook in '
... | [
"def",
"add_cookbook_mgmt_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'cookbook'",
",",
"help",
"=",
"'Invoke in a Jenkins job to '",
"'update a cookbook in '",
"'chef-repo'",
")",
"cookbook",
".",
"add_argument",
"(",
"'repo... | Add the cookbook management command and arguments.
:rtype: argparse.ArgumentParser | [
"Add",
"the",
"cookbook",
"management",
"command",
"and",
"arguments",
"."
] | 74368ae74e3f2b59376d6f8e457aefbe9c7debdf | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L19-L30 |
247,942 | gmr/remy | remy/cli.py | add_github_hook_options | def add_github_hook_options(parser):
"""Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('github', help='Install the Jenkins callback '
'hook in a GitHub repository')
cookbook.add_arg... | python | def add_github_hook_options(parser):
"""Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('github', help='Install the Jenkins callback '
'hook in a GitHub repository')
cookbook.add_arg... | [
"def",
"add_github_hook_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'github'",
",",
"help",
"=",
"'Install the Jenkins callback '",
"'hook in a GitHub repository'",
")",
"cookbook",
".",
"add_argument",
"(",
"'owner'",
",",
... | Add the github jenkins hook command and arguments.
:rtype: argparse.ArgumentParser | [
"Add",
"the",
"github",
"jenkins",
"hook",
"command",
"and",
"arguments",
"."
] | 74368ae74e3f2b59376d6f8e457aefbe9c7debdf | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L32-L61 |
247,943 | gmr/remy | remy/cli.py | add_jenkins_job_options | def add_jenkins_job_options(parser):
"""Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('jenkins', help='Add a new cookbook job to '
'Jenkins')
cookbook.add_argument('jenkins', action=... | python | def add_jenkins_job_options(parser):
"""Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser
"""
cookbook = parser.add_parser('jenkins', help='Add a new cookbook job to '
'Jenkins')
cookbook.add_argument('jenkins', action=... | [
"def",
"add_jenkins_job_options",
"(",
"parser",
")",
":",
"cookbook",
"=",
"parser",
".",
"add_parser",
"(",
"'jenkins'",
",",
"help",
"=",
"'Add a new cookbook job to '",
"'Jenkins'",
")",
"cookbook",
".",
"add_argument",
"(",
"'jenkins'",
",",
"action",
"=",
... | Add a new job to Jenkins for updating chef-repo
:rtype: argparse.ArgumentParser | [
"Add",
"a",
"new",
"job",
"to",
"Jenkins",
"for",
"updating",
"chef",
"-",
"repo"
] | 74368ae74e3f2b59376d6f8e457aefbe9c7debdf | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L64-L90 |
247,944 | gmr/remy | remy/cli.py | argparser | def argparser():
"""Build the argument parser
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description=__description__)
sparser = parser.add_subparsers()
add_cookbook_mgmt_options(sparser)
add_role_options(sparser)
add_github_hook_options(sparser)
add_jenkin... | python | def argparser():
"""Build the argument parser
:rtype: argparse.ArgumentParser
"""
parser = argparse.ArgumentParser(description=__description__)
sparser = parser.add_subparsers()
add_cookbook_mgmt_options(sparser)
add_role_options(sparser)
add_github_hook_options(sparser)
add_jenkin... | [
"def",
"argparser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__description__",
")",
"sparser",
"=",
"parser",
".",
"add_subparsers",
"(",
")",
"add_cookbook_mgmt_options",
"(",
"sparser",
")",
"add_role_options",
... | Build the argument parser
:rtype: argparse.ArgumentParser | [
"Build",
"the",
"argument",
"parser"
] | 74368ae74e3f2b59376d6f8e457aefbe9c7debdf | https://github.com/gmr/remy/blob/74368ae74e3f2b59376d6f8e457aefbe9c7debdf/remy/cli.py#L105-L117 |
247,945 | nickw444/wtforms-webwidgets | wtforms_webwidgets/bootstrap/util.py | render_field_description | def render_field_description(field):
"""
Render a field description as HTML.
"""
if hasattr(field, 'description') and field.description != '':
html = """<p class="help-block">{field.description}</p>"""
html = html.format(
field=field
)
return HTMLString(html)... | python | def render_field_description(field):
"""
Render a field description as HTML.
"""
if hasattr(field, 'description') and field.description != '':
html = """<p class="help-block">{field.description}</p>"""
html = html.format(
field=field
)
return HTMLString(html)... | [
"def",
"render_field_description",
"(",
"field",
")",
":",
"if",
"hasattr",
"(",
"field",
",",
"'description'",
")",
"and",
"field",
".",
"description",
"!=",
"''",
":",
"html",
"=",
"\"\"\"<p class=\"help-block\">{field.description}</p>\"\"\"",
"html",
"=",
"html",... | Render a field description as HTML. | [
"Render",
"a",
"field",
"description",
"as",
"HTML",
"."
] | 88f224b68c0b0f4f5c97de39fe1428b96e12f8db | https://github.com/nickw444/wtforms-webwidgets/blob/88f224b68c0b0f4f5c97de39fe1428b96e12f8db/wtforms_webwidgets/bootstrap/util.py#L19-L30 |
247,946 | tBaxter/django-fretboard | fretboard/helpers.py | update_post_relations | def update_post_relations(user, topic, deleting=False):
"""
helper function to update user post count and parent topic post_count.
"""
if deleting:
user.post_count = user.post_count - 1
else:
user.post_count += 1
user.save(update_fields=['post_count'])
topic.modified = d... | python | def update_post_relations(user, topic, deleting=False):
"""
helper function to update user post count and parent topic post_count.
"""
if deleting:
user.post_count = user.post_count - 1
else:
user.post_count += 1
user.save(update_fields=['post_count'])
topic.modified = d... | [
"def",
"update_post_relations",
"(",
"user",
",",
"topic",
",",
"deleting",
"=",
"False",
")",
":",
"if",
"deleting",
":",
"user",
".",
"post_count",
"=",
"user",
".",
"post_count",
"-",
"1",
"else",
":",
"user",
".",
"post_count",
"+=",
"1",
"user",
"... | helper function to update user post count and parent topic post_count. | [
"helper",
"function",
"to",
"update",
"user",
"post",
"count",
"and",
"parent",
"topic",
"post_count",
"."
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/helpers.py#L5-L17 |
247,947 | jmgilman/Neolib | neolib/pyamf/adapters/_django_db_models_base.py | DjangoReferenceCollection.addClassKey | def addClassKey(self, klass, key, obj):
"""
Adds an object to the collection, based on klass and key.
@param klass: The class of the object.
@param key: The datastore key of the object.
@param obj: The loaded instance from the datastore.
"""
d = self._getClass(kl... | python | def addClassKey(self, klass, key, obj):
"""
Adds an object to the collection, based on klass and key.
@param klass: The class of the object.
@param key: The datastore key of the object.
@param obj: The loaded instance from the datastore.
"""
d = self._getClass(kl... | [
"def",
"addClassKey",
"(",
"self",
",",
"klass",
",",
"key",
",",
"obj",
")",
":",
"d",
"=",
"self",
".",
"_getClass",
"(",
"klass",
")",
"d",
"[",
"key",
"]",
"=",
"obj"
] | Adds an object to the collection, based on klass and key.
@param klass: The class of the object.
@param key: The datastore key of the object.
@param obj: The loaded instance from the datastore. | [
"Adds",
"an",
"object",
"to",
"the",
"collection",
"based",
"on",
"klass",
"and",
"key",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/adapters/_django_db_models_base.py#L49-L59 |
247,948 | OldhamMade/PySO8601 | PySO8601/durations.py | parse_duration | def parse_duration(duration, start=None, end=None):
"""
Attepmt to parse an ISO8601 formatted duration.
Accepts a ``duration`` and optionally a start or end ``datetime``.
``duration`` must be an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object.
"""
if not start and not end... | python | def parse_duration(duration, start=None, end=None):
"""
Attepmt to parse an ISO8601 formatted duration.
Accepts a ``duration`` and optionally a start or end ``datetime``.
``duration`` must be an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object.
"""
if not start and not end... | [
"def",
"parse_duration",
"(",
"duration",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"if",
"not",
"start",
"and",
"not",
"end",
":",
"return",
"parse_simple_duration",
"(",
"duration",
")",
"if",
"start",
":",
"return",
"parse_duration_w... | Attepmt to parse an ISO8601 formatted duration.
Accepts a ``duration`` and optionally a start or end ``datetime``.
``duration`` must be an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object. | [
"Attepmt",
"to",
"parse",
"an",
"ISO8601",
"formatted",
"duration",
"."
] | b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4 | https://github.com/OldhamMade/PySO8601/blob/b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4/PySO8601/durations.py#L12-L28 |
247,949 | OldhamMade/PySO8601 | PySO8601/durations.py | parse_simple_duration | def parse_simple_duration(duration):
"""
Attepmt to parse an ISO8601 formatted duration, using a naive calculation.
Accepts a ``duration`` which must be an ISO8601 formatted string, and
assumes 365 days in a year and 30 days in a month for the calculation.
Returns a ``datetime.timedelta`` object.
... | python | def parse_simple_duration(duration):
"""
Attepmt to parse an ISO8601 formatted duration, using a naive calculation.
Accepts a ``duration`` which must be an ISO8601 formatted string, and
assumes 365 days in a year and 30 days in a month for the calculation.
Returns a ``datetime.timedelta`` object.
... | [
"def",
"parse_simple_duration",
"(",
"duration",
")",
":",
"elements",
"=",
"_parse_duration_string",
"(",
"_clean",
"(",
"duration",
")",
")",
"if",
"not",
"elements",
":",
"raise",
"ParseError",
"(",
")",
"return",
"_timedelta_from_elements",
"(",
"elements",
... | Attepmt to parse an ISO8601 formatted duration, using a naive calculation.
Accepts a ``duration`` which must be an ISO8601 formatted string, and
assumes 365 days in a year and 30 days in a month for the calculation.
Returns a ``datetime.timedelta`` object. | [
"Attepmt",
"to",
"parse",
"an",
"ISO8601",
"formatted",
"duration",
"using",
"a",
"naive",
"calculation",
"."
] | b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4 | https://github.com/OldhamMade/PySO8601/blob/b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4/PySO8601/durations.py#L31-L45 |
247,950 | OldhamMade/PySO8601 | PySO8601/durations.py | parse_duration_with_start | def parse_duration_with_start(start, duration):
"""
Attepmt to parse an ISO8601 formatted duration based on a start datetime.
Accepts a ``duration`` and a start ``datetime``. ``duration`` must be
an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object.
"""
elements = _parse_du... | python | def parse_duration_with_start(start, duration):
"""
Attepmt to parse an ISO8601 formatted duration based on a start datetime.
Accepts a ``duration`` and a start ``datetime``. ``duration`` must be
an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object.
"""
elements = _parse_du... | [
"def",
"parse_duration_with_start",
"(",
"start",
",",
"duration",
")",
":",
"elements",
"=",
"_parse_duration_string",
"(",
"_clean",
"(",
"duration",
")",
")",
"year",
",",
"month",
"=",
"_year_month_delta_from_elements",
"(",
"elements",
")",
"end",
"=",
"sta... | Attepmt to parse an ISO8601 formatted duration based on a start datetime.
Accepts a ``duration`` and a start ``datetime``. ``duration`` must be
an ISO8601 formatted string.
Returns a ``datetime.timedelta`` object. | [
"Attepmt",
"to",
"parse",
"an",
"ISO8601",
"formatted",
"duration",
"based",
"on",
"a",
"start",
"datetime",
"."
] | b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4 | https://github.com/OldhamMade/PySO8601/blob/b7d3b3cb3ed3e12eb2a21caa26a3abeab3c96fe4/PySO8601/durations.py#L63-L85 |
247,951 | wiggzz/siggy | siggy/siggy.py | int_to_var_bytes | def int_to_var_bytes(x):
"""Converts an integer to a bitcoin variable length integer as a bytearray
:param x: the integer to convert
"""
if x < 253:
return intbytes.to_bytes(x, 1)
elif x < 65536:
return bytearray([253]) + intbytes.to_bytes(x, 2)[::-1]
elif x < 4294967296:
... | python | def int_to_var_bytes(x):
"""Converts an integer to a bitcoin variable length integer as a bytearray
:param x: the integer to convert
"""
if x < 253:
return intbytes.to_bytes(x, 1)
elif x < 65536:
return bytearray([253]) + intbytes.to_bytes(x, 2)[::-1]
elif x < 4294967296:
... | [
"def",
"int_to_var_bytes",
"(",
"x",
")",
":",
"if",
"x",
"<",
"253",
":",
"return",
"intbytes",
".",
"to_bytes",
"(",
"x",
",",
"1",
")",
"elif",
"x",
"<",
"65536",
":",
"return",
"bytearray",
"(",
"[",
"253",
"]",
")",
"+",
"intbytes",
".",
"to... | Converts an integer to a bitcoin variable length integer as a bytearray
:param x: the integer to convert | [
"Converts",
"an",
"integer",
"to",
"a",
"bitcoin",
"variable",
"length",
"integer",
"as",
"a",
"bytearray"
] | bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1 | https://github.com/wiggzz/siggy/blob/bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1/siggy/siggy.py#L36-L48 |
247,952 | wiggzz/siggy | siggy/siggy.py | bitcoin_sig_hash | def bitcoin_sig_hash(message):
"""Bitcoin has a special format for hashing messages for signing.
:param message: the encoded message to hash in preparation for verifying
"""
padded = b'\x18Bitcoin Signed Message:\n' +\
int_to_var_bytes(len(message)) +\
message
return double_sha256(p... | python | def bitcoin_sig_hash(message):
"""Bitcoin has a special format for hashing messages for signing.
:param message: the encoded message to hash in preparation for verifying
"""
padded = b'\x18Bitcoin Signed Message:\n' +\
int_to_var_bytes(len(message)) +\
message
return double_sha256(p... | [
"def",
"bitcoin_sig_hash",
"(",
"message",
")",
":",
"padded",
"=",
"b'\\x18Bitcoin Signed Message:\\n'",
"+",
"int_to_var_bytes",
"(",
"len",
"(",
"message",
")",
")",
"+",
"message",
"return",
"double_sha256",
"(",
"padded",
")"
] | Bitcoin has a special format for hashing messages for signing.
:param message: the encoded message to hash in preparation for verifying | [
"Bitcoin",
"has",
"a",
"special",
"format",
"for",
"hashing",
"messages",
"for",
"signing",
"."
] | bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1 | https://github.com/wiggzz/siggy/blob/bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1/siggy/siggy.py#L51-L59 |
247,953 | wiggzz/siggy | siggy/siggy.py | verify_signature | def verify_signature(message, signature, address):
"""This function verifies a bitcoin signed message.
:param message: the plain text of the message to verify
:param signature: the signature in base64 format
:param address: the signing address
"""
if (len(signature) != SIGNATURE_LENGTH):
... | python | def verify_signature(message, signature, address):
"""This function verifies a bitcoin signed message.
:param message: the plain text of the message to verify
:param signature: the signature in base64 format
:param address: the signing address
"""
if (len(signature) != SIGNATURE_LENGTH):
... | [
"def",
"verify_signature",
"(",
"message",
",",
"signature",
",",
"address",
")",
":",
"if",
"(",
"len",
"(",
"signature",
")",
"!=",
"SIGNATURE_LENGTH",
")",
":",
"return",
"False",
"try",
":",
"binsig",
"=",
"base64",
".",
"b64decode",
"(",
"signature",
... | This function verifies a bitcoin signed message.
:param message: the plain text of the message to verify
:param signature: the signature in base64 format
:param address: the signing address | [
"This",
"function",
"verifies",
"a",
"bitcoin",
"signed",
"message",
"."
] | bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1 | https://github.com/wiggzz/siggy/blob/bfb67cbc9da3e4545b3e882bf7384fa265e6d6c1/siggy/siggy.py#L62-L96 |
247,954 | boilerroomtv/datastore.cloudfiles | datastore/cloudfiles/__init__.py | CloudFilesDatastore.query | def query(self, query):
"""Returns an iterable of objects matching criteria expressed in `query`.
Implementations of query will be the largest differentiating factor
amongst datastores. All datastores **must** implement query, even using
query's worst case scenario, see :ref:class:`Quer... | python | def query(self, query):
"""Returns an iterable of objects matching criteria expressed in `query`.
Implementations of query will be the largest differentiating factor
amongst datastores. All datastores **must** implement query, even using
query's worst case scenario, see :ref:class:`Quer... | [
"def",
"query",
"(",
"self",
",",
"query",
")",
":",
"return",
"query",
"(",
"(",
"self",
".",
"_deserialised_value",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"container",
".",
"get_objects",
"(",
"prefix",
"=",
"query",
".",
"key",
")",
")",
... | Returns an iterable of objects matching criteria expressed in `query`.
Implementations of query will be the largest differentiating factor
amongst datastores. All datastores **must** implement query, even using
query's worst case scenario, see :ref:class:`Query` for details.
:param que... | [
"Returns",
"an",
"iterable",
"of",
"objects",
"matching",
"criteria",
"expressed",
"in",
"query",
"."
] | 95e430c72078cfeaa4c640cae38315fb551128fa | https://github.com/boilerroomtv/datastore.cloudfiles/blob/95e430c72078cfeaa4c640cae38315fb551128fa/datastore/cloudfiles/__init__.py#L80-L90 |
247,955 | dstufft/crust | crust/resources.py | Resource.save | def save(self, force_insert=False, force_update=False):
"""
Saves the current instance. Override this in a subclass if you want to
control the saving process.
The 'force_insert' and 'force_update' parameters can be used to insist
that the "save" must be a POST or PUT respectivel... | python | def save(self, force_insert=False, force_update=False):
"""
Saves the current instance. Override this in a subclass if you want to
control the saving process.
The 'force_insert' and 'force_update' parameters can be used to insist
that the "save" must be a POST or PUT respectivel... | [
"def",
"save",
"(",
"self",
",",
"force_insert",
"=",
"False",
",",
"force_update",
"=",
"False",
")",
":",
"if",
"force_insert",
"and",
"force_update",
":",
"raise",
"ValueError",
"(",
"\"Cannot force both insert and updating in resource saving.\"",
")",
"data",
"=... | Saves the current instance. Override this in a subclass if you want to
control the saving process.
The 'force_insert' and 'force_update' parameters can be used to insist
that the "save" must be a POST or PUT respectively. Normally, they
should not be set. | [
"Saves",
"the",
"current",
"instance",
".",
"Override",
"this",
"in",
"a",
"subclass",
"if",
"you",
"want",
"to",
"control",
"the",
"saving",
"process",
"."
] | 5d4011ecace12fd3f68a03a17dbefb78390a9fc0 | https://github.com/dstufft/crust/blob/5d4011ecace12fd3f68a03a17dbefb78390a9fc0/crust/resources.py#L129-L164 |
247,956 | dstufft/crust | crust/resources.py | Resource.delete | def delete(self):
"""
Deletes the current instance. Override this in a subclass if you want to
control the deleting process.
"""
if self.resource_uri is None:
raise ValueError("{0} object cannot be deleted because resource_uri attribute cannot be None".format(self._me... | python | def delete(self):
"""
Deletes the current instance. Override this in a subclass if you want to
control the deleting process.
"""
if self.resource_uri is None:
raise ValueError("{0} object cannot be deleted because resource_uri attribute cannot be None".format(self._me... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"resource_uri",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"{0} object cannot be deleted because resource_uri attribute cannot be None\"",
".",
"format",
"(",
"self",
".",
"_meta",
".",
"resource_name",
... | Deletes the current instance. Override this in a subclass if you want to
control the deleting process. | [
"Deletes",
"the",
"current",
"instance",
".",
"Override",
"this",
"in",
"a",
"subclass",
"if",
"you",
"want",
"to",
"control",
"the",
"deleting",
"process",
"."
] | 5d4011ecace12fd3f68a03a17dbefb78390a9fc0 | https://github.com/dstufft/crust/blob/5d4011ecace12fd3f68a03a17dbefb78390a9fc0/crust/resources.py#L166-L174 |
247,957 | eallik/spinoff | spinoff/actor/cell.py | _BaseCell.spawn_actor | def spawn_actor(self, factory, name=None):
"""Spawns an actor using the given `factory` with the specified `name`.
Returns an immediately usable `Ref` to the newly created actor, regardless of the location of the new actor, or
when the actual spawning will take place.
"""
if nam... | python | def spawn_actor(self, factory, name=None):
"""Spawns an actor using the given `factory` with the specified `name`.
Returns an immediately usable `Ref` to the newly created actor, regardless of the location of the new actor, or
when the actual spawning will take place.
"""
if nam... | [
"def",
"spawn_actor",
"(",
"self",
",",
"factory",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"and",
"'/'",
"in",
"name",
":",
"# pragma: no cover",
"raise",
"TypeError",
"(",
"\"Actor names cannot contain slashes\"",
")",
"if",
"not",
"self",
".",
"_... | Spawns an actor using the given `factory` with the specified `name`.
Returns an immediately usable `Ref` to the newly created actor, regardless of the location of the new actor, or
when the actual spawning will take place. | [
"Spawns",
"an",
"actor",
"using",
"the",
"given",
"factory",
"with",
"the",
"specified",
"name",
"."
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/actor/cell.py#L48-L69 |
247,958 | eallik/spinoff | spinoff/actor/cell.py | _BaseCell.lookup_cell | def lookup_cell(self, uri):
"""Looks up a local actor by its location relative to this actor."""
steps = uri.steps
if steps[0] == '':
found = self.root
steps.popleft()
else:
found = self
for step in steps:
assert step != ''
... | python | def lookup_cell(self, uri):
"""Looks up a local actor by its location relative to this actor."""
steps = uri.steps
if steps[0] == '':
found = self.root
steps.popleft()
else:
found = self
for step in steps:
assert step != ''
... | [
"def",
"lookup_cell",
"(",
"self",
",",
"uri",
")",
":",
"steps",
"=",
"uri",
".",
"steps",
"if",
"steps",
"[",
"0",
"]",
"==",
"''",
":",
"found",
"=",
"self",
".",
"root",
"steps",
".",
"popleft",
"(",
")",
"else",
":",
"found",
"=",
"self",
... | Looks up a local actor by its location relative to this actor. | [
"Looks",
"up",
"a",
"local",
"actor",
"by",
"its",
"location",
"relative",
"to",
"this",
"actor",
"."
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/actor/cell.py#L94-L108 |
247,959 | amadev/doan | doan/dataset.py | r_num | def r_num(obj):
"""Read list of numbers."""
if isinstance(obj, (list, tuple)):
it = iter
else:
it = LinesIterator
dataset = Dataset([Dataset.FLOAT])
return dataset.load(it(obj)) | python | def r_num(obj):
"""Read list of numbers."""
if isinstance(obj, (list, tuple)):
it = iter
else:
it = LinesIterator
dataset = Dataset([Dataset.FLOAT])
return dataset.load(it(obj)) | [
"def",
"r_num",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"it",
"=",
"iter",
"else",
":",
"it",
"=",
"LinesIterator",
"dataset",
"=",
"Dataset",
"(",
"[",
"Dataset",
".",
"FLOAT",
"]",
")... | Read list of numbers. | [
"Read",
"list",
"of",
"numbers",
"."
] | 5adfa983ac547007a688fe7517291a432919aa3e | https://github.com/amadev/doan/blob/5adfa983ac547007a688fe7517291a432919aa3e/doan/dataset.py#L150-L157 |
247,960 | amadev/doan | doan/dataset.py | r_date_num | def r_date_num(obj, multiple=False):
"""Read date-value table."""
if isinstance(obj, (list, tuple)):
it = iter
else:
it = LinesIterator
if multiple:
datasets = {}
for line in it(obj):
label = line[2]
if label not in datasets:
datase... | python | def r_date_num(obj, multiple=False):
"""Read date-value table."""
if isinstance(obj, (list, tuple)):
it = iter
else:
it = LinesIterator
if multiple:
datasets = {}
for line in it(obj):
label = line[2]
if label not in datasets:
datase... | [
"def",
"r_date_num",
"(",
"obj",
",",
"multiple",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"it",
"=",
"iter",
"else",
":",
"it",
"=",
"LinesIterator",
"if",
"multiple",
":",
"datasets",
... | Read date-value table. | [
"Read",
"date",
"-",
"value",
"table",
"."
] | 5adfa983ac547007a688fe7517291a432919aa3e | https://github.com/amadev/doan/blob/5adfa983ac547007a688fe7517291a432919aa3e/doan/dataset.py#L160-L176 |
247,961 | sysr-q/rcmd.py | rcmd/parser.py | Regex.command | def command(self, rule, **options):
"""\
direct=False, override=True, inject=False, flags=0
"""
options.setdefault("direct", False)
options.setdefault("override", True)
options.setdefault("inject", False)
options.setdefault("flags", 0)
if not options["dire... | python | def command(self, rule, **options):
"""\
direct=False, override=True, inject=False, flags=0
"""
options.setdefault("direct", False)
options.setdefault("override", True)
options.setdefault("inject", False)
options.setdefault("flags", 0)
if not options["dire... | [
"def",
"command",
"(",
"self",
",",
"rule",
",",
"*",
"*",
"options",
")",
":",
"options",
".",
"setdefault",
"(",
"\"direct\"",
",",
"False",
")",
"options",
".",
"setdefault",
"(",
"\"override\"",
",",
"True",
")",
"options",
".",
"setdefault",
"(",
... | \
direct=False, override=True, inject=False, flags=0 | [
"\\",
"direct",
"=",
"False",
"override",
"=",
"True",
"inject",
"=",
"False",
"flags",
"=",
"0"
] | 0ecce1970164805cedb33d02a9dcf9eb6cd14e0c | https://github.com/sysr-q/rcmd.py/blob/0ecce1970164805cedb33d02a9dcf9eb6cd14e0c/rcmd/parser.py#L49-L72 |
247,962 | apiwatcher/apiwatcher-pyclient | apiwatcher_pyclient/client.py | Client.authorize_client_credentials | def authorize_client_credentials(
self, client_id, client_secret=None, scope="private_agent"
):
"""Authorize to platform with client credentials
This should be used if you posses client_id/client_secret pair
generated by platform.
"""
self.auth_data = {
"... | python | def authorize_client_credentials(
self, client_id, client_secret=None, scope="private_agent"
):
"""Authorize to platform with client credentials
This should be used if you posses client_id/client_secret pair
generated by platform.
"""
self.auth_data = {
"... | [
"def",
"authorize_client_credentials",
"(",
"self",
",",
"client_id",
",",
"client_secret",
"=",
"None",
",",
"scope",
"=",
"\"private_agent\"",
")",
":",
"self",
".",
"auth_data",
"=",
"{",
"\"grant_type\"",
":",
"\"client_credentials\"",
",",
"\"scope\"",
":",
... | Authorize to platform with client credentials
This should be used if you posses client_id/client_secret pair
generated by platform. | [
"Authorize",
"to",
"platform",
"with",
"client",
"credentials"
] | 54b5e659be11447d7bb4a05d182ce772ce74b2dc | https://github.com/apiwatcher/apiwatcher-pyclient/blob/54b5e659be11447d7bb4a05d182ce772ce74b2dc/apiwatcher_pyclient/client.py#L37-L52 |
247,963 | apiwatcher/apiwatcher-pyclient | apiwatcher_pyclient/client.py | Client.authorize_password | def authorize_password(self, client_id, username, password):
"""Authorize to platform as regular user
You must provide a valid client_id (same as web application),
your password and your username. Username and password is not stored in
client but refresh token is stored. The only valid ... | python | def authorize_password(self, client_id, username, password):
"""Authorize to platform as regular user
You must provide a valid client_id (same as web application),
your password and your username. Username and password is not stored in
client but refresh token is stored. The only valid ... | [
"def",
"authorize_password",
"(",
"self",
",",
"client_id",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"auth_data",
"=",
"{",
"\"grant_type\"",
":",
"\"password\"",
",",
"\"username\"",
":",
"username",
",",
"\"password\"",
":",
"password",
",",
... | Authorize to platform as regular user
You must provide a valid client_id (same as web application),
your password and your username. Username and password is not stored in
client but refresh token is stored. The only valid scope for this
authorization is "regular_user".
:param ... | [
"Authorize",
"to",
"platform",
"as",
"regular",
"user"
] | 54b5e659be11447d7bb4a05d182ce772ce74b2dc | https://github.com/apiwatcher/apiwatcher-pyclient/blob/54b5e659be11447d7bb4a05d182ce772ce74b2dc/apiwatcher_pyclient/client.py#L54-L78 |
247,964 | apiwatcher/apiwatcher-pyclient | apiwatcher_pyclient/client.py | Client._do_authorize | def _do_authorize(self):
""" Perform the authorization
"""
if self.auth_data is None:
raise ApiwatcherClientException("You must provide authorization data.")
r = requests.post(
"{0}/api/token".format(self.base_url), json=self.auth_data,
verify=self.ve... | python | def _do_authorize(self):
""" Perform the authorization
"""
if self.auth_data is None:
raise ApiwatcherClientException("You must provide authorization data.")
r = requests.post(
"{0}/api/token".format(self.base_url), json=self.auth_data,
verify=self.ve... | [
"def",
"_do_authorize",
"(",
"self",
")",
":",
"if",
"self",
".",
"auth_data",
"is",
"None",
":",
"raise",
"ApiwatcherClientException",
"(",
"\"You must provide authorization data.\"",
")",
"r",
"=",
"requests",
".",
"post",
"(",
"\"{0}/api/token\"",
".",
"format"... | Perform the authorization | [
"Perform",
"the",
"authorization"
] | 54b5e659be11447d7bb4a05d182ce772ce74b2dc | https://github.com/apiwatcher/apiwatcher-pyclient/blob/54b5e659be11447d7bb4a05d182ce772ce74b2dc/apiwatcher_pyclient/client.py#L80-L113 |
247,965 | apiwatcher/apiwatcher-pyclient | apiwatcher_pyclient/client.py | Client._do_request | def _do_request(self, method, endpoint, data=None):
"""Perform one request, possibly solving unauthorized return code
"""
# No token - authorize
if self.token is None:
self._do_authorize()
r = requests.request(
method,
"{0}{1}".format(self.bas... | python | def _do_request(self, method, endpoint, data=None):
"""Perform one request, possibly solving unauthorized return code
"""
# No token - authorize
if self.token is None:
self._do_authorize()
r = requests.request(
method,
"{0}{1}".format(self.bas... | [
"def",
"_do_request",
"(",
"self",
",",
"method",
",",
"endpoint",
",",
"data",
"=",
"None",
")",
":",
"# No token - authorize",
"if",
"self",
".",
"token",
"is",
"None",
":",
"self",
".",
"_do_authorize",
"(",
")",
"r",
"=",
"requests",
".",
"request",
... | Perform one request, possibly solving unauthorized return code | [
"Perform",
"one",
"request",
"possibly",
"solving",
"unauthorized",
"return",
"code"
] | 54b5e659be11447d7bb4a05d182ce772ce74b2dc | https://github.com/apiwatcher/apiwatcher-pyclient/blob/54b5e659be11447d7bb4a05d182ce772ce74b2dc/apiwatcher_pyclient/client.py#L115-L148 |
247,966 | shrubberysoft/homophony | src/homophony/__init__.py | DocFileSuite | def DocFileSuite(*paths, **kwargs):
"""Extension of the standard DocFileSuite that sets up test browser for
use in doctests."""
kwargs.setdefault('setUp', setUpBrowser)
kwargs.setdefault('tearDown', tearDownBrowser)
kwargs.setdefault('globs', {}).update(Browser=Browser)
kwargs.setdefault('option... | python | def DocFileSuite(*paths, **kwargs):
"""Extension of the standard DocFileSuite that sets up test browser for
use in doctests."""
kwargs.setdefault('setUp', setUpBrowser)
kwargs.setdefault('tearDown', tearDownBrowser)
kwargs.setdefault('globs', {}).update(Browser=Browser)
kwargs.setdefault('option... | [
"def",
"DocFileSuite",
"(",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'setUp'",
",",
"setUpBrowser",
")",
"kwargs",
".",
"setdefault",
"(",
"'tearDown'",
",",
"tearDownBrowser",
")",
"kwargs",
".",
"setdefault",
"(... | Extension of the standard DocFileSuite that sets up test browser for
use in doctests. | [
"Extension",
"of",
"the",
"standard",
"DocFileSuite",
"that",
"sets",
"up",
"test",
"browser",
"for",
"use",
"in",
"doctests",
"."
] | 5549371fd6c6fd73b69b3e9b5002d61cf42997f3 | https://github.com/shrubberysoft/homophony/blob/5549371fd6c6fd73b69b3e9b5002d61cf42997f3/src/homophony/__init__.py#L117-L130 |
247,967 | shrubberysoft/homophony | src/homophony/__init__.py | Browser.queryHTML | def queryHTML(self, path):
"""Run an XPath query on the HTML document and print matches."""
if etree is None:
raise Exception("lxml not available")
document = etree.HTML(self.contents)
for node in document.xpath(path):
if isinstance(node, basestring):
... | python | def queryHTML(self, path):
"""Run an XPath query on the HTML document and print matches."""
if etree is None:
raise Exception("lxml not available")
document = etree.HTML(self.contents)
for node in document.xpath(path):
if isinstance(node, basestring):
... | [
"def",
"queryHTML",
"(",
"self",
",",
"path",
")",
":",
"if",
"etree",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"lxml not available\"",
")",
"document",
"=",
"etree",
".",
"HTML",
"(",
"self",
".",
"contents",
")",
"for",
"node",
"in",
"document",... | Run an XPath query on the HTML document and print matches. | [
"Run",
"an",
"XPath",
"query",
"on",
"the",
"HTML",
"document",
"and",
"print",
"matches",
"."
] | 5549371fd6c6fd73b69b3e9b5002d61cf42997f3 | https://github.com/shrubberysoft/homophony/blob/5549371fd6c6fd73b69b3e9b5002d61cf42997f3/src/homophony/__init__.py#L80-L89 |
247,968 | redhog/pieshell | pieshell/pipeline.py | pipeline_repr | def pipeline_repr(obj):
"""Returns a string representation of an object, including pieshell
pipelines."""
if not hasattr(repr_state, 'in_repr'):
repr_state.in_repr = 0
repr_state.in_repr += 1
try:
return standard_repr(obj)
finally:
repr_state.in_repr -= 1 | python | def pipeline_repr(obj):
"""Returns a string representation of an object, including pieshell
pipelines."""
if not hasattr(repr_state, 'in_repr'):
repr_state.in_repr = 0
repr_state.in_repr += 1
try:
return standard_repr(obj)
finally:
repr_state.in_repr -= 1 | [
"def",
"pipeline_repr",
"(",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"repr_state",
",",
"'in_repr'",
")",
":",
"repr_state",
".",
"in_repr",
"=",
"0",
"repr_state",
".",
"in_repr",
"+=",
"1",
"try",
":",
"return",
"standard_repr",
"(",
"obj",
")",
... | Returns a string representation of an object, including pieshell
pipelines. | [
"Returns",
"a",
"string",
"representation",
"of",
"an",
"object",
"including",
"pieshell",
"pipelines",
"."
] | 11cff3b93785ee4446f99b9134be20380edeb767 | https://github.com/redhog/pieshell/blob/11cff3b93785ee4446f99b9134be20380edeb767/pieshell/pipeline.py#L28-L38 |
247,969 | redhog/pieshell | pieshell/pipeline.py | Pipeline.run | def run(self, redirects = []):
"""Runs the pipelines with the specified redirects and returns
a RunningPipeline instance."""
if not isinstance(redirects, redir.Redirects):
redirects = redir.Redirects(self._env._redirects, *redirects)
with copy.copy_session() as sess:
... | python | def run(self, redirects = []):
"""Runs the pipelines with the specified redirects and returns
a RunningPipeline instance."""
if not isinstance(redirects, redir.Redirects):
redirects = redir.Redirects(self._env._redirects, *redirects)
with copy.copy_session() as sess:
... | [
"def",
"run",
"(",
"self",
",",
"redirects",
"=",
"[",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"redirects",
",",
"redir",
".",
"Redirects",
")",
":",
"redirects",
"=",
"redir",
".",
"Redirects",
"(",
"self",
".",
"_env",
".",
"_redirects",
","... | Runs the pipelines with the specified redirects and returns
a RunningPipeline instance. | [
"Runs",
"the",
"pipelines",
"with",
"the",
"specified",
"redirects",
"and",
"returns",
"a",
"RunningPipeline",
"instance",
"."
] | 11cff3b93785ee4446f99b9134be20380edeb767 | https://github.com/redhog/pieshell/blob/11cff3b93785ee4446f99b9134be20380edeb767/pieshell/pipeline.py#L222-L232 |
247,970 | eallik/spinoff | spinoff/util/lockfile.py | lock_file | def lock_file(path, maxdelay=.1, lock_cls=LockFile, timeout=10.0):
"""Cooperative file lock. Uses `lockfile.LockFile` polling under the hood.
`maxdelay` defines the interval between individual polls.
"""
lock = lock_cls(path)
max_t = time.time() + timeout
while True:
if time.time() >= ... | python | def lock_file(path, maxdelay=.1, lock_cls=LockFile, timeout=10.0):
"""Cooperative file lock. Uses `lockfile.LockFile` polling under the hood.
`maxdelay` defines the interval between individual polls.
"""
lock = lock_cls(path)
max_t = time.time() + timeout
while True:
if time.time() >= ... | [
"def",
"lock_file",
"(",
"path",
",",
"maxdelay",
"=",
".1",
",",
"lock_cls",
"=",
"LockFile",
",",
"timeout",
"=",
"10.0",
")",
":",
"lock",
"=",
"lock_cls",
"(",
"path",
")",
"max_t",
"=",
"time",
".",
"time",
"(",
")",
"+",
"timeout",
"while",
"... | Cooperative file lock. Uses `lockfile.LockFile` polling under the hood.
`maxdelay` defines the interval between individual polls. | [
"Cooperative",
"file",
"lock",
".",
"Uses",
"lockfile",
".",
"LockFile",
"polling",
"under",
"the",
"hood",
"."
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/util/lockfile.py#L11-L31 |
247,971 | sveetch/py-css-styleguide | py_css_styleguide/parser.py | TinycssSourceParser.digest_content | def digest_content(self, rule):
"""
Walk on rule content tokens to return a dict of properties.
This is pretty naive and will choke/fail on everything that is more
evolved than simple ``ident(string):value(string)``
Arguments:
rule (tinycss2.ast.QualifiedRule): Qual... | python | def digest_content(self, rule):
"""
Walk on rule content tokens to return a dict of properties.
This is pretty naive and will choke/fail on everything that is more
evolved than simple ``ident(string):value(string)``
Arguments:
rule (tinycss2.ast.QualifiedRule): Qual... | [
"def",
"digest_content",
"(",
"self",
",",
"rule",
")",
":",
"data",
"=",
"OrderedDict",
"(",
")",
"current_key",
"=",
"None",
"for",
"token",
"in",
"rule",
".",
"content",
":",
"# Assume first identity token is the property name",
"if",
"token",
".",
"type",
... | Walk on rule content tokens to return a dict of properties.
This is pretty naive and will choke/fail on everything that is more
evolved than simple ``ident(string):value(string)``
Arguments:
rule (tinycss2.ast.QualifiedRule): Qualified rule object as
returned by ti... | [
"Walk",
"on",
"rule",
"content",
"tokens",
"to",
"return",
"a",
"dict",
"of",
"properties",
"."
] | 5acc693f71b2fa7d944d7fed561ae0a7699ccd0f | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/parser.py#L54-L87 |
247,972 | sveetch/py-css-styleguide | py_css_styleguide/parser.py | TinycssSourceParser.consume | def consume(self, source):
"""
Parse source and consume tokens from tinycss2.
Arguments:
source (string): Source content to parse.
Returns:
dict: Retrieved rules.
"""
manifest = OrderedDict()
rules = parse_stylesheet(
source,... | python | def consume(self, source):
"""
Parse source and consume tokens from tinycss2.
Arguments:
source (string): Source content to parse.
Returns:
dict: Retrieved rules.
"""
manifest = OrderedDict()
rules = parse_stylesheet(
source,... | [
"def",
"consume",
"(",
"self",
",",
"source",
")",
":",
"manifest",
"=",
"OrderedDict",
"(",
")",
"rules",
"=",
"parse_stylesheet",
"(",
"source",
",",
"skip_comments",
"=",
"True",
",",
"skip_whitespace",
"=",
"True",
",",
")",
"for",
"rule",
"in",
"rul... | Parse source and consume tokens from tinycss2.
Arguments:
source (string): Source content to parse.
Returns:
dict: Retrieved rules. | [
"Parse",
"source",
"and",
"consume",
"tokens",
"from",
"tinycss2",
"."
] | 5acc693f71b2fa7d944d7fed561ae0a7699ccd0f | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/parser.py#L89-L118 |
247,973 | tBaxter/tango-comments | build/lib/tango_comments/views/comments.py | post_comment | def post_comment(request, next=None, using=None):
"""
Post a comment.
HTTP POST is required.
"""
# Fill out some initial data fields from an authenticated user, if present
data = request.POST.copy()
if request.user.is_authenticated:
data["user"] = request.user
else:
retu... | python | def post_comment(request, next=None, using=None):
"""
Post a comment.
HTTP POST is required.
"""
# Fill out some initial data fields from an authenticated user, if present
data = request.POST.copy()
if request.user.is_authenticated:
data["user"] = request.user
else:
retu... | [
"def",
"post_comment",
"(",
"request",
",",
"next",
"=",
"None",
",",
"using",
"=",
"None",
")",
":",
"# Fill out some initial data fields from an authenticated user, if present",
"data",
"=",
"request",
".",
"POST",
".",
"copy",
"(",
")",
"if",
"request",
".",
... | Post a comment.
HTTP POST is required. | [
"Post",
"a",
"comment",
"."
] | 1fd335c6fc9e81bba158e42e1483f1a149622ab4 | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/views/comments.py#L35-L127 |
247,974 | dossier/dossier.web | dossier/web/search_engines.py | streaming_sample | def streaming_sample(seq, k, limit=None):
'''Streaming sample.
Iterate over seq (once!) keeping k random elements with uniform
distribution.
As a special case, if ``k`` is ``None``, then ``list(seq)`` is
returned.
:param seq: iterable of things to sample from
:param k: size of desired sam... | python | def streaming_sample(seq, k, limit=None):
'''Streaming sample.
Iterate over seq (once!) keeping k random elements with uniform
distribution.
As a special case, if ``k`` is ``None``, then ``list(seq)`` is
returned.
:param seq: iterable of things to sample from
:param k: size of desired sam... | [
"def",
"streaming_sample",
"(",
"seq",
",",
"k",
",",
"limit",
"=",
"None",
")",
":",
"if",
"k",
"is",
"None",
":",
"return",
"list",
"(",
"seq",
")",
"seq",
"=",
"iter",
"(",
"seq",
")",
"if",
"limit",
"is",
"not",
"None",
":",
"k",
"=",
"min"... | Streaming sample.
Iterate over seq (once!) keeping k random elements with uniform
distribution.
As a special case, if ``k`` is ``None``, then ``list(seq)`` is
returned.
:param seq: iterable of things to sample from
:param k: size of desired sample
:param limit: stop reading ``seq`` after ... | [
"Streaming",
"sample",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/search_engines.py#L102-L128 |
247,975 | minhhoit/yacms | yacms/accounts/__init__.py | get_profile_model | def get_profile_model():
"""
Returns the yacms profile model, defined in
``settings.ACCOUNTS_PROFILE_MODEL``, or ``None`` if no profile
model is configured.
"""
if not getattr(settings, "ACCOUNTS_PROFILE_MODEL", None):
raise ProfileNotConfigured
try:
return apps.get_model(s... | python | def get_profile_model():
"""
Returns the yacms profile model, defined in
``settings.ACCOUNTS_PROFILE_MODEL``, or ``None`` if no profile
model is configured.
"""
if not getattr(settings, "ACCOUNTS_PROFILE_MODEL", None):
raise ProfileNotConfigured
try:
return apps.get_model(s... | [
"def",
"get_profile_model",
"(",
")",
":",
"if",
"not",
"getattr",
"(",
"settings",
",",
"\"ACCOUNTS_PROFILE_MODEL\"",
",",
"None",
")",
":",
"raise",
"ProfileNotConfigured",
"try",
":",
"return",
"apps",
".",
"get_model",
"(",
"settings",
".",
"ACCOUNTS_PROFILE... | Returns the yacms profile model, defined in
``settings.ACCOUNTS_PROFILE_MODEL``, or ``None`` if no profile
model is configured. | [
"Returns",
"the",
"yacms",
"profile",
"model",
"defined",
"in",
"settings",
".",
"ACCOUNTS_PROFILE_MODEL",
"or",
"None",
"if",
"no",
"profile",
"model",
"is",
"configured",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/__init__.py#L22-L40 |
247,976 | minhhoit/yacms | yacms/accounts/__init__.py | get_profile_for_user | def get_profile_for_user(user):
"""
Returns site-specific profile for this user. Raises
``ProfileNotConfigured`` if ``settings.ACCOUNTS_PROFILE_MODEL`` is not
set, and ``ImproperlyConfigured`` if the corresponding model can't
be found.
"""
if not hasattr(user, '_yacms_profile'):
# Ra... | python | def get_profile_for_user(user):
"""
Returns site-specific profile for this user. Raises
``ProfileNotConfigured`` if ``settings.ACCOUNTS_PROFILE_MODEL`` is not
set, and ``ImproperlyConfigured`` if the corresponding model can't
be found.
"""
if not hasattr(user, '_yacms_profile'):
# Ra... | [
"def",
"get_profile_for_user",
"(",
"user",
")",
":",
"if",
"not",
"hasattr",
"(",
"user",
",",
"'_yacms_profile'",
")",
":",
"# Raises ProfileNotConfigured if not bool(ACCOUNTS_PROFILE_MODEL)",
"profile_model",
"=",
"get_profile_model",
"(",
")",
"profile_manager",
"=",
... | Returns site-specific profile for this user. Raises
``ProfileNotConfigured`` if ``settings.ACCOUNTS_PROFILE_MODEL`` is not
set, and ``ImproperlyConfigured`` if the corresponding model can't
be found. | [
"Returns",
"site",
"-",
"specific",
"profile",
"for",
"this",
"user",
".",
"Raises",
"ProfileNotConfigured",
"if",
"settings",
".",
"ACCOUNTS_PROFILE_MODEL",
"is",
"not",
"set",
"and",
"ImproperlyConfigured",
"if",
"the",
"corresponding",
"model",
"can",
"t",
"be"... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/__init__.py#L43-L61 |
247,977 | minhhoit/yacms | yacms/accounts/__init__.py | get_profile_form | def get_profile_form():
"""
Returns the profile form defined by
``settings.ACCOUNTS_PROFILE_FORM_CLASS``.
"""
from yacms.conf import settings
try:
return import_dotted_path(settings.ACCOUNTS_PROFILE_FORM_CLASS)
except ImportError:
raise ImproperlyConfigured("Value for ACCOUNT... | python | def get_profile_form():
"""
Returns the profile form defined by
``settings.ACCOUNTS_PROFILE_FORM_CLASS``.
"""
from yacms.conf import settings
try:
return import_dotted_path(settings.ACCOUNTS_PROFILE_FORM_CLASS)
except ImportError:
raise ImproperlyConfigured("Value for ACCOUNT... | [
"def",
"get_profile_form",
"(",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"try",
":",
"return",
"import_dotted_path",
"(",
"settings",
".",
"ACCOUNTS_PROFILE_FORM_CLASS",
")",
"except",
"ImportError",
":",
"raise",
"ImproperlyConfigured",
"(",
... | Returns the profile form defined by
``settings.ACCOUNTS_PROFILE_FORM_CLASS``. | [
"Returns",
"the",
"profile",
"form",
"defined",
"by",
"settings",
".",
"ACCOUNTS_PROFILE_FORM_CLASS",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/__init__.py#L64-L75 |
247,978 | minhhoit/yacms | yacms/accounts/__init__.py | get_profile_user_fieldname | def get_profile_user_fieldname(profile_model=None, user_model=None):
"""
Returns the name of the first field on the profile model that
points to the ``auth.User`` model.
"""
Profile = profile_model or get_profile_model()
User = user_model or get_user_model()
for field in Profile._meta.fields... | python | def get_profile_user_fieldname(profile_model=None, user_model=None):
"""
Returns the name of the first field on the profile model that
points to the ``auth.User`` model.
"""
Profile = profile_model or get_profile_model()
User = user_model or get_user_model()
for field in Profile._meta.fields... | [
"def",
"get_profile_user_fieldname",
"(",
"profile_model",
"=",
"None",
",",
"user_model",
"=",
"None",
")",
":",
"Profile",
"=",
"profile_model",
"or",
"get_profile_model",
"(",
")",
"User",
"=",
"user_model",
"or",
"get_user_model",
"(",
")",
"for",
"field",
... | Returns the name of the first field on the profile model that
points to the ``auth.User`` model. | [
"Returns",
"the",
"name",
"of",
"the",
"first",
"field",
"on",
"the",
"profile",
"model",
"that",
"points",
"to",
"the",
"auth",
".",
"User",
"model",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/__init__.py#L78-L90 |
247,979 | ttinies/sc2common | sc2common/containers.py | RestrictedType.gameValue | def gameValue(self):
"""identify the correpsonding internal SC2 game value for self.type's value"""
allowed = type(self).ALLOWED_TYPES
try:
if isinstance(allowed, dict): # if ALLOWED_TYPES is not a dict, there is no-internal game value mapping defined
return allowed.g... | python | def gameValue(self):
"""identify the correpsonding internal SC2 game value for self.type's value"""
allowed = type(self).ALLOWED_TYPES
try:
if isinstance(allowed, dict): # if ALLOWED_TYPES is not a dict, there is no-internal game value mapping defined
return allowed.g... | [
"def",
"gameValue",
"(",
"self",
")",
":",
"allowed",
"=",
"type",
"(",
"self",
")",
".",
"ALLOWED_TYPES",
"try",
":",
"if",
"isinstance",
"(",
"allowed",
",",
"dict",
")",
":",
"# if ALLOWED_TYPES is not a dict, there is no-internal game value mapping defined",
"re... | identify the correpsonding internal SC2 game value for self.type's value | [
"identify",
"the",
"correpsonding",
"internal",
"SC2",
"game",
"value",
"for",
"self",
".",
"type",
"s",
"value"
] | 469623c319c7ab7af799551055839ea3b3f87d54 | https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/containers.py#L86-L93 |
247,980 | ttinies/sc2common | sc2common/containers.py | MapPoint.direct2dDistance | def direct2dDistance(self, point):
"""consider the distance between two mapPoints, ignoring all terrain, pathing issues"""
if not isinstance(point, MapPoint): return 0.0
return ((self.x-point.x)**2 + (self.y-point.y)**2)**(0.5) # simple distance formula | python | def direct2dDistance(self, point):
"""consider the distance between two mapPoints, ignoring all terrain, pathing issues"""
if not isinstance(point, MapPoint): return 0.0
return ((self.x-point.x)**2 + (self.y-point.y)**2)**(0.5) # simple distance formula | [
"def",
"direct2dDistance",
"(",
"self",
",",
"point",
")",
":",
"if",
"not",
"isinstance",
"(",
"point",
",",
"MapPoint",
")",
":",
"return",
"0.0",
"return",
"(",
"(",
"self",
".",
"x",
"-",
"point",
".",
"x",
")",
"**",
"2",
"+",
"(",
"self",
"... | consider the distance between two mapPoints, ignoring all terrain, pathing issues | [
"consider",
"the",
"distance",
"between",
"two",
"mapPoints",
"ignoring",
"all",
"terrain",
"pathing",
"issues"
] | 469623c319c7ab7af799551055839ea3b3f87d54 | https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/containers.py#L241-L244 |
247,981 | ttinies/sc2common | sc2common/containers.py | MapPoint.midPoint | def midPoint(self, point):
"""identify the midpoint between two mapPoints"""
x = (self.x + point.x)/2.0
y = (self.y + point.y)/2.0
z = (self.z + point.z)/2.0
return MapPoint(x,y,z) | python | def midPoint(self, point):
"""identify the midpoint between two mapPoints"""
x = (self.x + point.x)/2.0
y = (self.y + point.y)/2.0
z = (self.z + point.z)/2.0
return MapPoint(x,y,z) | [
"def",
"midPoint",
"(",
"self",
",",
"point",
")",
":",
"x",
"=",
"(",
"self",
".",
"x",
"+",
"point",
".",
"x",
")",
"/",
"2.0",
"y",
"=",
"(",
"self",
".",
"y",
"+",
"point",
".",
"y",
")",
"/",
"2.0",
"z",
"=",
"(",
"self",
".",
"z",
... | identify the midpoint between two mapPoints | [
"identify",
"the",
"midpoint",
"between",
"two",
"mapPoints"
] | 469623c319c7ab7af799551055839ea3b3f87d54 | https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/containers.py#L246-L251 |
247,982 | fotonauts/fwissr-python | fwissr/conf.py | merge_conf | def merge_conf(to_hash, other_hash, path=[]):
"merges other_hash into to_hash"
for key in other_hash:
if (key in to_hash and isinstance(to_hash[key], dict)
and isinstance(other_hash[key], dict)):
merge_conf(to_hash[key], other_hash[key], path + [str(key)])
else:
... | python | def merge_conf(to_hash, other_hash, path=[]):
"merges other_hash into to_hash"
for key in other_hash:
if (key in to_hash and isinstance(to_hash[key], dict)
and isinstance(other_hash[key], dict)):
merge_conf(to_hash[key], other_hash[key], path + [str(key)])
else:
... | [
"def",
"merge_conf",
"(",
"to_hash",
",",
"other_hash",
",",
"path",
"=",
"[",
"]",
")",
":",
"for",
"key",
"in",
"other_hash",
":",
"if",
"(",
"key",
"in",
"to_hash",
"and",
"isinstance",
"(",
"to_hash",
"[",
"key",
"]",
",",
"dict",
")",
"and",
"... | merges other_hash into to_hash | [
"merges",
"other_hash",
"into",
"to_hash"
] | 4314aa53ca45b4534cd312f6343a88596b4416d4 | https://github.com/fotonauts/fwissr-python/blob/4314aa53ca45b4534cd312f6343a88596b4416d4/fwissr/conf.py#L7-L15 |
247,983 | hmartiniano/faz | faz/task.py | Task.check_inputs | def check_inputs(self):
""" Check for the existence of input files """
self.inputs = self.expand_filenames(self.inputs)
result = False
if len(self.inputs) == 0 or self.files_exist(self.inputs):
result = True
else:
print("Not executing task. Input file(s) d... | python | def check_inputs(self):
""" Check for the existence of input files """
self.inputs = self.expand_filenames(self.inputs)
result = False
if len(self.inputs) == 0 or self.files_exist(self.inputs):
result = True
else:
print("Not executing task. Input file(s) d... | [
"def",
"check_inputs",
"(",
"self",
")",
":",
"self",
".",
"inputs",
"=",
"self",
".",
"expand_filenames",
"(",
"self",
".",
"inputs",
")",
"result",
"=",
"False",
"if",
"len",
"(",
"self",
".",
"inputs",
")",
"==",
"0",
"or",
"self",
".",
"files_exi... | Check for the existence of input files | [
"Check",
"for",
"the",
"existence",
"of",
"input",
"files"
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L51-L59 |
247,984 | hmartiniano/faz | faz/task.py | Task.check_outputs | def check_outputs(self):
""" Check for the existence of output files """
self.outputs = self.expand_filenames(self.outputs)
result = False
if self.files_exist(self.outputs):
if self.dependencies_are_newer(self.outputs, self.inputs):
result = True
... | python | def check_outputs(self):
""" Check for the existence of output files """
self.outputs = self.expand_filenames(self.outputs)
result = False
if self.files_exist(self.outputs):
if self.dependencies_are_newer(self.outputs, self.inputs):
result = True
... | [
"def",
"check_outputs",
"(",
"self",
")",
":",
"self",
".",
"outputs",
"=",
"self",
".",
"expand_filenames",
"(",
"self",
".",
"outputs",
")",
"result",
"=",
"False",
"if",
"self",
".",
"files_exist",
"(",
"self",
".",
"outputs",
")",
":",
"if",
"self"... | Check for the existence of output files | [
"Check",
"for",
"the",
"existence",
"of",
"output",
"files"
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L61-L80 |
247,985 | hmartiniano/faz | faz/task.py | Task.expand_filenames | def expand_filenames(self, filenames):
"""
Expand a list of filenames using environment variables,
followed by expansion of shell-style wildcards.
"""
results = []
for filename in filenames:
result = filename
if "$" in filename:
tem... | python | def expand_filenames(self, filenames):
"""
Expand a list of filenames using environment variables,
followed by expansion of shell-style wildcards.
"""
results = []
for filename in filenames:
result = filename
if "$" in filename:
tem... | [
"def",
"expand_filenames",
"(",
"self",
",",
"filenames",
")",
":",
"results",
"=",
"[",
"]",
"for",
"filename",
"in",
"filenames",
":",
"result",
"=",
"filename",
"if",
"\"$\"",
"in",
"filename",
":",
"template",
"=",
"Template",
"(",
"filename",
")",
"... | Expand a list of filenames using environment variables,
followed by expansion of shell-style wildcards. | [
"Expand",
"a",
"list",
"of",
"filenames",
"using",
"environment",
"variables",
"followed",
"by",
"expansion",
"of",
"shell",
"-",
"style",
"wildcards",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L103-L126 |
247,986 | hmartiniano/faz | faz/task.py | Task.files_exist | def files_exist(self, filenames):
""" Check if all files in a given list exist. """
return all([os.path.exists(os.path.abspath(filename)) and os.path.isfile(os.path.abspath(filename))
for filename in filenames]) | python | def files_exist(self, filenames):
""" Check if all files in a given list exist. """
return all([os.path.exists(os.path.abspath(filename)) and os.path.isfile(os.path.abspath(filename))
for filename in filenames]) | [
"def",
"files_exist",
"(",
"self",
",",
"filenames",
")",
":",
"return",
"all",
"(",
"[",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
")",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
"."... | Check if all files in a given list exist. | [
"Check",
"if",
"all",
"files",
"in",
"a",
"given",
"list",
"exist",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L128-L131 |
247,987 | hmartiniano/faz | faz/task.py | Task.dependencies_are_newer | def dependencies_are_newer(self, files, dependencies):
"""
For two lists of files, check if any file in the
second list is newer than any file of the first.
"""
dependency_mtimes = [
os.path.getmtime(filename) for filename in dependencies]
file_mtimes = [os.pa... | python | def dependencies_are_newer(self, files, dependencies):
"""
For two lists of files, check if any file in the
second list is newer than any file of the first.
"""
dependency_mtimes = [
os.path.getmtime(filename) for filename in dependencies]
file_mtimes = [os.pa... | [
"def",
"dependencies_are_newer",
"(",
"self",
",",
"files",
",",
"dependencies",
")",
":",
"dependency_mtimes",
"=",
"[",
"os",
".",
"path",
".",
"getmtime",
"(",
"filename",
")",
"for",
"filename",
"in",
"dependencies",
"]",
"file_mtimes",
"=",
"[",
"os",
... | For two lists of files, check if any file in the
second list is newer than any file of the first. | [
"For",
"two",
"lists",
"of",
"files",
"check",
"if",
"any",
"file",
"in",
"the",
"second",
"list",
"is",
"newer",
"than",
"any",
"file",
"of",
"the",
"first",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L133-L146 |
247,988 | hmartiniano/faz | faz/task.py | Task.mktemp_file | def mktemp_file(self):
""" Create a temporary file in the '.faz' directory for
the code to feed to the interpreter. """
if not(os.path.exists(self.__dirname)):
logging.debug("Creating directory {}".format(self.__dirname))
os.mkdir(self.__dirname)
elif not(os.p... | python | def mktemp_file(self):
""" Create a temporary file in the '.faz' directory for
the code to feed to the interpreter. """
if not(os.path.exists(self.__dirname)):
logging.debug("Creating directory {}".format(self.__dirname))
os.mkdir(self.__dirname)
elif not(os.p... | [
"def",
"mktemp_file",
"(",
"self",
")",
":",
"if",
"not",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"__dirname",
")",
")",
":",
"logging",
".",
"debug",
"(",
"\"Creating directory {}\"",
".",
"format",
"(",
"self",
".",
"__dirname",
")",... | Create a temporary file in the '.faz' directory for
the code to feed to the interpreter. | [
"Create",
"a",
"temporary",
"file",
"in",
"the",
".",
"faz",
"directory",
"for",
"the",
"code",
"to",
"feed",
"to",
"the",
"interpreter",
"."
] | 36a58c45e8c0718d38cb3c533542c8743e7e7a65 | https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/task.py#L182-L194 |
247,989 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py | _get_max_page | def _get_max_page(dom):
"""
Try to guess how much pages are in book listing.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
int: Number of pages for given category.
"""
div = dom.find("div", {"class": "razeniKnihListovani"})
if not div:
... | python | def _get_max_page(dom):
"""
Try to guess how much pages are in book listing.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
int: Number of pages for given category.
"""
div = dom.find("div", {"class": "razeniKnihListovani"})
if not div:
... | [
"def",
"_get_max_page",
"(",
"dom",
")",
":",
"div",
"=",
"dom",
".",
"find",
"(",
"\"div\"",
",",
"{",
"\"class\"",
":",
"\"razeniKnihListovani\"",
"}",
")",
"if",
"not",
"div",
":",
"return",
"1",
"# isolate only page numbers from links",
"links",
"=",
"di... | Try to guess how much pages are in book listing.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
int: Number of pages for given category. | [
"Try",
"to",
"guess",
"how",
"much",
"pages",
"are",
"in",
"book",
"listing",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py#L34-L65 |
247,990 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py | _parse_book_links | def _parse_book_links(dom):
"""
Parse links to the details about publications from page with book list.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
list: List of strings / absolute links to book details.
"""
links = []
picker = lambda x: x.pa... | python | def _parse_book_links(dom):
"""
Parse links to the details about publications from page with book list.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
list: List of strings / absolute links to book details.
"""
links = []
picker = lambda x: x.pa... | [
"def",
"_parse_book_links",
"(",
"dom",
")",
":",
"links",
"=",
"[",
"]",
"picker",
"=",
"lambda",
"x",
":",
"x",
".",
"params",
".",
"get",
"(",
"\"class\"",
",",
"\"\"",
")",
".",
"startswith",
"(",
"\"boxProKnihy\"",
")",
"for",
"el",
"in",
"dom",... | Parse links to the details about publications from page with book list.
Args:
dom (obj): HTMLElement container of the page with book list.
Returns:
list: List of strings / absolute links to book details. | [
"Parse",
"links",
"to",
"the",
"details",
"about",
"publications",
"from",
"page",
"with",
"book",
"list",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py#L68-L89 |
247,991 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py | get_book_links | def get_book_links(links):
"""
Go thru `links` to categories and return list to all publications in all
given categories.
Args:
links (list): List of strings (absolute links to categories).
Returns:
list: List of strings / absolute links to book details.
"""
book_links = []... | python | def get_book_links(links):
"""
Go thru `links` to categories and return list to all publications in all
given categories.
Args:
links (list): List of strings (absolute links to categories).
Returns:
list: List of strings / absolute links to book details.
"""
book_links = []... | [
"def",
"get_book_links",
"(",
"links",
")",
":",
"book_links",
"=",
"[",
"]",
"for",
"link",
"in",
"links",
":",
"data",
"=",
"DOWNER",
".",
"download",
"(",
"link",
"+",
"\"1\"",
")",
"dom",
"=",
"dhtmlparser",
".",
"parseString",
"(",
"data",
")",
... | Go thru `links` to categories and return list to all publications in all
given categories.
Args:
links (list): List of strings (absolute links to categories).
Returns:
list: List of strings / absolute links to book details. | [
"Go",
"thru",
"links",
"to",
"categories",
"and",
"return",
"list",
"to",
"all",
"publications",
"in",
"all",
"given",
"categories",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py#L92-L124 |
247,992 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py | _parse_authors | def _parse_authors(authors):
"""
Parse informations about authors of the book.
Args:
dom (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`.Author` objects. Blank if no author \
found.
"""
link = authors.find("a")
lin... | python | def _parse_authors(authors):
"""
Parse informations about authors of the book.
Args:
dom (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`.Author` objects. Blank if no author \
found.
"""
link = authors.find("a")
lin... | [
"def",
"_parse_authors",
"(",
"authors",
")",
":",
"link",
"=",
"authors",
".",
"find",
"(",
"\"a\"",
")",
"link",
"=",
"link",
"[",
"0",
"]",
".",
"params",
".",
"get",
"(",
"\"href\"",
")",
"if",
"link",
"else",
"None",
"author_list",
"=",
"_strip_... | Parse informations about authors of the book.
Args:
dom (obj): HTMLElement containing slice of the page with details.
Returns:
list: List of :class:`.Author` objects. Blank if no author \
found. | [
"Parse",
"informations",
"about",
"authors",
"of",
"the",
"book",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py#L146-L171 |
247,993 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py | _process_book | def _process_book(link):
"""
Download and parse available informations about book from the publishers
webpages.
Args:
link (str): URL of the book at the publishers webpages.
Returns:
obj: :class:`.Publication` instance with book details.
"""
# download and parse book info
... | python | def _process_book(link):
"""
Download and parse available informations about book from the publishers
webpages.
Args:
link (str): URL of the book at the publishers webpages.
Returns:
obj: :class:`.Publication` instance with book details.
"""
# download and parse book info
... | [
"def",
"_process_book",
"(",
"link",
")",
":",
"# download and parse book info",
"data",
"=",
"DOWNER",
".",
"download",
"(",
"link",
")",
"dom",
"=",
"dhtmlparser",
".",
"parseString",
"(",
"utils",
".",
"handle_encodnig",
"(",
"data",
")",
")",
"dhtmlparser"... | Download and parse available informations about book from the publishers
webpages.
Args:
link (str): URL of the book at the publishers webpages.
Returns:
obj: :class:`.Publication` instance with book details. | [
"Download",
"and",
"parse",
"available",
"informations",
"about",
"book",
"from",
"the",
"publishers",
"webpages",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/__init__.py#L174-L238 |
247,994 | rorr73/LifeSOSpy | lifesospy/response.py | Response.parse | def parse(text) -> Optional['Response']:
"""Parse response into an instance of the appropriate child class."""
# Trim the start and end markers, and ensure only lowercase is used
if text.startswith(MARKER_START) and text.endswith(MARKER_END):
text = text[1:len(text)-1].lower()
... | python | def parse(text) -> Optional['Response']:
"""Parse response into an instance of the appropriate child class."""
# Trim the start and end markers, and ensure only lowercase is used
if text.startswith(MARKER_START) and text.endswith(MARKER_END):
text = text[1:len(text)-1].lower()
... | [
"def",
"parse",
"(",
"text",
")",
"->",
"Optional",
"[",
"'Response'",
"]",
":",
"# Trim the start and end markers, and ensure only lowercase is used",
"if",
"text",
".",
"startswith",
"(",
"MARKER_START",
")",
"and",
"text",
".",
"endswith",
"(",
"MARKER_END",
")",... | Parse response into an instance of the appropriate child class. | [
"Parse",
"response",
"into",
"an",
"instance",
"of",
"the",
"appropriate",
"child",
"class",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/response.py#L41-L106 |
247,995 | rorr73/LifeSOSpy | lifesospy/response.py | DeviceInfoResponse.is_closed | def is_closed(self) -> Optional[bool]:
"""For Magnet Sensor; True if Closed, False if Open."""
if self._device_type is not None and self._device_type == DeviceType.DoorMagnet:
return bool(self._current_status & 0x01)
return None | python | def is_closed(self) -> Optional[bool]:
"""For Magnet Sensor; True if Closed, False if Open."""
if self._device_type is not None and self._device_type == DeviceType.DoorMagnet:
return bool(self._current_status & 0x01)
return None | [
"def",
"is_closed",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"if",
"self",
".",
"_device_type",
"is",
"not",
"None",
"and",
"self",
".",
"_device_type",
"==",
"DeviceType",
".",
"DoorMagnet",
":",
"return",
"bool",
"(",
"self",
".",
"... | For Magnet Sensor; True if Closed, False if Open. | [
"For",
"Magnet",
"Sensor",
";",
"True",
"if",
"Closed",
"False",
"if",
"Open",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/response.py#L333-L337 |
247,996 | rorr73/LifeSOSpy | lifesospy/response.py | DeviceInfoResponse.rssi_bars | def rssi_bars(self) -> int:
"""Received Signal Strength Indication, from 0 to 4 bars."""
rssi_db = self.rssi_db
if rssi_db < 45:
return 0
elif rssi_db < 60:
return 1
elif rssi_db < 75:
return 2
elif rssi_db < 90:
return 3
... | python | def rssi_bars(self) -> int:
"""Received Signal Strength Indication, from 0 to 4 bars."""
rssi_db = self.rssi_db
if rssi_db < 45:
return 0
elif rssi_db < 60:
return 1
elif rssi_db < 75:
return 2
elif rssi_db < 90:
return 3
... | [
"def",
"rssi_bars",
"(",
"self",
")",
"->",
"int",
":",
"rssi_db",
"=",
"self",
".",
"rssi_db",
"if",
"rssi_db",
"<",
"45",
":",
"return",
"0",
"elif",
"rssi_db",
"<",
"60",
":",
"return",
"1",
"elif",
"rssi_db",
"<",
"75",
":",
"return",
"2",
"eli... | Received Signal Strength Indication, from 0 to 4 bars. | [
"Received",
"Signal",
"Strength",
"Indication",
"from",
"0",
"to",
"4",
"bars",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/response.py#L350-L361 |
247,997 | rorr73/LifeSOSpy | lifesospy/response.py | EventLogResponse.zone | def zone(self) -> Optional[str]:
"""Zone the device is assigned to."""
if self._device_category == DC_BASEUNIT:
return None
return '{:02x}-{:02x}'.format(self._group_number, self._unit_number) | python | def zone(self) -> Optional[str]:
"""Zone the device is assigned to."""
if self._device_category == DC_BASEUNIT:
return None
return '{:02x}-{:02x}'.format(self._group_number, self._unit_number) | [
"def",
"zone",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"_device_category",
"==",
"DC_BASEUNIT",
":",
"return",
"None",
"return",
"'{:02x}-{:02x}'",
".",
"format",
"(",
"self",
".",
"_group_number",
",",
"self",
".",
"... | Zone the device is assigned to. | [
"Zone",
"the",
"device",
"is",
"assigned",
"to",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/response.py#L926-L930 |
247,998 | ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/subscribers.py | workspace_state_changed | def workspace_state_changed(ob, event):
"""
when a workspace is made 'open', we need to
give all intranet users the 'Guest' role
equally, when the workspace is not open, we need
to remove the role again
"""
workspace = event.object
roles = ['Guest', ]
if event.new_state.id == 'open'... | python | def workspace_state_changed(ob, event):
"""
when a workspace is made 'open', we need to
give all intranet users the 'Guest' role
equally, when the workspace is not open, we need
to remove the role again
"""
workspace = event.object
roles = ['Guest', ]
if event.new_state.id == 'open'... | [
"def",
"workspace_state_changed",
"(",
"ob",
",",
"event",
")",
":",
"workspace",
"=",
"event",
".",
"object",
"roles",
"=",
"[",
"'Guest'",
",",
"]",
"if",
"event",
".",
"new_state",
".",
"id",
"==",
"'open'",
":",
"api",
".",
"group",
".",
"grant_rol... | when a workspace is made 'open', we need to
give all intranet users the 'Guest' role
equally, when the workspace is not open, we need
to remove the role again | [
"when",
"a",
"workspace",
"is",
"made",
"open",
"we",
"need",
"to",
"give",
"all",
"intranet",
"users",
"the",
"Guest",
"role"
] | a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/subscribers.py#L13-L36 |
247,999 | ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/subscribers.py | workspace_added | def workspace_added(ob, event):
"""
when a workspace is created, we add the creator to
the admin group. We then setup our placeful workflow
"""
# Whoever creates the workspace should be added as an Admin
creator = ob.Creator()
IWorkspace(ob).add_to_team(
user=creator,
groups... | python | def workspace_added(ob, event):
"""
when a workspace is created, we add the creator to
the admin group. We then setup our placeful workflow
"""
# Whoever creates the workspace should be added as an Admin
creator = ob.Creator()
IWorkspace(ob).add_to_team(
user=creator,
groups... | [
"def",
"workspace_added",
"(",
"ob",
",",
"event",
")",
":",
"# Whoever creates the workspace should be added as an Admin",
"creator",
"=",
"ob",
".",
"Creator",
"(",
")",
"IWorkspace",
"(",
"ob",
")",
".",
"add_to_team",
"(",
"user",
"=",
"creator",
",",
"group... | when a workspace is created, we add the creator to
the admin group. We then setup our placeful workflow | [
"when",
"a",
"workspace",
"is",
"created",
"we",
"add",
"the",
"creator",
"to",
"the",
"admin",
"group",
".",
"We",
"then",
"setup",
"our",
"placeful",
"workflow"
] | a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/subscribers.py#L39-L59 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.