id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
243,000 | honzamach/pynspect | pynspect/compilers.py | IDEAFilterCompiler.register_variable_compilation | def register_variable_compilation(self, path, compilation_cbk, listclass):
"""
Register given compilation method for variable on given path.
:param str path: JPath for given variable.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: Lis... | python | def register_variable_compilation(self, path, compilation_cbk, listclass):
"""
Register given compilation method for variable on given path.
:param str path: JPath for given variable.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: Lis... | [
"def",
"register_variable_compilation",
"(",
"self",
",",
"path",
",",
"compilation_cbk",
",",
"listclass",
")",
":",
"self",
".",
"compilations_variable",
"[",
"path",
"]",
"=",
"{",
"'callback'",
":",
"compilation_cbk",
",",
"'listclass'",
":",
"listclass",
"}... | Register given compilation method for variable on given path.
:param str path: JPath for given variable.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: List class to use for lists. | [
"Register",
"given",
"compilation",
"method",
"for",
"variable",
"on",
"given",
"path",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/compilers.py#L248-L259 |
243,001 | honzamach/pynspect | pynspect/compilers.py | IDEAFilterCompiler.register_function_compilation | def register_function_compilation(self, func, compilation_cbk, listclass):
"""
Register given compilation method for given function.
:param str path: Function name.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: List class to use for ... | python | def register_function_compilation(self, func, compilation_cbk, listclass):
"""
Register given compilation method for given function.
:param str path: Function name.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: List class to use for ... | [
"def",
"register_function_compilation",
"(",
"self",
",",
"func",
",",
"compilation_cbk",
",",
"listclass",
")",
":",
"self",
".",
"compilations_function",
"[",
"func",
"]",
"=",
"{",
"'callback'",
":",
"compilation_cbk",
",",
"'listclass'",
":",
"listclass",
"}... | Register given compilation method for given function.
:param str path: Function name.
:param callable compilation_cbk: Compilation callback to be called.
:param class listclass: List class to use for lists. | [
"Register",
"given",
"compilation",
"method",
"for",
"given",
"function",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/compilers.py#L261-L272 |
243,002 | honzamach/pynspect | pynspect/compilers.py | IDEAFilterCompiler._cor_compile | def _cor_compile(rule, var, val, result_class, key, compilation_list):
"""
Actual compilation worker method.
"""
compilation = compilation_list.get(key, None)
if compilation:
if isinstance(val, ListRule):
result = []
for itemv in val.va... | python | def _cor_compile(rule, var, val, result_class, key, compilation_list):
"""
Actual compilation worker method.
"""
compilation = compilation_list.get(key, None)
if compilation:
if isinstance(val, ListRule):
result = []
for itemv in val.va... | [
"def",
"_cor_compile",
"(",
"rule",
",",
"var",
",",
"val",
",",
"result_class",
",",
"key",
",",
"compilation_list",
")",
":",
"compilation",
"=",
"compilation_list",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
"compilation",
":",
"if",
"isinstance",
... | Actual compilation worker method. | [
"Actual",
"compilation",
"worker",
"method",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/compilers.py#L277-L291 |
243,003 | honzamach/pynspect | pynspect/compilers.py | IDEAFilterCompiler._compile_operation_rule | def _compile_operation_rule(self, rule, left, right, result_class):
"""
Compile given operation rule, when possible for given compination of
operation operands.
"""
# Make sure variables always have constant with correct datatype on the
# opposite side of operation.
... | python | def _compile_operation_rule(self, rule, left, right, result_class):
"""
Compile given operation rule, when possible for given compination of
operation operands.
"""
# Make sure variables always have constant with correct datatype on the
# opposite side of operation.
... | [
"def",
"_compile_operation_rule",
"(",
"self",
",",
"rule",
",",
"left",
",",
"right",
",",
"result_class",
")",
":",
"# Make sure variables always have constant with correct datatype on the",
"# opposite side of operation.",
"if",
"isinstance",
"(",
"left",
",",
"VariableR... | Compile given operation rule, when possible for given compination of
operation operands. | [
"Compile",
"given",
"operation",
"rule",
"when",
"possible",
"for",
"given",
"compination",
"of",
"operation",
"operands",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/compilers.py#L293-L342 |
243,004 | honzamach/pynspect | pynspect/compilers.py | IDEAFilterCompiler._calculate_operation_math | def _calculate_operation_math(self, rule, left, right):
"""
Perform compilation of given math operation by actually calculating given
math expression.
"""
# Attempt to keep integer data type for the result, when possible.
if isinstance(left, IntegerRule) and isinstance(r... | python | def _calculate_operation_math(self, rule, left, right):
"""
Perform compilation of given math operation by actually calculating given
math expression.
"""
# Attempt to keep integer data type for the result, when possible.
if isinstance(left, IntegerRule) and isinstance(r... | [
"def",
"_calculate_operation_math",
"(",
"self",
",",
"rule",
",",
"left",
",",
"right",
")",
":",
"# Attempt to keep integer data type for the result, when possible.",
"if",
"isinstance",
"(",
"left",
",",
"IntegerRule",
")",
"and",
"isinstance",
"(",
"right",
",",
... | Perform compilation of given math operation by actually calculating given
math expression. | [
"Perform",
"compilation",
"of",
"given",
"math",
"operation",
"by",
"actually",
"calculating",
"given",
"math",
"expression",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/compilers.py#L344-L365 |
243,005 | pyvec/pyvodb | pyvodb/load.py | get_db | def get_db(directory, engine=None):
"""Get a database
:param directory: The root data directory
:param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite)
"""
if engine is None:
engine = create_engine('sqlite://')
tables.metadata.create_all(engine)
Session = sessionm... | python | def get_db(directory, engine=None):
"""Get a database
:param directory: The root data directory
:param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite)
"""
if engine is None:
engine = create_engine('sqlite://')
tables.metadata.create_all(engine)
Session = sessionm... | [
"def",
"get_db",
"(",
"directory",
",",
"engine",
"=",
"None",
")",
":",
"if",
"engine",
"is",
"None",
":",
"engine",
"=",
"create_engine",
"(",
"'sqlite://'",
")",
"tables",
".",
"metadata",
".",
"create_all",
"(",
"engine",
")",
"Session",
"=",
"sessio... | Get a database
:param directory: The root data directory
:param engine: a pre-created SQLAlchemy engine (default: in-memory SQLite) | [
"Get",
"a",
"database"
] | 07183333df26eb12c5c2b98802cde3fb3a6c1339 | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/load.py#L22-L35 |
243,006 | legnaleurc/wcpan.listen | wcpan/listen/helper.py | bind_unix_socket | def bind_unix_socket(file_, mode=0o600, backlog=_DEFAULT_BACKLOG):
"""Creates a listening unix socket.
If a socket with the given name already exists, it will be deleted.
If any other file with that name exists, an exception will be
raised.
Returns a socket object (not a list of socket objects lik... | python | def bind_unix_socket(file_, mode=0o600, backlog=_DEFAULT_BACKLOG):
"""Creates a listening unix socket.
If a socket with the given name already exists, it will be deleted.
If any other file with that name exists, an exception will be
raised.
Returns a socket object (not a list of socket objects lik... | [
"def",
"bind_unix_socket",
"(",
"file_",
",",
"mode",
"=",
"0o600",
",",
"backlog",
"=",
"_DEFAULT_BACKLOG",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_UNIX",
",",
"socket",
".",
"SOCK_STREAM",
")",
"sock",
".",
"setsockopt",
... | Creates a listening unix socket.
If a socket with the given name already exists, it will be deleted.
If any other file with that name exists, an exception will be
raised.
Returns a socket object (not a list of socket objects like
`bind_sockets`) | [
"Creates",
"a",
"listening",
"unix",
"socket",
"."
] | 9c11e92ec5db588fc181543ad723b6eef0741db1 | https://github.com/legnaleurc/wcpan.listen/blob/9c11e92ec5db588fc181543ad723b6eef0741db1/wcpan/listen/helper.py#L188-L214 |
243,007 | noobermin/lspreader | lspreader/pmovie.py | firsthash | def firsthash(frame, removedupes=False):
'''
Hashes the first time step. Only will work as long as
the hash can fit in a uint64.
Parameters:
-----------
frame : first frame.
Keywords:
---------
removedups: specify duplicates for the given frame.
Returns a dictionary of... | python | def firsthash(frame, removedupes=False):
'''
Hashes the first time step. Only will work as long as
the hash can fit in a uint64.
Parameters:
-----------
frame : first frame.
Keywords:
---------
removedups: specify duplicates for the given frame.
Returns a dictionary of... | [
"def",
"firsthash",
"(",
"frame",
",",
"removedupes",
"=",
"False",
")",
":",
"#hashes must have i8 available",
"#overwise, we'll have overflow",
"def",
"avgdiff",
"(",
"d",
")",
":",
"d",
"=",
"np",
".",
"sort",
"(",
"d",
")",
"d",
"=",
"d",
"[",
"1",
"... | Hashes the first time step. Only will work as long as
the hash can fit in a uint64.
Parameters:
-----------
frame : first frame.
Keywords:
---------
removedups: specify duplicates for the given frame.
Returns a dictionary of everything needed
to generate hashes from the ge... | [
"Hashes",
"the",
"first",
"time",
"step",
".",
"Only",
"will",
"work",
"as",
"long",
"as",
"the",
"hash",
"can",
"fit",
"in",
"a",
"uint64",
"."
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L14-L67 |
243,008 | noobermin/lspreader | lspreader/pmovie.py | genhash | def genhash(frame,**kw):
'''
Generate the hashes for the given frame for a specification
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
d : hash specification generated from firsthash.
new ... | python | def genhash(frame,**kw):
'''
Generate the hashes for the given frame for a specification
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
d : hash specification generated from firsthash.
new ... | [
"def",
"genhash",
"(",
"frame",
",",
"*",
"*",
"kw",
")",
":",
"getkw",
"=",
"mk_getkw",
"(",
"kw",
",",
"genhash_defaults",
",",
"prefer_passed",
"=",
"True",
")",
"dims",
"=",
"getkw",
"(",
"'dims'",
")",
"dupes",
"=",
"getkw",
"(",
"'dupes'",
")",... | Generate the hashes for the given frame for a specification
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
d : hash specification generated from firsthash.
new : use new hashing, which isn't rea... | [
"Generate",
"the",
"hashes",
"for",
"the",
"given",
"frame",
"for",
"a",
"specification",
"given",
"in",
"the",
"dictionary",
"d",
"returned",
"from",
"firsthash",
"."
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L87-L130 |
243,009 | noobermin/lspreader | lspreader/pmovie.py | addhash | def addhash(frame,**kw):
'''
helper function to add hashes to the given frame
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
same as genhash
Returns frame with added hashes, although it will be add... | python | def addhash(frame,**kw):
'''
helper function to add hashes to the given frame
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
same as genhash
Returns frame with added hashes, although it will be add... | [
"def",
"addhash",
"(",
"frame",
",",
"*",
"*",
"kw",
")",
":",
"hashes",
"=",
"genhash",
"(",
"frame",
",",
"*",
"*",
"kw",
")",
"frame",
"[",
"'data'",
"]",
"=",
"rfn",
".",
"rec_append_fields",
"(",
"frame",
"[",
"'data'",
"]",
",",
"'hash'",
"... | helper function to add hashes to the given frame
given in the dictionary d returned from firsthash.
Parameters:
-----------
frame : frame to hash.
Keywords:
---------
same as genhash
Returns frame with added hashes, although it will be added in
place. | [
"helper",
"function",
"to",
"add",
"hashes",
"to",
"the",
"given",
"frame",
"given",
"in",
"the",
"dictionary",
"d",
"returned",
"from",
"firsthash",
"."
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L132-L151 |
243,010 | noobermin/lspreader | lspreader/pmovie.py | sortframe | def sortframe(frame):
'''
sorts particles for a frame
'''
d = frame['data'];
sortedargs = np.lexsort([d['xi'],d['yi'],d['zi']])
d = d[sortedargs];
frame['data']=d;
return frame; | python | def sortframe(frame):
'''
sorts particles for a frame
'''
d = frame['data'];
sortedargs = np.lexsort([d['xi'],d['yi'],d['zi']])
d = d[sortedargs];
frame['data']=d;
return frame; | [
"def",
"sortframe",
"(",
"frame",
")",
":",
"d",
"=",
"frame",
"[",
"'data'",
"]",
"sortedargs",
"=",
"np",
".",
"lexsort",
"(",
"[",
"d",
"[",
"'xi'",
"]",
",",
"d",
"[",
"'yi'",
"]",
",",
"d",
"[",
"'zi'",
"]",
"]",
")",
"d",
"=",
"d",
"[... | sorts particles for a frame | [
"sorts",
"particles",
"for",
"a",
"frame"
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L153-L161 |
243,011 | noobermin/lspreader | lspreader/pmovie.py | read_and_hash | def read_and_hash(fname, **kw):
'''
Read and and addhash each frame.
'''
return [addhash(frame, **kw) for frame in read(fname, **kw)]; | python | def read_and_hash(fname, **kw):
'''
Read and and addhash each frame.
'''
return [addhash(frame, **kw) for frame in read(fname, **kw)]; | [
"def",
"read_and_hash",
"(",
"fname",
",",
"*",
"*",
"kw",
")",
":",
"return",
"[",
"addhash",
"(",
"frame",
",",
"*",
"*",
"kw",
")",
"for",
"frame",
"in",
"read",
"(",
"fname",
",",
"*",
"*",
"kw",
")",
"]"
] | Read and and addhash each frame. | [
"Read",
"and",
"and",
"addhash",
"each",
"frame",
"."
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L163-L167 |
243,012 | noobermin/lspreader | lspreader/pmovie.py | filter_hashes_from_file | def filter_hashes_from_file(fname, f, **kw):
'''
Obtain good hashes from a .p4 file with the dict hashd and a
function that returns good hashes. Any keywords will be
sent to read_and_hash.
Parameters:
-----------
fname -- filename of file.
f -- function that returns a list of good ... | python | def filter_hashes_from_file(fname, f, **kw):
'''
Obtain good hashes from a .p4 file with the dict hashd and a
function that returns good hashes. Any keywords will be
sent to read_and_hash.
Parameters:
-----------
fname -- filename of file.
f -- function that returns a list of good ... | [
"def",
"filter_hashes_from_file",
"(",
"fname",
",",
"f",
",",
"*",
"*",
"kw",
")",
":",
"return",
"np",
".",
"concatenate",
"(",
"[",
"frame",
"[",
"'data'",
"]",
"[",
"'hash'",
"]",
"[",
"f",
"(",
"frame",
")",
"]",
"for",
"frame",
"in",
"read_an... | Obtain good hashes from a .p4 file with the dict hashd and a
function that returns good hashes. Any keywords will be
sent to read_and_hash.
Parameters:
-----------
fname -- filename of file.
f -- function that returns a list of good hashes. | [
"Obtain",
"good",
"hashes",
"from",
"a",
".",
"p4",
"file",
"with",
"the",
"dict",
"hashd",
"and",
"a",
"function",
"that",
"returns",
"good",
"hashes",
".",
"Any",
"keywords",
"will",
"be",
"sent",
"to",
"read_and_hash",
"."
] | 903b9d6427513b07986ffacf76cbca54e18d8be6 | https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/pmovie.py#L169-L184 |
243,013 | cuescience/goat | goat/matcher.py | GoatMatcher.check_match | def check_match(self, step) -> list:
"""Like matchers.CFParseMatcher.check_match but
also add the implicit parameters from the context
"""
args = []
match = super().check_match(step)
if match is None:
return None
for arg in match:
args.app... | python | def check_match(self, step) -> list:
"""Like matchers.CFParseMatcher.check_match but
also add the implicit parameters from the context
"""
args = []
match = super().check_match(step)
if match is None:
return None
for arg in match:
args.app... | [
"def",
"check_match",
"(",
"self",
",",
"step",
")",
"->",
"list",
":",
"args",
"=",
"[",
"]",
"match",
"=",
"super",
"(",
")",
".",
"check_match",
"(",
"step",
")",
"if",
"match",
"is",
"None",
":",
"return",
"None",
"for",
"arg",
"in",
"match",
... | Like matchers.CFParseMatcher.check_match but
also add the implicit parameters from the context | [
"Like",
"matchers",
".",
"CFParseMatcher",
".",
"check_match",
"but",
"also",
"add",
"the",
"implicit",
"parameters",
"from",
"the",
"context"
] | d76f44b9ec5dc40ad33abca50830c0d7492ef152 | https://github.com/cuescience/goat/blob/d76f44b9ec5dc40ad33abca50830c0d7492ef152/goat/matcher.py#L52-L67 |
243,014 | cuescience/goat | goat/matcher.py | GoatMatcher.convert | def convert(self, pattern: str) -> str:
"""Convert the goat step string to CFParse String"""
parameters = OrderedDict()
for parameter in self.signature.parameters.values():
annotation = self.convert_type_to_parse_type(parameter)
parameters[parameter.name] = "{%s:%s}" % (p... | python | def convert(self, pattern: str) -> str:
"""Convert the goat step string to CFParse String"""
parameters = OrderedDict()
for parameter in self.signature.parameters.values():
annotation = self.convert_type_to_parse_type(parameter)
parameters[parameter.name] = "{%s:%s}" % (p... | [
"def",
"convert",
"(",
"self",
",",
"pattern",
":",
"str",
")",
"->",
"str",
":",
"parameters",
"=",
"OrderedDict",
"(",
")",
"for",
"parameter",
"in",
"self",
".",
"signature",
".",
"parameters",
".",
"values",
"(",
")",
":",
"annotation",
"=",
"self"... | Convert the goat step string to CFParse String | [
"Convert",
"the",
"goat",
"step",
"string",
"to",
"CFParse",
"String"
] | d76f44b9ec5dc40ad33abca50830c0d7492ef152 | https://github.com/cuescience/goat/blob/d76f44b9ec5dc40ad33abca50830c0d7492ef152/goat/matcher.py#L76-L91 |
243,015 | BioMapOrg/biomap-utils | biomap/utils/xml.py | xml_to_json | def xml_to_json(root, tag_prefix=None, on_tag={}):
'''
Parses a XML element to JSON format.
This is a relatively generic function parsing a XML element
to JSON format. It does not guarantee any specific formal
behaviour but is empirically known to "work well" with respect
to the author's needs.... | python | def xml_to_json(root, tag_prefix=None, on_tag={}):
'''
Parses a XML element to JSON format.
This is a relatively generic function parsing a XML element
to JSON format. It does not guarantee any specific formal
behaviour but is empirically known to "work well" with respect
to the author's needs.... | [
"def",
"xml_to_json",
"(",
"root",
",",
"tag_prefix",
"=",
"None",
",",
"on_tag",
"=",
"{",
"}",
")",
":",
"def",
"get_key",
"(",
"tag",
")",
":",
"if",
"tag_prefix",
"is",
"not",
"None",
":",
"return",
"tag",
".",
"split",
"(",
"tag_prefix",
")",
... | Parses a XML element to JSON format.
This is a relatively generic function parsing a XML element
to JSON format. It does not guarantee any specific formal
behaviour but is empirically known to "work well" with respect
to the author's needs. External verification of the returned
results by the user ... | [
"Parses",
"a",
"XML",
"element",
"to",
"JSON",
"format",
"."
] | 270c5c5fc6361094a5e2f93fc2ad84c2fe9b6ce5 | https://github.com/BioMapOrg/biomap-utils/blob/270c5c5fc6361094a5e2f93fc2ad84c2fe9b6ce5/biomap/utils/xml.py#L1-L75 |
243,016 | mayfield/shellish | shellish/rendering/vtml.py | _textwrap_slices | def _textwrap_slices(text, width, strip_leading_indent=False):
""" Nearly identical to textwrap.wrap except this routine is a tad bit
safer in its algo that textwrap. I ran into some issues with textwrap
output that make it unusable to this usecase as a baseline text wrapper.
Further this utility retur... | python | def _textwrap_slices(text, width, strip_leading_indent=False):
""" Nearly identical to textwrap.wrap except this routine is a tad bit
safer in its algo that textwrap. I ran into some issues with textwrap
output that make it unusable to this usecase as a baseline text wrapper.
Further this utility retur... | [
"def",
"_textwrap_slices",
"(",
"text",
",",
"width",
",",
"strip_leading_indent",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected `str` type\"",
")",
"chunks",
"=",
"(",
"x",
"fo... | Nearly identical to textwrap.wrap except this routine is a tad bit
safer in its algo that textwrap. I ran into some issues with textwrap
output that make it unusable to this usecase as a baseline text wrapper.
Further this utility returns slices instead of strings. So the slices
can be used to extract... | [
"Nearly",
"identical",
"to",
"textwrap",
".",
"wrap",
"except",
"this",
"routine",
"is",
"a",
"tad",
"bit",
"safer",
"in",
"its",
"algo",
"that",
"textwrap",
".",
"I",
"ran",
"into",
"some",
"issues",
"with",
"textwrap",
"output",
"that",
"make",
"it",
"... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/vtml.py#L73-L149 |
243,017 | mayfield/shellish | shellish/rendering/vtml.py | vtmlrender | def vtmlrender(vtmarkup, plain=None, strict=False, vtmlparser=VTMLParser()):
""" Look for vt100 markup and render vt opcodes into a VTMLBuffer. """
if isinstance(vtmarkup, VTMLBuffer):
return vtmarkup.plain() if plain else vtmarkup
try:
vtmlparser.feed(vtmarkup)
vtmlparser.close()
... | python | def vtmlrender(vtmarkup, plain=None, strict=False, vtmlparser=VTMLParser()):
""" Look for vt100 markup and render vt opcodes into a VTMLBuffer. """
if isinstance(vtmarkup, VTMLBuffer):
return vtmarkup.plain() if plain else vtmarkup
try:
vtmlparser.feed(vtmarkup)
vtmlparser.close()
... | [
"def",
"vtmlrender",
"(",
"vtmarkup",
",",
"plain",
"=",
"None",
",",
"strict",
"=",
"False",
",",
"vtmlparser",
"=",
"VTMLParser",
"(",
")",
")",
":",
"if",
"isinstance",
"(",
"vtmarkup",
",",
"VTMLBuffer",
")",
":",
"return",
"vtmarkup",
".",
"plain",
... | Look for vt100 markup and render vt opcodes into a VTMLBuffer. | [
"Look",
"for",
"vt100",
"markup",
"and",
"render",
"vt",
"opcodes",
"into",
"a",
"VTMLBuffer",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/vtml.py#L554-L571 |
243,018 | tBaxter/tango-shared-core | build/lib/tango_shared/utils/sanetize.py | clean_text | def clean_text(value, topic=False):
"""
Replaces "profane" words with more suitable ones.
Uses bleach to strip all but whitelisted html.
Converts bbcode to Markdown
"""
for x in PROFANITY_REPLACEMENTS:
value = value.replace(x[0], x[1])
for bbset in BBCODE_REPLACEMENTS:
p = r... | python | def clean_text(value, topic=False):
"""
Replaces "profane" words with more suitable ones.
Uses bleach to strip all but whitelisted html.
Converts bbcode to Markdown
"""
for x in PROFANITY_REPLACEMENTS:
value = value.replace(x[0], x[1])
for bbset in BBCODE_REPLACEMENTS:
p = r... | [
"def",
"clean_text",
"(",
"value",
",",
"topic",
"=",
"False",
")",
":",
"for",
"x",
"in",
"PROFANITY_REPLACEMENTS",
":",
"value",
"=",
"value",
".",
"replace",
"(",
"x",
"[",
"0",
"]",
",",
"x",
"[",
"1",
"]",
")",
"for",
"bbset",
"in",
"BBCODE_RE... | Replaces "profane" words with more suitable ones.
Uses bleach to strip all but whitelisted html.
Converts bbcode to Markdown | [
"Replaces",
"profane",
"words",
"with",
"more",
"suitable",
"ones",
".",
"Uses",
"bleach",
"to",
"strip",
"all",
"but",
"whitelisted",
"html",
".",
"Converts",
"bbcode",
"to",
"Markdown"
] | 35fc10aef1ceedcdb4d6d866d44a22efff718812 | https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/utils/sanetize.py#L133-L150 |
243,019 | tBaxter/tango-shared-core | build/lib/tango_shared/utils/sanetize.py | is_email_simple | def is_email_simple(value):
"""Return True if value looks like an email address."""
# An @ must be in the middle of the value.
if '@' not in value or value.startswith('@') or value.endswith('@'):
return False
try:
p1, p2 = value.split('@')
except ValueErro... | python | def is_email_simple(value):
"""Return True if value looks like an email address."""
# An @ must be in the middle of the value.
if '@' not in value or value.startswith('@') or value.endswith('@'):
return False
try:
p1, p2 = value.split('@')
except ValueErro... | [
"def",
"is_email_simple",
"(",
"value",
")",
":",
"# An @ must be in the middle of the value.",
"if",
"'@'",
"not",
"in",
"value",
"or",
"value",
".",
"startswith",
"(",
"'@'",
")",
"or",
"value",
".",
"endswith",
"(",
"'@'",
")",
":",
"return",
"False",
"tr... | Return True if value looks like an email address. | [
"Return",
"True",
"if",
"value",
"looks",
"like",
"an",
"email",
"address",
"."
] | 35fc10aef1ceedcdb4d6d866d44a22efff718812 | https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/utils/sanetize.py#L153-L166 |
243,020 | tBaxter/tango-shared-core | build/lib/tango_shared/utils/sanetize.py | convert_links | def convert_links(text, trim_url_limit=None, nofollow=False, autoescape=False):
"""
Finds URLs in text and attempts to handle correctly.
Heavily based on django.utils.html.urlize
With the additions of attempting to embed media links, particularly images.
Works on http://, https://, www. links, and ... | python | def convert_links(text, trim_url_limit=None, nofollow=False, autoescape=False):
"""
Finds URLs in text and attempts to handle correctly.
Heavily based on django.utils.html.urlize
With the additions of attempting to embed media links, particularly images.
Works on http://, https://, www. links, and ... | [
"def",
"convert_links",
"(",
"text",
",",
"trim_url_limit",
"=",
"None",
",",
"nofollow",
"=",
"False",
",",
"autoescape",
"=",
"False",
")",
":",
"safe_input",
"=",
"isinstance",
"(",
"text",
",",
"SafeData",
")",
"words",
"=",
"word_split_re",
".",
"spli... | Finds URLs in text and attempts to handle correctly.
Heavily based on django.utils.html.urlize
With the additions of attempting to embed media links, particularly images.
Works on http://, https://, www. links, and also on links ending in one of
the original seven gTLDs (.com, .edu, .gov, .int, .mil, .... | [
"Finds",
"URLs",
"in",
"text",
"and",
"attempts",
"to",
"handle",
"correctly",
".",
"Heavily",
"based",
"on",
"django",
".",
"utils",
".",
"html",
".",
"urlize",
"With",
"the",
"additions",
"of",
"attempting",
"to",
"embed",
"media",
"links",
"particularly",... | 35fc10aef1ceedcdb4d6d866d44a22efff718812 | https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/utils/sanetize.py#L169-L254 |
243,021 | mrstephenneal/dirutility | dirutility/multiprocess.py | pool_process | def pool_process(func, iterable, cpus=cpu_count(), return_vals=False, cpu_reduction=0, progress_bar=False):
"""
Multiprocessing helper function for performing looped operation using multiple processors.
:param func: Function to call
:param iterable: Iterable object to perform each function on
:para... | python | def pool_process(func, iterable, cpus=cpu_count(), return_vals=False, cpu_reduction=0, progress_bar=False):
"""
Multiprocessing helper function for performing looped operation using multiple processors.
:param func: Function to call
:param iterable: Iterable object to perform each function on
:para... | [
"def",
"pool_process",
"(",
"func",
",",
"iterable",
",",
"cpus",
"=",
"cpu_count",
"(",
")",
",",
"return_vals",
"=",
"False",
",",
"cpu_reduction",
"=",
"0",
",",
"progress_bar",
"=",
"False",
")",
":",
"with",
"Pool",
"(",
"cpus",
"-",
"abs",
"(",
... | Multiprocessing helper function for performing looped operation using multiple processors.
:param func: Function to call
:param iterable: Iterable object to perform each function on
:param cpus: Number of cpu cores, defaults to system's cpu count
:param return_vals: Bool, returns output values when Tru... | [
"Multiprocessing",
"helper",
"function",
"for",
"performing",
"looped",
"operation",
"using",
"multiple",
"processors",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/multiprocess.py#L6-L38 |
243,022 | mrstephenneal/dirutility | dirutility/multiprocess.py | PoolProcess.map | def map(self):
"""Perform a function on every item in an iterable."""
with Pool(self.cpu_count) as pool:
pool.map(self._func, self._iterable)
pool.close()
return True | python | def map(self):
"""Perform a function on every item in an iterable."""
with Pool(self.cpu_count) as pool:
pool.map(self._func, self._iterable)
pool.close()
return True | [
"def",
"map",
"(",
"self",
")",
":",
"with",
"Pool",
"(",
"self",
".",
"cpu_count",
")",
"as",
"pool",
":",
"pool",
".",
"map",
"(",
"self",
".",
"_func",
",",
"self",
".",
"_iterable",
")",
"pool",
".",
"close",
"(",
")",
"return",
"True"
] | Perform a function on every item in an iterable. | [
"Perform",
"a",
"function",
"on",
"every",
"item",
"in",
"an",
"iterable",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/multiprocess.py#L58-L63 |
243,023 | mrstephenneal/dirutility | dirutility/multiprocess.py | PoolProcess.map_return | def map_return(self):
"""Perform a function on every item and return a list of yield values."""
with Pool(self.cpu_count) as pool:
vals = pool.map(self._func, self._iterable)
pool.close()
return vals | python | def map_return(self):
"""Perform a function on every item and return a list of yield values."""
with Pool(self.cpu_count) as pool:
vals = pool.map(self._func, self._iterable)
pool.close()
return vals | [
"def",
"map_return",
"(",
"self",
")",
":",
"with",
"Pool",
"(",
"self",
".",
"cpu_count",
")",
"as",
"pool",
":",
"vals",
"=",
"pool",
".",
"map",
"(",
"self",
".",
"_func",
",",
"self",
".",
"_iterable",
")",
"pool",
".",
"close",
"(",
")",
"re... | Perform a function on every item and return a list of yield values. | [
"Perform",
"a",
"function",
"on",
"every",
"item",
"and",
"return",
"a",
"list",
"of",
"yield",
"values",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/multiprocess.py#L65-L70 |
243,024 | mrstephenneal/dirutility | dirutility/multiprocess.py | PoolProcess.map_tqdm | def map_tqdm(self):
"""
Perform a function on every item while displaying a progress bar.
:return: A list of yielded values
"""
with Pool(self.cpu_count) as pool:
vals = [v for v in tqdm(pool.imap_unordered(self._func, self._iterable), total=len(self._iterable))]
... | python | def map_tqdm(self):
"""
Perform a function on every item while displaying a progress bar.
:return: A list of yielded values
"""
with Pool(self.cpu_count) as pool:
vals = [v for v in tqdm(pool.imap_unordered(self._func, self._iterable), total=len(self._iterable))]
... | [
"def",
"map_tqdm",
"(",
"self",
")",
":",
"with",
"Pool",
"(",
"self",
".",
"cpu_count",
")",
"as",
"pool",
":",
"vals",
"=",
"[",
"v",
"for",
"v",
"in",
"tqdm",
"(",
"pool",
".",
"imap_unordered",
"(",
"self",
".",
"_func",
",",
"self",
".",
"_i... | Perform a function on every item while displaying a progress bar.
:return: A list of yielded values | [
"Perform",
"a",
"function",
"on",
"every",
"item",
"while",
"displaying",
"a",
"progress",
"bar",
"."
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/multiprocess.py#L72-L81 |
243,025 | tshlabs/tunic | tunic/core.py | split_by_line | def split_by_line(content):
"""Split the given content into a list of items by newline.
Both \r\n and \n are supported. This is done since it seems
that TTY devices on POSIX systems use \r\n for newlines in
some instances.
If the given content is an empty string or a string of only
whitespace,... | python | def split_by_line(content):
"""Split the given content into a list of items by newline.
Both \r\n and \n are supported. This is done since it seems
that TTY devices on POSIX systems use \r\n for newlines in
some instances.
If the given content is an empty string or a string of only
whitespace,... | [
"def",
"split_by_line",
"(",
"content",
")",
":",
"# Make sure we don't end up splitting a string with",
"# just a single trailing \\n or \\r\\n into multiple parts.",
"stripped",
"=",
"content",
".",
"strip",
"(",
")",
"if",
"not",
"stripped",
":",
"return",
"[",
"]",
"i... | Split the given content into a list of items by newline.
Both \r\n and \n are supported. This is done since it seems
that TTY devices on POSIX systems use \r\n for newlines in
some instances.
If the given content is an empty string or a string of only
whitespace, an empty list will be returned. If... | [
"Split",
"the",
"given",
"content",
"into",
"a",
"list",
"of",
"items",
"by",
"newline",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L67-L96 |
243,026 | tshlabs/tunic | tunic/core.py | get_release_id | def get_release_id(version=None):
"""Get a unique, time-based identifier for a deployment
that optionally, also includes some sort of version number
or release.
If a version is supplied, the release ID will be of the form
'$timestamp-$version'. For example:
>>> get_release_id(version='1.4.1')
... | python | def get_release_id(version=None):
"""Get a unique, time-based identifier for a deployment
that optionally, also includes some sort of version number
or release.
If a version is supplied, the release ID will be of the form
'$timestamp-$version'. For example:
>>> get_release_id(version='1.4.1')
... | [
"def",
"get_release_id",
"(",
"version",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name",
"ts",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"RELEASE_DATE_FMT",
")",
"if",
"version",
"is",
"None",
":",
"return",
"ts",
"return",
"'{... | Get a unique, time-based identifier for a deployment
that optionally, also includes some sort of version number
or release.
If a version is supplied, the release ID will be of the form
'$timestamp-$version'. For example:
>>> get_release_id(version='1.4.1')
'20140214231159-1.4.1'
If the ve... | [
"Get",
"a",
"unique",
"time",
"-",
"based",
"identifier",
"for",
"a",
"deployment",
"that",
"optionally",
"also",
"includes",
"some",
"sort",
"of",
"version",
"number",
"or",
"release",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L147-L176 |
243,027 | tshlabs/tunic | tunic/core.py | try_repeatedly | def try_repeatedly(method, max_retries=None, delay=None):
"""Execute the given Fabric call, retrying up to a certain number of times.
The method is expected to be wrapper around a Fabric :func:`run` or :func:`sudo`
call that returns the results of that call. The call will be executed at least
once, and... | python | def try_repeatedly(method, max_retries=None, delay=None):
"""Execute the given Fabric call, retrying up to a certain number of times.
The method is expected to be wrapper around a Fabric :func:`run` or :func:`sudo`
call that returns the results of that call. The call will be executed at least
once, and... | [
"def",
"try_repeatedly",
"(",
"method",
",",
"max_retries",
"=",
"None",
",",
"delay",
"=",
"None",
")",
":",
"max_retries",
"=",
"max_retries",
"if",
"max_retries",
"is",
"not",
"None",
"else",
"1",
"delay",
"=",
"delay",
"if",
"delay",
"is",
"not",
"No... | Execute the given Fabric call, retrying up to a certain number of times.
The method is expected to be wrapper around a Fabric :func:`run` or :func:`sudo`
call that returns the results of that call. The call will be executed at least
once, and up to :code:`max_retries` additional times until the call execut... | [
"Execute",
"the",
"given",
"Fabric",
"call",
"retrying",
"up",
"to",
"a",
"certain",
"number",
"of",
"times",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L219-L249 |
243,028 | tshlabs/tunic | tunic/core.py | ReleaseManager.get_current_release | def get_current_release(self):
"""Get the release ID of the "current" deployment, None if
there is no current deployment.
This method performs one network operation.
:return: Get the current release ID
:rtype: str
"""
current = self._runner.run("readlink '{0}'".... | python | def get_current_release(self):
"""Get the release ID of the "current" deployment, None if
there is no current deployment.
This method performs one network operation.
:return: Get the current release ID
:rtype: str
"""
current = self._runner.run("readlink '{0}'".... | [
"def",
"get_current_release",
"(",
"self",
")",
":",
"current",
"=",
"self",
".",
"_runner",
".",
"run",
"(",
"\"readlink '{0}'\"",
".",
"format",
"(",
"self",
".",
"_current",
")",
")",
"if",
"current",
".",
"failed",
":",
"return",
"None",
"return",
"o... | Get the release ID of the "current" deployment, None if
there is no current deployment.
This method performs one network operation.
:return: Get the current release ID
:rtype: str | [
"Get",
"the",
"release",
"ID",
"of",
"the",
"current",
"deployment",
"None",
"if",
"there",
"is",
"no",
"current",
"deployment",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L304-L316 |
243,029 | tshlabs/tunic | tunic/core.py | ReleaseManager.get_previous_release | def get_previous_release(self):
"""Get the release ID of the deployment immediately
before the "current" deployment, ``None`` if no previous
release could be determined.
This method performs two network operations.
:return: The release ID of the release previous to the
... | python | def get_previous_release(self):
"""Get the release ID of the deployment immediately
before the "current" deployment, ``None`` if no previous
release could be determined.
This method performs two network operations.
:return: The release ID of the release previous to the
... | [
"def",
"get_previous_release",
"(",
"self",
")",
":",
"releases",
"=",
"self",
".",
"get_releases",
"(",
")",
"if",
"not",
"releases",
":",
"return",
"None",
"current",
"=",
"self",
".",
"get_current_release",
"(",
")",
"if",
"not",
"current",
":",
"return... | Get the release ID of the deployment immediately
before the "current" deployment, ``None`` if no previous
release could be determined.
This method performs two network operations.
:return: The release ID of the release previous to the
"current" release.
:rtype: str | [
"Get",
"the",
"release",
"ID",
"of",
"the",
"deployment",
"immediately",
"before",
"the",
"current",
"deployment",
"None",
"if",
"no",
"previous",
"release",
"could",
"be",
"determined",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L329-L356 |
243,030 | tshlabs/tunic | tunic/core.py | ReleaseManager.cleanup | def cleanup(self, keep=5):
"""Remove all but the ``keep`` most recent releases.
If any of the candidates for deletion are pointed to by the
'current' symlink, they will not be deleted.
This method performs N + 2 network operations where N is the
number of old releases that are ... | python | def cleanup(self, keep=5):
"""Remove all but the ``keep`` most recent releases.
If any of the candidates for deletion are pointed to by the
'current' symlink, they will not be deleted.
This method performs N + 2 network operations where N is the
number of old releases that are ... | [
"def",
"cleanup",
"(",
"self",
",",
"keep",
"=",
"5",
")",
":",
"releases",
"=",
"self",
".",
"get_releases",
"(",
")",
"current_version",
"=",
"self",
".",
"get_current_release",
"(",
")",
"to_delete",
"=",
"[",
"version",
"for",
"version",
"in",
"relea... | Remove all but the ``keep`` most recent releases.
If any of the candidates for deletion are pointed to by the
'current' symlink, they will not be deleted.
This method performs N + 2 network operations where N is the
number of old releases that are cleaned up.
:param int keep: ... | [
"Remove",
"all",
"but",
"the",
"keep",
"most",
"recent",
"releases",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L387-L403 |
243,031 | tshlabs/tunic | tunic/core.py | ProjectSetup.setup_directories | def setup_directories(self, use_sudo=True):
"""Create the minimal required directories for deploying multiple
releases of a project.
By default, creation of directories is done with the Fabric
``sudo`` function but can optionally use the ``run`` function.
This method performs o... | python | def setup_directories(self, use_sudo=True):
"""Create the minimal required directories for deploying multiple
releases of a project.
By default, creation of directories is done with the Fabric
``sudo`` function but can optionally use the ``run`` function.
This method performs o... | [
"def",
"setup_directories",
"(",
"self",
",",
"use_sudo",
"=",
"True",
")",
":",
"runner",
"=",
"self",
".",
"_runner",
".",
"sudo",
"if",
"use_sudo",
"else",
"self",
".",
"_runner",
".",
"run",
"runner",
"(",
"\"mkdir -p '{0}'\"",
".",
"format",
"(",
"s... | Create the minimal required directories for deploying multiple
releases of a project.
By default, creation of directories is done with the Fabric
``sudo`` function but can optionally use the ``run`` function.
This method performs one network operation.
:param bool use_sudo: If... | [
"Create",
"the",
"minimal",
"required",
"directories",
"for",
"deploying",
"multiple",
"releases",
"of",
"a",
"project",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L436-L450 |
243,032 | tshlabs/tunic | tunic/core.py | ProjectSetup.set_permissions | def set_permissions(
self, owner, file_perms=PERMS_FILE_DEFAULT,
dir_perms=PERMS_DIR_DEFAULT, use_sudo=True):
"""Set the owner and permissions of the code deploy.
The owner will be set recursively for the entire code deploy.
The directory permissions will be set on only... | python | def set_permissions(
self, owner, file_perms=PERMS_FILE_DEFAULT,
dir_perms=PERMS_DIR_DEFAULT, use_sudo=True):
"""Set the owner and permissions of the code deploy.
The owner will be set recursively for the entire code deploy.
The directory permissions will be set on only... | [
"def",
"set_permissions",
"(",
"self",
",",
"owner",
",",
"file_perms",
"=",
"PERMS_FILE_DEFAULT",
",",
"dir_perms",
"=",
"PERMS_DIR_DEFAULT",
",",
"use_sudo",
"=",
"True",
")",
":",
"runner",
"=",
"self",
".",
"_runner",
".",
"sudo",
"if",
"use_sudo",
"else... | Set the owner and permissions of the code deploy.
The owner will be set recursively for the entire code deploy.
The directory permissions will be set on only the base of the
code deploy and the releases directory. The file permissions
will be set recursively for the entire code deploy.... | [
"Set",
"the",
"owner",
"and",
"permissions",
"of",
"the",
"code",
"deploy",
"."
] | 621f4398d59a9c9eb8dd602beadff11616048aa0 | https://github.com/tshlabs/tunic/blob/621f4398d59a9c9eb8dd602beadff11616048aa0/tunic/core.py#L452-L500 |
243,033 | frigg/frigg-worker | frigg_worker/jobs.py | Job.create_pending_after_task | def create_pending_after_task(self):
"""
Creates pending task results in a dict on self.after_result with task string as key.
It will also create a list on self.tasks that is used to make sure the serialization
of the results creates a correctly ordered list.
"""
for task... | python | def create_pending_after_task(self):
"""
Creates pending task results in a dict on self.after_result with task string as key.
It will also create a list on self.tasks that is used to make sure the serialization
of the results creates a correctly ordered list.
"""
for task... | [
"def",
"create_pending_after_task",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"settings",
".",
"tasks",
"[",
"self",
".",
"after_tasks_key",
"]",
":",
"self",
".",
"after_tasks",
".",
"append",
"(",
"task",
")",
"self",
".",
"after_results",... | Creates pending task results in a dict on self.after_result with task string as key.
It will also create a list on self.tasks that is used to make sure the serialization
of the results creates a correctly ordered list. | [
"Creates",
"pending",
"task",
"results",
"in",
"a",
"dict",
"on",
"self",
".",
"after_result",
"with",
"task",
"string",
"as",
"key",
".",
"It",
"will",
"also",
"create",
"a",
"list",
"on",
"self",
".",
"tasks",
"that",
"is",
"used",
"to",
"make",
"sur... | 8c215cd8f5a27ff9f5a4fedafe93d2ef0fbca86c | https://github.com/frigg/frigg-worker/blob/8c215cd8f5a27ff9f5a4fedafe93d2ef0fbca86c/frigg_worker/jobs.py#L231-L239 |
243,034 | privacee/freelan-configurator | freelan_configurator/freelan_cmd.py | load_config | def load_config():
'''try loading config file from a default directory'''
cfg_path = '/usr/local/etc/freelan'
cfg_file = 'freelan.cfg'
if not os.path.isdir(cfg_path):
print("Can not find default freelan config directory.")
return
cfg_file_path = os.path.join(cfg_path,cfg_file)
... | python | def load_config():
'''try loading config file from a default directory'''
cfg_path = '/usr/local/etc/freelan'
cfg_file = 'freelan.cfg'
if not os.path.isdir(cfg_path):
print("Can not find default freelan config directory.")
return
cfg_file_path = os.path.join(cfg_path,cfg_file)
... | [
"def",
"load_config",
"(",
")",
":",
"cfg_path",
"=",
"'/usr/local/etc/freelan'",
"cfg_file",
"=",
"'freelan.cfg'",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"cfg_path",
")",
":",
"print",
"(",
"\"Can not find default freelan config directory.\"",
")",
"r... | try loading config file from a default directory | [
"try",
"loading",
"config",
"file",
"from",
"a",
"default",
"directory"
] | 7c070f8958454792f870ef0d195a7f5da36edb5a | https://github.com/privacee/freelan-configurator/blob/7c070f8958454792f870ef0d195a7f5da36edb5a/freelan_configurator/freelan_cmd.py#L14-L29 |
243,035 | privacee/freelan-configurator | freelan_configurator/freelan_cmd.py | write_config | def write_config(cfg):
'''try writing config file to a default directory'''
cfg_path = '/usr/local/etc/freelan'
cfg_file = 'freelan_TEST.cfg'
cfg_lines = []
if not isinstance(cfg, FreelanCFG):
if not isinstance(cfg, (list, tuple)):
print("Freelan write input can not be processe... | python | def write_config(cfg):
'''try writing config file to a default directory'''
cfg_path = '/usr/local/etc/freelan'
cfg_file = 'freelan_TEST.cfg'
cfg_lines = []
if not isinstance(cfg, FreelanCFG):
if not isinstance(cfg, (list, tuple)):
print("Freelan write input can not be processe... | [
"def",
"write_config",
"(",
"cfg",
")",
":",
"cfg_path",
"=",
"'/usr/local/etc/freelan'",
"cfg_file",
"=",
"'freelan_TEST.cfg'",
"cfg_lines",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"cfg",
",",
"FreelanCFG",
")",
":",
"if",
"not",
"isinstance",
"(",
"... | try writing config file to a default directory | [
"try",
"writing",
"config",
"file",
"to",
"a",
"default",
"directory"
] | 7c070f8958454792f870ef0d195a7f5da36edb5a | https://github.com/privacee/freelan-configurator/blob/7c070f8958454792f870ef0d195a7f5da36edb5a/freelan_configurator/freelan_cmd.py#L76-L106 |
243,036 | pyvec/pyvodb | pyvodb/cli/videometadata.py | cfgdump | def cfgdump(path, config):
"""Create output directory path and output there the config.yaml file."""
dump = yaml_dump(config)
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path, 'config.yaml'), 'w') as outf:
outf.write(dump)
print(dump) | python | def cfgdump(path, config):
"""Create output directory path and output there the config.yaml file."""
dump = yaml_dump(config)
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path, 'config.yaml'), 'w') as outf:
outf.write(dump)
print(dump) | [
"def",
"cfgdump",
"(",
"path",
",",
"config",
")",
":",
"dump",
"=",
"yaml_dump",
"(",
"config",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"with",
"open",
"(",
"os",
".",
... | Create output directory path and output there the config.yaml file. | [
"Create",
"output",
"directory",
"path",
"and",
"output",
"there",
"the",
"config",
".",
"yaml",
"file",
"."
] | 07183333df26eb12c5c2b98802cde3fb3a6c1339 | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/cli/videometadata.py#L11-L18 |
243,037 | pyvec/pyvodb | pyvodb/cli/videometadata.py | videometadata | def videometadata(ctx, city, date, outpath):
"""Generate metadata for video records.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN... | python | def videometadata(ctx, city, date, outpath):
"""Generate metadata for video records.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN... | [
"def",
"videometadata",
"(",
"ctx",
",",
"city",
",",
"date",
",",
"outpath",
")",
":",
"db",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"today",
"=",
"ctx",
".",
"obj",
"[",
"'now'",
"]",
".",
"date",
"(",
")",
"event",
"=",
"cliutil",
".",
"ge... | Generate metadata for video records.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN (e.g. p1): show the N-th last meetup | [
"Generate",
"metadata",
"for",
"video",
"records",
"."
] | 07183333df26eb12c5c2b98802cde3fb3a6c1339 | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/cli/videometadata.py#L26-L73 |
243,038 | anjos/rrbob | rr/database.py | split_data | def split_data(data, subset, splits):
'''Returns the data for a given protocol
'''
return dict([(k, data[k][splits[subset]]) for k in data]) | python | def split_data(data, subset, splits):
'''Returns the data for a given protocol
'''
return dict([(k, data[k][splits[subset]]) for k in data]) | [
"def",
"split_data",
"(",
"data",
",",
"subset",
",",
"splits",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"k",
",",
"data",
"[",
"k",
"]",
"[",
"splits",
"[",
"subset",
"]",
"]",
")",
"for",
"k",
"in",
"data",
"]",
")"
] | Returns the data for a given protocol | [
"Returns",
"the",
"data",
"for",
"a",
"given",
"protocol"
] | d32d35bab2aa2698d3caa923fd02afb6d67f3235 | https://github.com/anjos/rrbob/blob/d32d35bab2aa2698d3caa923fd02afb6d67f3235/rr/database.py#L37-L41 |
243,039 | anjos/rrbob | rr/database.py | get | def get(protocol, subset, classes=CLASSES, variables=VARIABLES):
'''Returns the data subset given a particular protocol
Parameters
protocol (string): one of the valid protocols supported by this interface
subset (string): one of 'train' or 'test'
classes (list of string): a list of strings containi... | python | def get(protocol, subset, classes=CLASSES, variables=VARIABLES):
'''Returns the data subset given a particular protocol
Parameters
protocol (string): one of the valid protocols supported by this interface
subset (string): one of 'train' or 'test'
classes (list of string): a list of strings containi... | [
"def",
"get",
"(",
"protocol",
",",
"subset",
",",
"classes",
"=",
"CLASSES",
",",
"variables",
"=",
"VARIABLES",
")",
":",
"retval",
"=",
"split_data",
"(",
"bob",
".",
"db",
".",
"iris",
".",
"data",
"(",
")",
",",
"subset",
",",
"PROTOCOLS",
"[",
... | Returns the data subset given a particular protocol
Parameters
protocol (string): one of the valid protocols supported by this interface
subset (string): one of 'train' or 'test'
classes (list of string): a list of strings containing the names of the
classes from which you want to have the data... | [
"Returns",
"the",
"data",
"subset",
"given",
"a",
"particular",
"protocol"
] | d32d35bab2aa2698d3caa923fd02afb6d67f3235 | https://github.com/anjos/rrbob/blob/d32d35bab2aa2698d3caa923fd02afb6d67f3235/rr/database.py#L44-L78 |
243,040 | mayfield/shellish | shellish/completer.py | ActionCompleter.silent_parse_args | def silent_parse_args(self, command, args):
""" Silently attempt to parse args. If there is a failure then we
ignore the effects. Using an in-place namespace object ensures we
capture as many of the valid arguments as possible when the argparse
system would otherwise throw away the res... | python | def silent_parse_args(self, command, args):
""" Silently attempt to parse args. If there is a failure then we
ignore the effects. Using an in-place namespace object ensures we
capture as many of the valid arguments as possible when the argparse
system would otherwise throw away the res... | [
"def",
"silent_parse_args",
"(",
"self",
",",
"command",
",",
"args",
")",
":",
"args_ns",
"=",
"argparse",
".",
"Namespace",
"(",
")",
"stderr_save",
"=",
"argparse",
".",
"_sys",
".",
"stderr",
"stdout_save",
"=",
"argparse",
".",
"_sys",
".",
"stdout",
... | Silently attempt to parse args. If there is a failure then we
ignore the effects. Using an in-place namespace object ensures we
capture as many of the valid arguments as possible when the argparse
system would otherwise throw away the results. | [
"Silently",
"attempt",
"to",
"parse",
"args",
".",
"If",
"there",
"is",
"a",
"failure",
"then",
"we",
"ignore",
"the",
"effects",
".",
"Using",
"an",
"in",
"-",
"place",
"namespace",
"object",
"ensures",
"we",
"capture",
"as",
"many",
"of",
"the",
"valid... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/completer.py#L53-L70 |
243,041 | mayfield/shellish | shellish/completer.py | ActionCompleter.parse_nargs | def parse_nargs(self, nargs):
""" Nargs is essentially a multi-type encoding. We have to parse it
to understand how many values this action may consume. """
self.max_args = self.min_args = 0
if nargs is None:
self.max_args = self.min_args = 1
elif nargs == argparse.O... | python | def parse_nargs(self, nargs):
""" Nargs is essentially a multi-type encoding. We have to parse it
to understand how many values this action may consume. """
self.max_args = self.min_args = 0
if nargs is None:
self.max_args = self.min_args = 1
elif nargs == argparse.O... | [
"def",
"parse_nargs",
"(",
"self",
",",
"nargs",
")",
":",
"self",
".",
"max_args",
"=",
"self",
".",
"min_args",
"=",
"0",
"if",
"nargs",
"is",
"None",
":",
"self",
".",
"max_args",
"=",
"self",
".",
"min_args",
"=",
"1",
"elif",
"nargs",
"==",
"a... | Nargs is essentially a multi-type encoding. We have to parse it
to understand how many values this action may consume. | [
"Nargs",
"is",
"essentially",
"a",
"multi",
"-",
"type",
"encoding",
".",
"We",
"have",
"to",
"parse",
"it",
"to",
"understand",
"how",
"many",
"values",
"this",
"action",
"may",
"consume",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/completer.py#L72-L86 |
243,042 | mayfield/shellish | shellish/completer.py | ActionCompleter.consume | def consume(self, args):
""" Consume the arguments we support. The args are modified inline.
The return value is the number of args eaten. """
consumable = args[:self.max_args]
self.consumed = len(consumable)
del args[:self.consumed]
return self.consumed | python | def consume(self, args):
""" Consume the arguments we support. The args are modified inline.
The return value is the number of args eaten. """
consumable = args[:self.max_args]
self.consumed = len(consumable)
del args[:self.consumed]
return self.consumed | [
"def",
"consume",
"(",
"self",
",",
"args",
")",
":",
"consumable",
"=",
"args",
"[",
":",
"self",
".",
"max_args",
"]",
"self",
".",
"consumed",
"=",
"len",
"(",
"consumable",
")",
"del",
"args",
"[",
":",
"self",
".",
"consumed",
"]",
"return",
"... | Consume the arguments we support. The args are modified inline.
The return value is the number of args eaten. | [
"Consume",
"the",
"arguments",
"we",
"support",
".",
"The",
"args",
"are",
"modified",
"inline",
".",
"The",
"return",
"value",
"is",
"the",
"number",
"of",
"args",
"eaten",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/completer.py#L88-L94 |
243,043 | mayfield/shellish | shellish/completer.py | ActionCompleter.about_action | def about_action(self):
""" Simple string describing the action. """
name = self.action.metavar or self.action.dest
type_name = self.action.type.__name__ if self.action.type else ''
if self.action.help or type_name:
extra = ' (%s)' % (self.action.help or 'type: %s' % type_nam... | python | def about_action(self):
""" Simple string describing the action. """
name = self.action.metavar or self.action.dest
type_name = self.action.type.__name__ if self.action.type else ''
if self.action.help or type_name:
extra = ' (%s)' % (self.action.help or 'type: %s' % type_nam... | [
"def",
"about_action",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"action",
".",
"metavar",
"or",
"self",
".",
"action",
".",
"dest",
"type_name",
"=",
"self",
".",
"action",
".",
"type",
".",
"__name__",
"if",
"self",
".",
"action",
".",
"type... | Simple string describing the action. | [
"Simple",
"string",
"describing",
"the",
"action",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/completer.py#L108-L116 |
243,044 | mayfield/shellish | shellish/completer.py | ActionCompleter.file_complete | def file_complete(self, prefix, args):
""" Look in the local filesystem for valid file choices. """
path = os.path.expanduser(prefix)
dirname, name = os.path.split(path)
if not dirname:
dirname = '.'
try:
dirs = os.listdir(dirname)
except FileNotFo... | python | def file_complete(self, prefix, args):
""" Look in the local filesystem for valid file choices. """
path = os.path.expanduser(prefix)
dirname, name = os.path.split(path)
if not dirname:
dirname = '.'
try:
dirs = os.listdir(dirname)
except FileNotFo... | [
"def",
"file_complete",
"(",
"self",
",",
"prefix",
",",
"args",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"prefix",
")",
"dirname",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"if",
"not",
"dirname"... | Look in the local filesystem for valid file choices. | [
"Look",
"in",
"the",
"local",
"filesystem",
"for",
"valid",
"file",
"choices",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/completer.py#L121-L145 |
243,045 | pytools/pytools-command | pytools_command/core.py | exec_command | def exec_command(command, **kwargs):
"""
Executes the given command and send the output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `stdin` (``*`` = None) --
* `stdout` (``*`` = None) --
* `stderr` (``*`` = None) --
... | python | def exec_command(command, **kwargs):
"""
Executes the given command and send the output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `stdin` (``*`` = None) --
* `stdout` (``*`` = None) --
* `stderr` (``*`` = None) --
... | [
"def",
"exec_command",
"(",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"shell",
"=",
"kwargs",
".",
"get",
"(",
"'shell'",
",",
"False",
")",
"stdin",
"=",
"kwargs",
".",
"get",
"(",
"'stdin'",
",",
"None",
")",
"stdout",
"=",
"kwargs",
".",
"ge... | Executes the given command and send the output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `stdin` (``*`` = None) --
* `stdout` (``*`` = None) --
* `stderr` (``*`` = None) --
:return: CommandReturnValue | [
"Executes",
"the",
"given",
"command",
"and",
"send",
"the",
"output",
"to",
"the",
"console"
] | ec6793d8ecac46fa0899f64596aa914f4a09d7f6 | https://github.com/pytools/pytools-command/blob/ec6793d8ecac46fa0899f64596aa914f4a09d7f6/pytools_command/core.py#L40-L73 |
243,046 | pytools/pytools-command | pytools_command/core.py | observe_command | def observe_command(command, **kwargs):
"""
Executes the given command and captures the output without any output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `timeout` (``int`` = 15) -- Timeout in seconds
* `stdin` (``*`` = None)... | python | def observe_command(command, **kwargs):
"""
Executes the given command and captures the output without any output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `timeout` (``int`` = 15) -- Timeout in seconds
* `stdin` (``*`` = None)... | [
"def",
"observe_command",
"(",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"shell",
"=",
"kwargs",
".",
"get",
"(",
"'shell'",
",",
"False",
")",
"timeout",
"=",
"kwargs",
".",
"get",
"(",
"'timeout'",
",",
"15",
")",
"stdin",
"=",
"kwargs",
".",
... | Executes the given command and captures the output without any output to the console
:param str|list command:
:kwargs:
* `shell` (``bool`` = False) --
* `timeout` (``int`` = 15) -- Timeout in seconds
* `stdin` (``*`` = None) --
* `stdout` (``*`` = None) --
... | [
"Executes",
"the",
"given",
"command",
"and",
"captures",
"the",
"output",
"without",
"any",
"output",
"to",
"the",
"console"
] | ec6793d8ecac46fa0899f64596aa914f4a09d7f6 | https://github.com/pytools/pytools-command/blob/ec6793d8ecac46fa0899f64596aa914f4a09d7f6/pytools_command/core.py#L76-L154 |
243,047 | political-memory/django-representatives | representatives/migrations/0016_chamber_migrate_data.py | calculate_hash | def calculate_hash(obj):
"""
Computes fingerprint for an object, this code is duplicated from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario.
"""
hashable_fields = {
'Chamber': ['name', 'country', 'abbreviation'],
'Cons... | python | def calculate_hash(obj):
"""
Computes fingerprint for an object, this code is duplicated from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario.
"""
hashable_fields = {
'Chamber': ['name', 'country', 'abbreviation'],
'Cons... | [
"def",
"calculate_hash",
"(",
"obj",
")",
":",
"hashable_fields",
"=",
"{",
"'Chamber'",
":",
"[",
"'name'",
",",
"'country'",
",",
"'abbreviation'",
"]",
",",
"'Constituency'",
":",
"[",
"'name'",
"]",
",",
"'Group'",
":",
"[",
"'name'",
",",
"'abbreviati... | Computes fingerprint for an object, this code is duplicated from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario. | [
"Computes",
"fingerprint",
"for",
"an",
"object",
"this",
"code",
"is",
"duplicated",
"from",
"representatives",
".",
"models",
".",
"HashableModel",
"because",
"we",
"don",
"t",
"have",
"access",
"to",
"model",
"methods",
"in",
"a",
"migration",
"scenario",
"... | 811c90d0250149e913e6196f0ab11c97d396be39 | https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/migrations/0016_chamber_migrate_data.py#L9-L36 |
243,048 | political-memory/django-representatives | representatives/migrations/0016_chamber_migrate_data.py | get_or_create | def get_or_create(cls, **kwargs):
"""
Implements get_or_create logic for models that inherit from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario.
"""
try:
obj = cls.objects.get(**kwargs)
created = False
except cls.D... | python | def get_or_create(cls, **kwargs):
"""
Implements get_or_create logic for models that inherit from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario.
"""
try:
obj = cls.objects.get(**kwargs)
created = False
except cls.D... | [
"def",
"get_or_create",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"obj",
"=",
"cls",
".",
"objects",
".",
"get",
"(",
"*",
"*",
"kwargs",
")",
"created",
"=",
"False",
"except",
"cls",
".",
"DoesNotExist",
":",
"obj",
"=",
"cls",
... | Implements get_or_create logic for models that inherit from
representatives.models.HashableModel because we don't have access to model
methods in a migration scenario. | [
"Implements",
"get_or_create",
"logic",
"for",
"models",
"that",
"inherit",
"from",
"representatives",
".",
"models",
".",
"HashableModel",
"because",
"we",
"don",
"t",
"have",
"access",
"to",
"model",
"methods",
"in",
"a",
"migration",
"scenario",
"."
] | 811c90d0250149e913e6196f0ab11c97d396be39 | https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/migrations/0016_chamber_migrate_data.py#L39-L55 |
243,049 | gongliyu/decoutils | decoutils/__init__.py | decorator_with_args | def decorator_with_args(func, return_original=False, target_pos=0):
"""Enable a function to work with a decorator with arguments
Args:
func (callable): The input function.
return_original (bool): Whether the resultant decorator returns
the decorating target unchanged. If True, will return... | python | def decorator_with_args(func, return_original=False, target_pos=0):
"""Enable a function to work with a decorator with arguments
Args:
func (callable): The input function.
return_original (bool): Whether the resultant decorator returns
the decorating target unchanged. If True, will return... | [
"def",
"decorator_with_args",
"(",
"func",
",",
"return_original",
"=",
"False",
",",
"target_pos",
"=",
"0",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"target_name",
"=",
"inspect",
".",
"getfullargspec",
"(",
"func",
")... | Enable a function to work with a decorator with arguments
Args:
func (callable): The input function.
return_original (bool): Whether the resultant decorator returns
the decorating target unchanged. If True, will return the
target unchanged. Otherwise, return the returned value from
... | [
"Enable",
"a",
"function",
"to",
"work",
"with",
"a",
"decorator",
"with",
"arguments"
] | f826cda612da7e6e0767bb0e1f0ac509f8316322 | https://github.com/gongliyu/decoutils/blob/f826cda612da7e6e0767bb0e1f0ac509f8316322/decoutils/__init__.py#L9-L85 |
243,050 | janbrohl/XMLCompare | xmlcompare.py | elements_equal | def elements_equal(first, *others):
"""
Check elements for equality
"""
f = first
lf = list(f)
for e in others:
le = list(e)
if (len(lf) != len(le)
or f.tag != e.tag
or f.text != e.text
or f.tail != e.tail
or f.attri... | python | def elements_equal(first, *others):
"""
Check elements for equality
"""
f = first
lf = list(f)
for e in others:
le = list(e)
if (len(lf) != len(le)
or f.tag != e.tag
or f.text != e.text
or f.tail != e.tail
or f.attri... | [
"def",
"elements_equal",
"(",
"first",
",",
"*",
"others",
")",
":",
"f",
"=",
"first",
"lf",
"=",
"list",
"(",
"f",
")",
"for",
"e",
"in",
"others",
":",
"le",
"=",
"list",
"(",
"e",
")",
"if",
"(",
"len",
"(",
"lf",
")",
"!=",
"len",
"(",
... | Check elements for equality | [
"Check",
"elements",
"for",
"equality"
] | 2592cc4a0976b7510bfa44a63822d7fb6c63b74f | https://github.com/janbrohl/XMLCompare/blob/2592cc4a0976b7510bfa44a63822d7fb6c63b74f/xmlcompare.py#L12-L28 |
243,051 | janbrohl/XMLCompare | xmlcompare.py | get_element | def get_element(text_or_tree_or_element):
"""
Get back an ET.Element for several possible input formats
"""
if isinstance(text_or_tree_or_element, ET.Element):
return text_or_tree_or_element
elif isinstance(text_or_tree_or_element, ET.ElementTree):
return text_or_tree_or_element.getr... | python | def get_element(text_or_tree_or_element):
"""
Get back an ET.Element for several possible input formats
"""
if isinstance(text_or_tree_or_element, ET.Element):
return text_or_tree_or_element
elif isinstance(text_or_tree_or_element, ET.ElementTree):
return text_or_tree_or_element.getr... | [
"def",
"get_element",
"(",
"text_or_tree_or_element",
")",
":",
"if",
"isinstance",
"(",
"text_or_tree_or_element",
",",
"ET",
".",
"Element",
")",
":",
"return",
"text_or_tree_or_element",
"elif",
"isinstance",
"(",
"text_or_tree_or_element",
",",
"ET",
".",
"Eleme... | Get back an ET.Element for several possible input formats | [
"Get",
"back",
"an",
"ET",
".",
"Element",
"for",
"several",
"possible",
"input",
"formats"
] | 2592cc4a0976b7510bfa44a63822d7fb6c63b74f | https://github.com/janbrohl/XMLCompare/blob/2592cc4a0976b7510bfa44a63822d7fb6c63b74f/xmlcompare.py#L31-L42 |
243,052 | deviantony/valigator | valigator/celery.py | task_failure_handler | def task_failure_handler(task_id=None, exception=None,
traceback=None, args=None, **kwargs):
"""Task failure handler"""
# TODO: find a better way to acces workdir/archive/image
task_report = {'task_id': task_id,
'exception': exception,
'tracebac... | python | def task_failure_handler(task_id=None, exception=None,
traceback=None, args=None, **kwargs):
"""Task failure handler"""
# TODO: find a better way to acces workdir/archive/image
task_report = {'task_id': task_id,
'exception': exception,
'tracebac... | [
"def",
"task_failure_handler",
"(",
"task_id",
"=",
"None",
",",
"exception",
"=",
"None",
",",
"traceback",
"=",
"None",
",",
"args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: find a better way to acces workdir/archive/image",
"task_report",
"=",
... | Task failure handler | [
"Task",
"failure",
"handler"
] | 0557029bc58ea1270e358c14ca382d3807ed5b6f | https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/celery.py#L29-L40 |
243,053 | esterhui/pypu | pypu/service_flickr.py | service_flickr._update_config | def _update_config(self,directory,filename):
"""Manages FLICKR config files"""
basefilename=os.path.splitext(filename)[0]
ext=os.path.splitext(filename)[1].lower()
if filename==LOCATION_FILE:
print("%s - Updating geotag information"%(LOCATION_FILE))
return self._u... | python | def _update_config(self,directory,filename):
"""Manages FLICKR config files"""
basefilename=os.path.splitext(filename)[0]
ext=os.path.splitext(filename)[1].lower()
if filename==LOCATION_FILE:
print("%s - Updating geotag information"%(LOCATION_FILE))
return self._u... | [
"def",
"_update_config",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"basefilename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"["... | Manages FLICKR config files | [
"Manages",
"FLICKR",
"config",
"files"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L122-L141 |
243,054 | esterhui/pypu | pypu/service_flickr.py | service_flickr._update_meta | def _update_meta(self,directory,filename):
"""Opens up filename.title and
filename.description, updates on flickr"""
if not self._connectToFlickr():
print("%s - Couldn't connect to flickr"%(directory))
return False
db = self._loadDB(directory)
# Look up... | python | def _update_meta(self,directory,filename):
"""Opens up filename.title and
filename.description, updates on flickr"""
if not self._connectToFlickr():
print("%s - Couldn't connect to flickr"%(directory))
return False
db = self._loadDB(directory)
# Look up... | [
"def",
"_update_meta",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to flickr\"",
"%",
"(",
"directory",
")",
")",
"return",
"False",
"db",
"=",
... | Opens up filename.title and
filename.description, updates on flickr | [
"Opens",
"up",
"filename",
".",
"title",
"and",
"filename",
".",
"description",
"updates",
"on",
"flickr"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L143-L182 |
243,055 | esterhui/pypu | pypu/service_flickr.py | service_flickr._createphotoset | def _createphotoset(self,myset,primary_photoid):
"""Creates a photo set on Flickr"""
if not self._connectToFlickr():
print("%s - Couldn't connect to flickr"%(directory))
return False
logger.debug('Creating photo set %s with prim photo %s'\
%(myset... | python | def _createphotoset(self,myset,primary_photoid):
"""Creates a photo set on Flickr"""
if not self._connectToFlickr():
print("%s - Couldn't connect to flickr"%(directory))
return False
logger.debug('Creating photo set %s with prim photo %s'\
%(myset... | [
"def",
"_createphotoset",
"(",
"self",
",",
"myset",
",",
"primary_photoid",
")",
":",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to flickr\"",
"%",
"(",
"directory",
")",
")",
"return",
"False",
"logger... | Creates a photo set on Flickr | [
"Creates",
"a",
"photo",
"set",
"on",
"Flickr"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L242-L257 |
243,056 | esterhui/pypu | pypu/service_flickr.py | service_flickr._update_config_sets | def _update_config_sets(self,directory,files=None):
"""
Loads set information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only upd... | python | def _update_config_sets(self,directory,files=None):
"""
Loads set information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only upd... | [
"def",
"_update_config_sets",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to flickr\"",
"%",
"(",
"directory",
")",
")",
"return",
"Fa... | Loads set information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only update files that are in the flickr DB and files list | [
"Loads",
"set",
"information",
"from",
"file",
"and",
"updates",
"on",
"flickr",
"only",
"reads",
"first",
"line",
".",
"Format",
"is",
"comma",
"separated",
"eg",
".",
"travel",
"2010",
"South",
"Africa",
"Pretoria",
"If",
"files",
"is",
"None",
"will",
"... | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L259-L330 |
243,057 | esterhui/pypu | pypu/service_flickr.py | service_flickr._getphotosets_forphoto | def _getphotosets_forphoto(self,pid):
"""Asks flickr which photosets photo with
given pid belongs to, returns list of
photoset names"""
resp=self.flickr.photos_getAllContexts(photo_id=pid)
if resp.attrib['stat']!='ok':
logger.error("%s - flickr: photos_getAllContext ... | python | def _getphotosets_forphoto(self,pid):
"""Asks flickr which photosets photo with
given pid belongs to, returns list of
photoset names"""
resp=self.flickr.photos_getAllContexts(photo_id=pid)
if resp.attrib['stat']!='ok':
logger.error("%s - flickr: photos_getAllContext ... | [
"def",
"_getphotosets_forphoto",
"(",
"self",
",",
"pid",
")",
":",
"resp",
"=",
"self",
".",
"flickr",
".",
"photos_getAllContexts",
"(",
"photo_id",
"=",
"pid",
")",
"if",
"resp",
".",
"attrib",
"[",
"'stat'",
"]",
"!=",
"'ok'",
":",
"logger",
".",
"... | Asks flickr which photosets photo with
given pid belongs to, returns list of
photoset names | [
"Asks",
"flickr",
"which",
"photosets",
"photo",
"with",
"given",
"pid",
"belongs",
"to",
"returns",
"list",
"of",
"photoset",
"names"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L333-L350 |
243,058 | esterhui/pypu | pypu/service_flickr.py | service_flickr._getphoto_originalsize | def _getphoto_originalsize(self,pid):
"""Asks flickr for photo original size
returns tuple with width,height
"""
logger.debug('%s - Getting original size from flickr'%(pid))
width=None
height=None
resp=self.flickr.photos_getSizes(photo_id=pid)
if resp.a... | python | def _getphoto_originalsize(self,pid):
"""Asks flickr for photo original size
returns tuple with width,height
"""
logger.debug('%s - Getting original size from flickr'%(pid))
width=None
height=None
resp=self.flickr.photos_getSizes(photo_id=pid)
if resp.a... | [
"def",
"_getphoto_originalsize",
"(",
"self",
",",
"pid",
")",
":",
"logger",
".",
"debug",
"(",
"'%s - Getting original size from flickr'",
"%",
"(",
"pid",
")",
")",
"width",
"=",
"None",
"height",
"=",
"None",
"resp",
"=",
"self",
".",
"flickr",
".",
"p... | Asks flickr for photo original size
returns tuple with width,height | [
"Asks",
"flickr",
"for",
"photo",
"original",
"size",
"returns",
"tuple",
"with",
"width",
"height"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L352-L375 |
243,059 | esterhui/pypu | pypu/service_flickr.py | service_flickr._getphoto_information | def _getphoto_information(self,pid):
"""Asks flickr for photo information
returns dictionary with attributes
{'dateuploaded': '1383410793',
'farm': '3',
'id': '10628709834',
'isfavorite': '0',
'license': '0',
'media': 'photo',
'originalforma... | python | def _getphoto_information(self,pid):
"""Asks flickr for photo information
returns dictionary with attributes
{'dateuploaded': '1383410793',
'farm': '3',
'id': '10628709834',
'isfavorite': '0',
'license': '0',
'media': 'photo',
'originalforma... | [
"def",
"_getphoto_information",
"(",
"self",
",",
"pid",
")",
":",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to flickr\"",
"%",
"(",
"directory",
")",
")",
"return",
"False",
"d",
"=",
"{",
"}",
"lo... | Asks flickr for photo information
returns dictionary with attributes
{'dateuploaded': '1383410793',
'farm': '3',
'id': '10628709834',
'isfavorite': '0',
'license': '0',
'media': 'photo',
'originalformat': 'jpg',
'originalsecret': 'b60f4f675... | [
"Asks",
"flickr",
"for",
"photo",
"information",
"returns",
"dictionary",
"with",
"attributes"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L429-L467 |
243,060 | esterhui/pypu | pypu/service_flickr.py | service_flickr._update_config_tags | def _update_config_tags(self,directory,files=None):
"""
Loads tags information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only up... | python | def _update_config_tags(self,directory,files=None):
"""
Loads tags information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only up... | [
"def",
"_update_config_tags",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to flickr\"",
"%",
"(",
"directory",
")",
")",
"return",
"Fa... | Loads tags information from file and updates on flickr,
only reads first line. Format is comma separated eg.
travel, 2010, South Africa, Pretoria
If files is None, will update all files in DB, otherwise
will only update files that are in the flickr DB and files list | [
"Loads",
"tags",
"information",
"from",
"file",
"and",
"updates",
"on",
"flickr",
"only",
"reads",
"first",
"line",
".",
"Format",
"is",
"comma",
"separated",
"eg",
".",
"travel",
"2010",
"South",
"Africa",
"Pretoria",
"If",
"files",
"is",
"None",
"will",
... | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L469-L502 |
243,061 | esterhui/pypu | pypu/service_flickr.py | service_flickr._remove_media | def _remove_media(self,directory,files=None):
"""Removes specified files from flickr"""
# Connect if we aren't already
if not self._connectToFlickr():
logger.error("%s - Couldn't connect to flickr")
return False
db=self._loadDB(directory)
# If no files gi... | python | def _remove_media(self,directory,files=None):
"""Removes specified files from flickr"""
# Connect if we aren't already
if not self._connectToFlickr():
logger.error("%s - Couldn't connect to flickr")
return False
db=self._loadDB(directory)
# If no files gi... | [
"def",
"_remove_media",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
")",
":",
"# Connect if we aren't already",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"logger",
".",
"error",
"(",
"\"%s - Couldn't connect to flickr\"",
")",
"r... | Removes specified files from flickr | [
"Removes",
"specified",
"files",
"from",
"flickr"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L574-L608 |
243,062 | esterhui/pypu | pypu/service_flickr.py | service_flickr._upload_media | def _upload_media(self,directory,files=None,resize_request=None):
"""Uploads media file to FLICKR, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
If no filename given, will go through all files in DB"""... | python | def _upload_media(self,directory,files=None,resize_request=None):
"""Uploads media file to FLICKR, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
If no filename given, will go through all files in DB"""... | [
"def",
"_upload_media",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
",",
"resize_request",
"=",
"None",
")",
":",
"# Connect if we aren't already",
"if",
"not",
"self",
".",
"_connectToFlickr",
"(",
")",
":",
"logger",
".",
"error",
"(",
"\"%s ... | Uploads media file to FLICKR, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
If no filename given, will go through all files in DB | [
"Uploads",
"media",
"file",
"to",
"FLICKR",
"returns",
"True",
"if",
"uploaded",
"successfully",
"Will",
"replace",
"if",
"already",
"uploaded",
"If",
"megapixels",
">",
"0",
"will",
"scale",
"photos",
"before",
"upload",
"If",
"no",
"filename",
"given",
"will... | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_flickr.py#L610-L653 |
243,063 | krukas/Trionyx | trionyx/quickstart/__init__.py | Quickstart.create_project | def create_project(self, project_path):
"""
Create Trionyx project in given path
:param str path: path to create project in.
:raises FileExistsError:
"""
shutil.copytree(self.project_path, project_path)
self.update_file(project_path, 'requirements.txt', {
... | python | def create_project(self, project_path):
"""
Create Trionyx project in given path
:param str path: path to create project in.
:raises FileExistsError:
"""
shutil.copytree(self.project_path, project_path)
self.update_file(project_path, 'requirements.txt', {
... | [
"def",
"create_project",
"(",
"self",
",",
"project_path",
")",
":",
"shutil",
".",
"copytree",
"(",
"self",
".",
"project_path",
",",
"project_path",
")",
"self",
".",
"update_file",
"(",
"project_path",
",",
"'requirements.txt'",
",",
"{",
"'trionyx_version'",... | Create Trionyx project in given path
:param str path: path to create project in.
:raises FileExistsError: | [
"Create",
"Trionyx",
"project",
"in",
"given",
"path"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/quickstart/__init__.py#L30-L45 |
243,064 | krukas/Trionyx | trionyx/quickstart/__init__.py | Quickstart.create_app | def create_app(self, apps_path, name):
"""
Create Trionyx app in given path
:param str path: path to create app in.
:param str name: name of app
:raises FileExistsError:
"""
app_path = os.path.join(apps_path, name.lower())
shutil.copytree(self.app_path, ... | python | def create_app(self, apps_path, name):
"""
Create Trionyx app in given path
:param str path: path to create app in.
:param str name: name of app
:raises FileExistsError:
"""
app_path = os.path.join(apps_path, name.lower())
shutil.copytree(self.app_path, ... | [
"def",
"create_app",
"(",
"self",
",",
"apps_path",
",",
"name",
")",
":",
"app_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"apps_path",
",",
"name",
".",
"lower",
"(",
")",
")",
"shutil",
".",
"copytree",
"(",
"self",
".",
"app_path",
",",
"a... | Create Trionyx app in given path
:param str path: path to create app in.
:param str name: name of app
:raises FileExistsError: | [
"Create",
"Trionyx",
"app",
"in",
"given",
"path"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/quickstart/__init__.py#L47-L66 |
243,065 | firstprayer/monsql | monsql/table.py | Table.find_one | def find_one(self, filter=None, fields=None, skip=0, sort=None):
"""
Similar to find. This method will only retrieve one row.
If no row matches, returns None
"""
result = self.find(filter=filter, fields=fields, skip=skip, limit=1, sort=sort)
if len(result) > 0:
... | python | def find_one(self, filter=None, fields=None, skip=0, sort=None):
"""
Similar to find. This method will only retrieve one row.
If no row matches, returns None
"""
result = self.find(filter=filter, fields=fields, skip=skip, limit=1, sort=sort)
if len(result) > 0:
... | [
"def",
"find_one",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"skip",
"=",
"0",
",",
"sort",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"find",
"(",
"filter",
"=",
"filter",
",",
"fields",
"=",
"fields",
","... | Similar to find. This method will only retrieve one row.
If no row matches, returns None | [
"Similar",
"to",
"find",
".",
"This",
"method",
"will",
"only",
"retrieve",
"one",
"row",
".",
"If",
"no",
"row",
"matches",
"returns",
"None"
] | 6285c15b574c8664046eae2edfeb548c7b173efd | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/table.py#L158-L167 |
243,066 | gear11/pypelogs | pypeout/mysql_out.py | MySQLOut.get_existing_keys | def get_existing_keys(self, events):
"""Returns the list of keys from the given event source that are already in the DB"""
data = [e[self.key] for e in events]
ss = ','.join(['%s' for _ in data])
query = 'SELECT %s FROM %s WHERE %s IN (%s)' % (self.key, self.table, self.key, ss)
... | python | def get_existing_keys(self, events):
"""Returns the list of keys from the given event source that are already in the DB"""
data = [e[self.key] for e in events]
ss = ','.join(['%s' for _ in data])
query = 'SELECT %s FROM %s WHERE %s IN (%s)' % (self.key, self.table, self.key, ss)
... | [
"def",
"get_existing_keys",
"(",
"self",
",",
"events",
")",
":",
"data",
"=",
"[",
"e",
"[",
"self",
".",
"key",
"]",
"for",
"e",
"in",
"events",
"]",
"ss",
"=",
"','",
".",
"join",
"(",
"[",
"'%s'",
"for",
"_",
"in",
"data",
"]",
")",
"query"... | Returns the list of keys from the given event source that are already in the DB | [
"Returns",
"the",
"list",
"of",
"keys",
"from",
"the",
"given",
"event",
"source",
"that",
"are",
"already",
"in",
"the",
"DB"
] | da5dc0fee5373a4be294798b5e32cd0a803d8bbe | https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypeout/mysql_out.py#L43-L53 |
243,067 | gear11/pypelogs | pypeout/mysql_out.py | MySQLOut.insert | def insert(self, events):
"""Constructs and executes a MySQL insert for the given events."""
if not len(events):
return
keys = sorted(events[0].keys())
ss = ','.join(['%s' for _ in keys])
query = 'INSERT INTO %s (%s) VALUES ' % (self.table, ','.join(keys))
dat... | python | def insert(self, events):
"""Constructs and executes a MySQL insert for the given events."""
if not len(events):
return
keys = sorted(events[0].keys())
ss = ','.join(['%s' for _ in keys])
query = 'INSERT INTO %s (%s) VALUES ' % (self.table, ','.join(keys))
dat... | [
"def",
"insert",
"(",
"self",
",",
"events",
")",
":",
"if",
"not",
"len",
"(",
"events",
")",
":",
"return",
"keys",
"=",
"sorted",
"(",
"events",
"[",
"0",
"]",
".",
"keys",
"(",
")",
")",
"ss",
"=",
"','",
".",
"join",
"(",
"[",
"'%s'",
"f... | Constructs and executes a MySQL insert for the given events. | [
"Constructs",
"and",
"executes",
"a",
"MySQL",
"insert",
"for",
"the",
"given",
"events",
"."
] | da5dc0fee5373a4be294798b5e32cd0a803d8bbe | https://github.com/gear11/pypelogs/blob/da5dc0fee5373a4be294798b5e32cd0a803d8bbe/pypeout/mysql_out.py#L55-L71 |
243,068 | krukas/Trionyx | trionyx/renderer.py | datetime_value_renderer | def datetime_value_renderer(value, **options):
"""Render datetime value with django formats, default is SHORT_DATETIME_FORMAT"""
datetime_format = options.get('datetime_format', 'SHORT_DATETIME_FORMAT')
return formats.date_format(timezone.localtime(value), datetime_format) | python | def datetime_value_renderer(value, **options):
"""Render datetime value with django formats, default is SHORT_DATETIME_FORMAT"""
datetime_format = options.get('datetime_format', 'SHORT_DATETIME_FORMAT')
return formats.date_format(timezone.localtime(value), datetime_format) | [
"def",
"datetime_value_renderer",
"(",
"value",
",",
"*",
"*",
"options",
")",
":",
"datetime_format",
"=",
"options",
".",
"get",
"(",
"'datetime_format'",
",",
"'SHORT_DATETIME_FORMAT'",
")",
"return",
"formats",
".",
"date_format",
"(",
"timezone",
".",
"loca... | Render datetime value with django formats, default is SHORT_DATETIME_FORMAT | [
"Render",
"datetime",
"value",
"with",
"django",
"formats",
"default",
"is",
"SHORT_DATETIME_FORMAT"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/renderer.py#L21-L24 |
243,069 | krukas/Trionyx | trionyx/renderer.py | price_value_renderer | def price_value_renderer(value, currency=None, **options):
"""Format price value, with current locale and CURRENCY in settings"""
if not currency:
currency = getattr(settings, 'CURRENCY', 'USD')
return format_currency(value, currency, locale=utils.get_current_locale()) | python | def price_value_renderer(value, currency=None, **options):
"""Format price value, with current locale and CURRENCY in settings"""
if not currency:
currency = getattr(settings, 'CURRENCY', 'USD')
return format_currency(value, currency, locale=utils.get_current_locale()) | [
"def",
"price_value_renderer",
"(",
"value",
",",
"currency",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"currency",
":",
"currency",
"=",
"getattr",
"(",
"settings",
",",
"'CURRENCY'",
",",
"'USD'",
")",
"return",
"format_currency",
"("... | Format price value, with current locale and CURRENCY in settings | [
"Format",
"price",
"value",
"with",
"current",
"locale",
"and",
"CURRENCY",
"in",
"settings"
] | edac132cc0797190153f2e60bc7e88cb50e80da6 | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/renderer.py#L32-L36 |
243,070 | ThreshingFloor/libtf | libtf/logparsers/tf_log_base.py | TFLogBase.reduce | def reduce(self, show_noisy=False):
"""
Yield the reduced log lines
:param show_noisy: If this is true, shows the reduced log file. If this is false, it shows the logs that
were deleted.
"""
if not show_noisy:
for log in self.quiet_logs:
yield... | python | def reduce(self, show_noisy=False):
"""
Yield the reduced log lines
:param show_noisy: If this is true, shows the reduced log file. If this is false, it shows the logs that
were deleted.
"""
if not show_noisy:
for log in self.quiet_logs:
yield... | [
"def",
"reduce",
"(",
"self",
",",
"show_noisy",
"=",
"False",
")",
":",
"if",
"not",
"show_noisy",
":",
"for",
"log",
"in",
"self",
".",
"quiet_logs",
":",
"yield",
"log",
"[",
"'raw'",
"]",
".",
"strip",
"(",
")",
"else",
":",
"for",
"log",
"in",... | Yield the reduced log lines
:param show_noisy: If this is true, shows the reduced log file. If this is false, it shows the logs that
were deleted. | [
"Yield",
"the",
"reduced",
"log",
"lines"
] | f1a8710f750639c9b9e2a468ece0d2923bf8c3df | https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_log_base.py#L80-L92 |
243,071 | ThreshingFloor/libtf | libtf/logparsers/tf_log_base.py | TFLogBase._get_filter | def _get_filter(self, features):
"""
Gets the filter for the features in the object
:param features: The features of the syslog file
"""
# This chops the features up into smaller lists so the api can handle them
for ip_batch in (features['ips'][pos:pos + self.ip_query_b... | python | def _get_filter(self, features):
"""
Gets the filter for the features in the object
:param features: The features of the syslog file
"""
# This chops the features up into smaller lists so the api can handle them
for ip_batch in (features['ips'][pos:pos + self.ip_query_b... | [
"def",
"_get_filter",
"(",
"self",
",",
"features",
")",
":",
"# This chops the features up into smaller lists so the api can handle them",
"for",
"ip_batch",
"in",
"(",
"features",
"[",
"'ips'",
"]",
"[",
"pos",
":",
"pos",
"+",
"self",
".",
"ip_query_batch_size",
... | Gets the filter for the features in the object
:param features: The features of the syslog file | [
"Gets",
"the",
"filter",
"for",
"the",
"features",
"in",
"the",
"object"
] | f1a8710f750639c9b9e2a468ece0d2923bf8c3df | https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_log_base.py#L94-L106 |
243,072 | ThreshingFloor/libtf | libtf/logparsers/tf_log_base.py | TFLogBase._send_features | def _send_features(self, features):
"""
Send a query to the backend api with a list of observed features in this log file
:param features: Features found in the log file
:return: Response text from ThreshingFloor API
"""
# Hit the auth endpoint with a list of features
... | python | def _send_features(self, features):
"""
Send a query to the backend api with a list of observed features in this log file
:param features: Features found in the log file
:return: Response text from ThreshingFloor API
"""
# Hit the auth endpoint with a list of features
... | [
"def",
"_send_features",
"(",
"self",
",",
"features",
")",
":",
"# Hit the auth endpoint with a list of features",
"try",
":",
"r",
"=",
"requests",
".",
"post",
"(",
"self",
".",
"base_uri",
"+",
"self",
".",
"api_endpoint",
",",
"json",
"=",
"features",
","... | Send a query to the backend api with a list of observed features in this log file
:param features: Features found in the log file
:return: Response text from ThreshingFloor API | [
"Send",
"a",
"query",
"to",
"the",
"backend",
"api",
"with",
"a",
"list",
"of",
"observed",
"features",
"in",
"this",
"log",
"file"
] | f1a8710f750639c9b9e2a468ece0d2923bf8c3df | https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_log_base.py#L108-L127 |
243,073 | crcresearch/py-utils | crc_nd/utils/file_io.py | clean_out_dir | def clean_out_dir(directory):
"""
Delete all the files and subdirectories in a directory.
"""
if not isinstance(directory, path):
directory = path(directory)
for file_path in directory.files():
file_path.remove()
for dir_path in directory.dirs():
dir_path.rmtree() | python | def clean_out_dir(directory):
"""
Delete all the files and subdirectories in a directory.
"""
if not isinstance(directory, path):
directory = path(directory)
for file_path in directory.files():
file_path.remove()
for dir_path in directory.dirs():
dir_path.rmtree() | [
"def",
"clean_out_dir",
"(",
"directory",
")",
":",
"if",
"not",
"isinstance",
"(",
"directory",
",",
"path",
")",
":",
"directory",
"=",
"path",
"(",
"directory",
")",
"for",
"file_path",
"in",
"directory",
".",
"files",
"(",
")",
":",
"file_path",
".",... | Delete all the files and subdirectories in a directory. | [
"Delete",
"all",
"the",
"files",
"and",
"subdirectories",
"in",
"a",
"directory",
"."
] | 04caf0425a047baf900da726cf47c42413b0dd81 | https://github.com/crcresearch/py-utils/blob/04caf0425a047baf900da726cf47c42413b0dd81/crc_nd/utils/file_io.py#L14-L23 |
243,074 | davidwtbuxton/appengine.py | appengine.py | _extract_zip | def _extract_zip(archive, dest=None, members=None):
"""Extract the ZipInfo object to a real file on the path targetpath."""
# Python 2.5 compatibility.
dest = dest or os.getcwd()
members = members or archive.infolist()
for member in members:
if isinstance(member, basestring):
me... | python | def _extract_zip(archive, dest=None, members=None):
"""Extract the ZipInfo object to a real file on the path targetpath."""
# Python 2.5 compatibility.
dest = dest or os.getcwd()
members = members or archive.infolist()
for member in members:
if isinstance(member, basestring):
me... | [
"def",
"_extract_zip",
"(",
"archive",
",",
"dest",
"=",
"None",
",",
"members",
"=",
"None",
")",
":",
"# Python 2.5 compatibility.",
"dest",
"=",
"dest",
"or",
"os",
".",
"getcwd",
"(",
")",
"members",
"=",
"members",
"or",
"archive",
".",
"infolist",
... | Extract the ZipInfo object to a real file on the path targetpath. | [
"Extract",
"the",
"ZipInfo",
"object",
"to",
"a",
"real",
"file",
"on",
"the",
"path",
"targetpath",
"."
] | 9ef666c282406b3d8799bfa4c70f99870b21a236 | https://github.com/davidwtbuxton/appengine.py/blob/9ef666c282406b3d8799bfa4c70f99870b21a236/appengine.py#L23-L33 |
243,075 | davidwtbuxton/appengine.py | appengine.py | make_parser | def make_parser():
"""Returns a new option parser."""
p = optparse.OptionParser()
p.add_option('--prefix', metavar='DIR', help='install SDK in DIR')
p.add_option('--bindir', metavar='DIR', help='install tools in DIR')
p.add_option('--force', action='store_true', default=False,
help='over-wri... | python | def make_parser():
"""Returns a new option parser."""
p = optparse.OptionParser()
p.add_option('--prefix', metavar='DIR', help='install SDK in DIR')
p.add_option('--bindir', metavar='DIR', help='install tools in DIR')
p.add_option('--force', action='store_true', default=False,
help='over-wri... | [
"def",
"make_parser",
"(",
")",
":",
"p",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"p",
".",
"add_option",
"(",
"'--prefix'",
",",
"metavar",
"=",
"'DIR'",
",",
"help",
"=",
"'install SDK in DIR'",
")",
"p",
".",
"add_option",
"(",
"'--bindir'",
"... | Returns a new option parser. | [
"Returns",
"a",
"new",
"option",
"parser",
"."
] | 9ef666c282406b3d8799bfa4c70f99870b21a236 | https://github.com/davidwtbuxton/appengine.py/blob/9ef666c282406b3d8799bfa4c70f99870b21a236/appengine.py#L60-L70 |
243,076 | davidwtbuxton/appengine.py | appengine.py | check_version | def check_version(url=VERSION_URL):
"""Returns the version string for the latest SDK."""
for line in get(url):
if 'release:' in line:
return line.split(':')[-1].strip(' \'"\r\n') | python | def check_version(url=VERSION_URL):
"""Returns the version string for the latest SDK."""
for line in get(url):
if 'release:' in line:
return line.split(':')[-1].strip(' \'"\r\n') | [
"def",
"check_version",
"(",
"url",
"=",
"VERSION_URL",
")",
":",
"for",
"line",
"in",
"get",
"(",
"url",
")",
":",
"if",
"'release:'",
"in",
"line",
":",
"return",
"line",
".",
"split",
"(",
"':'",
")",
"[",
"-",
"1",
"]",
".",
"strip",
"(",
"' ... | Returns the version string for the latest SDK. | [
"Returns",
"the",
"version",
"string",
"for",
"the",
"latest",
"SDK",
"."
] | 9ef666c282406b3d8799bfa4c70f99870b21a236 | https://github.com/davidwtbuxton/appengine.py/blob/9ef666c282406b3d8799bfa4c70f99870b21a236/appengine.py#L92-L96 |
243,077 | davidwtbuxton/appengine.py | appengine.py | parse_sdk_name | def parse_sdk_name(name):
"""Returns a filename or URL for the SDK name.
The name can be a version string, a remote URL or a local path.
"""
# Version like x.y.z, return as-is.
if all(part.isdigit() for part in name.split('.', 2)):
return DOWNLOAD_URL % name
# A network location.
u... | python | def parse_sdk_name(name):
"""Returns a filename or URL for the SDK name.
The name can be a version string, a remote URL or a local path.
"""
# Version like x.y.z, return as-is.
if all(part.isdigit() for part in name.split('.', 2)):
return DOWNLOAD_URL % name
# A network location.
u... | [
"def",
"parse_sdk_name",
"(",
"name",
")",
":",
"# Version like x.y.z, return as-is.",
"if",
"all",
"(",
"part",
".",
"isdigit",
"(",
")",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
",",
"2",
")",
")",
":",
"return",
"DOWNLOAD_URL",
"%",
"nam... | Returns a filename or URL for the SDK name.
The name can be a version string, a remote URL or a local path. | [
"Returns",
"a",
"filename",
"or",
"URL",
"for",
"the",
"SDK",
"name",
"."
] | 9ef666c282406b3d8799bfa4c70f99870b21a236 | https://github.com/davidwtbuxton/appengine.py/blob/9ef666c282406b3d8799bfa4c70f99870b21a236/appengine.py#L99-L114 |
243,078 | davidwtbuxton/appengine.py | appengine.py | open_sdk | def open_sdk(url):
"""Open the SDK from the URL, which can be either a network location or
a filename path. Returns a file-like object open for reading.
"""
if urlparse.urlparse(url).scheme:
return _download(url)
else:
return open(url) | python | def open_sdk(url):
"""Open the SDK from the URL, which can be either a network location or
a filename path. Returns a file-like object open for reading.
"""
if urlparse.urlparse(url).scheme:
return _download(url)
else:
return open(url) | [
"def",
"open_sdk",
"(",
"url",
")",
":",
"if",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
".",
"scheme",
":",
"return",
"_download",
"(",
"url",
")",
"else",
":",
"return",
"open",
"(",
"url",
")"
] | Open the SDK from the URL, which can be either a network location or
a filename path. Returns a file-like object open for reading. | [
"Open",
"the",
"SDK",
"from",
"the",
"URL",
"which",
"can",
"be",
"either",
"a",
"network",
"location",
"or",
"a",
"filename",
"path",
".",
"Returns",
"a",
"file",
"-",
"like",
"object",
"open",
"for",
"reading",
"."
] | 9ef666c282406b3d8799bfa4c70f99870b21a236 | https://github.com/davidwtbuxton/appengine.py/blob/9ef666c282406b3d8799bfa4c70f99870b21a236/appengine.py#L117-L124 |
243,079 | bcho/bearychat-py | bearychat/incoming.py | Incoming.reset | def reset(self):
'''Reset stream.'''
self._text = None
self._markdown = False
self._channel = Incoming.DEFAULT_CHANNEL
self._attachments = []
return self | python | def reset(self):
'''Reset stream.'''
self._text = None
self._markdown = False
self._channel = Incoming.DEFAULT_CHANNEL
self._attachments = []
return self | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_text",
"=",
"None",
"self",
".",
"_markdown",
"=",
"False",
"self",
".",
"_channel",
"=",
"Incoming",
".",
"DEFAULT_CHANNEL",
"self",
".",
"_attachments",
"=",
"[",
"]",
"return",
"self"
] | Reset stream. | [
"Reset",
"stream",
"."
] | d492595d6334dfba511f82770995160ee12b5de1 | https://github.com/bcho/bearychat-py/blob/d492595d6334dfba511f82770995160ee12b5de1/bearychat/incoming.py#L43-L50 |
243,080 | bcho/bearychat-py | bearychat/incoming.py | Incoming.with_text | def with_text(self, text, markdown=None):
'''Set text content.
:param text: text content.
:param markdown: is markdown? Defaults to ``False``.
'''
self._text = text
self._markdown = markdown or False
return self | python | def with_text(self, text, markdown=None):
'''Set text content.
:param text: text content.
:param markdown: is markdown? Defaults to ``False``.
'''
self._text = text
self._markdown = markdown or False
return self | [
"def",
"with_text",
"(",
"self",
",",
"text",
",",
"markdown",
"=",
"None",
")",
":",
"self",
".",
"_text",
"=",
"text",
"self",
".",
"_markdown",
"=",
"markdown",
"or",
"False",
"return",
"self"
] | Set text content.
:param text: text content.
:param markdown: is markdown? Defaults to ``False``. | [
"Set",
"text",
"content",
"."
] | d492595d6334dfba511f82770995160ee12b5de1 | https://github.com/bcho/bearychat-py/blob/d492595d6334dfba511f82770995160ee12b5de1/bearychat/incoming.py#L61-L70 |
243,081 | bcho/bearychat-py | bearychat/incoming.py | Incoming.push | def push(self):
'''Deliver the message.'''
message = self.build_message()
return requests.post(self.hook, json=message) | python | def push(self):
'''Deliver the message.'''
message = self.build_message()
return requests.post(self.hook, json=message) | [
"def",
"push",
"(",
"self",
")",
":",
"message",
"=",
"self",
".",
"build_message",
"(",
")",
"return",
"requests",
".",
"post",
"(",
"self",
".",
"hook",
",",
"json",
"=",
"message",
")"
] | Deliver the message. | [
"Deliver",
"the",
"message",
"."
] | d492595d6334dfba511f82770995160ee12b5de1 | https://github.com/bcho/bearychat-py/blob/d492595d6334dfba511f82770995160ee12b5de1/bearychat/incoming.py#L113-L116 |
243,082 | luismasuelli/python-cantrips | cantrips/patterns/identify.py | List.create | def create(self, key, *args, **kwargs):
"""
Creates and inserts an identified object with the passed params
using the specified class.
"""
instance = self._class(key, *args, **kwargs)
self._events.create.trigger(list=self, instance=instance, key=key, args=args, kwargs... | python | def create(self, key, *args, **kwargs):
"""
Creates and inserts an identified object with the passed params
using the specified class.
"""
instance = self._class(key, *args, **kwargs)
self._events.create.trigger(list=self, instance=instance, key=key, args=args, kwargs... | [
"def",
"create",
"(",
"self",
",",
"key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"self",
".",
"_class",
"(",
"key",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_events",
".",
"create",
".",
"trig... | Creates and inserts an identified object with the passed params
using the specified class. | [
"Creates",
"and",
"inserts",
"an",
"identified",
"object",
"with",
"the",
"passed",
"params",
"using",
"the",
"specified",
"class",
"."
] | dba2742c1d1a60863bb65f4a291464f6e68eb2ee | https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/identify.py#L53-L60 |
243,083 | luismasuelli/python-cantrips | cantrips/patterns/identify.py | List.insert | def insert(self, identified):
"""
Inserts an already-created identified object of the expected class.
"""
if not isinstance(identified, self._class):
raise self.Error("Passed instance is not of the needed class",
self.Error.INVALID_INSTANCE_CLASS... | python | def insert(self, identified):
"""
Inserts an already-created identified object of the expected class.
"""
if not isinstance(identified, self._class):
raise self.Error("Passed instance is not of the needed class",
self.Error.INVALID_INSTANCE_CLASS... | [
"def",
"insert",
"(",
"self",
",",
"identified",
")",
":",
"if",
"not",
"isinstance",
"(",
"identified",
",",
"self",
".",
"_class",
")",
":",
"raise",
"self",
".",
"Error",
"(",
"\"Passed instance is not of the needed class\"",
",",
"self",
".",
"Error",
".... | Inserts an already-created identified object of the expected class. | [
"Inserts",
"an",
"already",
"-",
"created",
"identified",
"object",
"of",
"the",
"expected",
"class",
"."
] | dba2742c1d1a60863bb65f4a291464f6e68eb2ee | https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/identify.py#L62-L78 |
243,084 | luismasuelli/python-cantrips | cantrips/patterns/identify.py | List.remove | def remove(self, identified):
"""
Removes an already-created identified object.
A key may be passed instead of an identified object.
If an object is passed, and its key is held by another
object inside the record, an error is triggered.
Returns the removed object.
... | python | def remove(self, identified):
"""
Removes an already-created identified object.
A key may be passed instead of an identified object.
If an object is passed, and its key is held by another
object inside the record, an error is triggered.
Returns the removed object.
... | [
"def",
"remove",
"(",
"self",
",",
"identified",
")",
":",
"by_val",
"=",
"isinstance",
"(",
"identified",
",",
"Identified",
")",
"if",
"by_val",
":",
"key",
"=",
"identified",
".",
"key",
"if",
"not",
"isinstance",
"(",
"identified",
",",
"self",
".",
... | Removes an already-created identified object.
A key may be passed instead of an identified object.
If an object is passed, and its key is held by another
object inside the record, an error is triggered.
Returns the removed object. | [
"Removes",
"an",
"already",
"-",
"created",
"identified",
"object",
".",
"A",
"key",
"may",
"be",
"passed",
"instead",
"of",
"an",
"identified",
"object",
".",
"If",
"an",
"object",
"is",
"passed",
"and",
"its",
"key",
"is",
"held",
"by",
"another",
"obj... | dba2742c1d1a60863bb65f4a291464f6e68eb2ee | https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/patterns/identify.py#L80-L106 |
243,085 | pydron/twistit | twistit/_timeout.py | timeout_deferred | def timeout_deferred(deferred, timeout, error_message="Timeout occured"):
"""
Waits a given time, if the given deferred hasn't called back
by then we cancel it. If the deferred was cancelled by the timeout,
a `TimeoutError` error is produced.
Returns `deferred`.
"""
timeout_occured... | python | def timeout_deferred(deferred, timeout, error_message="Timeout occured"):
"""
Waits a given time, if the given deferred hasn't called back
by then we cancel it. If the deferred was cancelled by the timeout,
a `TimeoutError` error is produced.
Returns `deferred`.
"""
timeout_occured... | [
"def",
"timeout_deferred",
"(",
"deferred",
",",
"timeout",
",",
"error_message",
"=",
"\"Timeout occured\"",
")",
":",
"timeout_occured",
"=",
"[",
"False",
"]",
"def",
"got_result",
"(",
"result",
")",
":",
"if",
"not",
"timeout_occured",
"[",
"0",
"]",
":... | Waits a given time, if the given deferred hasn't called back
by then we cancel it. If the deferred was cancelled by the timeout,
a `TimeoutError` error is produced.
Returns `deferred`. | [
"Waits",
"a",
"given",
"time",
"if",
"the",
"given",
"deferred",
"hasn",
"t",
"called",
"back",
"by",
"then",
"we",
"cancel",
"it",
".",
"If",
"the",
"deferred",
"was",
"cancelled",
"by",
"the",
"timeout",
"a",
"TimeoutError",
"error",
"is",
"produced",
... | 23ac43b830083fd32c400fcdfa5300e302769c74 | https://github.com/pydron/twistit/blob/23ac43b830083fd32c400fcdfa5300e302769c74/twistit/_timeout.py#L24-L58 |
243,086 | bitlabstudio/django-unshorten | unshorten/auth.py | SimpleAuthentication.http_auth | def http_auth(self):
"""
Returns ``True`` if valid http auth credentials are found in the
request header.
"""
if 'HTTP_AUTHORIZATION' in self.request.META.keys():
authmeth, auth = self.request.META['HTTP_AUTHORIZATION'].split(
' ', 1)
if a... | python | def http_auth(self):
"""
Returns ``True`` if valid http auth credentials are found in the
request header.
"""
if 'HTTP_AUTHORIZATION' in self.request.META.keys():
authmeth, auth = self.request.META['HTTP_AUTHORIZATION'].split(
' ', 1)
if a... | [
"def",
"http_auth",
"(",
"self",
")",
":",
"if",
"'HTTP_AUTHORIZATION'",
"in",
"self",
".",
"request",
".",
"META",
".",
"keys",
"(",
")",
":",
"authmeth",
",",
"auth",
"=",
"self",
".",
"request",
".",
"META",
"[",
"'HTTP_AUTHORIZATION'",
"]",
".",
"s... | Returns ``True`` if valid http auth credentials are found in the
request header. | [
"Returns",
"True",
"if",
"valid",
"http",
"auth",
"credentials",
"are",
"found",
"in",
"the",
"request",
"header",
"."
] | 6d184de908bb9df3aad5ac3fd9732d976afb6953 | https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/auth.py#L38-L54 |
243,087 | hactar-is/frink | frink/__init__.py | Frink.init | def init(self, db=RDB_DB, host=RDB_HOST, port=RDB_PORT):
"""Create the Frink object to store the connection credentials."""
self.RDB_HOST = host
self.RDB_PORT = port
self.RDB_DB = db
from .connection import RethinkDB
self.rdb = RethinkDB()
self.rdb.init() | python | def init(self, db=RDB_DB, host=RDB_HOST, port=RDB_PORT):
"""Create the Frink object to store the connection credentials."""
self.RDB_HOST = host
self.RDB_PORT = port
self.RDB_DB = db
from .connection import RethinkDB
self.rdb = RethinkDB()
self.rdb.init() | [
"def",
"init",
"(",
"self",
",",
"db",
"=",
"RDB_DB",
",",
"host",
"=",
"RDB_HOST",
",",
"port",
"=",
"RDB_PORT",
")",
":",
"self",
".",
"RDB_HOST",
"=",
"host",
"self",
".",
"RDB_PORT",
"=",
"port",
"self",
".",
"RDB_DB",
"=",
"db",
"from",
".",
... | Create the Frink object to store the connection credentials. | [
"Create",
"the",
"Frink",
"object",
"to",
"store",
"the",
"connection",
"credentials",
"."
] | 0d2c11daca8ef6d4365e98914bdc0bc65478ae72 | https://github.com/hactar-is/frink/blob/0d2c11daca8ef6d4365e98914bdc0bc65478ae72/frink/__init__.py#L17-L25 |
243,088 | zerok/zs.bibtex | src/zs/bibtex/parser.py | normalize_value | def normalize_value(text):
"""
This removes newlines and multiple spaces from a string.
"""
result = text.replace('\n', ' ')
result = re.subn('[ ]{2,}', ' ', result)[0]
return result | python | def normalize_value(text):
"""
This removes newlines and multiple spaces from a string.
"""
result = text.replace('\n', ' ')
result = re.subn('[ ]{2,}', ' ', result)[0]
return result | [
"def",
"normalize_value",
"(",
"text",
")",
":",
"result",
"=",
"text",
".",
"replace",
"(",
"'\\n'",
",",
"' '",
")",
"result",
"=",
"re",
".",
"subn",
"(",
"'[ ]{2,}'",
",",
"' '",
",",
"result",
")",
"[",
"0",
"]",
"return",
"result"
] | This removes newlines and multiple spaces from a string. | [
"This",
"removes",
"newlines",
"and",
"multiple",
"spaces",
"from",
"a",
"string",
"."
] | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L16-L22 |
243,089 | zerok/zs.bibtex | src/zs/bibtex/parser.py | parse_field | def parse_field(source, loc, tokens):
"""
Returns the tokens of a field as key-value pair.
"""
name = tokens[0].lower()
value = normalize_value(tokens[2])
if name == 'author' and ' and ' in value:
value = [field.strip() for field in value.split(' and ')]
return (name, value) | python | def parse_field(source, loc, tokens):
"""
Returns the tokens of a field as key-value pair.
"""
name = tokens[0].lower()
value = normalize_value(tokens[2])
if name == 'author' and ' and ' in value:
value = [field.strip() for field in value.split(' and ')]
return (name, value) | [
"def",
"parse_field",
"(",
"source",
",",
"loc",
",",
"tokens",
")",
":",
"name",
"=",
"tokens",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"value",
"=",
"normalize_value",
"(",
"tokens",
"[",
"2",
"]",
")",
"if",
"name",
"==",
"'author'",
"and",
"' an... | Returns the tokens of a field as key-value pair. | [
"Returns",
"the",
"tokens",
"of",
"a",
"field",
"as",
"key",
"-",
"value",
"pair",
"."
] | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L27-L35 |
243,090 | zerok/zs.bibtex | src/zs/bibtex/parser.py | parse_entry | def parse_entry(source, loc, tokens):
"""
Converts the tokens of an entry into an Entry instance. If no applicable
type is available, an UnsupportedEntryType exception is raised.
"""
type_ = tokens[1].lower()
entry_type = structures.TypeRegistry.get_type(type_)
if entry_type is None or not i... | python | def parse_entry(source, loc, tokens):
"""
Converts the tokens of an entry into an Entry instance. If no applicable
type is available, an UnsupportedEntryType exception is raised.
"""
type_ = tokens[1].lower()
entry_type = structures.TypeRegistry.get_type(type_)
if entry_type is None or not i... | [
"def",
"parse_entry",
"(",
"source",
",",
"loc",
",",
"tokens",
")",
":",
"type_",
"=",
"tokens",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"entry_type",
"=",
"structures",
".",
"TypeRegistry",
".",
"get_type",
"(",
"type_",
")",
"if",
"entry_type",
"is",... | Converts the tokens of an entry into an Entry instance. If no applicable
type is available, an UnsupportedEntryType exception is raised. | [
"Converts",
"the",
"tokens",
"of",
"an",
"entry",
"into",
"an",
"Entry",
"instance",
".",
"If",
"no",
"applicable",
"type",
"is",
"available",
"an",
"UnsupportedEntryType",
"exception",
"is",
"raised",
"."
] | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L37-L52 |
243,091 | zerok/zs.bibtex | src/zs/bibtex/parser.py | parse_bibliography | def parse_bibliography(source, loc, tokens):
"""
Combines the parsed entries into a Bibliography instance.
"""
bib = structures.Bibliography()
for entry in tokens:
bib.add(entry)
return bib | python | def parse_bibliography(source, loc, tokens):
"""
Combines the parsed entries into a Bibliography instance.
"""
bib = structures.Bibliography()
for entry in tokens:
bib.add(entry)
return bib | [
"def",
"parse_bibliography",
"(",
"source",
",",
"loc",
",",
"tokens",
")",
":",
"bib",
"=",
"structures",
".",
"Bibliography",
"(",
")",
"for",
"entry",
"in",
"tokens",
":",
"bib",
".",
"add",
"(",
"entry",
")",
"return",
"bib"
] | Combines the parsed entries into a Bibliography instance. | [
"Combines",
"the",
"parsed",
"entries",
"into",
"a",
"Bibliography",
"instance",
"."
] | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L54-L61 |
243,092 | zerok/zs.bibtex | src/zs/bibtex/parser.py | parse_string | def parse_string(str_, validate=False):
"""
Tries to parse a given string into a Bibliography instance. If ``validate``
is passed as keyword argument and set to ``True``, the Bibliography
will be validated using the standard rules.
"""
result = pattern.parseString(str_)[0]
if validate:
... | python | def parse_string(str_, validate=False):
"""
Tries to parse a given string into a Bibliography instance. If ``validate``
is passed as keyword argument and set to ``True``, the Bibliography
will be validated using the standard rules.
"""
result = pattern.parseString(str_)[0]
if validate:
... | [
"def",
"parse_string",
"(",
"str_",
",",
"validate",
"=",
"False",
")",
":",
"result",
"=",
"pattern",
".",
"parseString",
"(",
"str_",
")",
"[",
"0",
"]",
"if",
"validate",
":",
"result",
".",
"validate",
"(",
")",
"return",
"result"
] | Tries to parse a given string into a Bibliography instance. If ``validate``
is passed as keyword argument and set to ``True``, the Bibliography
will be validated using the standard rules. | [
"Tries",
"to",
"parse",
"a",
"given",
"string",
"into",
"a",
"Bibliography",
"instance",
".",
"If",
"validate",
"is",
"passed",
"as",
"keyword",
"argument",
"and",
"set",
"to",
"True",
"the",
"Bibliography",
"will",
"be",
"validated",
"using",
"the",
"standa... | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L103-L112 |
243,093 | zerok/zs.bibtex | src/zs/bibtex/parser.py | parse_file | def parse_file(file_or_path, encoding='utf-8', validate=False):
"""
Tries to parse a given filepath or fileobj into a Bibliography instance. If
``validate`` is passed as keyword argument and set to ``True``, the
Bibliography will be validated using the standard rules.
"""
try:
is_string ... | python | def parse_file(file_or_path, encoding='utf-8', validate=False):
"""
Tries to parse a given filepath or fileobj into a Bibliography instance. If
``validate`` is passed as keyword argument and set to ``True``, the
Bibliography will be validated using the standard rules.
"""
try:
is_string ... | [
"def",
"parse_file",
"(",
"file_or_path",
",",
"encoding",
"=",
"'utf-8'",
",",
"validate",
"=",
"False",
")",
":",
"try",
":",
"is_string",
"=",
"isinstance",
"(",
"file_or_path",
",",
"basestring",
")",
"except",
"NameError",
":",
"is_string",
"=",
"isinst... | Tries to parse a given filepath or fileobj into a Bibliography instance. If
``validate`` is passed as keyword argument and set to ``True``, the
Bibliography will be validated using the standard rules. | [
"Tries",
"to",
"parse",
"a",
"given",
"filepath",
"or",
"fileobj",
"into",
"a",
"Bibliography",
"instance",
".",
"If",
"validate",
"is",
"passed",
"as",
"keyword",
"argument",
"and",
"set",
"to",
"True",
"the",
"Bibliography",
"will",
"be",
"validated",
"usi... | ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9 | https://github.com/zerok/zs.bibtex/blob/ac9594b36b9d4ec9a3593c0dc7c1a35e5aea04d9/src/zs/bibtex/parser.py#L115-L132 |
243,094 | luismasuelli/python-cantrips | cantrips/types/record.py | TrackableRecord.track_end | def track_end(self):
"""
Ends tracking of attributes changes.
Returns the changes that occurred to the attributes.
Only the final state of each attribute is obtained
"""
self.__tracking = False
changes = self.__changes
self.__changes = {}
return ... | python | def track_end(self):
"""
Ends tracking of attributes changes.
Returns the changes that occurred to the attributes.
Only the final state of each attribute is obtained
"""
self.__tracking = False
changes = self.__changes
self.__changes = {}
return ... | [
"def",
"track_end",
"(",
"self",
")",
":",
"self",
".",
"__tracking",
"=",
"False",
"changes",
"=",
"self",
".",
"__changes",
"self",
".",
"__changes",
"=",
"{",
"}",
"return",
"changes"
] | Ends tracking of attributes changes.
Returns the changes that occurred to the attributes.
Only the final state of each attribute is obtained | [
"Ends",
"tracking",
"of",
"attributes",
"changes",
".",
"Returns",
"the",
"changes",
"that",
"occurred",
"to",
"the",
"attributes",
".",
"Only",
"the",
"final",
"state",
"of",
"each",
"attribute",
"is",
"obtained"
] | dba2742c1d1a60863bb65f4a291464f6e68eb2ee | https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/types/record.py#L33-L42 |
243,095 | lvh/maxims | maxims/creation.py | creationTime | def creationTime(item):
"""
Returns the creation time of the given item.
"""
forThisItem = _CreationTime.createdItem == item
return item.store.findUnique(_CreationTime, forThisItem).timestamp | python | def creationTime(item):
"""
Returns the creation time of the given item.
"""
forThisItem = _CreationTime.createdItem == item
return item.store.findUnique(_CreationTime, forThisItem).timestamp | [
"def",
"creationTime",
"(",
"item",
")",
":",
"forThisItem",
"=",
"_CreationTime",
".",
"createdItem",
"==",
"item",
"return",
"item",
".",
"store",
".",
"findUnique",
"(",
"_CreationTime",
",",
"forThisItem",
")",
".",
"timestamp"
] | Returns the creation time of the given item. | [
"Returns",
"the",
"creation",
"time",
"of",
"the",
"given",
"item",
"."
] | 5c53b25d2cc4ccecbfe90193ade9ce0dbfbe4623 | https://github.com/lvh/maxims/blob/5c53b25d2cc4ccecbfe90193ade9ce0dbfbe4623/maxims/creation.py#L21-L26 |
243,096 | davehughes/righthook | righthook/views.py | access_key | def access_key(root, key, sep='.', default=None):
'''
Look up a key in a potentially nested object `root` by its `sep`-separated
path. Returns `default` if the key is not found.
Example:
access_key({'foo': {'bar': 1}}, 'foo.bar') -> 1
'''
props = key.split('.')
props.reverse()
w... | python | def access_key(root, key, sep='.', default=None):
'''
Look up a key in a potentially nested object `root` by its `sep`-separated
path. Returns `default` if the key is not found.
Example:
access_key({'foo': {'bar': 1}}, 'foo.bar') -> 1
'''
props = key.split('.')
props.reverse()
w... | [
"def",
"access_key",
"(",
"root",
",",
"key",
",",
"sep",
"=",
"'.'",
",",
"default",
"=",
"None",
")",
":",
"props",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"props",
".",
"reverse",
"(",
")",
"while",
"props",
"and",
"root",
":",
"prop",
"=",... | Look up a key in a potentially nested object `root` by its `sep`-separated
path. Returns `default` if the key is not found.
Example:
access_key({'foo': {'bar': 1}}, 'foo.bar') -> 1 | [
"Look",
"up",
"a",
"key",
"in",
"a",
"potentially",
"nested",
"object",
"root",
"by",
"its",
"sep",
"-",
"separated",
"path",
".",
"Returns",
"default",
"if",
"the",
"key",
"is",
"not",
"found",
"."
] | d40e8dea0b6ce53b3099af8ed5cb1d4dadda9dba | https://github.com/davehughes/righthook/blob/d40e8dea0b6ce53b3099af8ed5cb1d4dadda9dba/righthook/views.py#L17-L30 |
243,097 | jpablo128/simplystatic | bin/s2.py | dispatch | def dispatch(argdict):
'''Call the command-specific function, depending on the command.'''
cmd = argdict['command']
ftc = getattr(THIS_MODULE, 'do_'+cmd)
ftc(argdict) | python | def dispatch(argdict):
'''Call the command-specific function, depending on the command.'''
cmd = argdict['command']
ftc = getattr(THIS_MODULE, 'do_'+cmd)
ftc(argdict) | [
"def",
"dispatch",
"(",
"argdict",
")",
":",
"cmd",
"=",
"argdict",
"[",
"'command'",
"]",
"ftc",
"=",
"getattr",
"(",
"THIS_MODULE",
",",
"'do_'",
"+",
"cmd",
")",
"ftc",
"(",
"argdict",
")"
] | Call the command-specific function, depending on the command. | [
"Call",
"the",
"command",
"-",
"specific",
"function",
"depending",
"on",
"the",
"command",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/s2.py#L116-L120 |
243,098 | jpablo128/simplystatic | bin/s2.py | do_init | def do_init(argdict):
'''Create the structure of a s2site.'''
site = make_site_obj(argdict)
try:
site.init_structure()
print "Initialized directory."
if argdict['randomsite']:
#all_tags = ['tag1','tag2','tag3','tag4']
for i in range(1,argdict['numpages']+1):
... | python | def do_init(argdict):
'''Create the structure of a s2site.'''
site = make_site_obj(argdict)
try:
site.init_structure()
print "Initialized directory."
if argdict['randomsite']:
#all_tags = ['tag1','tag2','tag3','tag4']
for i in range(1,argdict['numpages']+1):
... | [
"def",
"do_init",
"(",
"argdict",
")",
":",
"site",
"=",
"make_site_obj",
"(",
"argdict",
")",
"try",
":",
"site",
".",
"init_structure",
"(",
")",
"print",
"\"Initialized directory.\"",
"if",
"argdict",
"[",
"'randomsite'",
"]",
":",
"#all_tags = ['tag1','tag2'... | Create the structure of a s2site. | [
"Create",
"the",
"structure",
"of",
"a",
"s2site",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/s2.py#L122-L138 |
243,099 | jpablo128/simplystatic | bin/s2.py | do_add | def do_add(argdict):
'''Add a new page to the site.'''
site = make_site_obj(argdict)
if not site.tree_ready:
print "Cannot add page. You are not within a simplystatic \
tree and you didn't specify a directory."
sys.exit()
title = argdict['title']
try:
new_page = site.add_pag... | python | def do_add(argdict):
'''Add a new page to the site.'''
site = make_site_obj(argdict)
if not site.tree_ready:
print "Cannot add page. You are not within a simplystatic \
tree and you didn't specify a directory."
sys.exit()
title = argdict['title']
try:
new_page = site.add_pag... | [
"def",
"do_add",
"(",
"argdict",
")",
":",
"site",
"=",
"make_site_obj",
"(",
"argdict",
")",
"if",
"not",
"site",
".",
"tree_ready",
":",
"print",
"\"Cannot add page. You are not within a simplystatic \\\ntree and you didn't specify a directory.\"",
"sys",
".",
"exit",
... | Add a new page to the site. | [
"Add",
"a",
"new",
"page",
"to",
"the",
"site",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/bin/s2.py#L140-L154 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.