repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
ronaldguillen/wave | wave/exceptions.py | _force_text_recursive | def _force_text_recursive(data):
"""
Descend into a nested data structure, forcing any
lazy translation strings into plain text.
"""
if isinstance(data, list):
ret = [
_force_text_recursive(item) for item in data
]
if isinstance(data, ReturnList):
retu... | python | def _force_text_recursive(data):
"""
Descend into a nested data structure, forcing any
lazy translation strings into plain text.
"""
if isinstance(data, list):
ret = [
_force_text_recursive(item) for item in data
]
if isinstance(data, ReturnList):
retu... | [
"def",
"_force_text_recursive",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"ret",
"=",
"[",
"_force_text_recursive",
"(",
"item",
")",
"for",
"item",
"in",
"data",
"]",
"if",
"isinstance",
"(",
"data",
",",
"ReturnList... | Descend into a nested data structure, forcing any
lazy translation strings into plain text. | [
"Descend",
"into",
"a",
"nested",
"data",
"structure",
"forcing",
"any",
"lazy",
"translation",
"strings",
"into",
"plain",
"text",
"."
] | train | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/exceptions.py#L20-L40 |
OlivierB/Bashutils | bashutils/colors.py | color_text | def color_text(text, color="none", bcolor="none", effect="none"):
"""
Return a formated text with bash color
"""
istty = False
try:
istty = sys.stdout.isatty()
except:
pass
if not istty or not COLOR_ON:
return text
else:
if not effect in COLOR_EFFET.keys()... | python | def color_text(text, color="none", bcolor="none", effect="none"):
"""
Return a formated text with bash color
"""
istty = False
try:
istty = sys.stdout.isatty()
except:
pass
if not istty or not COLOR_ON:
return text
else:
if not effect in COLOR_EFFET.keys()... | [
"def",
"color_text",
"(",
"text",
",",
"color",
"=",
"\"none\"",
",",
"bcolor",
"=",
"\"none\"",
",",
"effect",
"=",
"\"none\"",
")",
":",
"istty",
"=",
"False",
"try",
":",
"istty",
"=",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
"except",
":",
... | Return a formated text with bash color | [
"Return",
"a",
"formated",
"text",
"with",
"bash",
"color"
] | train | https://github.com/OlivierB/Bashutils/blob/487762049f5d09f14f8a6c764bc0a823f332d8a1/bashutils/colors.py#L68-L94 |
radjkarl/fancyTools | fancytools/os/countLines.py | countLines | def countLines(filename, buf_size=1048576):
"""
fast counting to the lines of a given filename
through only reading out a limited buffer
"""
f = open(filename)
try:
lines = 1
read_f = f.read # loop optimization
buf = read_f(buf_size)
# Empty file
if not b... | python | def countLines(filename, buf_size=1048576):
"""
fast counting to the lines of a given filename
through only reading out a limited buffer
"""
f = open(filename)
try:
lines = 1
read_f = f.read # loop optimization
buf = read_f(buf_size)
# Empty file
if not b... | [
"def",
"countLines",
"(",
"filename",
",",
"buf_size",
"=",
"1048576",
")",
":",
"f",
"=",
"open",
"(",
"filename",
")",
"try",
":",
"lines",
"=",
"1",
"read_f",
"=",
"f",
".",
"read",
"# loop optimization",
"buf",
"=",
"read_f",
"(",
"buf_size",
")",
... | fast counting to the lines of a given filename
through only reading out a limited buffer | [
"fast",
"counting",
"to",
"the",
"lines",
"of",
"a",
"given",
"filename",
"through",
"only",
"reading",
"out",
"a",
"limited",
"buffer"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/os/countLines.py#L5-L23 |
beatmax/redmodel | redmodel/models/base.py | Model.zfind | def zfind(cls, **kwargs):
""" Calls typecast_for_write, so it can be used with datetime values,
or other special field types. For other z* methods,
typecast_for_write must be called explicitly if needed. """
assert len(kwargs) == 1
fldcond = kwargs.keys()[0].split('__')
... | python | def zfind(cls, **kwargs):
""" Calls typecast_for_write, so it can be used with datetime values,
or other special field types. For other z* methods,
typecast_for_write must be called explicitly if needed. """
assert len(kwargs) == 1
fldcond = kwargs.keys()[0].split('__')
... | [
"def",
"zfind",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"kwargs",
")",
"==",
"1",
"fldcond",
"=",
"kwargs",
".",
"keys",
"(",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'__'",
")",
"fld",
"=",
"fldcond",
"[",
"0",
"]... | Calls typecast_for_write, so it can be used with datetime values,
or other special field types. For other z* methods,
typecast_for_write must be called explicitly if needed. | [
"Calls",
"typecast_for_write",
"so",
"it",
"can",
"be",
"used",
"with",
"datetime",
"values",
"or",
"other",
"special",
"field",
"types",
".",
"For",
"other",
"z",
"*",
"methods",
"typecast_for_write",
"must",
"be",
"called",
"explicitly",
"if",
"needed",
"."
... | train | https://github.com/beatmax/redmodel/blob/1df545ecd8e36e8addeaac124db32d9d0e22938c/redmodel/models/base.py#L191-L209 |
pybel/pybel-artifactory | src/pybel_artifactory/hashing.py | _names_to_bytes | def _names_to_bytes(names):
"""Reproducibly converts an iterable of strings to bytes
:param iter[str] names: An iterable of strings
:rtype: bytes
"""
names = sorted(names)
names_bytes = json.dumps(names).encode('utf8')
return names_bytes | python | def _names_to_bytes(names):
"""Reproducibly converts an iterable of strings to bytes
:param iter[str] names: An iterable of strings
:rtype: bytes
"""
names = sorted(names)
names_bytes = json.dumps(names).encode('utf8')
return names_bytes | [
"def",
"_names_to_bytes",
"(",
"names",
")",
":",
"names",
"=",
"sorted",
"(",
"names",
")",
"names_bytes",
"=",
"json",
".",
"dumps",
"(",
"names",
")",
".",
"encode",
"(",
"'utf8'",
")",
"return",
"names_bytes"
] | Reproducibly converts an iterable of strings to bytes
:param iter[str] names: An iterable of strings
:rtype: bytes | [
"Reproducibly",
"converts",
"an",
"iterable",
"of",
"strings",
"to",
"bytes"
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L19-L27 |
pybel/pybel-artifactory | src/pybel_artifactory/hashing.py | hash_names | def hash_names(names, hash_function=None):
"""Return the hash of an iterable of strings, or a dict if multiple hash functions given.
:param iter[str] names: An iterable of strings
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512`
:rtype:... | python | def hash_names(names, hash_function=None):
"""Return the hash of an iterable of strings, or a dict if multiple hash functions given.
:param iter[str] names: An iterable of strings
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512`
:rtype:... | [
"def",
"hash_names",
"(",
"names",
",",
"hash_function",
"=",
"None",
")",
":",
"hash_function",
"=",
"hash_function",
"or",
"hashlib",
".",
"md5",
"names_bytes",
"=",
"_names_to_bytes",
"(",
"names",
")",
"return",
"hash_function",
"(",
"names_bytes",
")",
".... | Return the hash of an iterable of strings, or a dict if multiple hash functions given.
:param iter[str] names: An iterable of strings
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :func:`hashlib.sha512`
:rtype: str | [
"Return",
"the",
"hash",
"of",
"an",
"iterable",
"of",
"strings",
"or",
"a",
"dict",
"if",
"multiple",
"hash",
"functions",
"given",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L30-L39 |
pybel/pybel-artifactory | src/pybel_artifactory/hashing.py | get_bel_resource_hash | def get_bel_resource_hash(location, hash_function=None):
"""Get a BEL resource file and returns its semantic hash.
:param str location: URL of a resource
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512`
:return: The hexadecimal digest o... | python | def get_bel_resource_hash(location, hash_function=None):
"""Get a BEL resource file and returns its semantic hash.
:param str location: URL of a resource
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512`
:return: The hexadecimal digest o... | [
"def",
"get_bel_resource_hash",
"(",
"location",
",",
"hash_function",
"=",
"None",
")",
":",
"resource",
"=",
"get_bel_resource",
"(",
"location",
")",
"return",
"hash_names",
"(",
"resource",
"[",
"'Values'",
"]",
",",
"hash_function",
"=",
"hash_function",
")... | Get a BEL resource file and returns its semantic hash.
:param str location: URL of a resource
:param hash_function: A hash function or list of hash functions, like :func:`hashlib.md5` or :code:`hashlib.sha512`
:return: The hexadecimal digest of the hash of the values in the resource
:rtype: str
:ra... | [
"Get",
"a",
"BEL",
"resource",
"file",
"and",
"returns",
"its",
"semantic",
"hash",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/hashing.py#L42-L56 |
dankelley/nota | nota/notaclass.py | Nota.compute_hash | def compute_hash(self, noteId, date, title):
'''
Compute a hash. This is somewhat resistant to errors, e.g. if somehow the date is None,
this will still work.
'''
if not noteId:
noteId = ''.join(random.choice(string.digits) for _ in range(4))
if not date:
... | python | def compute_hash(self, noteId, date, title):
'''
Compute a hash. This is somewhat resistant to errors, e.g. if somehow the date is None,
this will still work.
'''
if not noteId:
noteId = ''.join(random.choice(string.digits) for _ in range(4))
if not date:
... | [
"def",
"compute_hash",
"(",
"self",
",",
"noteId",
",",
"date",
",",
"title",
")",
":",
"if",
"not",
"noteId",
":",
"noteId",
"=",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"digits",
")",
"for",
"_",
"in",
"range",
"(",
... | Compute a hash. This is somewhat resistant to errors, e.g. if somehow the date is None,
this will still work. | [
"Compute",
"a",
"hash",
".",
"This",
"is",
"somewhat",
"resistant",
"to",
"errors",
"e",
".",
"g",
".",
"if",
"somehow",
"the",
"date",
"is",
"None",
"this",
"will",
"still",
"work",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L256-L268 |
dankelley/nota | nota/notaclass.py | Nota.book_name | def book_name(self, number):
'''Return name of book with given index.'''
try:
name = self.cur.execute("SELECT name FROM book WHERE number = ?;", [number]).fetchone()
except:
self.error("cannot look up name of book number %s" % number)
return(str(name[0])) | python | def book_name(self, number):
'''Return name of book with given index.'''
try:
name = self.cur.execute("SELECT name FROM book WHERE number = ?;", [number]).fetchone()
except:
self.error("cannot look up name of book number %s" % number)
return(str(name[0])) | [
"def",
"book_name",
"(",
"self",
",",
"number",
")",
":",
"try",
":",
"name",
"=",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT name FROM book WHERE number = ?;\"",
",",
"[",
"number",
"]",
")",
".",
"fetchone",
"(",
")",
"except",
":",
"self",
"."... | Return name of book with given index. | [
"Return",
"name",
"of",
"book",
"with",
"given",
"index",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L271-L277 |
dankelley/nota | nota/notaclass.py | Nota.book_number | def book_number(self, name):
'''Return number of book with given name.'''
try:
number = self.cur.execute("SELECT number FROM book WHERE name= ?;", [name]).fetchone()
except:
self.error("cannot look up number of book with name %s" % name)
return(number) | python | def book_number(self, name):
'''Return number of book with given name.'''
try:
number = self.cur.execute("SELECT number FROM book WHERE name= ?;", [name]).fetchone()
except:
self.error("cannot look up number of book with name %s" % name)
return(number) | [
"def",
"book_number",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"number",
"=",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT number FROM book WHERE name= ?;\"",
",",
"[",
"name",
"]",
")",
".",
"fetchone",
"(",
")",
"except",
":",
"self",
".",... | Return number of book with given name. | [
"Return",
"number",
"of",
"book",
"with",
"given",
"name",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L280-L286 |
dankelley/nota | nota/notaclass.py | Nota.list_books | def list_books(self):
''' Return the list of book names '''
names = []
try:
for n in self.cur.execute("SELECT name FROM book;").fetchall():
names.extend(n)
except:
self.error("ERROR: cannot find database table 'book'")
return(names) | python | def list_books(self):
''' Return the list of book names '''
names = []
try:
for n in self.cur.execute("SELECT name FROM book;").fetchall():
names.extend(n)
except:
self.error("ERROR: cannot find database table 'book'")
return(names) | [
"def",
"list_books",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"try",
":",
"for",
"n",
"in",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT name FROM book;\"",
")",
".",
"fetchall",
"(",
")",
":",
"names",
".",
"extend",
"(",
"n",
")",
"ex... | Return the list of book names | [
"Return",
"the",
"list",
"of",
"book",
"names"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L289-L297 |
dankelley/nota | nota/notaclass.py | Nota.create_book | def create_book(self, name):
"""Create a new book"""
name = name.strip()
if not len(name):
self.error("Cannot have a blank book name")
# The next could be relaxed, if users want commas in book names, but
# I prefer to keep it, in case later there could be a syntax for... | python | def create_book(self, name):
"""Create a new book"""
name = name.strip()
if not len(name):
self.error("Cannot have a blank book name")
# The next could be relaxed, if users want commas in book names, but
# I prefer to keep it, in case later there could be a syntax for... | [
"def",
"create_book",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"if",
"not",
"len",
"(",
"name",
")",
":",
"self",
".",
"error",
"(",
"\"Cannot have a blank book name\"",
")",
"# The next could be relaxed, if users want c... | Create a new book | [
"Create",
"a",
"new",
"book"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L300-L318 |
dankelley/nota | nota/notaclass.py | Nota.initialize | def initialize(self, author=""):
''' Initialize the database. This is dangerous since it removes any
existing content.'''
self.cur.execute("CREATE TABLE version(major, minor);")
self.cur.execute("INSERT INTO version(major, minor) VALUES (?,?);",
(self.appversion[0], self... | python | def initialize(self, author=""):
''' Initialize the database. This is dangerous since it removes any
existing content.'''
self.cur.execute("CREATE TABLE version(major, minor);")
self.cur.execute("INSERT INTO version(major, minor) VALUES (?,?);",
(self.appversion[0], self... | [
"def",
"initialize",
"(",
"self",
",",
"author",
"=",
"\"\"",
")",
":",
"self",
".",
"cur",
".",
"execute",
"(",
"\"CREATE TABLE version(major, minor);\"",
")",
"self",
".",
"cur",
".",
"execute",
"(",
"\"INSERT INTO version(major, minor) VALUES (?,?);\"",
",",
"(... | Initialize the database. This is dangerous since it removes any
existing content. | [
"Initialize",
"the",
"database",
".",
"This",
"is",
"dangerous",
"since",
"it",
"removes",
"any",
"existing",
"content",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L369-L384 |
dankelley/nota | nota/notaclass.py | Nota.add | def add(self, title="", keywords="", content="", attachments="", due="", book=1, privacy=0, date="", modified=""):
''' Add a note to the database. The title should be short (perhaps 3
to 7 words). The keywords are comma-separated, and should be similar
in style to others in the database. The ... | python | def add(self, title="", keywords="", content="", attachments="", due="", book=1, privacy=0, date="", modified=""):
''' Add a note to the database. The title should be short (perhaps 3
to 7 words). The keywords are comma-separated, and should be similar
in style to others in the database. The ... | [
"def",
"add",
"(",
"self",
",",
"title",
"=",
"\"\"",
",",
"keywords",
"=",
"\"\"",
",",
"content",
"=",
"\"\"",
",",
"attachments",
"=",
"\"\"",
",",
"due",
"=",
"\"\"",
",",
"book",
"=",
"1",
",",
"privacy",
"=",
"0",
",",
"date",
"=",
"\"\"",
... | Add a note to the database. The title should be short (perhaps 3
to 7 words). The keywords are comma-separated, and should be similar
in style to others in the database. The content may be of any length. The
attachments are comma-separated, and must be full pathnames to files
that ex... | [
"Add",
"a",
"note",
"to",
"the",
"database",
".",
"The",
"title",
"should",
"be",
"short",
"(",
"perhaps",
"3",
"to",
"7",
"words",
")",
".",
"The",
"keywords",
"are",
"comma",
"-",
"separated",
"and",
"should",
"be",
"similar",
"in",
"style",
"to",
... | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L387-L473 |
dankelley/nota | nota/notaclass.py | Nota.keyword_hookup | def keyword_hookup(self, noteId, keywords):
'''
Unhook existing cross-linking entries.
'''
try:
self.cur.execute("DELETE FROM notekeyword WHERE noteid=?", [noteId])
except:
self.error("ERROR: cannot unhook previous keywords")
# Now, hook up new the... | python | def keyword_hookup(self, noteId, keywords):
'''
Unhook existing cross-linking entries.
'''
try:
self.cur.execute("DELETE FROM notekeyword WHERE noteid=?", [noteId])
except:
self.error("ERROR: cannot unhook previous keywords")
# Now, hook up new the... | [
"def",
"keyword_hookup",
"(",
"self",
",",
"noteId",
",",
"keywords",
")",
":",
"try",
":",
"self",
".",
"cur",
".",
"execute",
"(",
"\"DELETE FROM notekeyword WHERE noteid=?\"",
",",
"[",
"noteId",
"]",
")",
"except",
":",
"self",
".",
"error",
"(",
"\"ER... | Unhook existing cross-linking entries. | [
"Unhook",
"existing",
"cross",
"-",
"linking",
"entries",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L505-L531 |
dankelley/nota | nota/notaclass.py | Nota.list_keywords | def list_keywords(self):
''' Return the list of keywords '''
names = []
try:
for n in self.cur.execute("SELECT keyword FROM keyword;").fetchall():
# Strip out leading and trailing whitespaces (can be artifacts of old data)
k = n[0].strip()
... | python | def list_keywords(self):
''' Return the list of keywords '''
names = []
try:
for n in self.cur.execute("SELECT keyword FROM keyword;").fetchall():
# Strip out leading and trailing whitespaces (can be artifacts of old data)
k = n[0].strip()
... | [
"def",
"list_keywords",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"try",
":",
"for",
"n",
"in",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT keyword FROM keyword;\"",
")",
".",
"fetchall",
"(",
")",
":",
"# Strip out leading and trailing whitespaces... | Return the list of keywords | [
"Return",
"the",
"list",
"of",
"keywords"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L534-L547 |
dankelley/nota | nota/notaclass.py | Nota.edit | def edit(self, hash=""):
'''
Edit a note, given its abbreviated hash, which must be unique
across both visible and trashed notes. (It is permitted to edit
notes in the trash.)
'''
if not len(hash):
exit(0)
self.fyi("nota.edit() has hash: %s" % hash)
... | python | def edit(self, hash=""):
'''
Edit a note, given its abbreviated hash, which must be unique
across both visible and trashed notes. (It is permitted to edit
notes in the trash.)
'''
if not len(hash):
exit(0)
self.fyi("nota.edit() has hash: %s" % hash)
... | [
"def",
"edit",
"(",
"self",
",",
"hash",
"=",
"\"\"",
")",
":",
"if",
"not",
"len",
"(",
"hash",
")",
":",
"exit",
"(",
"0",
")",
"self",
".",
"fyi",
"(",
"\"nota.edit() has hash: %s\"",
"%",
"hash",
")",
"## do not use find_by_hash() because can be in hash ... | Edit a note, given its abbreviated hash, which must be unique
across both visible and trashed notes. (It is permitted to edit
notes in the trash.) | [
"Edit",
"a",
"note",
"given",
"its",
"abbreviated",
"hash",
"which",
"must",
"be",
"unique",
"across",
"both",
"visible",
"and",
"trashed",
"notes",
".",
"(",
"It",
"is",
"permitted",
"to",
"edit",
"notes",
"in",
"the",
"trash",
".",
")"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L673-L722 |
dankelley/nota | nota/notaclass.py | Nota.cleanup | def cleanup(self):
''' Clean up the database, e.g. removing unused keywords.'''
allList = []
allList.extend(self.cur.execute("SELECT keywordid FROM keyword;"))
usedList = []
usedList.extend(self.cur.execute("SELECT keywordid FROM notekeyword;"))
unusedList = [val for val ... | python | def cleanup(self):
''' Clean up the database, e.g. removing unused keywords.'''
allList = []
allList.extend(self.cur.execute("SELECT keywordid FROM keyword;"))
usedList = []
usedList.extend(self.cur.execute("SELECT keywordid FROM notekeyword;"))
unusedList = [val for val ... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"allList",
"=",
"[",
"]",
"allList",
".",
"extend",
"(",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT keywordid FROM keyword;\"",
")",
")",
"usedList",
"=",
"[",
"]",
"usedList",
".",
"extend",
"(",
"self",
... | Clean up the database, e.g. removing unused keywords. | [
"Clean",
"up",
"the",
"database",
"e",
".",
"g",
".",
"removing",
"unused",
"keywords",
"."
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L725-L739 |
dankelley/nota | nota/notaclass.py | Nota.find_by_hash | def find_by_hash(self, hash=None, book=-1):
'''Search notes for a given (possibly abbreviated) hash'''
if hash:
self.fyi("nota.find_by_hash() with abbreviated hash %s; book=%s" % (hash, book))
try:
if book < 0:
rows = self.cur.execute("SELECT noteId, hash ... | python | def find_by_hash(self, hash=None, book=-1):
'''Search notes for a given (possibly abbreviated) hash'''
if hash:
self.fyi("nota.find_by_hash() with abbreviated hash %s; book=%s" % (hash, book))
try:
if book < 0:
rows = self.cur.execute("SELECT noteId, hash ... | [
"def",
"find_by_hash",
"(",
"self",
",",
"hash",
"=",
"None",
",",
"book",
"=",
"-",
"1",
")",
":",
"if",
"hash",
":",
"self",
".",
"fyi",
"(",
"\"nota.find_by_hash() with abbreviated hash %s; book=%s\"",
"%",
"(",
"hash",
",",
"book",
")",
")",
"try",
"... | Search notes for a given (possibly abbreviated) hash | [
"Search",
"notes",
"for",
"a",
"given",
"(",
"possibly",
"abbreviated",
")",
"hash"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L756-L797 |
dankelley/nota | nota/notaclass.py | Nota.find_by_keyword | def find_by_keyword(self, keywords="", strict_match=False, book=-1):
self.fyi("find_by_keyword, ... book=%s" % book)
'''Search notes for a given keyword'''
self.fyi("nota.find_by_keyword() with keywords %s; book=%s" % (keywords, book))
keywordsKnown = []
if not strict_match:
... | python | def find_by_keyword(self, keywords="", strict_match=False, book=-1):
self.fyi("find_by_keyword, ... book=%s" % book)
'''Search notes for a given keyword'''
self.fyi("nota.find_by_keyword() with keywords %s; book=%s" % (keywords, book))
keywordsKnown = []
if not strict_match:
... | [
"def",
"find_by_keyword",
"(",
"self",
",",
"keywords",
"=",
"\"\"",
",",
"strict_match",
"=",
"False",
",",
"book",
"=",
"-",
"1",
")",
":",
"self",
".",
"fyi",
"(",
"\"find_by_keyword, ... book=%s\"",
"%",
"book",
")",
"self",
".",
"fyi",
"(",
"\"nota.... | Search notes for a given keyword | [
"Search",
"notes",
"for",
"a",
"given",
"keyword"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L800-L915 |
dankelley/nota | nota/notaclass.py | Nota.find_recent | def find_recent(self, nrecent=4):
'''Find recent non-trashed notes'''
try:
rows = self.cur.execute("SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;"%nrecent).fetchall()
except:
self.error("nota.find_recent() cannot look up note list")
# Possibl... | python | def find_recent(self, nrecent=4):
'''Find recent non-trashed notes'''
try:
rows = self.cur.execute("SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;"%nrecent).fetchall()
except:
self.error("nota.find_recent() cannot look up note list")
# Possibl... | [
"def",
"find_recent",
"(",
"self",
",",
"nrecent",
"=",
"4",
")",
":",
"try",
":",
"rows",
"=",
"self",
".",
"cur",
".",
"execute",
"(",
"\"SELECT noteId FROM note WHERE book > 0 ORDER BY date DESC LIMIT %d;\"",
"%",
"nrecent",
")",
".",
"fetchall",
"(",
")",
... | Find recent non-trashed notes | [
"Find",
"recent",
"non",
"-",
"trashed",
"notes"
] | train | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L918-L945 |
dasevilla/rovi-python | roviclient/video.py | VideoApi.make_request | def make_request(self, resource, params=None):
"""
Performs the API request. Most methods are a wrapper around this one.
"""
return super(VideoApi, self).make_request('video/%s' % resource, params) | python | def make_request(self, resource, params=None):
"""
Performs the API request. Most methods are a wrapper around this one.
"""
return super(VideoApi, self).make_request('video/%s' % resource, params) | [
"def",
"make_request",
"(",
"self",
",",
"resource",
",",
"params",
"=",
"None",
")",
":",
"return",
"super",
"(",
"VideoApi",
",",
"self",
")",
".",
"make_request",
"(",
"'video/%s'",
"%",
"resource",
",",
"params",
")"
] | Performs the API request. Most methods are a wrapper around this one. | [
"Performs",
"the",
"API",
"request",
".",
"Most",
"methods",
"are",
"a",
"wrapper",
"around",
"this",
"one",
"."
] | train | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L9-L13 |
dasevilla/rovi-python | roviclient/video.py | VideoApi._cosmoid_request | def _cosmoid_request(self, resource, cosmoid, **kwargs):
"""
Maps to the Generic API method for requests who's only parameter is ``cosmoid``
"""
params = {
'cosmoid': cosmoid,
}
params.update(kwargs)
return self.make_request(resource, params) | python | def _cosmoid_request(self, resource, cosmoid, **kwargs):
"""
Maps to the Generic API method for requests who's only parameter is ``cosmoid``
"""
params = {
'cosmoid': cosmoid,
}
params.update(kwargs)
return self.make_request(resource, params) | [
"def",
"_cosmoid_request",
"(",
"self",
",",
"resource",
",",
"cosmoid",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"'cosmoid'",
":",
"cosmoid",
",",
"}",
"params",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"make_request",
"... | Maps to the Generic API method for requests who's only parameter is ``cosmoid`` | [
"Maps",
"to",
"the",
"Generic",
"API",
"method",
"for",
"requests",
"who",
"s",
"only",
"parameter",
"is",
"cosmoid"
] | train | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L15-L25 |
dasevilla/rovi-python | roviclient/video.py | VideoApi.season_info | def season_info(self, cosmoid, season, **kwargs):
"""
Returns information about a season of a TV series
Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method.
"""
resource = 'season/%d/info' % season
... | python | def season_info(self, cosmoid, season, **kwargs):
"""
Returns information about a season of a TV series
Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method.
"""
resource = 'season/%d/info' % season
... | [
"def",
"season_info",
"(",
"self",
",",
"cosmoid",
",",
"season",
",",
"*",
"*",
"kwargs",
")",
":",
"resource",
"=",
"'season/%d/info'",
"%",
"season",
"return",
"self",
".",
"_cosmoid_request",
"(",
"resource",
",",
"cosmoid",
",",
"*",
"*",
"kwargs",
... | Returns information about a season of a TV series
Maps to the `season info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:Season>`_ API method. | [
"Returns",
"information",
"about",
"a",
"season",
"of",
"a",
"TV",
"series"
] | train | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L36-L51 |
dasevilla/rovi-python | roviclient/video.py | VideoApi.episode_info | def episode_info(self, cosmoid, season, episode, **kwargs):
"""
Returns information about an episode in a television series
Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method.
"""
resource = 'seas... | python | def episode_info(self, cosmoid, season, episode, **kwargs):
"""
Returns information about an episode in a television series
Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method.
"""
resource = 'seas... | [
"def",
"episode_info",
"(",
"self",
",",
"cosmoid",
",",
"season",
",",
"episode",
",",
"*",
"*",
"kwargs",
")",
":",
"resource",
"=",
"'season/%d/episode/%d/info'",
"%",
"(",
"season",
",",
"episode",
")",
"return",
"self",
".",
"_cosmoid_request",
"(",
"... | Returns information about an episode in a television series
Maps to the `episode info <http://prod-doc.rovicorp.com/mashery/index.php/V1.MetaData.VideoService.Video:SeasonEpisode>`_ API method. | [
"Returns",
"information",
"about",
"an",
"episode",
"in",
"a",
"television",
"series"
] | train | https://github.com/dasevilla/rovi-python/blob/46039d6ebfcf2ff20b4edb4636cb972682cf6af4/roviclient/video.py#L53-L62 |
rikrd/inspire | inspirespeech/__init__.py | _load_zip_wav | def _load_zip_wav(zfile, offset=0, count=None):
"""Load a wav file into an array from frame start to fram end
:param zfile: ZipExtFile file-like object from where to load the audio
:param offset: First sample to load
:param count: Maximum number of samples to load
:return: The audio samples in a nu... | python | def _load_zip_wav(zfile, offset=0, count=None):
"""Load a wav file into an array from frame start to fram end
:param zfile: ZipExtFile file-like object from where to load the audio
:param offset: First sample to load
:param count: Maximum number of samples to load
:return: The audio samples in a nu... | [
"def",
"_load_zip_wav",
"(",
"zfile",
",",
"offset",
"=",
"0",
",",
"count",
"=",
"None",
")",
":",
"buf",
"=",
"StringIO",
".",
"StringIO",
"(",
"zfile",
".",
"read",
"(",
")",
")",
"sample_rate",
",",
"audio",
"=",
"wavfile",
".",
"read",
"(",
"b... | Load a wav file into an array from frame start to fram end
:param zfile: ZipExtFile file-like object from where to load the audio
:param offset: First sample to load
:param count: Maximum number of samples to load
:return: The audio samples in a numpy array of floats | [
"Load",
"a",
"wav",
"file",
"into",
"an",
"array",
"from",
"frame",
"start",
"to",
"fram",
"end"
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L39-L56 |
rikrd/inspire | inspirespeech/__init__.py | get_edit_scripts | def get_edit_scripts(pron_a, pron_b, edit_costs=(1.0, 1.0, 1.0)):
"""Get the edit scripts to transform between two given pronunciations.
:param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme
:param pron_b: Target pronunciation as list of strings, each string corresp... | python | def get_edit_scripts(pron_a, pron_b, edit_costs=(1.0, 1.0, 1.0)):
"""Get the edit scripts to transform between two given pronunciations.
:param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme
:param pron_b: Target pronunciation as list of strings, each string corresp... | [
"def",
"get_edit_scripts",
"(",
"pron_a",
",",
"pron_b",
",",
"edit_costs",
"=",
"(",
"1.0",
",",
"1.0",
",",
"1.0",
")",
")",
":",
"op_costs",
"=",
"{",
"'insert'",
":",
"lambda",
"x",
":",
"edit_costs",
"[",
"0",
"]",
",",
"'match'",
":",
"lambda",... | Get the edit scripts to transform between two given pronunciations.
:param pron_a: Source pronunciation as list of strings, each string corresponding to a phoneme
:param pron_b: Target pronunciation as list of strings, each string corresponding to a phoneme
:param edit_costs: Costs of insert, replace and d... | [
"Get",
"the",
"edit",
"scripts",
"to",
"transform",
"between",
"two",
"given",
"pronunciations",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L712-L727 |
rikrd/inspire | inspirespeech/__init__.py | edit_script_to_strings | def edit_script_to_strings(edit_script, use_colors=True):
"""Convert an edit script to a pair of strings representing the operation in a human readable way.
:param edit_script: The edit script as a list of operations, where each operation is a dictionary.
:param use_colors: Boolean indicating whether to us... | python | def edit_script_to_strings(edit_script, use_colors=True):
"""Convert an edit script to a pair of strings representing the operation in a human readable way.
:param edit_script: The edit script as a list of operations, where each operation is a dictionary.
:param use_colors: Boolean indicating whether to us... | [
"def",
"edit_script_to_strings",
"(",
"edit_script",
",",
"use_colors",
"=",
"True",
")",
":",
"colors",
"=",
"collections",
".",
"defaultdict",
"(",
"str",
")",
"if",
"use_colors",
":",
"colors",
"[",
"'red'",
"]",
"=",
"'\\x1b[31m'",
"colors",
"[",
"'norma... | Convert an edit script to a pair of strings representing the operation in a human readable way.
:param edit_script: The edit script as a list of operations, where each operation is a dictionary.
:param use_colors: Boolean indicating whether to use terminal color codes to color the output.
:return: Tuple wi... | [
"Convert",
"an",
"edit",
"script",
"to",
"a",
"pair",
"of",
"strings",
"representing",
"the",
"operation",
"in",
"a",
"human",
"readable",
"way",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L786-L837 |
rikrd/inspire | inspirespeech/__init__.py | Submission._where_default | def _where_default(self, pronunciation):
"""Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index
"""... | python | def _where_default(self, pronunciation):
"""Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index
"""... | [
"def",
"_where_default",
"(",
"self",
",",
"pronunciation",
")",
":",
"token_default",
"=",
"self",
"[",
"'metadata'",
"]",
"[",
"'token_default'",
"]",
"[",
"'where'",
"]",
"index_count",
"=",
"2",
"*",
"len",
"(",
"pronunciation",
")",
"+",
"1",
"confusi... | Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index | [
"Provide",
"the",
"default",
"prediction",
"of",
"the",
"where",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L244-L257 |
rikrd/inspire | inspirespeech/__init__.py | Submission._what_default | def _what_default(self, pronunciation):
"""Provide the default prediction of the what task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index
"""
... | python | def _what_default(self, pronunciation):
"""Provide the default prediction of the what task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index
"""
... | [
"def",
"_what_default",
"(",
"self",
",",
"pronunciation",
")",
":",
"token_default",
"=",
"self",
"[",
"'metadata'",
"]",
"[",
"'token_default'",
"]",
"[",
"'what'",
"]",
"index_count",
"=",
"2",
"*",
"len",
"(",
"pronunciation",
")",
"+",
"1",
"predictio... | Provide the default prediction of the what task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The list or array of confusion probabilities at each index | [
"Provide",
"the",
"default",
"prediction",
"of",
"the",
"what",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L259-L285 |
rikrd/inspire | inspirespeech/__init__.py | Submission._full_default | def _full_default(self, pronunciation):
"""Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The pronunciation of the token
"""
token_default = sel... | python | def _full_default(self, pronunciation):
"""Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The pronunciation of the token
"""
token_default = sel... | [
"def",
"_full_default",
"(",
"self",
",",
"pronunciation",
")",
":",
"token_default",
"=",
"self",
"[",
"'metadata'",
"]",
"[",
"'token_default'",
"]",
"[",
"'full'",
"]",
"key",
"=",
"pronunciation",
"if",
"isinstance",
"(",
"key",
",",
"list",
")",
":",
... | Provide the default prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param pronunciation: The pronunciation of the token | [
"Provide",
"the",
"default",
"prediction",
"of",
"the",
"where",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L287-L309 |
rikrd/inspire | inspirespeech/__init__.py | Submission.where_task | def where_task(self, token_id, presented_pronunciation, confusion_probability):
"""Provide the prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param token_id: The token for which the prediction is being ... | python | def where_task(self, token_id, presented_pronunciation, confusion_probability):
"""Provide the prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param token_id: The token for which the prediction is being ... | [
"def",
"where_task",
"(",
"self",
",",
"token_id",
",",
"presented_pronunciation",
",",
"confusion_probability",
")",
":",
"self",
"[",
"'tokens'",
"]",
".",
"setdefault",
"(",
"token_id",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"'where'",
",",
"self",
... | Provide the prediction of the where task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param token_id: The token for which the prediction is being provided
:param confusion_probability: The list or array of confusion probabilities... | [
"Provide",
"the",
"prediction",
"of",
"the",
"where",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L311-L323 |
rikrd/inspire | inspirespeech/__init__.py | Submission.what_task | def what_task(self, token_id, presented_pronunciation, index, phonemes, phonemes_probability,
warn=True, default=True):
"""Provide the prediction of the what task.
This function is used to predict the probability of a given phoneme being reported at a given index
for a given t... | python | def what_task(self, token_id, presented_pronunciation, index, phonemes, phonemes_probability,
warn=True, default=True):
"""Provide the prediction of the what task.
This function is used to predict the probability of a given phoneme being reported at a given index
for a given t... | [
"def",
"what_task",
"(",
"self",
",",
"token_id",
",",
"presented_pronunciation",
",",
"index",
",",
"phonemes",
",",
"phonemes_probability",
",",
"warn",
"=",
"True",
",",
"default",
"=",
"True",
")",
":",
"if",
"phonemes_probability",
"is",
"not",
"None",
... | Provide the prediction of the what task.
This function is used to predict the probability of a given phoneme being reported at a given index
for a given token.
:param token_id: The token for which the prediction is provided
:param index: The index of the token for which the prediction ... | [
"Provide",
"the",
"prediction",
"of",
"the",
"what",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L325-L371 |
rikrd/inspire | inspirespeech/__init__.py | Submission.full_task | def full_task(self, token_id, presented_pronunciation, pronunciation, pronunciation_probability,
warn=True, default=True):
"""Provide the prediction of the full task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:... | python | def full_task(self, token_id, presented_pronunciation, pronunciation, pronunciation_probability,
warn=True, default=True):
"""Provide the prediction of the full task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:... | [
"def",
"full_task",
"(",
"self",
",",
"token_id",
",",
"presented_pronunciation",
",",
"pronunciation",
",",
"pronunciation_probability",
",",
"warn",
"=",
"True",
",",
"default",
"=",
"True",
")",
":",
"if",
"pronunciation_probability",
"is",
"not",
"None",
"an... | Provide the prediction of the full task.
This function is used to predict the probability of a given pronunciation being reported for a given token.
:param token_id: The token for which the prediction is provided
:param pronunciation: The pronunciation for which the prediction is being made (a... | [
"Provide",
"the",
"prediction",
"of",
"the",
"full",
"task",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L373-L417 |
rikrd/inspire | inspirespeech/__init__.py | Submission.load | def load(fileobj):
"""Load the submission from a file-like object
:param fileobj: File-like object
:return: the loaded submission
"""
with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
submission = Submission(metadata=json.loads(z.readline()))
for line ... | python | def load(fileobj):
"""Load the submission from a file-like object
:param fileobj: File-like object
:return: the loaded submission
"""
with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
submission = Submission(metadata=json.loads(z.readline()))
for line ... | [
"def",
"load",
"(",
"fileobj",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"fileobj",
",",
"mode",
"=",
"'r'",
")",
"as",
"z",
":",
"submission",
"=",
"Submission",
"(",
"metadata",
"=",
"json",
".",
"loads",
"(",
"z",
".",
"rea... | Load the submission from a file-like object
:param fileobj: File-like object
:return: the loaded submission | [
"Load",
"the",
"submission",
"from",
"a",
"file",
"-",
"like",
"object"
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L481-L494 |
rikrd/inspire | inspirespeech/__init__.py | Submission.load_metadata | def load_metadata(fileobj):
"""Load the submission from a file.
:param filename: where to load the submission from
"""
with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
return json.loads(z.readline()) | python | def load_metadata(fileobj):
"""Load the submission from a file.
:param filename: where to load the submission from
"""
with gzip.GzipFile(fileobj=fileobj, mode='r') as z:
return json.loads(z.readline()) | [
"def",
"load_metadata",
"(",
"fileobj",
")",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"fileobj",
",",
"mode",
"=",
"'r'",
")",
"as",
"z",
":",
"return",
"json",
".",
"loads",
"(",
"z",
".",
"readline",
"(",
")",
")"
] | Load the submission from a file.
:param filename: where to load the submission from | [
"Load",
"the",
"submission",
"from",
"a",
"file",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L502-L508 |
rikrd/inspire | inspirespeech/__init__.py | Submission.submit | def submit(self, password=''):
"""Submits the participation to the web site.
The passwords is sent as plain text.
:return: the evaluation results.
"""
url = '{}/api/submit'.format(BASE_URL)
try:
r = requests.post(url,
data=self... | python | def submit(self, password=''):
"""Submits the participation to the web site.
The passwords is sent as plain text.
:return: the evaluation results.
"""
url = '{}/api/submit'.format(BASE_URL)
try:
r = requests.post(url,
data=self... | [
"def",
"submit",
"(",
"self",
",",
"password",
"=",
"''",
")",
":",
"url",
"=",
"'{}/api/submit'",
".",
"format",
"(",
"BASE_URL",
")",
"try",
":",
"r",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"data",
"=",
"self",
".",
"dumps",
"(",
")",
"... | Submits the participation to the web site.
The passwords is sent as plain text.
:return: the evaluation results. | [
"Submits",
"the",
"participation",
"to",
"the",
"web",
"site",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L525-L550 |
rikrd/inspire | inspirespeech/__init__.py | Submission.evaluate | def evaluate(self, password=''):
"""Evaluates the development set.
The passwords is sent as plain text.
:return: the evaluation results.
"""
# Make a copy only keeping the development set
dev_submission = self
if self['metadata'].get('evaluation_setting', {}).g... | python | def evaluate(self, password=''):
"""Evaluates the development set.
The passwords is sent as plain text.
:return: the evaluation results.
"""
# Make a copy only keeping the development set
dev_submission = self
if self['metadata'].get('evaluation_setting', {}).g... | [
"def",
"evaluate",
"(",
"self",
",",
"password",
"=",
"''",
")",
":",
"# Make a copy only keeping the development set",
"dev_submission",
"=",
"self",
"if",
"self",
"[",
"'metadata'",
"]",
".",
"get",
"(",
"'evaluation_setting'",
",",
"{",
"}",
")",
".",
"get"... | Evaluates the development set.
The passwords is sent as plain text.
:return: the evaluation results. | [
"Evaluates",
"the",
"development",
"set",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L552-L584 |
stephanepechard/projy | projy/collectors/AuthorMailCollector.py | AuthorMailCollector.author_mail_from_git | def author_mail_from_git(self):
""" Get the author mail from git information. """
try:
# launch git command and get answer
cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE)
stdoutdata = cmd.communicate()
if (stdoutdata[0]):
... | python | def author_mail_from_git(self):
""" Get the author mail from git information. """
try:
# launch git command and get answer
cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE)
stdoutdata = cmd.communicate()
if (stdoutdata[0]):
... | [
"def",
"author_mail_from_git",
"(",
"self",
")",
":",
"try",
":",
"# launch git command and get answer",
"cmd",
"=",
"Popen",
"(",
"[",
"\"git\"",
",",
"\"config\"",
",",
"\"--get\"",
",",
"\"user.email\"",
"]",
",",
"stdout",
"=",
"PIPE",
")",
"stdoutdata",
"... | Get the author mail from git information. | [
"Get",
"the",
"author",
"mail",
"from",
"git",
"information",
"."
] | train | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/AuthorMailCollector.py#L24-L39 |
stephanepechard/projy | projy/collectors/AuthorMailCollector.py | AuthorMailCollector.author_mail_from_system | def author_mail_from_system(self):
""" Get the author mail from system information.
It is probably often innacurate.
"""
self.author_mail = getpass.getuser() + '@' + socket.gethostname()
return self.author_mail | python | def author_mail_from_system(self):
""" Get the author mail from system information.
It is probably often innacurate.
"""
self.author_mail = getpass.getuser() + '@' + socket.gethostname()
return self.author_mail | [
"def",
"author_mail_from_system",
"(",
"self",
")",
":",
"self",
".",
"author_mail",
"=",
"getpass",
".",
"getuser",
"(",
")",
"+",
"'@'",
"+",
"socket",
".",
"gethostname",
"(",
")",
"return",
"self",
".",
"author_mail"
] | Get the author mail from system information.
It is probably often innacurate. | [
"Get",
"the",
"author",
"mail",
"from",
"system",
"information",
".",
"It",
"is",
"probably",
"often",
"innacurate",
"."
] | train | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/AuthorMailCollector.py#L42-L47 |
minorg/pastpy | py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py | OnlineDatabaseObjectDetailImage.read | def read(cls, iprot):
'''
Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage
'''
i... | python | def read(cls, iprot):
'''
Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage
'''
i... | [
"def",
"read",
"(",
"cls",
",",
"iprot",
")",
":",
"init_kwds",
"=",
"{",
"}",
"iprot",
".",
"read_struct_begin",
"(",
")",
"while",
"True",
":",
"ifield_name",
",",
"ifield_type",
",",
"_ifield_id",
"=",
"iprot",
".",
"read_field_begin",
"(",
")",
"if",... | Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage | [
"Read",
"a",
"new",
"object",
"from",
"the",
"given",
"input",
"protocol",
"and",
"return",
"the",
"object",
"."
] | train | https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py#L381-L413 |
minorg/pastpy | py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py | OnlineDatabaseObjectDetailImage.write | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage
'''
opro... | python | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage
'''
opro... | [
"def",
"write",
"(",
"self",
",",
"oprot",
")",
":",
"oprot",
".",
"write_struct_begin",
"(",
"'OnlineDatabaseObjectDetailImage'",
")",
"oprot",
".",
"write_field_begin",
"(",
"name",
"=",
"'full_size_url'",
",",
"type",
"=",
"11",
",",
"id",
"=",
"None",
")... | Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.online.online_database_object_detail_image.OnlineDatabaseObjectDetailImage | [
"Write",
"this",
"object",
"to",
"the",
"given",
"output",
"protocol",
"and",
"return",
"self",
"."
] | train | https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/online/online_database_object_detail_image.py#L445-L487 |
emory-libraries/eulcommon | eulcommon/djangoextras/http/decorators.py | content_negotiation | def content_negotiation(formats, default_type='text/html'):
"""
Provides basic content negotiation and returns a view method based on the
best match of content types as indicated in formats.
:param formats: dictionary of content types and corresponding methods
:param default_type: string the decora... | python | def content_negotiation(formats, default_type='text/html'):
"""
Provides basic content negotiation and returns a view method based on the
best match of content types as indicated in formats.
:param formats: dictionary of content types and corresponding methods
:param default_type: string the decora... | [
"def",
"content_negotiation",
"(",
"formats",
",",
"default_type",
"=",
"'text/html'",
")",
":",
"def",
"_decorator",
"(",
"view_method",
")",
":",
"@",
"wraps",
"(",
"view_method",
")",
"def",
"_wrapped",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
... | Provides basic content negotiation and returns a view method based on the
best match of content types as indicated in formats.
:param formats: dictionary of content types and corresponding methods
:param default_type: string the decorated method is the return type for.
Example usage::
def rdf... | [
"Provides",
"basic",
"content",
"negotiation",
"and",
"returns",
"a",
"view",
"method",
"based",
"on",
"the",
"best",
"match",
"of",
"content",
"types",
"as",
"indicated",
"in",
"formats",
"."
] | train | https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/http/decorators.py#L23-L94 |
johnwlockwood/cooperative | examples/non_blocking.py | do_less_expensive_things | def do_less_expensive_things(number):
"""
Perform one expensive computation cooperatively with any
other iterator passed into twisted's cooperate, then
use it's result to pass into the second computation.
:param number:
:return:
"""
result = yield batch_accumulate(1000, expensive(numb... | python | def do_less_expensive_things(number):
"""
Perform one expensive computation cooperatively with any
other iterator passed into twisted's cooperate, then
use it's result to pass into the second computation.
:param number:
:return:
"""
result = yield batch_accumulate(1000, expensive(numb... | [
"def",
"do_less_expensive_things",
"(",
"number",
")",
":",
"result",
"=",
"yield",
"batch_accumulate",
"(",
"1000",
",",
"expensive",
"(",
"number",
")",
")",
"total",
"=",
"reduce",
"(",
"add",
",",
"result",
",",
"0",
")",
"log",
".",
"msg",
"(",
"\... | Perform one expensive computation cooperatively with any
other iterator passed into twisted's cooperate, then
use it's result to pass into the second computation.
:param number:
:return: | [
"Perform",
"one",
"expensive",
"computation",
"cooperatively",
"with",
"any",
"other",
"iterator",
"passed",
"into",
"twisted",
"s",
"cooperate",
"then",
"use",
"it",
"s",
"result",
"to",
"pass",
"into",
"the",
"second",
"computation",
"."
] | train | https://github.com/johnwlockwood/cooperative/blob/bec25451a6d2b06260be809b72cfd6287c75da39/examples/non_blocking.py#L63-L75 |
django-py/django-doberman | doberman/contrib/captcha/fields.py | DobermanCaptchaField._captcha_form | def _captcha_form(self):
"""
captcha form
:return:
"""
try:
last_attempt = FailedAccessAttempt.objects.get(
ip_address=self._ip,
is_locked=True,
captcha_enabled=True,
is_expired=False
)
... | python | def _captcha_form(self):
"""
captcha form
:return:
"""
try:
last_attempt = FailedAccessAttempt.objects.get(
ip_address=self._ip,
is_locked=True,
captcha_enabled=True,
is_expired=False
)
... | [
"def",
"_captcha_form",
"(",
"self",
")",
":",
"try",
":",
"last_attempt",
"=",
"FailedAccessAttempt",
".",
"objects",
".",
"get",
"(",
"ip_address",
"=",
"self",
".",
"_ip",
",",
"is_locked",
"=",
"True",
",",
"captcha_enabled",
"=",
"True",
",",
"is_expi... | captcha form
:return: | [
"captcha",
"form",
":",
"return",
":"
] | train | https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/captcha/fields.py#L59-L84 |
delfick/aws_syncr | aws_syncr/option_spec/route53.py | DNSRoutes.sync_one | def sync_one(self, aws_syncr, amazon, route):
"""Make sure this role exists and has only what policies we want it to have"""
route_info = amazon.route53.route_info(route.name, route.zone)
target = route.record_target
if callable(target):
target = target(amazon)
if no... | python | def sync_one(self, aws_syncr, amazon, route):
"""Make sure this role exists and has only what policies we want it to have"""
route_info = amazon.route53.route_info(route.name, route.zone)
target = route.record_target
if callable(target):
target = target(amazon)
if no... | [
"def",
"sync_one",
"(",
"self",
",",
"aws_syncr",
",",
"amazon",
",",
"route",
")",
":",
"route_info",
"=",
"amazon",
".",
"route53",
".",
"route_info",
"(",
"route",
".",
"name",
",",
"route",
".",
"zone",
")",
"target",
"=",
"route",
".",
"record_tar... | Make sure this role exists and has only what policies we want it to have | [
"Make",
"sure",
"this",
"role",
"exists",
"and",
"has",
"only",
"what",
"policies",
"we",
"want",
"it",
"to",
"have"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/route53.py#L44-L54 |
slarse/clanimtk | clanimtk/decorator.py | animation | def animation(frame_function: types.FrameFunction) -> types.Animation:
"""Turn a FrameFunction into an Animation.
Args:
frame_function: A function that returns a FrameGenerator.
Returns:
an Animation decorator function.
"""
animation_ = core.Animation(frame_function)
@functool... | python | def animation(frame_function: types.FrameFunction) -> types.Animation:
"""Turn a FrameFunction into an Animation.
Args:
frame_function: A function that returns a FrameGenerator.
Returns:
an Animation decorator function.
"""
animation_ = core.Animation(frame_function)
@functool... | [
"def",
"animation",
"(",
"frame_function",
":",
"types",
".",
"FrameFunction",
")",
"->",
"types",
".",
"Animation",
":",
"animation_",
"=",
"core",
".",
"Animation",
"(",
"frame_function",
")",
"@",
"functools",
".",
"wraps",
"(",
"frame_function",
")",
"de... | Turn a FrameFunction into an Animation.
Args:
frame_function: A function that returns a FrameGenerator.
Returns:
an Animation decorator function. | [
"Turn",
"a",
"FrameFunction",
"into",
"an",
"Animation",
"."
] | train | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L18-L33 |
slarse/clanimtk | clanimtk/decorator.py | animate | def animate(func: types.AnyFunction = None,
*,
animation: types.AnimationGenerator = _default_animation(),
step: float = 0.1) -> types.AnyFunction:
"""Wrapper function for the _Animate wrapper class.
Args:
func: A function to run while animation is showing.
... | python | def animate(func: types.AnyFunction = None,
*,
animation: types.AnimationGenerator = _default_animation(),
step: float = 0.1) -> types.AnyFunction:
"""Wrapper function for the _Animate wrapper class.
Args:
func: A function to run while animation is showing.
... | [
"def",
"animate",
"(",
"func",
":",
"types",
".",
"AnyFunction",
"=",
"None",
",",
"*",
",",
"animation",
":",
"types",
".",
"AnimationGenerator",
"=",
"_default_animation",
"(",
")",
",",
"step",
":",
"float",
"=",
"0.1",
")",
"->",
"types",
".",
"Any... | Wrapper function for the _Animate wrapper class.
Args:
func: A function to run while animation is showing.
animation: An AnimationGenerator that yields animation frames.
step: Approximate timestep (in seconds) between frames.
Returns:
An animated version of func if func is n... | [
"Wrapper",
"function",
"for",
"the",
"_Animate",
"wrapper",
"class",
".",
"Args",
":",
"func",
":",
"A",
"function",
"to",
"run",
"while",
"animation",
"is",
"showing",
".",
"animation",
":",
"An",
"AnimationGenerator",
"that",
"yields",
"animation",
"frames",... | train | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L41-L60 |
slarse/clanimtk | clanimtk/decorator.py | annotate | def annotate(*,
start_msg: Optional[str] = None,
end_msg: Optional[str] = None,
start_no_nl: bool = False) -> types.AnyFunction:
"""A decorator meant for decorating functions that are decorated with the
`animate` decorator. It prints a message to stdout before and/or after... | python | def annotate(*,
start_msg: Optional[str] = None,
end_msg: Optional[str] = None,
start_no_nl: bool = False) -> types.AnyFunction:
"""A decorator meant for decorating functions that are decorated with the
`animate` decorator. It prints a message to stdout before and/or after... | [
"def",
"annotate",
"(",
"*",
",",
"start_msg",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"end_msg",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"start_no_nl",
":",
"bool",
"=",
"False",
")",
"->",
"types",
".",
"AnyFunction",
":",
... | A decorator meant for decorating functions that are decorated with the
`animate` decorator. It prints a message to stdout before and/or after the
function has finished.
.. DANGER::
This decorator can also be used standalone, but you should NOT decorate a
function that is decorated with `an... | [
"A",
"decorator",
"meant",
"for",
"decorating",
"functions",
"that",
"are",
"decorated",
"with",
"the",
"animate",
"decorator",
".",
"It",
"prints",
"a",
"message",
"to",
"stdout",
"before",
"and",
"/",
"or",
"after",
"the",
"function",
"has",
"finished",
".... | train | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L84-L105 |
slarse/clanimtk | clanimtk/decorator.py | multiline_frame_function | def multiline_frame_function(frame_function: types.FrameFunction,
height: int,
offset: int = 0,
*args,
**kwargs) -> types.FrameGenerator:
"""Multiline a singlelined frame function. Simply chains sever... | python | def multiline_frame_function(frame_function: types.FrameFunction,
height: int,
offset: int = 0,
*args,
**kwargs) -> types.FrameGenerator:
"""Multiline a singlelined frame function. Simply chains sever... | [
"def",
"multiline_frame_function",
"(",
"frame_function",
":",
"types",
".",
"FrameFunction",
",",
"height",
":",
"int",
",",
"offset",
":",
"int",
"=",
"0",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"types",
".",
"FrameGenerator",
":",
"fram... | Multiline a singlelined frame function. Simply chains several frame
generators together, and applies the specified offset to each one.
Args:
frame_function: A function that returns a singleline FrameGenerator.
height: The amount of frame generators to stack vertically (determines
the he... | [
"Multiline",
"a",
"singlelined",
"frame",
"function",
".",
"Simply",
"chains",
"several",
"frame",
"generators",
"together",
"and",
"applies",
"the",
"specified",
"offset",
"to",
"each",
"one",
"."
] | train | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/decorator.py#L108-L133 |
JIC-CSB/jicbioimage.segment | jicbioimage/segment/__init__.py | connected_components | def connected_components(image, connectivity=2, background=None):
"""Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param connectivity: maximum number of orthagonal hops to consider a
pixel/voxel as a neighbor
:... | python | def connected_components(image, connectivity=2, background=None):
"""Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param connectivity: maximum number of orthagonal hops to consider a
pixel/voxel as a neighbor
:... | [
"def",
"connected_components",
"(",
"image",
",",
"connectivity",
"=",
"2",
",",
"background",
"=",
"None",
")",
":",
"# Work around skimage.measure.label behaviour in version 0.12 and higher",
"# treats all 0 pixels as background even if \"background\" argument is set",
"# to None."... | Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param connectivity: maximum number of orthagonal hops to consider a
pixel/voxel as a neighbor
:param background: consider all pixels with this value (int) as background... | [
"Return",
":",
"class",
":",
"jicbioimage",
".",
"core",
".",
"image",
".",
"SegmentedImage",
"."
] | train | https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L249-L283 |
JIC-CSB/jicbioimage.segment | jicbioimage/segment/__init__.py | watershed_with_seeds | def watershed_with_seeds(image, seeds, mask=None):
"""Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param seeds: numpy.ndarray of same shape as image,
each seed needs to be a unique integer
:param mask: bool numpy.nda... | python | def watershed_with_seeds(image, seeds, mask=None):
"""Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param seeds: numpy.ndarray of same shape as image,
each seed needs to be a unique integer
:param mask: bool numpy.nda... | [
"def",
"watershed_with_seeds",
"(",
"image",
",",
"seeds",
",",
"mask",
"=",
"None",
")",
":",
"ar",
"=",
"skimage",
".",
"morphology",
".",
"watershed",
"(",
"-",
"image",
",",
"seeds",
",",
"mask",
"=",
"mask",
")",
"segmentation",
"=",
"SegmentedImage... | Return :class:`jicbioimage.core.image.SegmentedImage`.
:param image: input :class:`jicbioimage.core.image.Image`
:param seeds: numpy.ndarray of same shape as image,
each seed needs to be a unique integer
:param mask: bool numpy.ndarray of same shape as image,
only regions... | [
"Return",
":",
"class",
":",
"jicbioimage",
".",
"core",
".",
"image",
".",
"SegmentedImage",
"."
] | train | https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L287-L299 |
JIC-CSB/jicbioimage.segment | jicbioimage/segment/__init__.py | SegmentedImage.region_by_identifier | def region_by_identifier(self, identifier):
"""Return region of interest corresponding to the supplied identifier.
:param identifier: integer corresponding to the segment of interest
:returns: `jicbioimage.core.region.Region`
"""
if identifier < 0:
raise(ValueError(... | python | def region_by_identifier(self, identifier):
"""Return region of interest corresponding to the supplied identifier.
:param identifier: integer corresponding to the segment of interest
:returns: `jicbioimage.core.region.Region`
"""
if identifier < 0:
raise(ValueError(... | [
"def",
"region_by_identifier",
"(",
"self",
",",
"identifier",
")",
":",
"if",
"identifier",
"<",
"0",
":",
"raise",
"(",
"ValueError",
"(",
"\"Identifier must be a positive integer.\"",
")",
")",
"if",
"not",
"np",
".",
"equal",
"(",
"np",
".",
"mod",
"(",
... | Return region of interest corresponding to the supplied identifier.
:param identifier: integer corresponding to the segment of interest
:returns: `jicbioimage.core.region.Region` | [
"Return",
"region",
"of",
"interest",
"corresponding",
"to",
"the",
"supplied",
"identifier",
"."
] | train | https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L175-L191 |
JIC-CSB/jicbioimage.segment | jicbioimage/segment/__init__.py | SegmentedImage.merge_regions | def merge_regions(self, id1, id2):
"""Merge two regions into one.
The merged region will take on the id1 identifier.
:param id1: region 1 identifier
:param id2: region 2 identifier
"""
region2 = self.region_by_identifier(id2)
self[region2] = id1 | python | def merge_regions(self, id1, id2):
"""Merge two regions into one.
The merged region will take on the id1 identifier.
:param id1: region 1 identifier
:param id2: region 2 identifier
"""
region2 = self.region_by_identifier(id2)
self[region2] = id1 | [
"def",
"merge_regions",
"(",
"self",
",",
"id1",
",",
"id2",
")",
":",
"region2",
"=",
"self",
".",
"region_by_identifier",
"(",
"id2",
")",
"self",
"[",
"region2",
"]",
"=",
"id1"
] | Merge two regions into one.
The merged region will take on the id1 identifier.
:param id1: region 1 identifier
:param id2: region 2 identifier | [
"Merge",
"two",
"regions",
"into",
"one",
"."
] | train | https://github.com/JIC-CSB/jicbioimage.segment/blob/289e5ab834913326a097e57bea458ea0737efb0c/jicbioimage/segment/__init__.py#L236-L245 |
jspricke/python-icstask | icstask.py | task2ics | def task2ics():
"""Command line tool to convert from Taskwarrior to iCalendar"""
from argparse import ArgumentParser, FileType
from sys import stdout
parser = ArgumentParser(description='Converter from Taskwarrior to iCalendar syntax.')
parser.add_argument('indir', nargs='?', help='Input Taskwarrio... | python | def task2ics():
"""Command line tool to convert from Taskwarrior to iCalendar"""
from argparse import ArgumentParser, FileType
from sys import stdout
parser = ArgumentParser(description='Converter from Taskwarrior to iCalendar syntax.')
parser.add_argument('indir', nargs='?', help='Input Taskwarrio... | [
"def",
"task2ics",
"(",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
",",
"FileType",
"from",
"sys",
"import",
"stdout",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"'Converter from Taskwarrior to iCalendar syntax.'",
")",
"parser",
".",
"... | Command line tool to convert from Taskwarrior to iCalendar | [
"Command",
"line",
"tool",
"to",
"convert",
"from",
"Taskwarrior",
"to",
"iCalendar"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L338-L350 |
jspricke/python-icstask | icstask.py | ics2task | def ics2task():
"""Command line tool to convert from iCalendar to Taskwarrior"""
from argparse import ArgumentParser, FileType
from sys import stdin
parser = ArgumentParser(description='Converter from iCalendar to Taskwarrior syntax.')
parser.add_argument('infile', nargs='?', type=FileType('r'), de... | python | def ics2task():
"""Command line tool to convert from iCalendar to Taskwarrior"""
from argparse import ArgumentParser, FileType
from sys import stdin
parser = ArgumentParser(description='Converter from iCalendar to Taskwarrior syntax.')
parser.add_argument('infile', nargs='?', type=FileType('r'), de... | [
"def",
"ics2task",
"(",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
",",
"FileType",
"from",
"sys",
"import",
"stdin",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"'Converter from iCalendar to Taskwarrior syntax.'",
")",
"parser",
".",
"a... | Command line tool to convert from iCalendar to Taskwarrior | [
"Command",
"line",
"tool",
"to",
"convert",
"from",
"iCalendar",
"to",
"Taskwarrior"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L353-L367 |
jspricke/python-icstask | icstask.py | IcsTask._update | def _update(self):
"""Reload Taskwarrior files if the mtime is newer"""
update = False
with self._lock:
for fname in ['pending.data', 'completed.data']:
data_file = join(self._data_location, fname)
if exists(data_file):
mtime = get... | python | def _update(self):
"""Reload Taskwarrior files if the mtime is newer"""
update = False
with self._lock:
for fname in ['pending.data', 'completed.data']:
data_file = join(self._data_location, fname)
if exists(data_file):
mtime = get... | [
"def",
"_update",
"(",
"self",
")",
":",
"update",
"=",
"False",
"with",
"self",
".",
"_lock",
":",
"for",
"fname",
"in",
"[",
"'pending.data'",
",",
"'completed.data'",
"]",
":",
"data_file",
"=",
"join",
"(",
"self",
".",
"_data_location",
",",
"fname"... | Reload Taskwarrior files if the mtime is newer | [
"Reload",
"Taskwarrior",
"files",
"if",
"the",
"mtime",
"is",
"newer"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L47-L67 |
jspricke/python-icstask | icstask.py | IcsTask.to_vobjects | def to_vobjects(self, filename, uids=None):
"""Return iCal objects and etags of all Taskwarrior entries in uids
filename -- the Taskwarrior project
uids -- the UIDs of the Taskwarrior tasks (all if None)
"""
self._update()
if not uids:
uids = self.get_uids(f... | python | def to_vobjects(self, filename, uids=None):
"""Return iCal objects and etags of all Taskwarrior entries in uids
filename -- the Taskwarrior project
uids -- the UIDs of the Taskwarrior tasks (all if None)
"""
self._update()
if not uids:
uids = self.get_uids(f... | [
"def",
"to_vobjects",
"(",
"self",
",",
"filename",
",",
"uids",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"if",
"not",
"uids",
":",
"uids",
"=",
"self",
".",
"get_uids",
"(",
"filename",
")",
"project",
"=",
"basename",
"(",
"filename... | Return iCal objects and etags of all Taskwarrior entries in uids
filename -- the Taskwarrior project
uids -- the UIDs of the Taskwarrior tasks (all if None) | [
"Return",
"iCal",
"objects",
"and",
"etags",
"of",
"all",
"Taskwarrior",
"entries",
"in",
"uids"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L89-L108 |
jspricke/python-icstask | icstask.py | IcsTask.to_vobject | def to_vobject(self, project=None, uid=None):
"""Return vObject object of Taskwarrior tasks
If filename and UID are specified, the vObject only contains that task.
If only a filename is specified, the vObject contains all events in the project.
Otherwise the vObject contains all all obje... | python | def to_vobject(self, project=None, uid=None):
"""Return vObject object of Taskwarrior tasks
If filename and UID are specified, the vObject only contains that task.
If only a filename is specified, the vObject contains all events in the project.
Otherwise the vObject contains all all obje... | [
"def",
"to_vobject",
"(",
"self",
",",
"project",
"=",
"None",
",",
"uid",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"vtodos",
"=",
"iCalendar",
"(",
")",
"if",
"uid",
":",
"uid",
"=",
"uid",
".",
"split",
"(",
"'@'",
")",
"[",
"... | Return vObject object of Taskwarrior tasks
If filename and UID are specified, the vObject only contains that task.
If only a filename is specified, the vObject contains all events in the project.
Otherwise the vObject contains all all objects of all files associated with the IcsTask object.
... | [
"Return",
"vObject",
"object",
"of",
"Taskwarrior",
"tasks",
"If",
"filename",
"and",
"UID",
"are",
"specified",
"the",
"vObject",
"only",
"contains",
"that",
"task",
".",
"If",
"only",
"a",
"filename",
"is",
"specified",
"the",
"vObject",
"contains",
"all",
... | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L110-L138 |
jspricke/python-icstask | icstask.py | IcsTask.to_task | def to_task(self, vtodo, project=None, uuid=None):
"""Add or modify a task from vTodo to Taskwarrior
vtodo -- the vTodo to add
project -- the project to add (see get_filesnames() as well)
uuid -- the UID of the task in Taskwarrior
"""
task = {}
if project and pro... | python | def to_task(self, vtodo, project=None, uuid=None):
"""Add or modify a task from vTodo to Taskwarrior
vtodo -- the vTodo to add
project -- the project to add (see get_filesnames() as well)
uuid -- the UID of the task in Taskwarrior
"""
task = {}
if project and pro... | [
"def",
"to_task",
"(",
"self",
",",
"vtodo",
",",
"project",
"=",
"None",
",",
"uuid",
"=",
"None",
")",
":",
"task",
"=",
"{",
"}",
"if",
"project",
"and",
"project",
"!=",
"'all_projects'",
"and",
"project",
"!=",
"'unaffiliated'",
":",
"task",
"[",
... | Add or modify a task from vTodo to Taskwarrior
vtodo -- the vTodo to add
project -- the project to add (see get_filesnames() as well)
uuid -- the UID of the task in Taskwarrior | [
"Add",
"or",
"modify",
"a",
"task",
"from",
"vTodo",
"to",
"Taskwarrior",
"vtodo",
"--",
"the",
"vTodo",
"to",
"add",
"project",
"--",
"the",
"project",
"to",
"add",
"(",
"see",
"get_filesnames",
"()",
"as",
"well",
")",
"uuid",
"--",
"the",
"UID",
"of... | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L191-L267 |
jspricke/python-icstask | icstask.py | IcsTask.get_filesnames | def get_filesnames(self):
"""Return a list of all Taskwarrior projects as virtual files in the data directory"""
self._update()
projects = set(list(self._tasks.keys()) + self._task_projects + ['all_projects', 'unaffiliated'])
return [join(self._data_location, p.split()[0]) for p in proje... | python | def get_filesnames(self):
"""Return a list of all Taskwarrior projects as virtual files in the data directory"""
self._update()
projects = set(list(self._tasks.keys()) + self._task_projects + ['all_projects', 'unaffiliated'])
return [join(self._data_location, p.split()[0]) for p in proje... | [
"def",
"get_filesnames",
"(",
"self",
")",
":",
"self",
".",
"_update",
"(",
")",
"projects",
"=",
"set",
"(",
"list",
"(",
"self",
".",
"_tasks",
".",
"keys",
"(",
")",
")",
"+",
"self",
".",
"_task_projects",
"+",
"[",
"'all_projects'",
",",
"'unaf... | Return a list of all Taskwarrior projects as virtual files in the data directory | [
"Return",
"a",
"list",
"of",
"all",
"Taskwarrior",
"projects",
"as",
"virtual",
"files",
"in",
"the",
"data",
"directory"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L269-L273 |
jspricke/python-icstask | icstask.py | IcsTask.get_uids | def get_uids(self, project=None):
"""Return a list of UIDs
project -- the Project to filter for
"""
self._update()
if not project or project.endswith('all_projects'):
return [self._gen_uid(task['uuid']) for project in self._tasks for task in self._tasks[project].valu... | python | def get_uids(self, project=None):
"""Return a list of UIDs
project -- the Project to filter for
"""
self._update()
if not project or project.endswith('all_projects'):
return [self._gen_uid(task['uuid']) for project in self._tasks for task in self._tasks[project].valu... | [
"def",
"get_uids",
"(",
"self",
",",
"project",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"if",
"not",
"project",
"or",
"project",
".",
"endswith",
"(",
"'all_projects'",
")",
":",
"return",
"[",
"self",
".",
"_gen_uid",
"(",
"task",
"... | Return a list of UIDs
project -- the Project to filter for | [
"Return",
"a",
"list",
"of",
"UIDs",
"project",
"--",
"the",
"Project",
"to",
"filter",
"for"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L275-L287 |
jspricke/python-icstask | icstask.py | IcsTask.append_vobject | def append_vobject(self, vtodo, project=None):
"""Add a task from vObject to Taskwarrior
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well)
"""
if project:
project = basename(project)
return self.to_task(vtodo.vtodo, pro... | python | def append_vobject(self, vtodo, project=None):
"""Add a task from vObject to Taskwarrior
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well)
"""
if project:
project = basename(project)
return self.to_task(vtodo.vtodo, pro... | [
"def",
"append_vobject",
"(",
"self",
",",
"vtodo",
",",
"project",
"=",
"None",
")",
":",
"if",
"project",
":",
"project",
"=",
"basename",
"(",
"project",
")",
"return",
"self",
".",
"to_task",
"(",
"vtodo",
".",
"vtodo",
",",
"project",
")"
] | Add a task from vObject to Taskwarrior
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well) | [
"Add",
"a",
"task",
"from",
"vObject",
"to",
"Taskwarrior",
"vtodo",
"--",
"the",
"iCalendar",
"to",
"add",
"project",
"--",
"the",
"project",
"to",
"add",
"(",
"see",
"get_filesnames",
"()",
"as",
"well",
")"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L298-L305 |
jspricke/python-icstask | icstask.py | IcsTask.remove | def remove(self, uuid, project=None):
"""Remove a task from Taskwarrior
uuid -- the UID of the task
project -- not used
"""
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self._data_location}'.format(**locals()... | python | def remove(self, uuid, project=None):
"""Remove a task from Taskwarrior
uuid -- the UID of the task
project -- not used
"""
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self._data_location}'.format(**locals()... | [
"def",
"remove",
"(",
"self",
",",
"uuid",
",",
"project",
"=",
"None",
")",
":",
"uuid",
"=",
"uuid",
".",
"split",
"(",
"'@'",
")",
"[",
"0",
"]",
"with",
"self",
".",
"_lock",
":",
"run",
"(",
"[",
"'task'",
",",
"'rc.verbose=nothing'",
",",
"... | Remove a task from Taskwarrior
uuid -- the UID of the task
project -- not used | [
"Remove",
"a",
"task",
"from",
"Taskwarrior",
"uuid",
"--",
"the",
"UID",
"of",
"the",
"task",
"project",
"--",
"not",
"used"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L307-L314 |
jspricke/python-icstask | icstask.py | IcsTask.replace_vobject | def replace_vobject(self, uuid, vtodo, project=None):
"""Update the task with the UID from the vObject
uuid -- the UID of the task
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well)
"""
self._update()
uuid = uuid.split('@')[... | python | def replace_vobject(self, uuid, vtodo, project=None):
"""Update the task with the UID from the vObject
uuid -- the UID of the task
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well)
"""
self._update()
uuid = uuid.split('@')[... | [
"def",
"replace_vobject",
"(",
"self",
",",
"uuid",
",",
"vtodo",
",",
"project",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"uuid",
"=",
"uuid",
".",
"split",
"(",
"'@'",
")",
"[",
"0",
"]",
"if",
"project",
":",
"project",
"=",
"b... | Update the task with the UID from the vObject
uuid -- the UID of the task
vtodo -- the iCalendar to add
project -- the project to add (see get_filesnames() as well) | [
"Update",
"the",
"task",
"with",
"the",
"UID",
"from",
"the",
"vObject",
"uuid",
"--",
"the",
"UID",
"of",
"the",
"task",
"vtodo",
"--",
"the",
"iCalendar",
"to",
"add",
"project",
"--",
"the",
"project",
"to",
"add",
"(",
"see",
"get_filesnames",
"()",
... | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L316-L326 |
jspricke/python-icstask | icstask.py | IcsTask.move_vobject | def move_vobject(self, uuid, from_project, to_project):
"""Update the project of the task with the UID uuid"""
if to_project not in self.get_filesnames():
return
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self... | python | def move_vobject(self, uuid, from_project, to_project):
"""Update the project of the task with the UID uuid"""
if to_project not in self.get_filesnames():
return
uuid = uuid.split('@')[0]
with self._lock:
run(['task', 'rc.verbose=nothing', 'rc.data.location={self... | [
"def",
"move_vobject",
"(",
"self",
",",
"uuid",
",",
"from_project",
",",
"to_project",
")",
":",
"if",
"to_project",
"not",
"in",
"self",
".",
"get_filesnames",
"(",
")",
":",
"return",
"uuid",
"=",
"uuid",
".",
"split",
"(",
"'@'",
")",
"[",
"0",
... | Update the project of the task with the UID uuid | [
"Update",
"the",
"project",
"of",
"the",
"task",
"with",
"the",
"UID",
"uuid"
] | train | https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L328-L335 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | Layer.merge | def merge(self, obj):
"""This function merge another object's values with this instance
:param obj: An object to be merged with into this layer
:type obj: object
"""
for attribute in dir(obj):
if '__' in attribute:
continue
setattr(self, a... | python | def merge(self, obj):
"""This function merge another object's values with this instance
:param obj: An object to be merged with into this layer
:type obj: object
"""
for attribute in dir(obj):
if '__' in attribute:
continue
setattr(self, a... | [
"def",
"merge",
"(",
"self",
",",
"obj",
")",
":",
"for",
"attribute",
"in",
"dir",
"(",
"obj",
")",
":",
"if",
"'__'",
"in",
"attribute",
":",
"continue",
"setattr",
"(",
"self",
",",
"attribute",
",",
"getattr",
"(",
"obj",
",",
"attribute",
")",
... | This function merge another object's values with this instance
:param obj: An object to be merged with into this layer
:type obj: object | [
"This",
"function",
"merge",
"another",
"object",
"s",
"values",
"with",
"this",
"instance"
] | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L16-L25 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | FlapjackStack.add_layer | def add_layer(self, obj=None):
"""This function adds another empty layer (Layer) to the layers
list and optionally merges a given object into this layer
:param obj: An object to be merged with this layer
:type obj: object
"""
new_layer = Layer()
if obj:
... | python | def add_layer(self, obj=None):
"""This function adds another empty layer (Layer) to the layers
list and optionally merges a given object into this layer
:param obj: An object to be merged with this layer
:type obj: object
"""
new_layer = Layer()
if obj:
... | [
"def",
"add_layer",
"(",
"self",
",",
"obj",
"=",
"None",
")",
":",
"new_layer",
"=",
"Layer",
"(",
")",
"if",
"obj",
":",
"new_layer",
".",
"merge",
"(",
"obj",
")",
"self",
".",
"layers",
".",
"append",
"(",
"new_layer",
")"
] | This function adds another empty layer (Layer) to the layers
list and optionally merges a given object into this layer
:param obj: An object to be merged with this layer
:type obj: object | [
"This",
"function",
"adds",
"another",
"empty",
"layer",
"(",
"Layer",
")",
"to",
"the",
"layers",
"list",
"and",
"optionally",
"merges",
"a",
"given",
"object",
"into",
"this",
"layer"
] | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L37-L47 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | FlapjackStack.add_layer_from_py_file | def add_layer_from_py_file(self, filename):
"""This function implements loading a Python file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string
"""
if filename.endswith('.py'):
try:
... | python | def add_layer_from_py_file(self, filename):
"""This function implements loading a Python file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string
"""
if filename.endswith('.py'):
try:
... | [
"def",
"add_layer_from_py_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.py'",
")",
":",
"try",
":",
"path",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"abspath",
"("... | This function implements loading a Python file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string | [
"This",
"function",
"implements",
"loading",
"a",
"Python",
"file",
"and",
"populating",
"a",
"new",
"empty",
"layer",
"(",
"Layer",
")",
"with",
"its",
"contents"
] | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L59-L81 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | FlapjackStack.add_layer_from_yaml_file | def add_layer_from_yaml_file(self, filename):
"""This function implements loading a YAML file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string
"""
if filename.endswith(('.yaml', '.yml')):
... | python | def add_layer_from_yaml_file(self, filename):
"""This function implements loading a YAML file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string
"""
if filename.endswith(('.yaml', '.yml')):
... | [
"def",
"add_layer_from_yaml_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"(",
"'.yaml'",
",",
"'.yml'",
")",
")",
":",
"file_stream",
"=",
"None",
"try",
":",
"file_stream",
"=",
"open",
"(",
"os",
".",
"path",
... | This function implements loading a YAML file and populating a new
empty layer (Layer) with its contents
:param filename: The name of a file to read
:type filename: string | [
"This",
"function",
"implements",
"loading",
"a",
"YAML",
"file",
"and",
"populating",
"a",
"new",
"empty",
"layer",
"(",
"Layer",
")",
"with",
"its",
"contents"
] | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L83-L104 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | FlapjackStack.get_attributes | def get_attributes(self):
"""This function through the layers from top to bottom, and creates a
list of all the attributes found
:returns: A list of all the attributes names
:rtype: list
"""
attributes = []
for i in reversed(xrange(len(self.layers))):
... | python | def get_attributes(self):
"""This function through the layers from top to bottom, and creates a
list of all the attributes found
:returns: A list of all the attributes names
:rtype: list
"""
attributes = []
for i in reversed(xrange(len(self.layers))):
... | [
"def",
"get_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"[",
"]",
"for",
"i",
"in",
"reversed",
"(",
"xrange",
"(",
"len",
"(",
"self",
".",
"layers",
")",
")",
")",
":",
"obj",
"=",
"self",
".",
"layers",
"[",
"i",
"]",
"stack_attribute... | This function through the layers from top to bottom, and creates a
list of all the attributes found
:returns: A list of all the attributes names
:rtype: list | [
"This",
"function",
"through",
"the",
"layers",
"from",
"top",
"to",
"bottom",
"and",
"creates",
"a",
"list",
"of",
"all",
"the",
"attributes",
"found"
] | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L146-L160 |
juiceinc/flapjack_stack | flapjack_stack/flapjack_stack.py | FlapjackStack.add_layer_from_env | def add_layer_from_env(self):
"""This function creates a new layer, gets a list of all the
current attributes, and attempts to find matching environment variables
with the prefix of FJS\_. If matches are found it sets those attributes
in the new layer.
"""
self.add_layer(... | python | def add_layer_from_env(self):
"""This function creates a new layer, gets a list of all the
current attributes, and attempts to find matching environment variables
with the prefix of FJS\_. If matches are found it sets those attributes
in the new layer.
"""
self.add_layer(... | [
"def",
"add_layer_from_env",
"(",
"self",
")",
":",
"self",
".",
"add_layer",
"(",
")",
"for",
"attribute",
"in",
"self",
".",
"get_attributes",
"(",
")",
":",
"env_attribute",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'FJS_{}'",
".",
"format",
"(",
... | This function creates a new layer, gets a list of all the
current attributes, and attempts to find matching environment variables
with the prefix of FJS\_. If matches are found it sets those attributes
in the new layer. | [
"This",
"function",
"creates",
"a",
"new",
"layer",
"gets",
"a",
"list",
"of",
"all",
"the",
"current",
"attributes",
"and",
"attempts",
"to",
"find",
"matching",
"environment",
"variables",
"with",
"the",
"prefix",
"of",
"FJS",
"\\",
"_",
".",
"If",
"matc... | train | https://github.com/juiceinc/flapjack_stack/blob/5929f1b10ba5be5567a88a4b294bc8d49015a5ff/flapjack_stack/flapjack_stack.py#L162-L172 |
MinchinWeb/colourettu | colourettu/_colour.py | luminance | def luminance(mycolour):
r"""Determine (relative) luminance of a colour.
Args:
mycolour(colourettu.Colour): a colour
Luminance is a measure of how 'bright' a colour is. Values are
normalized so that the Luminance of White is 1 and the Luminance of
Black is 0. That is to say:
.. code::... | python | def luminance(mycolour):
r"""Determine (relative) luminance of a colour.
Args:
mycolour(colourettu.Colour): a colour
Luminance is a measure of how 'bright' a colour is. Values are
normalized so that the Luminance of White is 1 and the Luminance of
Black is 0. That is to say:
.. code::... | [
"def",
"luminance",
"(",
"mycolour",
")",
":",
"colour_for_type",
"=",
"Colour",
"(",
")",
"if",
"type",
"(",
"mycolour",
")",
"is",
"type",
"(",
"colour_for_type",
")",
":",
"mycolour2",
"=",
"mycolour",
"else",
":",
"try",
":",
"mycolour2",
"=",
"Colou... | r"""Determine (relative) luminance of a colour.
Args:
mycolour(colourettu.Colour): a colour
Luminance is a measure of how 'bright' a colour is. Values are
normalized so that the Luminance of White is 1 and the Luminance of
Black is 0. That is to say:
.. code:: pycon
>>> colourett... | [
"r",
"Determine",
"(",
"relative",
")",
"luminance",
"of",
"a",
"colour",
"."
] | train | https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/colourettu/_colour.py#L239-L285 |
MinchinWeb/colourettu | colourettu/_colour.py | contrast | def contrast(colour1, colour2):
r"""Determines the contrast between two colours.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
Contrast the difference in (perceived) brightness between colours.
Values vary between 1:1 (a given colour on itself... | python | def contrast(colour1, colour2):
r"""Determines the contrast between two colours.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
Contrast the difference in (perceived) brightness between colours.
Values vary between 1:1 (a given colour on itself... | [
"def",
"contrast",
"(",
"colour1",
",",
"colour2",
")",
":",
"colour_for_type",
"=",
"Colour",
"(",
")",
"if",
"type",
"(",
"colour1",
")",
"is",
"type",
"(",
"colour_for_type",
")",
":",
"mycolour1",
"=",
"colour1",
"else",
":",
"try",
":",
"mycolour1",... | r"""Determines the contrast between two colours.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
Contrast the difference in (perceived) brightness between colours.
Values vary between 1:1 (a given colour on itself) and 21:1 (white on
black).
... | [
"r",
"Determines",
"the",
"contrast",
"between",
"two",
"colours",
"."
] | train | https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/colourettu/_colour.py#L288-L377 |
MinchinWeb/colourettu | colourettu/_colour.py | blend | def blend(colour1, colour2):
r"""Takes two :py:class:`Colour` s and returns the 'average' Colour.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
.. note::
Uses the formula:
\\[ r_{blended} = \\sqrt \\frac{r_1^2 + r_2^2}{2} \\]
... | python | def blend(colour1, colour2):
r"""Takes two :py:class:`Colour` s and returns the 'average' Colour.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
.. note::
Uses the formula:
\\[ r_{blended} = \\sqrt \\frac{r_1^2 + r_2^2}{2} \\]
... | [
"def",
"blend",
"(",
"colour1",
",",
"colour2",
")",
":",
"# raw docstring is needed so that MathJax will render in generated",
"# documentation",
"# gamma is the power we're going to use to do this conversion",
"gamma",
"=",
"2.0",
"# start by normalizing values",
"r_1",
"=",
"col... | r"""Takes two :py:class:`Colour` s and returns the 'average' Colour.
Args:
colour1 (colourettu.Colour): a colour
colour2 (colourettu.Colour): a second colour
.. note::
Uses the formula:
\\[ r_{blended} = \\sqrt \\frac{r_1^2 + r_2^2}{2} \\]
It is hown here for the re... | [
"r",
"Takes",
"two",
":",
"py",
":",
"class",
":",
"Colour",
"s",
"and",
"returns",
"the",
"average",
"Colour",
"."
] | train | https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/colourettu/_colour.py#L380-L424 |
MinchinWeb/colourettu | colourettu/_colour.py | Colour.hex | def hex(self):
"""
Returns the HTML-style hex code for the Colour.
Returns:
str: the colour as a HTML-sytle hex string
"""
return "#{:02x}{:02x}{:02x}".format(self._r, self._g, self._b).upper() | python | def hex(self):
"""
Returns the HTML-style hex code for the Colour.
Returns:
str: the colour as a HTML-sytle hex string
"""
return "#{:02x}{:02x}{:02x}".format(self._r, self._g, self._b).upper() | [
"def",
"hex",
"(",
"self",
")",
":",
"return",
"\"#{:02x}{:02x}{:02x}\"",
".",
"format",
"(",
"self",
".",
"_r",
",",
"self",
".",
"_g",
",",
"self",
".",
"_b",
")",
".",
"upper",
"(",
")"
] | Returns the HTML-style hex code for the Colour.
Returns:
str: the colour as a HTML-sytle hex string | [
"Returns",
"the",
"HTML",
"-",
"style",
"hex",
"code",
"for",
"the",
"Colour",
"."
] | train | https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/colourettu/_colour.py#L142-L149 |
MinchinWeb/colourettu | colourettu/_colour.py | Colour.normalized_rgb | def normalized_rgb(self):
r"""
Returns a tuples of the normalized values of the red, green, and blue
channels of the Colour.
Returns:
tuple: the rgb values of the colour (with values normalized between
0.0 and 1.0)
.. note::
Uses the ... | python | def normalized_rgb(self):
r"""
Returns a tuples of the normalized values of the red, green, and blue
channels of the Colour.
Returns:
tuple: the rgb values of the colour (with values normalized between
0.0 and 1.0)
.. note::
Uses the ... | [
"def",
"normalized_rgb",
"(",
"self",
")",
":",
"r1",
"=",
"self",
".",
"_r",
"/",
"255",
"g1",
"=",
"self",
".",
"_g",
"/",
"255",
"b1",
"=",
"self",
".",
"_b",
"/",
"255",
"if",
"r1",
"<=",
"0.03928",
":",
"r2",
"=",
"r1",
"/",
"12.92",
"el... | r"""
Returns a tuples of the normalized values of the red, green, and blue
channels of the Colour.
Returns:
tuple: the rgb values of the colour (with values normalized between
0.0 and 1.0)
.. note::
Uses the formula:
\\[ r_{norm}... | [
"r",
"Returns",
"a",
"tuples",
"of",
"the",
"normalized",
"values",
"of",
"the",
"red",
"green",
"and",
"blue",
"channels",
"of",
"the",
"Colour",
"."
] | train | https://github.com/MinchinWeb/colourettu/blob/f0b2f6b1d44055f3ccee62ac2759829f1e16a252/colourettu/_colour.py#L188-L228 |
char16t/wa | wa/env.py | copy_tree | def copy_tree(src, dst):
"""Copy directory tree"""
for root, subdirs, files in os.walk(src):
current_dest = root.replace(src, dst)
if not os.path.exists(current_dest):
os.makedirs(current_dest)
for f in files:
shutil.copy(os.path.join(root, f), os.path.join(curren... | python | def copy_tree(src, dst):
"""Copy directory tree"""
for root, subdirs, files in os.walk(src):
current_dest = root.replace(src, dst)
if not os.path.exists(current_dest):
os.makedirs(current_dest)
for f in files:
shutil.copy(os.path.join(root, f), os.path.join(curren... | [
"def",
"copy_tree",
"(",
"src",
",",
"dst",
")",
":",
"for",
"root",
",",
"subdirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"src",
")",
":",
"current_dest",
"=",
"root",
".",
"replace",
"(",
"src",
",",
"dst",
")",
"if",
"not",
"os",
".",
... | Copy directory tree | [
"Copy",
"directory",
"tree"
] | train | https://github.com/char16t/wa/blob/ee28bf47665ea57f3a03a08dfc0a5daaa33d8121/wa/env.py#L65-L72 |
bird-house/birdhousebuilder.recipe.conda | birdhousebuilder/recipe/conda/__init__.py | conda_info | def conda_info(prefix):
"""returns conda infos"""
cmd = [join(prefix, 'bin', 'conda')]
cmd.extend(['info', '--json'])
output = check_output(cmd)
return yaml.load(output) | python | def conda_info(prefix):
"""returns conda infos"""
cmd = [join(prefix, 'bin', 'conda')]
cmd.extend(['info', '--json'])
output = check_output(cmd)
return yaml.load(output) | [
"def",
"conda_info",
"(",
"prefix",
")",
":",
"cmd",
"=",
"[",
"join",
"(",
"prefix",
",",
"'bin'",
",",
"'conda'",
")",
"]",
"cmd",
".",
"extend",
"(",
"[",
"'info'",
",",
"'--json'",
"]",
")",
"output",
"=",
"check_output",
"(",
"cmd",
")",
"retu... | returns conda infos | [
"returns",
"conda",
"infos"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.conda/blob/a5c0224ca4424c0c5cb1c302ba220c43cbc7ab3d/birdhousebuilder/recipe/conda/__init__.py#L30-L35 |
bird-house/birdhousebuilder.recipe.conda | birdhousebuilder/recipe/conda/__init__.py | Recipe.install | def install(self, update=False):
"""
install conda packages
"""
offline = self.offline or update
self.create_env(offline)
self.install_pkgs(offline)
self.install_pip(offline)
return tuple() | python | def install(self, update=False):
"""
install conda packages
"""
offline = self.offline or update
self.create_env(offline)
self.install_pkgs(offline)
self.install_pip(offline)
return tuple() | [
"def",
"install",
"(",
"self",
",",
"update",
"=",
"False",
")",
":",
"offline",
"=",
"self",
".",
"offline",
"or",
"update",
"self",
".",
"create_env",
"(",
"offline",
")",
"self",
".",
"install_pkgs",
"(",
"offline",
")",
"self",
".",
"install_pip",
... | install conda packages | [
"install",
"conda",
"packages"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.conda/blob/a5c0224ca4424c0c5cb1c302ba220c43cbc7ab3d/birdhousebuilder/recipe/conda/__init__.py#L130-L138 |
bird-house/birdhousebuilder.recipe.conda | birdhousebuilder/recipe/conda/__init__.py | Recipe.install_pkgs | def install_pkgs(self, offline=False):
"""
TODO: maybe use conda as python package
"""
if not offline and self.pkgs:
self.logger.info("Installing conda packages ...")
cmd = [join(self.anaconda_home, 'bin', 'conda')]
cmd.append('install')
# ... | python | def install_pkgs(self, offline=False):
"""
TODO: maybe use conda as python package
"""
if not offline and self.pkgs:
self.logger.info("Installing conda packages ...")
cmd = [join(self.anaconda_home, 'bin', 'conda')]
cmd.append('install')
# ... | [
"def",
"install_pkgs",
"(",
"self",
",",
"offline",
"=",
"False",
")",
":",
"if",
"not",
"offline",
"and",
"self",
".",
"pkgs",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Installing conda packages ...\"",
")",
"cmd",
"=",
"[",
"join",
"(",
"self",
... | TODO: maybe use conda as python package | [
"TODO",
":",
"maybe",
"use",
"conda",
"as",
"python",
"package"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.conda/blob/a5c0224ca4424c0c5cb1c302ba220c43cbc7ab3d/birdhousebuilder/recipe/conda/__init__.py#L172-L211 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | BaseJobsModel.set_fields | def set_fields(self, **fields):
"""
Set many fields using the proxy setter for each of them.
"""
for field_name, value in iteritems(fields):
field = getattr(self, field_name)
field.proxy_set(value) | python | def set_fields(self, **fields):
"""
Set many fields using the proxy setter for each of them.
"""
for field_name, value in iteritems(fields):
field = getattr(self, field_name)
field.proxy_set(value) | [
"def",
"set_fields",
"(",
"self",
",",
"*",
"*",
"fields",
")",
":",
"for",
"field_name",
",",
"value",
"in",
"iteritems",
"(",
"fields",
")",
":",
"field",
"=",
"getattr",
"(",
"self",
",",
"field_name",
")",
"field",
".",
"proxy_set",
"(",
"value",
... | Set many fields using the proxy setter for each of them. | [
"Set",
"many",
"fields",
"using",
"the",
"proxy",
"setter",
"for",
"each",
"of",
"them",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L33-L39 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.get_queue | def get_queue(cls, name, priority=0, **fields_if_new):
"""
Get, or create, and return the wanted queue.
If the queue is created, fields in fields_if_new will be set for the new
queue.
"""
queue_kwargs = {'name': name, 'priority': priority}
retries = 0
whil... | python | def get_queue(cls, name, priority=0, **fields_if_new):
"""
Get, or create, and return the wanted queue.
If the queue is created, fields in fields_if_new will be set for the new
queue.
"""
queue_kwargs = {'name': name, 'priority': priority}
retries = 0
whil... | [
"def",
"get_queue",
"(",
"cls",
",",
"name",
",",
"priority",
"=",
"0",
",",
"*",
"*",
"fields_if_new",
")",
":",
"queue_kwargs",
"=",
"{",
"'name'",
":",
"name",
",",
"'priority'",
":",
"priority",
"}",
"retries",
"=",
"0",
"while",
"retries",
"<",
... | Get, or create, and return the wanted queue.
If the queue is created, fields in fields_if_new will be set for the new
queue. | [
"Get",
"or",
"create",
"and",
"return",
"the",
"wanted",
"queue",
".",
"If",
"the",
"queue",
"is",
"created",
"fields",
"in",
"fields_if_new",
"will",
"be",
"set",
"for",
"the",
"new",
"queue",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L51-L84 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.delay_job | def delay_job(self, job, delayed_until):
"""
Add the job to the delayed list (zset) of the queue.
"""
timestamp = datetime_to_score(delayed_until)
self.delayed.zadd(timestamp, job.ident) | python | def delay_job(self, job, delayed_until):
"""
Add the job to the delayed list (zset) of the queue.
"""
timestamp = datetime_to_score(delayed_until)
self.delayed.zadd(timestamp, job.ident) | [
"def",
"delay_job",
"(",
"self",
",",
"job",
",",
"delayed_until",
")",
":",
"timestamp",
"=",
"datetime_to_score",
"(",
"delayed_until",
")",
"self",
".",
"delayed",
".",
"zadd",
"(",
"timestamp",
",",
"job",
".",
"ident",
")"
] | Add the job to the delayed list (zset) of the queue. | [
"Add",
"the",
"job",
"to",
"the",
"delayed",
"list",
"(",
"zset",
")",
"of",
"the",
"queue",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L86-L91 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.enqueue_job | def enqueue_job(self, job, prepend=False):
"""
Add the job to the waiting list, at the end (it's a fifo list). If
`prepend` is True, add it at the beginning of the list.
"""
push_method = getattr(self.waiting, 'lpush' if prepend else 'rpush')
push_method(job.ident) | python | def enqueue_job(self, job, prepend=False):
"""
Add the job to the waiting list, at the end (it's a fifo list). If
`prepend` is True, add it at the beginning of the list.
"""
push_method = getattr(self.waiting, 'lpush' if prepend else 'rpush')
push_method(job.ident) | [
"def",
"enqueue_job",
"(",
"self",
",",
"job",
",",
"prepend",
"=",
"False",
")",
":",
"push_method",
"=",
"getattr",
"(",
"self",
".",
"waiting",
",",
"'lpush'",
"if",
"prepend",
"else",
"'rpush'",
")",
"push_method",
"(",
"job",
".",
"ident",
")"
] | Add the job to the waiting list, at the end (it's a fifo list). If
`prepend` is True, add it at the beginning of the list. | [
"Add",
"the",
"job",
"to",
"the",
"waiting",
"list",
"at",
"the",
"end",
"(",
"it",
"s",
"a",
"fifo",
"list",
")",
".",
"If",
"prepend",
"is",
"True",
"add",
"it",
"at",
"the",
"beginning",
"of",
"the",
"list",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L93-L99 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.get_all | def get_all(cls, names):
"""
Return all queues for the given names (for all available priorities)
"""
names = cls._get_iterable_for_names(names)
queues = []
for queue_name in names:
queues.extend(cls.collection(name=queue_name).instances())
return qu... | python | def get_all(cls, names):
"""
Return all queues for the given names (for all available priorities)
"""
names = cls._get_iterable_for_names(names)
queues = []
for queue_name in names:
queues.extend(cls.collection(name=queue_name).instances())
return qu... | [
"def",
"get_all",
"(",
"cls",
",",
"names",
")",
":",
"names",
"=",
"cls",
".",
"_get_iterable_for_names",
"(",
"names",
")",
"queues",
"=",
"[",
"]",
"for",
"queue_name",
"in",
"names",
":",
"queues",
".",
"extend",
"(",
"cls",
".",
"collection",
"(",... | Return all queues for the given names (for all available priorities) | [
"Return",
"all",
"queues",
"for",
"the",
"given",
"names",
"(",
"for",
"all",
"available",
"priorities",
")"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L112-L122 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.get_all_by_priority | def get_all_by_priority(cls, names):
"""
Return all the queues with the given names, sorted by priorities (higher
priority first), then by name
"""
names = cls._get_iterable_for_names(names)
queues = cls.get_all(names)
# sort all queues by priority
queue... | python | def get_all_by_priority(cls, names):
"""
Return all the queues with the given names, sorted by priorities (higher
priority first), then by name
"""
names = cls._get_iterable_for_names(names)
queues = cls.get_all(names)
# sort all queues by priority
queue... | [
"def",
"get_all_by_priority",
"(",
"cls",
",",
"names",
")",
":",
"names",
"=",
"cls",
".",
"_get_iterable_for_names",
"(",
"names",
")",
"queues",
"=",
"cls",
".",
"get_all",
"(",
"names",
")",
"# sort all queues by priority",
"queues",
".",
"sort",
"(",
"k... | Return all the queues with the given names, sorted by priorities (higher
priority first), then by name | [
"Return",
"all",
"the",
"queues",
"with",
"the",
"given",
"names",
"sorted",
"by",
"priorities",
"(",
"higher",
"priority",
"first",
")",
"then",
"by",
"name"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L125-L137 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.get_waiting_keys | def get_waiting_keys(cls, names):
"""
Return a list of all queue waiting keys, to use with blpop
"""
return [queue.waiting.key for queue in cls.get_all_by_priority(names)] | python | def get_waiting_keys(cls, names):
"""
Return a list of all queue waiting keys, to use with blpop
"""
return [queue.waiting.key for queue in cls.get_all_by_priority(names)] | [
"def",
"get_waiting_keys",
"(",
"cls",
",",
"names",
")",
":",
"return",
"[",
"queue",
".",
"waiting",
".",
"key",
"for",
"queue",
"in",
"cls",
".",
"get_all_by_priority",
"(",
"names",
")",
"]"
] | Return a list of all queue waiting keys, to use with blpop | [
"Return",
"a",
"list",
"of",
"all",
"queue",
"waiting",
"keys",
"to",
"use",
"with",
"blpop"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L140-L144 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.count_waiting_jobs | def count_waiting_jobs(cls, names):
"""
Return the number of all jobs waiting in queues with the given names
"""
return sum([queue.waiting.llen() for queue in cls.get_all(names)]) | python | def count_waiting_jobs(cls, names):
"""
Return the number of all jobs waiting in queues with the given names
"""
return sum([queue.waiting.llen() for queue in cls.get_all(names)]) | [
"def",
"count_waiting_jobs",
"(",
"cls",
",",
"names",
")",
":",
"return",
"sum",
"(",
"[",
"queue",
".",
"waiting",
".",
"llen",
"(",
")",
"for",
"queue",
"in",
"cls",
".",
"get_all",
"(",
"names",
")",
"]",
")"
] | Return the number of all jobs waiting in queues with the given names | [
"Return",
"the",
"number",
"of",
"all",
"jobs",
"waiting",
"in",
"queues",
"with",
"the",
"given",
"names"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L147-L151 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.count_delayed_jobs | def count_delayed_jobs(cls, names):
"""
Return the number of all delayed jobs in queues with the given names
"""
return sum([queue.delayed.zcard() for queue in cls.get_all(names)]) | python | def count_delayed_jobs(cls, names):
"""
Return the number of all delayed jobs in queues with the given names
"""
return sum([queue.delayed.zcard() for queue in cls.get_all(names)]) | [
"def",
"count_delayed_jobs",
"(",
"cls",
",",
"names",
")",
":",
"return",
"sum",
"(",
"[",
"queue",
".",
"delayed",
".",
"zcard",
"(",
")",
"for",
"queue",
"in",
"cls",
".",
"get_all",
"(",
"names",
")",
"]",
")"
] | Return the number of all delayed jobs in queues with the given names | [
"Return",
"the",
"number",
"of",
"all",
"delayed",
"jobs",
"in",
"queues",
"with",
"the",
"given",
"names"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L154-L158 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.first_delayed | def first_delayed(self):
"""
Return the first entry in the delayed zset (a tuple with the job's pk
and the score of the zset, which it's delayed time as a timestamp)
Returns None if no delayed jobs
"""
entries = self.delayed.zrange(0, 0, withscores=True)
return en... | python | def first_delayed(self):
"""
Return the first entry in the delayed zset (a tuple with the job's pk
and the score of the zset, which it's delayed time as a timestamp)
Returns None if no delayed jobs
"""
entries = self.delayed.zrange(0, 0, withscores=True)
return en... | [
"def",
"first_delayed",
"(",
"self",
")",
":",
"entries",
"=",
"self",
".",
"delayed",
".",
"zrange",
"(",
"0",
",",
"0",
",",
"withscores",
"=",
"True",
")",
"return",
"entries",
"[",
"0",
"]",
"if",
"entries",
"else",
"None"
] | Return the first entry in the delayed zset (a tuple with the job's pk
and the score of the zset, which it's delayed time as a timestamp)
Returns None if no delayed jobs | [
"Return",
"the",
"first",
"entry",
"in",
"the",
"delayed",
"zset",
"(",
"a",
"tuple",
"with",
"the",
"job",
"s",
"pk",
"and",
"the",
"score",
"of",
"the",
"zset",
"which",
"it",
"s",
"delayed",
"time",
"as",
"a",
"timestamp",
")",
"Returns",
"None",
... | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L161-L168 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Queue.requeue_delayed_jobs | def requeue_delayed_jobs(self):
"""
Put all delayed jobs that are now ready, back in the queue waiting list
Return a list of failures
"""
lock_key = self.make_key(
self._name,
self.pk.get(),
"requeue_all_delayed_ready_jobs",
)
c... | python | def requeue_delayed_jobs(self):
"""
Put all delayed jobs that are now ready, back in the queue waiting list
Return a list of failures
"""
lock_key = self.make_key(
self._name,
self.pk.get(),
"requeue_all_delayed_ready_jobs",
)
c... | [
"def",
"requeue_delayed_jobs",
"(",
"self",
")",
":",
"lock_key",
"=",
"self",
".",
"make_key",
"(",
"self",
".",
"_name",
",",
"self",
".",
"pk",
".",
"get",
"(",
")",
",",
"\"requeue_all_delayed_ready_jobs\"",
",",
")",
"connection",
"=",
"self",
".",
... | Put all delayed jobs that are now ready, back in the queue waiting list
Return a list of failures | [
"Put",
"all",
"delayed",
"jobs",
"that",
"are",
"now",
"ready",
"back",
"in",
"the",
"queue",
"waiting",
"list",
"Return",
"a",
"list",
"of",
"failures"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L180-L241 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job.get_from_ident | def get_from_ident(self, ident):
"""
Take a string as returned by get_ident and return a job,
based on the class representation and the job's pk from the ident
"""
model_repr, job_pk = ident.split(':', 1)
klass = import_class(model_repr)
return klass.get(job_pk) | python | def get_from_ident(self, ident):
"""
Take a string as returned by get_ident and return a job,
based on the class representation and the job's pk from the ident
"""
model_repr, job_pk = ident.split(':', 1)
klass = import_class(model_repr)
return klass.get(job_pk) | [
"def",
"get_from_ident",
"(",
"self",
",",
"ident",
")",
":",
"model_repr",
",",
"job_pk",
"=",
"ident",
".",
"split",
"(",
"':'",
",",
"1",
")",
"klass",
"=",
"import_class",
"(",
"model_repr",
")",
"return",
"klass",
".",
"get",
"(",
"job_pk",
")"
] | Take a string as returned by get_ident and return a job,
based on the class representation and the job's pk from the ident | [
"Take",
"a",
"string",
"as",
"returned",
"by",
"get_ident",
"and",
"return",
"a",
"job",
"based",
"on",
"the",
"class",
"representation",
"and",
"the",
"job",
"s",
"pk",
"from",
"the",
"ident"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L276-L283 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job._get_queue_name | def _get_queue_name(cls, queue_name=None):
"""
Return the given queue_name if defined, else the class's one.
If both are None, raise an Exception
"""
if queue_name is None and cls.queue_name is None:
raise LimpydJobsException("Queue's name not defined")
if que... | python | def _get_queue_name(cls, queue_name=None):
"""
Return the given queue_name if defined, else the class's one.
If both are None, raise an Exception
"""
if queue_name is None and cls.queue_name is None:
raise LimpydJobsException("Queue's name not defined")
if que... | [
"def",
"_get_queue_name",
"(",
"cls",
",",
"queue_name",
"=",
"None",
")",
":",
"if",
"queue_name",
"is",
"None",
"and",
"cls",
".",
"queue_name",
"is",
"None",
":",
"raise",
"LimpydJobsException",
"(",
"\"Queue's name not defined\"",
")",
"if",
"queue_name",
... | Return the given queue_name if defined, else the class's one.
If both are None, raise an Exception | [
"Return",
"the",
"given",
"queue_name",
"if",
"defined",
"else",
"the",
"class",
"s",
"one",
".",
"If",
"both",
"are",
"None",
"raise",
"an",
"Exception"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L286-L295 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job.add_job | def add_job(cls, identifier, queue_name=None, priority=0, queue_model=None,
prepend=False, delayed_for=None, delayed_until=None,
**fields_if_new):
"""
Add a job to a queue.
If this job already exists, check it's current priority. If its higher
than the new... | python | def add_job(cls, identifier, queue_name=None, priority=0, queue_model=None,
prepend=False, delayed_for=None, delayed_until=None,
**fields_if_new):
"""
Add a job to a queue.
If this job already exists, check it's current priority. If its higher
than the new... | [
"def",
"add_job",
"(",
"cls",
",",
"identifier",
",",
"queue_name",
"=",
"None",
",",
"priority",
"=",
"0",
",",
"queue_model",
"=",
"None",
",",
"prepend",
"=",
"False",
",",
"delayed_for",
"=",
"None",
",",
"delayed_until",
"=",
"None",
",",
"*",
"*"... | Add a job to a queue.
If this job already exists, check it's current priority. If its higher
than the new one, don't touch it, else move the job to the wanted queue.
Before setting/moving the job to the queue, check for a `delayed_for`
(int/foat/timedelta) or `delayed_until` (datetime) a... | [
"Add",
"a",
"job",
"to",
"a",
"queue",
".",
"If",
"this",
"job",
"already",
"exists",
"check",
"it",
"s",
"current",
"priority",
".",
"If",
"its",
"higher",
"than",
"the",
"new",
"one",
"don",
"t",
"touch",
"it",
"else",
"move",
"the",
"job",
"to",
... | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L298-L372 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job.duration | def duration(self):
"""
If the start and end times of the job are defined, return a timedelta,
else return None
"""
try:
start, end = self.hmget('start', 'end')
return parse(end) - parse(start)
except:
return None | python | def duration(self):
"""
If the start and end times of the job are defined, return a timedelta,
else return None
"""
try:
start, end = self.hmget('start', 'end')
return parse(end) - parse(start)
except:
return None | [
"def",
"duration",
"(",
"self",
")",
":",
"try",
":",
"start",
",",
"end",
"=",
"self",
".",
"hmget",
"(",
"'start'",
",",
"'end'",
")",
"return",
"parse",
"(",
"end",
")",
"-",
"parse",
"(",
"start",
")",
"except",
":",
"return",
"None"
] | If the start and end times of the job are defined, return a timedelta,
else return None | [
"If",
"the",
"start",
"and",
"end",
"times",
"of",
"the",
"job",
"are",
"defined",
"return",
"a",
"timedelta",
"else",
"return",
"None"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L392-L401 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job.requeue | def requeue(self, queue_name=None, priority=None, delayed_for=None,
delayed_until=None, queue_model=None):
"""
Requeue the job in the given queue if it has previously failed
"""
queue_name = self._get_queue_name(queue_name)
# we can only r... | python | def requeue(self, queue_name=None, priority=None, delayed_for=None,
delayed_until=None, queue_model=None):
"""
Requeue the job in the given queue if it has previously failed
"""
queue_name = self._get_queue_name(queue_name)
# we can only r... | [
"def",
"requeue",
"(",
"self",
",",
"queue_name",
"=",
"None",
",",
"priority",
"=",
"None",
",",
"delayed_for",
"=",
"None",
",",
"delayed_until",
"=",
"None",
",",
"queue_model",
"=",
"None",
")",
":",
"queue_name",
"=",
"self",
".",
"_get_queue_name",
... | Requeue the job in the given queue if it has previously failed | [
"Requeue",
"the",
"job",
"in",
"the",
"given",
"queue",
"if",
"it",
"has",
"previously",
"failed"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L403-L421 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Job.enqueue_or_delay | def enqueue_or_delay(self, queue_name=None, priority=None,
delayed_until=None, prepend=False, queue_model=None):
"""
Will enqueue or delay the job depending of the delayed_until.
"""
queue_name = self._get_queue_name(queue_name)
fields = {'queued': '1'}
... | python | def enqueue_or_delay(self, queue_name=None, priority=None,
delayed_until=None, prepend=False, queue_model=None):
"""
Will enqueue or delay the job depending of the delayed_until.
"""
queue_name = self._get_queue_name(queue_name)
fields = {'queued': '1'}
... | [
"def",
"enqueue_or_delay",
"(",
"self",
",",
"queue_name",
"=",
"None",
",",
"priority",
"=",
"None",
",",
"delayed_until",
"=",
"None",
",",
"prepend",
"=",
"False",
",",
"queue_model",
"=",
"None",
")",
":",
"queue_name",
"=",
"self",
".",
"_get_queue_na... | Will enqueue or delay the job depending of the delayed_until. | [
"Will",
"enqueue",
"or",
"delay",
"the",
"job",
"depending",
"of",
"the",
"delayed_until",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L423-L455 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Error.add_error | def add_error(cls, queue_name, job, error, when=None, trace=None,
**additional_fields):
"""
Add a new error in redis.
`job` is a job which generated the error
`queue_name` is the name of the queue where the error arrived
`er... | python | def add_error(cls, queue_name, job, error, when=None, trace=None,
**additional_fields):
"""
Add a new error in redis.
`job` is a job which generated the error
`queue_name` is the name of the queue where the error arrived
`er... | [
"def",
"add_error",
"(",
"cls",
",",
"queue_name",
",",
"job",
",",
"error",
",",
"when",
"=",
"None",
",",
"trace",
"=",
"None",
",",
"*",
"*",
"additional_fields",
")",
":",
"if",
"when",
"is",
"None",
":",
"when",
"=",
"datetime",
".",
"utcnow",
... | Add a new error in redis.
`job` is a job which generated the error
`queue_name` is the name of the queue where the error arrived
`error` is an exception, which can has a code (better if it is)
`when` is the datetime of the error, utcnow will be used if not defined
`trace` is the ... | [
"Add",
"a",
"new",
"error",
"in",
"redis",
".",
"job",
"is",
"a",
"job",
"which",
"generated",
"the",
"error",
"queue_name",
"is",
"the",
"name",
"of",
"the",
"queue",
"where",
"the",
"error",
"arrived",
"error",
"is",
"an",
"exception",
"which",
"can",
... | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L490-L536 |
limpyd/redis-limpyd-jobs | limpyd_jobs/models.py | Error.collection_for_job | def collection_for_job(cls, job):
"""
Helper to return a collection of errors for the given job
"""
return cls.collection(job_model_repr=job.get_model_repr(), identifier=getattr(job, '_cached_identifier', job.identifier.hget())) | python | def collection_for_job(cls, job):
"""
Helper to return a collection of errors for the given job
"""
return cls.collection(job_model_repr=job.get_model_repr(), identifier=getattr(job, '_cached_identifier', job.identifier.hget())) | [
"def",
"collection_for_job",
"(",
"cls",
",",
"job",
")",
":",
"return",
"cls",
".",
"collection",
"(",
"job_model_repr",
"=",
"job",
".",
"get_model_repr",
"(",
")",
",",
"identifier",
"=",
"getattr",
"(",
"job",
",",
"'_cached_identifier'",
",",
"job",
"... | Helper to return a collection of errors for the given job | [
"Helper",
"to",
"return",
"a",
"collection",
"of",
"errors",
"for",
"the",
"given",
"job"
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L539-L543 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.