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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
251,200 | tomnor/channelpack | channelpack/pulltxt.py | loadtxt | def loadtxt(fn, **kwargs):
"""Study the text data file fn. Call numpys loadtxt with keyword
arguments based on the study.
Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`.
kwargs: keyword arguments accepted by numpys loadt... | python | def loadtxt(fn, **kwargs):
"""Study the text data file fn. Call numpys loadtxt with keyword
arguments based on the study.
Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`.
kwargs: keyword arguments accepted by numpys loadt... | [
"def",
"loadtxt",
"(",
"fn",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"PP",
"PP",
"=",
"PatternPull",
"(",
"fn",
")",
"txtargs",
"=",
"PP",
".",
"loadtxtargs",
"(",
")",
"txtargs",
".",
"update",
"(",
"kwargs",
")",
"# Let kwargs dominate.",
"retur... | Study the text data file fn. Call numpys loadtxt with keyword
arguments based on the study.
Return data returned from numpy `loadtxt <http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html#numpy-loadtxt>`.
kwargs: keyword arguments accepted by numpys loadtxt. Any keyword
arguments prov... | [
"Study",
"the",
"text",
"data",
"file",
"fn",
".",
"Call",
"numpys",
"loadtxt",
"with",
"keyword",
"arguments",
"based",
"on",
"the",
"study",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L325-L342 |
251,201 | tomnor/channelpack | channelpack/pulltxt.py | loadtxt_asdict | def loadtxt_asdict(fn, **kwargs):
"""Return what is returned from loadtxt as a dict.
The 'unpack' keyword is enforced to True.
The keys in the dict is the column numbers loaded. It is the
integers 0...N-1 for N loaded columns, or the numbers in usecols."""
kwargs.update(unpack=True)
d = loadtx... | python | def loadtxt_asdict(fn, **kwargs):
"""Return what is returned from loadtxt as a dict.
The 'unpack' keyword is enforced to True.
The keys in the dict is the column numbers loaded. It is the
integers 0...N-1 for N loaded columns, or the numbers in usecols."""
kwargs.update(unpack=True)
d = loadtx... | [
"def",
"loadtxt_asdict",
"(",
"fn",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"unpack",
"=",
"True",
")",
"d",
"=",
"loadtxt",
"(",
"fn",
",",
"*",
"*",
"kwargs",
")",
"if",
"len",
"(",
"np",
".",
"shape",
"(",
"d",
")",
... | Return what is returned from loadtxt as a dict.
The 'unpack' keyword is enforced to True.
The keys in the dict is the column numbers loaded. It is the
integers 0...N-1 for N loaded columns, or the numbers in usecols. | [
"Return",
"what",
"is",
"returned",
"from",
"loadtxt",
"as",
"a",
"dict",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L345-L363 |
251,202 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.file_rows | def file_rows(self, fo):
"""Return the lines in the file as a list.
fo is the open file object."""
rows = []
for i in range(NUMROWS):
line = fo.readline()
if not line:
break
rows += [line]
return rows | python | def file_rows(self, fo):
"""Return the lines in the file as a list.
fo is the open file object."""
rows = []
for i in range(NUMROWS):
line = fo.readline()
if not line:
break
rows += [line]
return rows | [
"def",
"file_rows",
"(",
"self",
",",
"fo",
")",
":",
"rows",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"NUMROWS",
")",
":",
"line",
"=",
"fo",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"break",
"rows",
"+=",
"[",
"line",
"]",
... | Return the lines in the file as a list.
fo is the open file object. | [
"Return",
"the",
"lines",
"in",
"the",
"file",
"as",
"a",
"list",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L101-L113 |
251,203 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.count_matches | def count_matches(self):
"""Set the matches_p, matches_c and rows attributes."""
try:
self.fn = self.fo.name
rows = self.file_rows(self.fo)
self.fo.seek(0)
except AttributeError:
with open(self.fn) as fo:
rows = self.file_rows(fo)... | python | def count_matches(self):
"""Set the matches_p, matches_c and rows attributes."""
try:
self.fn = self.fo.name
rows = self.file_rows(self.fo)
self.fo.seek(0)
except AttributeError:
with open(self.fn) as fo:
rows = self.file_rows(fo)... | [
"def",
"count_matches",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"fn",
"=",
"self",
".",
"fo",
".",
"name",
"rows",
"=",
"self",
".",
"file_rows",
"(",
"self",
".",
"fo",
")",
"self",
".",
"fo",
".",
"seek",
"(",
"0",
")",
"except",
"Att... | Set the matches_p, matches_c and rows attributes. | [
"Set",
"the",
"matches_p",
"matches_c",
"and",
"rows",
"attributes",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L115-L137 |
251,204 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.rows2skip | def rows2skip(self, decdel):
"""
Return the number of rows to skip based on the decimal delimiter
decdel.
When each record start to have the same number of matches, this
is where the data starts. This is the idea. And the number of
consecutive records to have the same nu... | python | def rows2skip(self, decdel):
"""
Return the number of rows to skip based on the decimal delimiter
decdel.
When each record start to have the same number of matches, this
is where the data starts. This is the idea. And the number of
consecutive records to have the same nu... | [
"def",
"rows2skip",
"(",
"self",
",",
"decdel",
")",
":",
"if",
"decdel",
"==",
"'.'",
":",
"ms",
"=",
"self",
".",
"matches_p",
"elif",
"decdel",
"==",
"','",
":",
"ms",
"=",
"self",
".",
"matches_c",
"# else make error...",
"cnt",
"=",
"row",
"=",
... | Return the number of rows to skip based on the decimal delimiter
decdel.
When each record start to have the same number of matches, this
is where the data starts. This is the idea. And the number of
consecutive records to have the same number of matches is to be
EQUAL_CNT_REQ. | [
"Return",
"the",
"number",
"of",
"rows",
"to",
"skip",
"based",
"on",
"the",
"decimal",
"delimiter",
"decdel",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L139-L173 |
251,205 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.set_decdel_rts | def set_decdel_rts(self):
"""Figure out the decimal seperator and rows to skip and set
corresponding attributes.
"""
lnr = max(self.rows2skip(','), self.rows2skip('.')) + 1
# If EQUAL_CNT_REQ was not met, raise error. Implement!
if self.cnt > EQUAL_CNT_REQ:
r... | python | def set_decdel_rts(self):
"""Figure out the decimal seperator and rows to skip and set
corresponding attributes.
"""
lnr = max(self.rows2skip(','), self.rows2skip('.')) + 1
# If EQUAL_CNT_REQ was not met, raise error. Implement!
if self.cnt > EQUAL_CNT_REQ:
r... | [
"def",
"set_decdel_rts",
"(",
"self",
")",
":",
"lnr",
"=",
"max",
"(",
"self",
".",
"rows2skip",
"(",
"','",
")",
",",
"self",
".",
"rows2skip",
"(",
"'.'",
")",
")",
"+",
"1",
"# If EQUAL_CNT_REQ was not met, raise error. Implement!",
"if",
"self",
".",
... | Figure out the decimal seperator and rows to skip and set
corresponding attributes. | [
"Figure",
"out",
"the",
"decimal",
"seperator",
"and",
"rows",
"to",
"skip",
"and",
"set",
"corresponding",
"attributes",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L175-L197 |
251,206 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.study_datdel | def study_datdel(self):
"""Figure out the data delimiter."""
nodigs = r'(\D+)'
line = self.rows[self.rts + 1] # Study second line of data only.
digs = re.findall(self.datrx, line)
# if any of the numbers contain a '+' in it, it need to be escaped
# before used in the ... | python | def study_datdel(self):
"""Figure out the data delimiter."""
nodigs = r'(\D+)'
line = self.rows[self.rts + 1] # Study second line of data only.
digs = re.findall(self.datrx, line)
# if any of the numbers contain a '+' in it, it need to be escaped
# before used in the ... | [
"def",
"study_datdel",
"(",
"self",
")",
":",
"nodigs",
"=",
"r'(\\D+)'",
"line",
"=",
"self",
".",
"rows",
"[",
"self",
".",
"rts",
"+",
"1",
"]",
"# Study second line of data only.",
"digs",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"datrx",
",",
... | Figure out the data delimiter. | [
"Figure",
"out",
"the",
"data",
"delimiter",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L199-L244 |
251,207 | tomnor/channelpack | channelpack/pulltxt.py | PatternPull.channel_names | def channel_names(self, usecols=None):
"""Attempt to extract the channel names from the data
file. Return a list with names. Return None on failed attempt.
usecols: A list with columns to use. If present, the returned
list will include only names for columns requested. It will
a... | python | def channel_names(self, usecols=None):
"""Attempt to extract the channel names from the data
file. Return a list with names. Return None on failed attempt.
usecols: A list with columns to use. If present, the returned
list will include only names for columns requested. It will
a... | [
"def",
"channel_names",
"(",
"self",
",",
"usecols",
"=",
"None",
")",
":",
"# Search from [rts - 1] and up (last row before data). Split respective",
"# row on datdel. Accept consecutive elements starting with alphas",
"# character after strip. If the count of elements equals the data count... | Attempt to extract the channel names from the data
file. Return a list with names. Return None on failed attempt.
usecols: A list with columns to use. If present, the returned
list will include only names for columns requested. It will
align with the columns returned by numpys loadtxt b... | [
"Attempt",
"to",
"extract",
"the",
"channel",
"names",
"from",
"the",
"data",
"file",
".",
"Return",
"a",
"list",
"with",
"names",
".",
"Return",
"None",
"on",
"failed",
"attempt",
"."
] | 9ad3cd11c698aed4c0fc178385b2ba38a7d0efae | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulltxt.py#L273-L317 |
251,208 | exekias/droplet | droplet/catalog.py | LocalCatalog.register | def register(self, cls, instance):
"""
Register the given instance as implementation for a class interface
"""
if not issubclass(cls, DropletInterface):
raise TypeError('Given class is not a NAZInterface subclass: %s'
% cls)
if not isinsta... | python | def register(self, cls, instance):
"""
Register the given instance as implementation for a class interface
"""
if not issubclass(cls, DropletInterface):
raise TypeError('Given class is not a NAZInterface subclass: %s'
% cls)
if not isinsta... | [
"def",
"register",
"(",
"self",
",",
"cls",
",",
"instance",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"DropletInterface",
")",
":",
"raise",
"TypeError",
"(",
"'Given class is not a NAZInterface subclass: %s'",
"%",
"cls",
")",
"if",
"not",
"isins... | Register the given instance as implementation for a class interface | [
"Register",
"the",
"given",
"instance",
"as",
"implementation",
"for",
"a",
"class",
"interface"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/catalog.py#L34-L52 |
251,209 | johnwlockwood/stream_tap | stream_tap/__init__.py | stream_tap | def stream_tap(callables, stream):
"""
Calls each callable with each item in the stream.
Use with Buckets. Make a Bucket with a callable
and then pass a tuple of those buckets
in as the callables. After iterating over
this generator, get contents from each Spigot.
:param callables: collecti... | python | def stream_tap(callables, stream):
"""
Calls each callable with each item in the stream.
Use with Buckets. Make a Bucket with a callable
and then pass a tuple of those buckets
in as the callables. After iterating over
this generator, get contents from each Spigot.
:param callables: collecti... | [
"def",
"stream_tap",
"(",
"callables",
",",
"stream",
")",
":",
"for",
"item",
"in",
"stream",
":",
"for",
"caller",
"in",
"callables",
":",
"caller",
"(",
"item",
")",
"yield",
"item"
] | Calls each callable with each item in the stream.
Use with Buckets. Make a Bucket with a callable
and then pass a tuple of those buckets
in as the callables. After iterating over
this generator, get contents from each Spigot.
:param callables: collection of callable.
:param stream: Iterator if ... | [
"Calls",
"each",
"callable",
"with",
"each",
"item",
"in",
"the",
"stream",
".",
"Use",
"with",
"Buckets",
".",
"Make",
"a",
"Bucket",
"with",
"a",
"callable",
"and",
"then",
"pass",
"a",
"tuple",
"of",
"those",
"buckets",
"in",
"as",
"the",
"callables",... | 068f6427c39202991a1db2be842b0fa43c6c5b91 | https://github.com/johnwlockwood/stream_tap/blob/068f6427c39202991a1db2be842b0fa43c6c5b91/stream_tap/__init__.py#L40-L54 |
251,210 | tbreitenfeldt/invisible_ui | invisible_ui/elements/element.py | Element.selected | def selected(self, interrupt=False):
"""This object has been selected."""
self.ao2.output(self.get_title(), interrupt=interrupt) | python | def selected(self, interrupt=False):
"""This object has been selected."""
self.ao2.output(self.get_title(), interrupt=interrupt) | [
"def",
"selected",
"(",
"self",
",",
"interrupt",
"=",
"False",
")",
":",
"self",
".",
"ao2",
".",
"output",
"(",
"self",
".",
"get_title",
"(",
")",
",",
"interrupt",
"=",
"interrupt",
")"
] | This object has been selected. | [
"This",
"object",
"has",
"been",
"selected",
"."
] | 1a6907bfa61bded13fa9fb83ec7778c0df84487f | https://github.com/tbreitenfeldt/invisible_ui/blob/1a6907bfa61bded13fa9fb83ec7778c0df84487f/invisible_ui/elements/element.py#L42-L44 |
251,211 | tomokinakamaru/mapletree | mapletree/response.py | Response.header | def header(self, k, v, replace=True):
""" Sets header value. Replaces existing value if `replace` is True.
Otherwise create a list of existing values and `v`
:param k: Header key
:param v: Header value
:param replace: flag for setting mode.
:type k: str
:type v: ... | python | def header(self, k, v, replace=True):
""" Sets header value. Replaces existing value if `replace` is True.
Otherwise create a list of existing values and `v`
:param k: Header key
:param v: Header value
:param replace: flag for setting mode.
:type k: str
:type v: ... | [
"def",
"header",
"(",
"self",
",",
"k",
",",
"v",
",",
"replace",
"=",
"True",
")",
":",
"if",
"replace",
":",
"self",
".",
"_headers",
"[",
"k",
"]",
"=",
"[",
"v",
"]",
"else",
":",
"self",
".",
"_headers",
".",
"setdefault",
"(",
"k",
",",
... | Sets header value. Replaces existing value if `replace` is True.
Otherwise create a list of existing values and `v`
:param k: Header key
:param v: Header value
:param replace: flag for setting mode.
:type k: str
:type v: str
:type replace: bool | [
"Sets",
"header",
"value",
".",
"Replaces",
"existing",
"value",
"if",
"replace",
"is",
"True",
".",
"Otherwise",
"create",
"a",
"list",
"of",
"existing",
"values",
"and",
"v"
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/response.py#L41-L58 |
251,212 | tomokinakamaru/mapletree | mapletree/response.py | Response.cookie | def cookie(self, k, v, expires=None, domain=None, path='/', secure=False):
""" Sets cookie value.
:param k: Name for cookie value
:param v: Cookie value
:param expires: Cookie expiration date
:param domain: Cookie domain
:param path: Cookie path
:param secure: Fl... | python | def cookie(self, k, v, expires=None, domain=None, path='/', secure=False):
""" Sets cookie value.
:param k: Name for cookie value
:param v: Cookie value
:param expires: Cookie expiration date
:param domain: Cookie domain
:param path: Cookie path
:param secure: Fl... | [
"def",
"cookie",
"(",
"self",
",",
"k",
",",
"v",
",",
"expires",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"'/'",
",",
"secure",
"=",
"False",
")",
":",
"ls",
"=",
"[",
"'{}={}'",
".",
"format",
"(",
"k",
",",
"v",
")",
"]",... | Sets cookie value.
:param k: Name for cookie value
:param v: Cookie value
:param expires: Cookie expiration date
:param domain: Cookie domain
:param path: Cookie path
:param secure: Flag for `https only`
:type k: str
:type v: str
:type expires: da... | [
"Sets",
"cookie",
"value",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/response.py#L85-L116 |
251,213 | pjuren/pyokit | src/pyokit/util/meta.py | decorate_all_methods | def decorate_all_methods(decorator):
"""
Build and return a decorator that will decorate all class members.
This will apply the passed decorator to all of the methods in the decorated
class, except the __init__ method, when a class is decorated with it.
"""
def decorate_class(cls):
for name, m in inspe... | python | def decorate_all_methods(decorator):
"""
Build and return a decorator that will decorate all class members.
This will apply the passed decorator to all of the methods in the decorated
class, except the __init__ method, when a class is decorated with it.
"""
def decorate_class(cls):
for name, m in inspe... | [
"def",
"decorate_all_methods",
"(",
"decorator",
")",
":",
"def",
"decorate_class",
"(",
"cls",
")",
":",
"for",
"name",
",",
"m",
"in",
"inspect",
".",
"getmembers",
"(",
"cls",
",",
"inspect",
".",
"ismethod",
")",
":",
"if",
"name",
"!=",
"\"__init__\... | Build and return a decorator that will decorate all class members.
This will apply the passed decorator to all of the methods in the decorated
class, except the __init__ method, when a class is decorated with it. | [
"Build",
"and",
"return",
"a",
"decorator",
"that",
"will",
"decorate",
"all",
"class",
"members",
"."
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L49-L61 |
251,214 | pjuren/pyokit | src/pyokit/util/meta.py | just_in_time_method | def just_in_time_method(func):
"""
This is a dcorator for methods. It redirect calls to the decorated method
to the equivalent method in a class member called 'item'. 'item' is expected
to be None when the class is instantiated. The point is to easily allow
on-demand construction or loading of large, expensiv... | python | def just_in_time_method(func):
"""
This is a dcorator for methods. It redirect calls to the decorated method
to the equivalent method in a class member called 'item'. 'item' is expected
to be None when the class is instantiated. The point is to easily allow
on-demand construction or loading of large, expensiv... | [
"def",
"just_in_time_method",
"(",
"func",
")",
":",
"if",
"not",
"inspect",
".",
"ismethod",
":",
"raise",
"MetaError",
"(",
"\"oops\"",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"ite... | This is a dcorator for methods. It redirect calls to the decorated method
to the equivalent method in a class member called 'item'. 'item' is expected
to be None when the class is instantiated. The point is to easily allow
on-demand construction or loading of large, expensive objects just-in-time.
To apply thi... | [
"This",
"is",
"a",
"dcorator",
"for",
"methods",
".",
"It",
"redirect",
"calls",
"to",
"the",
"decorated",
"method",
"to",
"the",
"equivalent",
"method",
"in",
"a",
"class",
"member",
"called",
"item",
".",
"item",
"is",
"expected",
"to",
"be",
"None",
"... | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/util/meta.py#L79-L118 |
251,215 | chrisnorman7/MyGui | MyGui/frame.py | AddAccelerator | def AddAccelerator(self, modifiers, key, action):
"""
Add an accelerator.
Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects.
"""
newId = wx.NewId()
self.Bind(wx.EVT_MENU, action, id = newId)
self.RawAcceleratorTable.append((modifiers, key, newId))
self.SetAcceler... | python | def AddAccelerator(self, modifiers, key, action):
"""
Add an accelerator.
Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects.
"""
newId = wx.NewId()
self.Bind(wx.EVT_MENU, action, id = newId)
self.RawAcceleratorTable.append((modifiers, key, newId))
self.SetAcceler... | [
"def",
"AddAccelerator",
"(",
"self",
",",
"modifiers",
",",
"key",
",",
"action",
")",
":",
"newId",
"=",
"wx",
".",
"NewId",
"(",
")",
"self",
".",
"Bind",
"(",
"wx",
".",
"EVT_MENU",
",",
"action",
",",
"id",
"=",
"newId",
")",
"self",
".",
"R... | Add an accelerator.
Modifiers and key follow the same pattern as the list used to create wx.AcceleratorTable objects. | [
"Add",
"an",
"accelerator",
".",
"Modifiers",
"and",
"key",
"follow",
"the",
"same",
"pattern",
"as",
"the",
"list",
"used",
"to",
"create",
"wx",
".",
"AcceleratorTable",
"objects",
"."
] | 83aecb9c24107b41085cd0047a3e5b3fa18fac35 | https://github.com/chrisnorman7/MyGui/blob/83aecb9c24107b41085cd0047a3e5b3fa18fac35/MyGui/frame.py#L11-L21 |
251,216 | dhain/potpy | potpy/configparser.py | parse_config | def parse_config(lines, module=None):
"""Parse a config file.
Names referenced within the config file are found within the calling
scope. For example::
>>> from potpy.configparser import parse_config
>>> class foo:
... @staticmethod
... def bar():
... ... | python | def parse_config(lines, module=None):
"""Parse a config file.
Names referenced within the config file are found within the calling
scope. For example::
>>> from potpy.configparser import parse_config
>>> class foo:
... @staticmethod
... def bar():
... ... | [
"def",
"parse_config",
"(",
"lines",
",",
"module",
"=",
"None",
")",
":",
"if",
"module",
"is",
"None",
":",
"module",
"=",
"_calling_scope",
"(",
"2",
")",
"lines",
"=",
"IndentChecker",
"(",
"lines",
")",
"path_router",
"=",
"PathRouter",
"(",
")",
... | Parse a config file.
Names referenced within the config file are found within the calling
scope. For example::
>>> from potpy.configparser import parse_config
>>> class foo:
... @staticmethod
... def bar():
... pass
...
>>> config = '''
... | [
"Parse",
"a",
"config",
"file",
"."
] | e39a5a84f763fbf144b07a620afb02a5ff3741c9 | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/configparser.py#L244-L287 |
251,217 | dhain/potpy | potpy/configparser.py | load_config | def load_config(name='urls.conf'):
"""Load a config from a resource file.
The resource is found using `pkg_resources.resource_stream()`_,
relative to the calling module.
See :func:`parse_config` for config file details.
:param name: The name of the resource, relative to the calling module.
.... | python | def load_config(name='urls.conf'):
"""Load a config from a resource file.
The resource is found using `pkg_resources.resource_stream()`_,
relative to the calling module.
See :func:`parse_config` for config file details.
:param name: The name of the resource, relative to the calling module.
.... | [
"def",
"load_config",
"(",
"name",
"=",
"'urls.conf'",
")",
":",
"module",
"=",
"_calling_scope",
"(",
"2",
")",
"config",
"=",
"resource_stream",
"(",
"module",
".",
"__name__",
",",
"name",
")",
"return",
"parse_config",
"(",
"config",
",",
"module",
")"... | Load a config from a resource file.
The resource is found using `pkg_resources.resource_stream()`_,
relative to the calling module.
See :func:`parse_config` for config file details.
:param name: The name of the resource, relative to the calling module.
.. _pkg_resources.resource_stream(): http:/... | [
"Load",
"a",
"config",
"from",
"a",
"resource",
"file",
"."
] | e39a5a84f763fbf144b07a620afb02a5ff3741c9 | https://github.com/dhain/potpy/blob/e39a5a84f763fbf144b07a620afb02a5ff3741c9/potpy/configparser.py#L290-L304 |
251,218 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.to_placeholder | def to_placeholder(self, name=None, db_type=None):
"""Returns a placeholder for the specified name, by applying the instance's format strings.
:name: if None an unamed placeholder is returned, otherwise a named placeholder is returned.
:db_type: if not None the placeholder is typecast.
"""
if name ... | python | def to_placeholder(self, name=None, db_type=None):
"""Returns a placeholder for the specified name, by applying the instance's format strings.
:name: if None an unamed placeholder is returned, otherwise a named placeholder is returned.
:db_type: if not None the placeholder is typecast.
"""
if name ... | [
"def",
"to_placeholder",
"(",
"self",
",",
"name",
"=",
"None",
",",
"db_type",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"placeholder",
"=",
"self",
".",
"unnamed_placeholder",
"else",
":",
"placeholder",
"=",
"self",
".",
"named_placeholder... | Returns a placeholder for the specified name, by applying the instance's format strings.
:name: if None an unamed placeholder is returned, otherwise a named placeholder is returned.
:db_type: if not None the placeholder is typecast. | [
"Returns",
"a",
"placeholder",
"for",
"the",
"specified",
"name",
"by",
"applying",
"the",
"instance",
"s",
"format",
"strings",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L29-L43 |
251,219 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.to_tuple | def to_tuple(self, iterable, surround="()", joiner=", "):
"""Returns the iterable as a SQL tuple."""
return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1]) | python | def to_tuple(self, iterable, surround="()", joiner=", "):
"""Returns the iterable as a SQL tuple."""
return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1]) | [
"def",
"to_tuple",
"(",
"self",
",",
"iterable",
",",
"surround",
"=",
"\"()\"",
",",
"joiner",
"=",
"\", \"",
")",
":",
"return",
"\"{0}{1}{2}\"",
".",
"format",
"(",
"surround",
"[",
"0",
"]",
",",
"joiner",
".",
"join",
"(",
"iterable",
")",
",",
... | Returns the iterable as a SQL tuple. | [
"Returns",
"the",
"iterable",
"as",
"a",
"SQL",
"tuple",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L45-L47 |
251,220 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.to_expression | def to_expression(self, lhs, rhs, op):
"""Builds a binary sql expression.
At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the
'in' and 'between' operators. For each of these operators it is expected that rhs will be
iterable.
If the comparison operator i... | python | def to_expression(self, lhs, rhs, op):
"""Builds a binary sql expression.
At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the
'in' and 'between' operators. For each of these operators it is expected that rhs will be
iterable.
If the comparison operator i... | [
"def",
"to_expression",
"(",
"self",
",",
"lhs",
",",
"rhs",
",",
"op",
")",
":",
"if",
"op",
"==",
"\"raw\"",
":",
"# TODO: This is not documented",
"return",
"lhs",
"elif",
"op",
"==",
"\"between\"",
":",
"return",
"\"{0} between {1} and {2}\"",
".",
"format... | Builds a binary sql expression.
At its most basic, returns 'lhs op rhs' such as '5 + 3'. However, it also specially handles the
'in' and 'between' operators. For each of these operators it is expected that rhs will be
iterable.
If the comparison operator is of the form 'not(op)' where op is the operat... | [
"Builds",
"a",
"binary",
"sql",
"expression",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L49-L76 |
251,221 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.value_comparisons | def value_comparisons(self, values, comp="=", is_assignment=False):
"""Builds out a series of value comparisions.
:values: can either be a dictionary, in which case the return will compare a name to a named
placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"}
... | python | def value_comparisons(self, values, comp="=", is_assignment=False):
"""Builds out a series of value comparisions.
:values: can either be a dictionary, in which case the return will compare a name to a named
placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"}
... | [
"def",
"value_comparisons",
"(",
"self",
",",
"values",
",",
"comp",
"=",
"\"=\"",
",",
"is_assignment",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"dict",
")",
":",
"if",
"self",
".",
"sort_columns",
":",
"keys",
"=",
"sorted",
"(... | Builds out a series of value comparisions.
:values: can either be a dictionary, in which case the return will compare a name to a named
placeholder, using the comp argument. I.E. values = {"first_name": "John", "last_name": "Smith"}
will return ["first_name = %(first_name)s", "last_name = %(last_name)s"].
... | [
"Builds",
"out",
"a",
"series",
"of",
"value",
"comparisions",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L91-L137 |
251,222 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.join_comparisons | def join_comparisons(self, values, joiner, *, is_assignment=False, comp="="):
"""Generates comparisons with the value_comparisions method, and joins them with joiner.
:is_assignment: if false, transform_op will be called on each comparison operator.
"""
if isinstance(values, str):
return values
... | python | def join_comparisons(self, values, joiner, *, is_assignment=False, comp="="):
"""Generates comparisons with the value_comparisions method, and joins them with joiner.
:is_assignment: if false, transform_op will be called on each comparison operator.
"""
if isinstance(values, str):
return values
... | [
"def",
"join_comparisons",
"(",
"self",
",",
"values",
",",
"joiner",
",",
"*",
",",
"is_assignment",
"=",
"False",
",",
"comp",
"=",
"\"=\"",
")",
":",
"if",
"isinstance",
"(",
"values",
",",
"str",
")",
":",
"return",
"values",
"else",
":",
"return",... | Generates comparisons with the value_comparisions method, and joins them with joiner.
:is_assignment: if false, transform_op will be called on each comparison operator. | [
"Generates",
"comparisons",
"with",
"the",
"value_comparisions",
"method",
"and",
"joins",
"them",
"with",
"joiner",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L139-L147 |
251,223 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.get_params | def get_params(self, values):
"""Gets params to be passed to execute from values.
:values: can either be a dict, in which case it will be returned as is, or can be an enumerable
of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some
operators such as 'in' and 'betw... | python | def get_params(self, values):
"""Gets params to be passed to execute from values.
:values: can either be a dict, in which case it will be returned as is, or can be an enumerable
of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some
operators such as 'in' and 'betw... | [
"def",
"get_params",
"(",
"self",
",",
"values",
")",
":",
"if",
"values",
"is",
"None",
":",
"return",
"None",
"elif",
"isinstance",
"(",
"values",
",",
"dict",
")",
":",
"return",
"values",
"elif",
"isinstance",
"(",
"values",
",",
"(",
"list",
",",
... | Gets params to be passed to execute from values.
:values: can either be a dict, in which case it will be returned as is, or can be an enumerable
of 2- or 3-tuples. This will return an enumerable of the 2nd values, and in the case of some
operators such as 'in' and 'between' the values will be specially han... | [
"Gets",
"params",
"to",
"be",
"passed",
"to",
"execute",
"from",
"values",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L177-L203 |
251,224 | treycucco/bidon | bidon/db/core/sql_writer.py | SqlWriter.get_find_all_query | def get_find_all_query(self, table_name, constraints=None, *, columns=None, order_by=None,
limiting=(None, None)):
"""Builds a find query.
:limiting: if present must be a 2-tuple of (limit, offset) either of which can be None.
"""
where, params = self.parse_constraints(constrai... | python | def get_find_all_query(self, table_name, constraints=None, *, columns=None, order_by=None,
limiting=(None, None)):
"""Builds a find query.
:limiting: if present must be a 2-tuple of (limit, offset) either of which can be None.
"""
where, params = self.parse_constraints(constrai... | [
"def",
"get_find_all_query",
"(",
"self",
",",
"table_name",
",",
"constraints",
"=",
"None",
",",
"*",
",",
"columns",
"=",
"None",
",",
"order_by",
"=",
"None",
",",
"limiting",
"=",
"(",
"None",
",",
"None",
")",
")",
":",
"where",
",",
"params",
... | Builds a find query.
:limiting: if present must be a 2-tuple of (limit, offset) either of which can be None. | [
"Builds",
"a",
"find",
"query",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/core/sql_writer.py#L205-L240 |
251,225 | mkouhei/tonicdnscli | src/tonicdnscli/utils.py | pretty_print | def pretty_print(rows, keyword, domain):
"""
rows is
list when get domains
dict when get specific domain
"""
if isinstance(rows, dict):
pretty_print_domain(rows, keyword, domain)
elif isinstance(rows, list):
pretty_print_zones(rows) | python | def pretty_print(rows, keyword, domain):
"""
rows is
list when get domains
dict when get specific domain
"""
if isinstance(rows, dict):
pretty_print_domain(rows, keyword, domain)
elif isinstance(rows, list):
pretty_print_zones(rows) | [
"def",
"pretty_print",
"(",
"rows",
",",
"keyword",
",",
"domain",
")",
":",
"if",
"isinstance",
"(",
"rows",
",",
"dict",
")",
":",
"pretty_print_domain",
"(",
"rows",
",",
"keyword",
",",
"domain",
")",
"elif",
"isinstance",
"(",
"rows",
",",
"list",
... | rows is
list when get domains
dict when get specific domain | [
"rows",
"is",
"list",
"when",
"get",
"domains",
"dict",
"when",
"get",
"specific",
"domain"
] | df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c | https://github.com/mkouhei/tonicdnscli/blob/df2d6fb2104ae4d49fa89d1bba2f3ccd2fed388c/src/tonicdnscli/utils.py#L118-L127 |
251,226 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.load_data | def load_data(self,
data,
datatype="ttl",
namespace=None,
graph=None,
is_file=False,
**kwargs):
"""
Loads data via file stream from python to triplestore
Args:
-----
dat... | python | def load_data(self,
data,
datatype="ttl",
namespace=None,
graph=None,
is_file=False,
**kwargs):
"""
Loads data via file stream from python to triplestore
Args:
-----
dat... | [
"def",
"load_data",
"(",
"self",
",",
"data",
",",
"datatype",
"=",
"\"ttl\"",
",",
"namespace",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"is_file",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"setLevel",
"(",
"kwargs",
".",
"g... | Loads data via file stream from python to triplestore
Args:
-----
data: The data or filepath to load
datatype(['ttl', 'xml', 'rdf']): the type of data to load
namespace: the namespace to use
graph: the graph to load the data to.
is_file(False): If true ... | [
"Loads",
"data",
"via",
"file",
"stream",
"from",
"python",
"to",
"triplestore"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L273-L332 |
251,227 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.load_local_file | def load_local_file(self, file_path, namespace=None, graph=None, **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
in directory that is available locally to blazegraph
args:
file_path: full path to the file
namespace: the B... | python | def load_local_file(self, file_path, namespace=None, graph=None, **kwargs):
""" Uploads data to the Blazegraph Triplestore that is stored in files
in directory that is available locally to blazegraph
args:
file_path: full path to the file
namespace: the B... | [
"def",
"load_local_file",
"(",
"self",
",",
"file_path",
",",
"namespace",
"=",
"None",
",",
"graph",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"time_start",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"url",
"=",
"self",
".",
"_mak... | Uploads data to the Blazegraph Triplestore that is stored in files
in directory that is available locally to blazegraph
args:
file_path: full path to the file
namespace: the Blazegraph namespace to load the data
graph: uri of the graph to load the... | [
"Uploads",
"data",
"to",
"the",
"Blazegraph",
"Triplestore",
"that",
"is",
"stored",
"in",
"files",
"in",
"directory",
"that",
"is",
"available",
"locally",
"to",
"blazegraph"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L439-L471 |
251,228 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.has_namespace | def has_namespace(self, namespace):
""" tests to see if the namespace exists
args:
namespace: the name of the namespace
"""
result = requests.get(self._make_url(namespace))
if result.status_code == 200:
return True
elif result.status_code == 404:
... | python | def has_namespace(self, namespace):
""" tests to see if the namespace exists
args:
namespace: the name of the namespace
"""
result = requests.get(self._make_url(namespace))
if result.status_code == 200:
return True
elif result.status_code == 404:
... | [
"def",
"has_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"result",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"_make_url",
"(",
"namespace",
")",
")",
"if",
"result",
".",
"status_code",
"==",
"200",
":",
"return",
"True",
"elif",
"result",
... | tests to see if the namespace exists
args:
namespace: the name of the namespace | [
"tests",
"to",
"see",
"if",
"the",
"namespace",
"exists"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L473-L483 |
251,229 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.create_namespace | def create_namespace(self, namespace=None, params=None):
""" Creates a namespace in the triplestore
args:
namespace: the name of the namspace to create
params: Dictionary of Blazegraph paramaters. defaults are:
{'axioms': 'com.bigdata.rdf.axioms.NoAxioms',
... | python | def create_namespace(self, namespace=None, params=None):
""" Creates a namespace in the triplestore
args:
namespace: the name of the namspace to create
params: Dictionary of Blazegraph paramaters. defaults are:
{'axioms': 'com.bigdata.rdf.axioms.NoAxioms',
... | [
"def",
"create_namespace",
"(",
"self",
",",
"namespace",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"namespace",
"=",
"pick",
"(",
"namespace",
",",
"self",
".",
"namespace",
")",
"params",
"=",
"pick",
"(",
"params",
",",
"self",
".",
"namesp... | Creates a namespace in the triplestore
args:
namespace: the name of the namspace to create
params: Dictionary of Blazegraph paramaters. defaults are:
{'axioms': 'com.bigdata.rdf.axioms.NoAxioms',
'geoSpatial': False,
'isolat... | [
"Creates",
"a",
"namespace",
"in",
"the",
"triplestore"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L485-L535 |
251,230 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.delete_namespace | def delete_namespace(self, namespace):
""" Deletes a namespace fromt the triplestore
args:
namespace: the name of the namespace
"""
# if not self.has_namespace(namespace):
# return "Namespace does not exists"
# log = logging.getLogger("%s.%s" % (self.lo... | python | def delete_namespace(self, namespace):
""" Deletes a namespace fromt the triplestore
args:
namespace: the name of the namespace
"""
# if not self.has_namespace(namespace):
# return "Namespace does not exists"
# log = logging.getLogger("%s.%s" % (self.lo... | [
"def",
"delete_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"# if not self.has_namespace(namespace):",
"# return \"Namespace does not exists\"",
"# log = logging.getLogger(\"%s.%s\" % (self.log_name,",
"# inspect.stack()[0][3]))",
"# log.setLeve... | Deletes a namespace fromt the triplestore
args:
namespace: the name of the namespace | [
"Deletes",
"a",
"namespace",
"fromt",
"the",
"triplestore"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L537-L556 |
251,231 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph._make_url | def _make_url(self, namespace=None, url=None, **kwargs):
""" Creates the REST Url based on the supplied namespace
args:
namespace: string of the namespace
kwargs:
check_status_call: True/False, whether the function is called from
check_status. Used to... | python | def _make_url(self, namespace=None, url=None, **kwargs):
""" Creates the REST Url based on the supplied namespace
args:
namespace: string of the namespace
kwargs:
check_status_call: True/False, whether the function is called from
check_status. Used to... | [
"def",
"_make_url",
"(",
"self",
",",
"namespace",
"=",
"None",
",",
"url",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"get",
"(",
"\"check_status_call\"",
")",
":",
"if",
"not",
"self",
".",
"url",
":",
"self",
"."... | Creates the REST Url based on the supplied namespace
args:
namespace: string of the namespace
kwargs:
check_status_call: True/False, whether the function is called from
check_status. Used to avoid recurrsion error | [
"Creates",
"the",
"REST",
"Url",
"based",
"on",
"the",
"supplied",
"namespace"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L558-L583 |
251,232 | KnowledgeLinks/rdfframework | rdfframework/connections/blazegraph.py | Blazegraph.reset_namespace | def reset_namespace(self, namespace=None, params=None):
""" Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace
"""
log = logging.getLogger("%s.%s" % (self.log_name,
... | python | def reset_namespace(self, namespace=None, params=None):
""" Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace
"""
log = logging.getLogger("%s.%s" % (self.log_name,
... | [
"def",
"reset_namespace",
"(",
"self",
",",
"namespace",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"log_name",
",",
"inspect",
".",
"stack",
"(",
")",
"[",
"0"... | Will delete and recreate specified namespace
args:
namespace(str): Namespace to reset
params(dict): params used to reset the namespace | [
"Will",
"delete",
"and",
"recreate",
"specified",
"namespace"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/connections/blazegraph.py#L585-L604 |
251,233 | 20tab/twentytab-tree | tree/views.py | tree_render | def tree_render(request, upy_context, vars_dictionary):
"""
It renders template defined in upy_context's page passed in arguments
"""
page = upy_context['PAGE']
return render_to_response(page.template.file_name, vars_dictionary, context_instance=RequestContext(request)) | python | def tree_render(request, upy_context, vars_dictionary):
"""
It renders template defined in upy_context's page passed in arguments
"""
page = upy_context['PAGE']
return render_to_response(page.template.file_name, vars_dictionary, context_instance=RequestContext(request)) | [
"def",
"tree_render",
"(",
"request",
",",
"upy_context",
",",
"vars_dictionary",
")",
":",
"page",
"=",
"upy_context",
"[",
"'PAGE'",
"]",
"return",
"render_to_response",
"(",
"page",
".",
"template",
".",
"file_name",
",",
"vars_dictionary",
",",
"context_inst... | It renders template defined in upy_context's page passed in arguments | [
"It",
"renders",
"template",
"defined",
"in",
"upy_context",
"s",
"page",
"passed",
"in",
"arguments"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L8-L13 |
251,234 | 20tab/twentytab-tree | tree/views.py | view_404 | def view_404(request, url=None):
"""
It returns a 404 http response
"""
res = render_to_response("404.html", {"PAGE_URL": request.get_full_path()},
context_instance=RequestContext(request))
res.status_code = 404
return res | python | def view_404(request, url=None):
"""
It returns a 404 http response
"""
res = render_to_response("404.html", {"PAGE_URL": request.get_full_path()},
context_instance=RequestContext(request))
res.status_code = 404
return res | [
"def",
"view_404",
"(",
"request",
",",
"url",
"=",
"None",
")",
":",
"res",
"=",
"render_to_response",
"(",
"\"404.html\"",
",",
"{",
"\"PAGE_URL\"",
":",
"request",
".",
"get_full_path",
"(",
")",
"}",
",",
"context_instance",
"=",
"RequestContext",
"(",
... | It returns a 404 http response | [
"It",
"returns",
"a",
"404",
"http",
"response"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L16-L23 |
251,235 | 20tab/twentytab-tree | tree/views.py | view_500 | def view_500(request, url=None):
"""
it returns a 500 http response
"""
res = render_to_response("500.html", context_instance=RequestContext(request))
res.status_code = 500
return res | python | def view_500(request, url=None):
"""
it returns a 500 http response
"""
res = render_to_response("500.html", context_instance=RequestContext(request))
res.status_code = 500
return res | [
"def",
"view_500",
"(",
"request",
",",
"url",
"=",
"None",
")",
":",
"res",
"=",
"render_to_response",
"(",
"\"500.html\"",
",",
"context_instance",
"=",
"RequestContext",
"(",
"request",
")",
")",
"res",
".",
"status_code",
"=",
"500",
"return",
"res"
] | it returns a 500 http response | [
"it",
"returns",
"a",
"500",
"http",
"response"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L26-L32 |
251,236 | 20tab/twentytab-tree | tree/views.py | favicon | def favicon(request):
"""
It returns favicon's location
"""
favicon = u"{}tree/images/favicon.ico".format(settings.STATIC_URL)
try:
from seo.models import MetaSite
site = MetaSite.objects.get(default=True)
return HttpResponseRedirect(site.favicon.url)
except:
retu... | python | def favicon(request):
"""
It returns favicon's location
"""
favicon = u"{}tree/images/favicon.ico".format(settings.STATIC_URL)
try:
from seo.models import MetaSite
site = MetaSite.objects.get(default=True)
return HttpResponseRedirect(site.favicon.url)
except:
retu... | [
"def",
"favicon",
"(",
"request",
")",
":",
"favicon",
"=",
"u\"{}tree/images/favicon.ico\"",
".",
"format",
"(",
"settings",
".",
"STATIC_URL",
")",
"try",
":",
"from",
"seo",
".",
"models",
"import",
"MetaSite",
"site",
"=",
"MetaSite",
".",
"objects",
"."... | It returns favicon's location | [
"It",
"returns",
"favicon",
"s",
"location"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/views.py#L51-L61 |
251,237 | minhhoit/yacms | yacms/accounts/forms.py | ProfileForm.clean_username | def clean_username(self):
"""
Ensure the username doesn't exist or contain invalid chars.
We limit it to slugifiable chars since it's used as the slug
for the user's profile view.
"""
username = self.cleaned_data.get("username")
if username.lower() != slugify(user... | python | def clean_username(self):
"""
Ensure the username doesn't exist or contain invalid chars.
We limit it to slugifiable chars since it's used as the slug
for the user's profile view.
"""
username = self.cleaned_data.get("username")
if username.lower() != slugify(user... | [
"def",
"clean_username",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"username\"",
")",
"if",
"username",
".",
"lower",
"(",
")",
"!=",
"slugify",
"(",
"username",
")",
".",
"lower",
"(",
")",
":",
"raise",
... | Ensure the username doesn't exist or contain invalid chars.
We limit it to slugifiable chars since it's used as the slug
for the user's profile view. | [
"Ensure",
"the",
"username",
"doesn",
"t",
"exist",
"or",
"contain",
"invalid",
"chars",
".",
"We",
"limit",
"it",
"to",
"slugifiable",
"chars",
"since",
"it",
"s",
"used",
"as",
"the",
"slug",
"for",
"the",
"user",
"s",
"profile",
"view",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L130-L147 |
251,238 | minhhoit/yacms | yacms/accounts/forms.py | ProfileForm.clean_password2 | def clean_password2(self):
"""
Ensure the password fields are equal, and match the minimum
length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``.
"""
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1:
... | python | def clean_password2(self):
"""
Ensure the password fields are equal, and match the minimum
length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``.
"""
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1:
... | [
"def",
"clean_password2",
"(",
"self",
")",
":",
"password1",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"password1\"",
")",
"password2",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"password2\"",
")",
"if",
"password1",
":",
"errors",
"... | Ensure the password fields are equal, and match the minimum
length defined by ``ACCOUNTS_MIN_PASSWORD_LENGTH``. | [
"Ensure",
"the",
"password",
"fields",
"are",
"equal",
"and",
"match",
"the",
"minimum",
"length",
"defined",
"by",
"ACCOUNTS_MIN_PASSWORD_LENGTH",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L149-L167 |
251,239 | minhhoit/yacms | yacms/accounts/forms.py | ProfileForm.clean_email | def clean_email(self):
"""
Ensure the email address is not already registered.
"""
email = self.cleaned_data.get("email")
qs = User.objects.exclude(id=self.instance.id).filter(email=email)
if len(qs) == 0:
return email
raise forms.ValidationError(
... | python | def clean_email(self):
"""
Ensure the email address is not already registered.
"""
email = self.cleaned_data.get("email")
qs = User.objects.exclude(id=self.instance.id).filter(email=email)
if len(qs) == 0:
return email
raise forms.ValidationError(
... | [
"def",
"clean_email",
"(",
"self",
")",
":",
"email",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"\"email\"",
")",
"qs",
"=",
"User",
".",
"objects",
".",
"exclude",
"(",
"id",
"=",
"self",
".",
"instance",
".",
"id",
")",
".",
"filter",
"(... | Ensure the email address is not already registered. | [
"Ensure",
"the",
"email",
"address",
"is",
"not",
"already",
"registered",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/accounts/forms.py#L169-L178 |
251,240 | voidabhi/TheZineAPI | tz/tz.py | TZ.get_articles | def get_articles(self, issue=''):
"""
Yields a list of articles from the given issue.
"""
soup = get_soup() # get soup of all articles
issues = soup.find_all('ul')
# validating and assigning default value for issue
if not type(issue) is int or issue < 0 :
issue = 1
if issue > len(is... | python | def get_articles(self, issue=''):
"""
Yields a list of articles from the given issue.
"""
soup = get_soup() # get soup of all articles
issues = soup.find_all('ul')
# validating and assigning default value for issue
if not type(issue) is int or issue < 0 :
issue = 1
if issue > len(is... | [
"def",
"get_articles",
"(",
"self",
",",
"issue",
"=",
"''",
")",
":",
"soup",
"=",
"get_soup",
"(",
")",
"# get soup of all articles ",
"issues",
"=",
"soup",
".",
"find_all",
"(",
"'ul'",
")",
"# validating and assigning default value for issue",
"if",
"not",
... | Yields a list of articles from the given issue. | [
"Yields",
"a",
"list",
"of",
"articles",
"from",
"the",
"given",
"issue",
"."
] | c13da4c464fe3e0d31cea0f7d4e6a50a360947ad | https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L30-L54 |
251,241 | voidabhi/TheZineAPI | tz/tz.py | Article.fromLink | def fromLink(self, link):
"""
Factory Method. Fetches article data from given link and builds the object
"""
soup = get_article_soup(link)
head = soup.find_all('article',class_='')[0]
parts = link.split('/')
id = '%s-%s'%(parts[0],parts[-1])
issue = parts[0].split('-')[-1]
#fetching head
title =... | python | def fromLink(self, link):
"""
Factory Method. Fetches article data from given link and builds the object
"""
soup = get_article_soup(link)
head = soup.find_all('article',class_='')[0]
parts = link.split('/')
id = '%s-%s'%(parts[0],parts[-1])
issue = parts[0].split('-')[-1]
#fetching head
title =... | [
"def",
"fromLink",
"(",
"self",
",",
"link",
")",
":",
"soup",
"=",
"get_article_soup",
"(",
"link",
")",
"head",
"=",
"soup",
".",
"find_all",
"(",
"'article'",
",",
"class_",
"=",
"''",
")",
"[",
"0",
"]",
"parts",
"=",
"link",
".",
"split",
"(",... | Factory Method. Fetches article data from given link and builds the object | [
"Factory",
"Method",
".",
"Fetches",
"article",
"data",
"from",
"given",
"link",
"and",
"builds",
"the",
"object"
] | c13da4c464fe3e0d31cea0f7d4e6a50a360947ad | https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L73-L95 |
251,242 | voidabhi/TheZineAPI | tz/tz.py | Author.from_soup | def from_soup(self,soup):
"""
Factory Pattern. Fetches author data from given soup and builds the object
"""
if soup is None or soup is '':
return None
else:
author_name = soup.find('em').contents[0].strip() if soup.find('em') else ''
author_image = soup.find('img').get('src') if soup.find('img') ... | python | def from_soup(self,soup):
"""
Factory Pattern. Fetches author data from given soup and builds the object
"""
if soup is None or soup is '':
return None
else:
author_name = soup.find('em').contents[0].strip() if soup.find('em') else ''
author_image = soup.find('img').get('src') if soup.find('img') ... | [
"def",
"from_soup",
"(",
"self",
",",
"soup",
")",
":",
"if",
"soup",
"is",
"None",
"or",
"soup",
"is",
"''",
":",
"return",
"None",
"else",
":",
"author_name",
"=",
"soup",
".",
"find",
"(",
"'em'",
")",
".",
"contents",
"[",
"0",
"]",
".",
"str... | Factory Pattern. Fetches author data from given soup and builds the object | [
"Factory",
"Pattern",
".",
"Fetches",
"author",
"data",
"from",
"given",
"soup",
"and",
"builds",
"the",
"object"
] | c13da4c464fe3e0d31cea0f7d4e6a50a360947ad | https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L122-L132 |
251,243 | voidabhi/TheZineAPI | tz/tz.py | Contact.from_soup | def from_soup(self,author,soup):
"""
Factory Pattern. Fetches contact data from given soup and builds the object
"""
email = soup.find('span',class_='icon icon-mail').findParent('a').get('href').split(':')[-1] if soup.find('span',class_='icon icon-mail') else ''
facebook = soup.find('span',class_='icon ico... | python | def from_soup(self,author,soup):
"""
Factory Pattern. Fetches contact data from given soup and builds the object
"""
email = soup.find('span',class_='icon icon-mail').findParent('a').get('href').split(':')[-1] if soup.find('span',class_='icon icon-mail') else ''
facebook = soup.find('span',class_='icon ico... | [
"def",
"from_soup",
"(",
"self",
",",
"author",
",",
"soup",
")",
":",
"email",
"=",
"soup",
".",
"find",
"(",
"'span'",
",",
"class_",
"=",
"'icon icon-mail'",
")",
".",
"findParent",
"(",
"'a'",
")",
".",
"get",
"(",
"'href'",
")",
".",
"split",
... | Factory Pattern. Fetches contact data from given soup and builds the object | [
"Factory",
"Pattern",
".",
"Fetches",
"contact",
"data",
"from",
"given",
"soup",
"and",
"builds",
"the",
"object"
] | c13da4c464fe3e0d31cea0f7d4e6a50a360947ad | https://github.com/voidabhi/TheZineAPI/blob/c13da4c464fe3e0d31cea0f7d4e6a50a360947ad/tz/tz.py#L148-L156 |
251,244 | marteinn/genres | genres/finder.py | Finder.find | def find(self, text):
"""
Return a list of genres found in text.
"""
genres = []
text = text.lower()
category_counter = Counter()
counter = Counter()
for genre in self.db.genres:
found = self.contains_entity(genre, text)
if found... | python | def find(self, text):
"""
Return a list of genres found in text.
"""
genres = []
text = text.lower()
category_counter = Counter()
counter = Counter()
for genre in self.db.genres:
found = self.contains_entity(genre, text)
if found... | [
"def",
"find",
"(",
"self",
",",
"text",
")",
":",
"genres",
"=",
"[",
"]",
"text",
"=",
"text",
".",
"lower",
"(",
")",
"category_counter",
"=",
"Counter",
"(",
")",
"counter",
"=",
"Counter",
"(",
")",
"for",
"genre",
"in",
"self",
".",
"db",
"... | Return a list of genres found in text. | [
"Return",
"a",
"list",
"of",
"genres",
"found",
"in",
"text",
"."
] | 4bbc90f7c2c527631380c08b4d99a4e40abed955 | https://github.com/marteinn/genres/blob/4bbc90f7c2c527631380c08b4d99a4e40abed955/genres/finder.py#L22-L78 |
251,245 | marteinn/genres | genres/finder.py | Finder.contains_entity | def contains_entity(entity, text):
"""
Attempt to try entity, return false if not found. Otherwise the
amount of time entitu is occuring.
"""
try:
entity = re.escape(entity)
entity = entity.replace("\ ", "([^\w])?")
pattern = "(\ |-|\\\|/|\.|,... | python | def contains_entity(entity, text):
"""
Attempt to try entity, return false if not found. Otherwise the
amount of time entitu is occuring.
"""
try:
entity = re.escape(entity)
entity = entity.replace("\ ", "([^\w])?")
pattern = "(\ |-|\\\|/|\.|,... | [
"def",
"contains_entity",
"(",
"entity",
",",
"text",
")",
":",
"try",
":",
"entity",
"=",
"re",
".",
"escape",
"(",
"entity",
")",
"entity",
"=",
"entity",
".",
"replace",
"(",
"\"\\ \"",
",",
"\"([^\\w])?\"",
")",
"pattern",
"=",
"\"(\\ |-|\\\\\\|/|\\.|,... | Attempt to try entity, return false if not found. Otherwise the
amount of time entitu is occuring. | [
"Attempt",
"to",
"try",
"entity",
"return",
"false",
"if",
"not",
"found",
".",
"Otherwise",
"the",
"amount",
"of",
"time",
"entitu",
"is",
"occuring",
"."
] | 4bbc90f7c2c527631380c08b4d99a4e40abed955 | https://github.com/marteinn/genres/blob/4bbc90f7c2c527631380c08b4d99a4e40abed955/genres/finder.py#L81-L95 |
251,246 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | is_executable | def is_executable(path):
'''is the given path executable?'''
return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE]
or stat.S_IXGRP & os.stat(path)[stat.ST_MODE]
or stat.S_IXOTH & os.stat(path)[stat.ST_MODE]) | python | def is_executable(path):
'''is the given path executable?'''
return (stat.S_IXUSR & os.stat(path)[stat.ST_MODE]
or stat.S_IXGRP & os.stat(path)[stat.ST_MODE]
or stat.S_IXOTH & os.stat(path)[stat.ST_MODE]) | [
"def",
"is_executable",
"(",
"path",
")",
":",
"return",
"(",
"stat",
".",
"S_IXUSR",
"&",
"os",
".",
"stat",
"(",
"path",
")",
"[",
"stat",
".",
"ST_MODE",
"]",
"or",
"stat",
".",
"S_IXGRP",
"&",
"os",
".",
"stat",
"(",
"path",
")",
"[",
"stat",... | is the given path executable? | [
"is",
"the",
"given",
"path",
"executable?"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L159-L163 |
251,247 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | prepare_writeable_dir | def prepare_writeable_dir(tree):
''' make sure a directory exists and is writeable '''
if tree != '/':
tree = os.path.realpath(os.path.expanduser(tree))
if not os.path.exists(tree):
try:
os.makedirs(tree)
except (IOError, OSError), e:
exit("Could not make dir... | python | def prepare_writeable_dir(tree):
''' make sure a directory exists and is writeable '''
if tree != '/':
tree = os.path.realpath(os.path.expanduser(tree))
if not os.path.exists(tree):
try:
os.makedirs(tree)
except (IOError, OSError), e:
exit("Could not make dir... | [
"def",
"prepare_writeable_dir",
"(",
"tree",
")",
":",
"if",
"tree",
"!=",
"'/'",
":",
"tree",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"tree",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",... | make sure a directory exists and is writeable | [
"make",
"sure",
"a",
"directory",
"exists",
"and",
"is",
"writeable"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L165-L176 |
251,248 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | path_dwim | def path_dwim(basedir, given):
'''
make relative paths work like folks expect.
'''
if given.startswith("/"):
return given
elif given.startswith("~/"):
return os.path.expanduser(given)
else:
return os.path.join(basedir, given) | python | def path_dwim(basedir, given):
'''
make relative paths work like folks expect.
'''
if given.startswith("/"):
return given
elif given.startswith("~/"):
return os.path.expanduser(given)
else:
return os.path.join(basedir, given) | [
"def",
"path_dwim",
"(",
"basedir",
",",
"given",
")",
":",
"if",
"given",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"return",
"given",
"elif",
"given",
".",
"startswith",
"(",
"\"~/\"",
")",
":",
"return",
"os",
".",
"path",
".",
"expanduser",
"(",
... | make relative paths work like folks expect. | [
"make",
"relative",
"paths",
"work",
"like",
"folks",
"expect",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L178-L188 |
251,249 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | parse_json | def parse_json(raw_data):
''' this version for module return data only '''
orig_data = raw_data
# ignore stuff like tcgetattr spewage or other warnings
data = filter_leading_non_json_lines(raw_data)
try:
return json.loads(data)
except:
# not JSON, but try "Baby JSON" which all... | python | def parse_json(raw_data):
''' this version for module return data only '''
orig_data = raw_data
# ignore stuff like tcgetattr spewage or other warnings
data = filter_leading_non_json_lines(raw_data)
try:
return json.loads(data)
except:
# not JSON, but try "Baby JSON" which all... | [
"def",
"parse_json",
"(",
"raw_data",
")",
":",
"orig_data",
"=",
"raw_data",
"# ignore stuff like tcgetattr spewage or other warnings",
"data",
"=",
"filter_leading_non_json_lines",
"(",
"raw_data",
")",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"data",
")",
... | this version for module return data only | [
"this",
"version",
"for",
"module",
"return",
"data",
"only"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L195-L229 |
251,250 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | md5 | def md5(filename):
''' Return MD5 hex digest of local file, or None if file is not present. '''
if not os.path.exists(filename):
return None
digest = _md5()
blocksize = 64 * 1024
infile = open(filename, 'rb')
block = infile.read(blocksize)
while block:
digest.update(block)
... | python | def md5(filename):
''' Return MD5 hex digest of local file, or None if file is not present. '''
if not os.path.exists(filename):
return None
digest = _md5()
blocksize = 64 * 1024
infile = open(filename, 'rb')
block = infile.read(blocksize)
while block:
digest.update(block)
... | [
"def",
"md5",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"return",
"None",
"digest",
"=",
"_md5",
"(",
")",
"blocksize",
"=",
"64",
"*",
"1024",
"infile",
"=",
"open",
"(",
"filename",
",",
... | Return MD5 hex digest of local file, or None if file is not present. | [
"Return",
"MD5",
"hex",
"digest",
"of",
"local",
"file",
"or",
"None",
"if",
"file",
"is",
"not",
"present",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L304-L317 |
251,251 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | _gitinfo | def _gitinfo():
''' returns a string containing git branch, commit id and commit date '''
result = None
repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '.git')
if os.path.exists(repo_path):
# Check if the .git is a file. If it is a file, it means that we are in a submodule... | python | def _gitinfo():
''' returns a string containing git branch, commit id and commit date '''
result = None
repo_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '.git')
if os.path.exists(repo_path):
# Check if the .git is a file. If it is a file, it means that we are in a submodule... | [
"def",
"_gitinfo",
"(",
")",
":",
"result",
"=",
"None",
"repo_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'..'",
",",
"'..'",
",",
"'..'",
",",
"'.git'",
")",
"if",
"os",
".",
... | returns a string containing git branch, commit id and commit date | [
"returns",
"a",
"string",
"containing",
"git",
"branch",
"commit",
"id",
"and",
"commit",
"date"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L325-L359 |
251,252 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | compile_when_to_only_if | def compile_when_to_only_if(expression):
'''
when is a shorthand for writing only_if conditionals. It requires less quoting
magic. only_if is retained for backwards compatibility.
'''
# when: set $variable
# when: unset $variable
# when: failed $json_result
# when: changed $json_resul... | python | def compile_when_to_only_if(expression):
'''
when is a shorthand for writing only_if conditionals. It requires less quoting
magic. only_if is retained for backwards compatibility.
'''
# when: set $variable
# when: unset $variable
# when: failed $json_result
# when: changed $json_resul... | [
"def",
"compile_when_to_only_if",
"(",
"expression",
")",
":",
"# when: set $variable",
"# when: unset $variable",
"# when: failed $json_result",
"# when: changed $json_result",
"# when: int $x >= $z and $y < 3",
"# when: int $x in $alist",
"# when: float $x > 2 and $y <= $z",
"# when: str... | when is a shorthand for writing only_if conditionals. It requires less quoting
magic. only_if is retained for backwards compatibility. | [
"when",
"is",
"a",
"shorthand",
"for",
"writing",
"only_if",
"conditionals",
".",
"It",
"requires",
"less",
"quoting",
"magic",
".",
"only_if",
"is",
"retained",
"for",
"backwards",
"compatibility",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L506-L578 |
251,253 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/utils/__init__.py | make_sudo_cmd | def make_sudo_cmd(sudo_user, executable, cmd):
"""
helper function for connection plugins to create sudo commands
"""
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required.
# Passing a quoted compound command to sudo (or sudo -s)
... | python | def make_sudo_cmd(sudo_user, executable, cmd):
"""
helper function for connection plugins to create sudo commands
"""
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required.
# Passing a quoted compound command to sudo (or sudo -s)
... | [
"def",
"make_sudo_cmd",
"(",
"sudo_user",
",",
"executable",
",",
"cmd",
")",
":",
"# Rather than detect if sudo wants a password this time, -k makes",
"# sudo always ask for a password if one is required.",
"# Passing a quoted compound command to sudo (or sudo -s)",
"# directly doesn't wo... | helper function for connection plugins to create sudo commands | [
"helper",
"function",
"for",
"connection",
"plugins",
"to",
"create",
"sudo",
"commands"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/utils/__init__.py#L580-L596 |
251,254 | jmgilman/Neolib | neolib/user/User.py | User.login | def login(self):
""" Logs the user in, returns the result
Returns
bool - Whether or not the user logged in successfully
"""
# Request index to obtain initial cookies and look more human
pg = self.getPage("http://www.neopets.com")
form = pg.... | python | def login(self):
""" Logs the user in, returns the result
Returns
bool - Whether or not the user logged in successfully
"""
# Request index to obtain initial cookies and look more human
pg = self.getPage("http://www.neopets.com")
form = pg.... | [
"def",
"login",
"(",
"self",
")",
":",
"# Request index to obtain initial cookies and look more human",
"pg",
"=",
"self",
".",
"getPage",
"(",
"\"http://www.neopets.com\"",
")",
"form",
"=",
"pg",
".",
"form",
"(",
"action",
"=",
"\"/login.phtml\"",
")",
"form",
... | Logs the user in, returns the result
Returns
bool - Whether or not the user logged in successfully | [
"Logs",
"the",
"user",
"in",
"returns",
"the",
"result",
"Returns",
"bool",
"-",
"Whether",
"or",
"not",
"the",
"user",
"logged",
"in",
"successfully"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L158-L173 |
251,255 | jmgilman/Neolib | neolib/user/User.py | User.sync | def sync(self, browser):
""" Enables cookie synchronization with specified browser, returns result
Returns
bool - True if successful, false otherwise
"""
BrowserCookies.loadBrowsers()
if not browser in BrowserCookies.browsers:
return False
... | python | def sync(self, browser):
""" Enables cookie synchronization with specified browser, returns result
Returns
bool - True if successful, false otherwise
"""
BrowserCookies.loadBrowsers()
if not browser in BrowserCookies.browsers:
return False
... | [
"def",
"sync",
"(",
"self",
",",
"browser",
")",
":",
"BrowserCookies",
".",
"loadBrowsers",
"(",
")",
"if",
"not",
"browser",
"in",
"BrowserCookies",
".",
"browsers",
":",
"return",
"False",
"self",
".",
"browserSync",
"=",
"True",
"self",
".",
"browser",... | Enables cookie synchronization with specified browser, returns result
Returns
bool - True if successful, false otherwise | [
"Enables",
"cookie",
"synchronization",
"with",
"specified",
"browser",
"returns",
"result",
"Returns",
"bool",
"-",
"True",
"if",
"successful",
"false",
"otherwise"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L185-L197 |
251,256 | jmgilman/Neolib | neolib/user/User.py | User.save | def save(self):
""" Exports all user attributes to the user's configuration and writes configuration
Saves the values for each attribute stored in User.configVars
into the user's configuration. The password is automatically
encoded and salted to prevent saving it as plaintext. T... | python | def save(self):
""" Exports all user attributes to the user's configuration and writes configuration
Saves the values for each attribute stored in User.configVars
into the user's configuration. The password is automatically
encoded and salted to prevent saving it as plaintext. T... | [
"def",
"save",
"(",
"self",
")",
":",
"# Code to load all attributes",
"for",
"prop",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"prop",
")",
"==",
"None",
":",
"continue",
"if",
"not",
"prop",
"in",
"self",
".",
"configVars... | Exports all user attributes to the user's configuration and writes configuration
Saves the values for each attribute stored in User.configVars
into the user's configuration. The password is automatically
encoded and salted to prevent saving it as plaintext. The
session is pickl... | [
"Exports",
"all",
"user",
"attributes",
"to",
"the",
"user",
"s",
"configuration",
"and",
"writes",
"configuration",
"Saves",
"the",
"values",
"for",
"each",
"attribute",
"stored",
"in",
"User",
".",
"configVars",
"into",
"the",
"user",
"s",
"configuration",
"... | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/User.py#L204-L238 |
251,257 | KnowledgeLinks/rdfframework | rdfframework/utilities/gitutilities.py | mod_git_ignore | def mod_git_ignore(directory, ignore_item, action):
""" checks if an item is in the specified gitignore file and adds it if it
is not in the file
"""
if not os.path.isdir(directory):
return
ignore_filepath = os.path.join(directory,".gitignore")
if not os.path.exists(ignore_filepath):
... | python | def mod_git_ignore(directory, ignore_item, action):
""" checks if an item is in the specified gitignore file and adds it if it
is not in the file
"""
if not os.path.isdir(directory):
return
ignore_filepath = os.path.join(directory,".gitignore")
if not os.path.exists(ignore_filepath):
... | [
"def",
"mod_git_ignore",
"(",
"directory",
",",
"ignore_item",
",",
"action",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"return",
"ignore_filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"... | checks if an item is in the specified gitignore file and adds it if it
is not in the file | [
"checks",
"if",
"an",
"item",
"is",
"in",
"the",
"specified",
"gitignore",
"file",
"and",
"adds",
"it",
"if",
"it",
"is",
"not",
"in",
"the",
"file"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/gitutilities.py#L3-L27 |
251,258 | etcher-be/elib_run | elib_run/_run/_monitor_running_process.py | monitor_running_process | def monitor_running_process(context: RunContext):
"""
Runs an infinite loop that waits for the process to either exit on its or time out
Captures all output from the running process
:param context: run context
:type context: RunContext
"""
while True:
capture_output_from_running_pr... | python | def monitor_running_process(context: RunContext):
"""
Runs an infinite loop that waits for the process to either exit on its or time out
Captures all output from the running process
:param context: run context
:type context: RunContext
"""
while True:
capture_output_from_running_pr... | [
"def",
"monitor_running_process",
"(",
"context",
":",
"RunContext",
")",
":",
"while",
"True",
":",
"capture_output_from_running_process",
"(",
"context",
")",
"if",
"context",
".",
"process_finished",
"(",
")",
":",
"context",
".",
"return_code",
"=",
"context",... | Runs an infinite loop that waits for the process to either exit on its or time out
Captures all output from the running process
:param context: run context
:type context: RunContext | [
"Runs",
"an",
"infinite",
"loop",
"that",
"waits",
"for",
"the",
"process",
"to",
"either",
"exit",
"on",
"its",
"or",
"time",
"out"
] | c9d8ba9f067ab90c5baa27375a92b23f1b97cdde | https://github.com/etcher-be/elib_run/blob/c9d8ba9f067ab90c5baa27375a92b23f1b97cdde/elib_run/_run/_monitor_running_process.py#L12-L33 |
251,259 | b3j0f/utils | b3j0f/utils/reflect.py | base_elts | def base_elts(elt, cls=None, depth=None):
"""Get bases elements of the input elt.
- If elt is an instance, get class and all base classes.
- If elt is a method, get all base methods.
- If elt is a class, get all base classes.
- In other case, get an empty list.
:param elt: supposed inherited e... | python | def base_elts(elt, cls=None, depth=None):
"""Get bases elements of the input elt.
- If elt is an instance, get class and all base classes.
- If elt is a method, get all base methods.
- If elt is a class, get all base classes.
- In other case, get an empty list.
:param elt: supposed inherited e... | [
"def",
"base_elts",
"(",
"elt",
",",
"cls",
"=",
"None",
",",
"depth",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"elt_name",
"=",
"getattr",
"(",
"elt",
",",
"'__name__'",
",",
"None",
")",
"if",
"elt_name",
"is",
"not",
"None",
":",
"cls",
... | Get bases elements of the input elt.
- If elt is an instance, get class and all base classes.
- If elt is a method, get all base methods.
- If elt is a class, get all base classes.
- In other case, get an empty list.
:param elt: supposed inherited elt.
:param cls: cls from where find attribute... | [
"Get",
"bases",
"elements",
"of",
"the",
"input",
"elt",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/reflect.py#L48-L145 |
251,260 | b3j0f/utils | b3j0f/utils/reflect.py | find_embedding | def find_embedding(elt, embedding=None):
"""Try to get elt embedding elements.
:param embedding: embedding element. Must have a module.
:return: a list of [module [,class]*] embedding elements which define elt.
:rtype: list
"""
result = [] # result is empty in the worst case
# start to ... | python | def find_embedding(elt, embedding=None):
"""Try to get elt embedding elements.
:param embedding: embedding element. Must have a module.
:return: a list of [module [,class]*] embedding elements which define elt.
:rtype: list
"""
result = [] # result is empty in the worst case
# start to ... | [
"def",
"find_embedding",
"(",
"elt",
",",
"embedding",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"# result is empty in the worst case",
"# start to get module",
"module",
"=",
"getmodule",
"(",
"elt",
")",
"if",
"module",
"is",
"not",
"None",
":",
"# if ... | Try to get elt embedding elements.
:param embedding: embedding element. Must have a module.
:return: a list of [module [,class]*] embedding elements which define elt.
:rtype: list | [
"Try",
"to",
"get",
"elt",
"embedding",
"elements",
"."
] | 793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/reflect.py#L160-L223 |
251,261 | wohlgejm/accountable | accountable/cli.py | projects | def projects(accountable):
"""
List all projects.
"""
projects = accountable.metadata()['projects']
headers = sorted(['id', 'key', 'self'])
rows = [[v for k, v in sorted(p.items()) if k in headers] for p in projects]
rows.insert(0, headers)
print_table(SingleTable(rows)) | python | def projects(accountable):
"""
List all projects.
"""
projects = accountable.metadata()['projects']
headers = sorted(['id', 'key', 'self'])
rows = [[v for k, v in sorted(p.items()) if k in headers] for p in projects]
rows.insert(0, headers)
print_table(SingleTable(rows)) | [
"def",
"projects",
"(",
"accountable",
")",
":",
"projects",
"=",
"accountable",
".",
"metadata",
"(",
")",
"[",
"'projects'",
"]",
"headers",
"=",
"sorted",
"(",
"[",
"'id'",
",",
"'key'",
",",
"'self'",
"]",
")",
"rows",
"=",
"[",
"[",
"v",
"for",
... | List all projects. | [
"List",
"all",
"projects",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L71-L79 |
251,262 | wohlgejm/accountable | accountable/cli.py | issuetypes | def issuetypes(accountable, project_key):
"""
List all issue types. Optional parameter to list issue types by a given
project.
"""
projects = accountable.issue_types(project_key)
headers = sorted(['id', 'name', 'description'])
rows = []
for key, issue_types in sorted(projects.items()):
... | python | def issuetypes(accountable, project_key):
"""
List all issue types. Optional parameter to list issue types by a given
project.
"""
projects = accountable.issue_types(project_key)
headers = sorted(['id', 'name', 'description'])
rows = []
for key, issue_types in sorted(projects.items()):
... | [
"def",
"issuetypes",
"(",
"accountable",
",",
"project_key",
")",
":",
"projects",
"=",
"accountable",
".",
"issue_types",
"(",
"project_key",
")",
"headers",
"=",
"sorted",
"(",
"[",
"'id'",
",",
"'name'",
",",
"'description'",
"]",
")",
"rows",
"=",
"[",... | List all issue types. Optional parameter to list issue types by a given
project. | [
"List",
"all",
"issue",
"types",
".",
"Optional",
"parameter",
"to",
"list",
"issue",
"types",
"by",
"a",
"given",
"project",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L85-L100 |
251,263 | wohlgejm/accountable | accountable/cli.py | components | def components(accountable, project_key):
"""
Returns a list of all a project's components.
"""
components = accountable.project_components(project_key)
headers = sorted(['id', 'name', 'self'])
rows = [[v for k, v in sorted(component.items()) if k in headers]
for component in compone... | python | def components(accountable, project_key):
"""
Returns a list of all a project's components.
"""
components = accountable.project_components(project_key)
headers = sorted(['id', 'name', 'self'])
rows = [[v for k, v in sorted(component.items()) if k in headers]
for component in compone... | [
"def",
"components",
"(",
"accountable",
",",
"project_key",
")",
":",
"components",
"=",
"accountable",
".",
"project_components",
"(",
"project_key",
")",
"headers",
"=",
"sorted",
"(",
"[",
"'id'",
",",
"'name'",
",",
"'self'",
"]",
")",
"rows",
"=",
"[... | Returns a list of all a project's components. | [
"Returns",
"a",
"list",
"of",
"all",
"a",
"project",
"s",
"components",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L106-L115 |
251,264 | wohlgejm/accountable | accountable/cli.py | checkoutbranch | def checkoutbranch(accountable, options):
"""
Create a new issue and checkout a branch named after it.
"""
issue = accountable.checkout_branch(options)
headers = sorted(['id', 'key', 'self'])
rows = [headers, [itemgetter(header)(issue) for header in headers]]
print_table(SingleTable(rows)) | python | def checkoutbranch(accountable, options):
"""
Create a new issue and checkout a branch named after it.
"""
issue = accountable.checkout_branch(options)
headers = sorted(['id', 'key', 'self'])
rows = [headers, [itemgetter(header)(issue) for header in headers]]
print_table(SingleTable(rows)) | [
"def",
"checkoutbranch",
"(",
"accountable",
",",
"options",
")",
":",
"issue",
"=",
"accountable",
".",
"checkout_branch",
"(",
"options",
")",
"headers",
"=",
"sorted",
"(",
"[",
"'id'",
",",
"'key'",
",",
"'self'",
"]",
")",
"rows",
"=",
"[",
"headers... | Create a new issue and checkout a branch named after it. | [
"Create",
"a",
"new",
"issue",
"and",
"checkout",
"a",
"branch",
"named",
"after",
"it",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L168-L175 |
251,265 | wohlgejm/accountable | accountable/cli.py | checkout | def checkout(accountable, issue_key):
"""
Checkout a new branch or checkout to a branch for a given issue.
"""
issue = accountable.checkout(issue_key)
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(SingleTable(rows)) | python | def checkout(accountable, issue_key):
"""
Checkout a new branch or checkout to a branch for a given issue.
"""
issue = accountable.checkout(issue_key)
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(SingleTable(rows)) | [
"def",
"checkout",
"(",
"accountable",
",",
"issue_key",
")",
":",
"issue",
"=",
"accountable",
".",
"checkout",
"(",
"issue_key",
")",
"headers",
"=",
"issue",
".",
"keys",
"(",
")",
"rows",
"=",
"[",
"headers",
",",
"[",
"v",
"for",
"k",
",",
"v",
... | Checkout a new branch or checkout to a branch for a given issue. | [
"Checkout",
"a",
"new",
"branch",
"or",
"checkout",
"to",
"a",
"branch",
"for",
"a",
"given",
"issue",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L181-L188 |
251,266 | wohlgejm/accountable | accountable/cli.py | issue | def issue(ctx, accountable, issue_key):
"""
List metadata for a given issue key.
"""
accountable.issue_key = issue_key
if not ctx.invoked_subcommand:
issue = accountable.issue_meta()
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(Si... | python | def issue(ctx, accountable, issue_key):
"""
List metadata for a given issue key.
"""
accountable.issue_key = issue_key
if not ctx.invoked_subcommand:
issue = accountable.issue_meta()
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(Si... | [
"def",
"issue",
"(",
"ctx",
",",
"accountable",
",",
"issue_key",
")",
":",
"accountable",
".",
"issue_key",
"=",
"issue_key",
"if",
"not",
"ctx",
".",
"invoked_subcommand",
":",
"issue",
"=",
"accountable",
".",
"issue_meta",
"(",
")",
"headers",
"=",
"is... | List metadata for a given issue key. | [
"List",
"metadata",
"for",
"a",
"given",
"issue",
"key",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L195-L204 |
251,267 | wohlgejm/accountable | accountable/cli.py | update | def update(accountable, options):
"""
Update an existing issue.
"""
issue = accountable.issue_update(options)
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(SingleTable(rows)) | python | def update(accountable, options):
"""
Update an existing issue.
"""
issue = accountable.issue_update(options)
headers = issue.keys()
rows = [headers, [v for k, v in issue.items()]]
print_table(SingleTable(rows)) | [
"def",
"update",
"(",
"accountable",
",",
"options",
")",
":",
"issue",
"=",
"accountable",
".",
"issue_update",
"(",
"options",
")",
"headers",
"=",
"issue",
".",
"keys",
"(",
")",
"rows",
"=",
"[",
"headers",
",",
"[",
"v",
"for",
"k",
",",
"v",
... | Update an existing issue. | [
"Update",
"an",
"existing",
"issue",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L209-L216 |
251,268 | wohlgejm/accountable | accountable/cli.py | comments | def comments(accountable):
"""
Lists all comments for a given issue key.
"""
comments = accountable.issue_comments()
headers = sorted(['author_name', 'body', 'updated'])
if comments:
rows = [[v for k, v in sorted(c.items()) if k in headers]
for c in comments]
row... | python | def comments(accountable):
"""
Lists all comments for a given issue key.
"""
comments = accountable.issue_comments()
headers = sorted(['author_name', 'body', 'updated'])
if comments:
rows = [[v for k, v in sorted(c.items()) if k in headers]
for c in comments]
row... | [
"def",
"comments",
"(",
"accountable",
")",
":",
"comments",
"=",
"accountable",
".",
"issue_comments",
"(",
")",
"headers",
"=",
"sorted",
"(",
"[",
"'author_name'",
",",
"'body'",
",",
"'updated'",
"]",
")",
"if",
"comments",
":",
"rows",
"=",
"[",
"["... | Lists all comments for a given issue key. | [
"Lists",
"all",
"comments",
"for",
"a",
"given",
"issue",
"key",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L221-L236 |
251,269 | wohlgejm/accountable | accountable/cli.py | addcomment | def addcomment(accountable, body):
"""
Add a comment to the given issue key. Accepts a body argument to be used
as the comment's body.
"""
r = accountable.issue_add_comment(body)
headers = sorted(['author_name', 'body', 'updated'])
rows = [[v for k, v in sorted(r.items()) if k in headers]]
... | python | def addcomment(accountable, body):
"""
Add a comment to the given issue key. Accepts a body argument to be used
as the comment's body.
"""
r = accountable.issue_add_comment(body)
headers = sorted(['author_name', 'body', 'updated'])
rows = [[v for k, v in sorted(r.items()) if k in headers]]
... | [
"def",
"addcomment",
"(",
"accountable",
",",
"body",
")",
":",
"r",
"=",
"accountable",
".",
"issue_add_comment",
"(",
"body",
")",
"headers",
"=",
"sorted",
"(",
"[",
"'author_name'",
",",
"'body'",
",",
"'updated'",
"]",
")",
"rows",
"=",
"[",
"[",
... | Add a comment to the given issue key. Accepts a body argument to be used
as the comment's body. | [
"Add",
"a",
"comment",
"to",
"the",
"given",
"issue",
"key",
".",
"Accepts",
"a",
"body",
"argument",
"to",
"be",
"used",
"as",
"the",
"comment",
"s",
"body",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L242-L252 |
251,270 | wohlgejm/accountable | accountable/cli.py | worklog | def worklog(accountable):
"""
List all worklogs for a given issue key.
"""
worklog = accountable.issue_worklog()
headers = ['author_name', 'comment', 'time_spent']
if worklog:
rows = [[v for k, v in sorted(w.items()) if k in headers]
for w in worklog]
rows.insert(... | python | def worklog(accountable):
"""
List all worklogs for a given issue key.
"""
worklog = accountable.issue_worklog()
headers = ['author_name', 'comment', 'time_spent']
if worklog:
rows = [[v for k, v in sorted(w.items()) if k in headers]
for w in worklog]
rows.insert(... | [
"def",
"worklog",
"(",
"accountable",
")",
":",
"worklog",
"=",
"accountable",
".",
"issue_worklog",
"(",
")",
"headers",
"=",
"[",
"'author_name'",
",",
"'comment'",
",",
"'time_spent'",
"]",
"if",
"worklog",
":",
"rows",
"=",
"[",
"[",
"v",
"for",
"k",... | List all worklogs for a given issue key. | [
"List",
"all",
"worklogs",
"for",
"a",
"given",
"issue",
"key",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L257-L272 |
251,271 | wohlgejm/accountable | accountable/cli.py | transitions | def transitions(accountable):
"""
List all possible transitions for a given issue.
"""
transitions = accountable.issue_transitions().get('transitions')
headers = ['id', 'name']
if transitions:
rows = [[v for k, v in sorted(t.items()) if k in headers]
for t in transitions]... | python | def transitions(accountable):
"""
List all possible transitions for a given issue.
"""
transitions = accountable.issue_transitions().get('transitions')
headers = ['id', 'name']
if transitions:
rows = [[v for k, v in sorted(t.items()) if k in headers]
for t in transitions]... | [
"def",
"transitions",
"(",
"accountable",
")",
":",
"transitions",
"=",
"accountable",
".",
"issue_transitions",
"(",
")",
".",
"get",
"(",
"'transitions'",
")",
"headers",
"=",
"[",
"'id'",
",",
"'name'",
"]",
"if",
"transitions",
":",
"rows",
"=",
"[",
... | List all possible transitions for a given issue. | [
"List",
"all",
"possible",
"transitions",
"for",
"a",
"given",
"issue",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L277-L292 |
251,272 | wohlgejm/accountable | accountable/cli.py | dotransition | def dotransition(accountable, transition_id):
"""
Transition the given issue to the provided ID. The API does not return a
JSON response for this call.
"""
t = accountable.issue_do_transition(transition_id)
if t.status_code == 204:
click.secho(
'Successfully transitioned {}'.... | python | def dotransition(accountable, transition_id):
"""
Transition the given issue to the provided ID. The API does not return a
JSON response for this call.
"""
t = accountable.issue_do_transition(transition_id)
if t.status_code == 204:
click.secho(
'Successfully transitioned {}'.... | [
"def",
"dotransition",
"(",
"accountable",
",",
"transition_id",
")",
":",
"t",
"=",
"accountable",
".",
"issue_do_transition",
"(",
"transition_id",
")",
"if",
"t",
".",
"status_code",
"==",
"204",
":",
"click",
".",
"secho",
"(",
"'Successfully transitioned {}... | Transition the given issue to the provided ID. The API does not return a
JSON response for this call. | [
"Transition",
"the",
"given",
"issue",
"to",
"the",
"provided",
"ID",
".",
"The",
"API",
"does",
"not",
"return",
"a",
"JSON",
"response",
"for",
"this",
"call",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L298-L308 |
251,273 | wohlgejm/accountable | accountable/cli.py | users | def users(accountable, query):
"""
Executes a user search for the given query.
"""
users = accountable.users(query)
headers = ['display_name', 'key']
if users:
rows = [[v for k, v in sorted(u.items()) if k in headers]
for u in users]
rows.insert(0, headers)
... | python | def users(accountable, query):
"""
Executes a user search for the given query.
"""
users = accountable.users(query)
headers = ['display_name', 'key']
if users:
rows = [[v for k, v in sorted(u.items()) if k in headers]
for u in users]
rows.insert(0, headers)
... | [
"def",
"users",
"(",
"accountable",
",",
"query",
")",
":",
"users",
"=",
"accountable",
".",
"users",
"(",
"query",
")",
"headers",
"=",
"[",
"'display_name'",
",",
"'key'",
"]",
"if",
"users",
":",
"rows",
"=",
"[",
"[",
"v",
"for",
"k",
",",
"v"... | Executes a user search for the given query. | [
"Executes",
"a",
"user",
"search",
"for",
"the",
"given",
"query",
"."
] | 20586365ccd319061e5548ce14fb0b8f449580fa | https://github.com/wohlgejm/accountable/blob/20586365ccd319061e5548ce14fb0b8f449580fa/accountable/cli.py#L314-L328 |
251,274 | abalkin/tz | tz/system_tzdata.py | guess_saves | def guess_saves(zone, data):
"""Return types with guessed DST saves"""
saves = {}
details = {}
for (time0, type0), (time1, type1) in pairs(data.times):
is_dst0 = bool(data.types[type0][1])
is_dst1 = bool(data.types[type1][1])
if (is_dst0, is_dst1) == (False, True):
sh... | python | def guess_saves(zone, data):
"""Return types with guessed DST saves"""
saves = {}
details = {}
for (time0, type0), (time1, type1) in pairs(data.times):
is_dst0 = bool(data.types[type0][1])
is_dst1 = bool(data.types[type1][1])
if (is_dst0, is_dst1) == (False, True):
sh... | [
"def",
"guess_saves",
"(",
"zone",
",",
"data",
")",
":",
"saves",
"=",
"{",
"}",
"details",
"=",
"{",
"}",
"for",
"(",
"time0",
",",
"type0",
")",
",",
"(",
"time1",
",",
"type1",
")",
"in",
"pairs",
"(",
"data",
".",
"times",
")",
":",
"is_ds... | Return types with guessed DST saves | [
"Return",
"types",
"with",
"guessed",
"DST",
"saves"
] | f25fca6afbf1abd46fd7aeb978282823c7dab5ab | https://github.com/abalkin/tz/blob/f25fca6afbf1abd46fd7aeb978282823c7dab5ab/tz/system_tzdata.py#L69-L105 |
251,275 | jtpaasch/simplygithub | simplygithub/files.py | get_commit_tree | def get_commit_tree(profile, sha):
"""Get the SHA of a commit's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
... | python | def get_commit_tree(profile, sha):
"""Get the SHA of a commit's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
... | [
"def",
"get_commit_tree",
"(",
"profile",
",",
"sha",
")",
":",
"data",
"=",
"commits",
".",
"get_commit",
"(",
"profile",
",",
"sha",
")",
"tree",
"=",
"data",
".",
"get",
"(",
"\"tree\"",
")",
"sha",
"=",
"tree",
".",
"get",
"(",
"\"sha\"",
")",
... | Get the SHA of a commit's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
sha
The SHA of a commit.
Retu... | [
"Get",
"the",
"SHA",
"of",
"a",
"commit",
"s",
"tree",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L43-L63 |
251,276 | jtpaasch/simplygithub | simplygithub/files.py | remove_file_from_tree | def remove_file_from_tree(tree, file_path):
"""Remove a file from a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of a file to remove from a tree.
Returns:
The provided tree, but with the item matching the s... | python | def remove_file_from_tree(tree, file_path):
"""Remove a file from a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of a file to remove from a tree.
Returns:
The provided tree, but with the item matching the s... | [
"def",
"remove_file_from_tree",
"(",
"tree",
",",
"file_path",
")",
":",
"match",
"=",
"None",
"for",
"item",
"in",
"tree",
":",
"if",
"item",
".",
"get",
"(",
"\"path\"",
")",
"==",
"file_path",
":",
"match",
"=",
"item",
"break",
"if",
"match",
":",
... | Remove a file from a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of a file to remove from a tree.
Returns:
The provided tree, but with the item matching the specified
file_path removed. | [
"Remove",
"a",
"file",
"from",
"a",
"tree",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L89-L112 |
251,277 | jtpaasch/simplygithub | simplygithub/files.py | add_file_to_tree | def add_file_to_tree(tree, file_path, file_contents, is_executable=False):
"""Add a file to a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of the new file in the tree.
file_contents
The (UTF-8 encod... | python | def add_file_to_tree(tree, file_path, file_contents, is_executable=False):
"""Add a file to a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of the new file in the tree.
file_contents
The (UTF-8 encod... | [
"def",
"add_file_to_tree",
"(",
"tree",
",",
"file_path",
",",
"file_contents",
",",
"is_executable",
"=",
"False",
")",
":",
"record",
"=",
"{",
"\"path\"",
":",
"file_path",
",",
"\"mode\"",
":",
"\"100755\"",
"if",
"is_executable",
"else",
"\"100644\"",
","... | Add a file to a tree.
Args:
tree
A list of dicts containing info about each blob in a tree.
file_path
The path of the new file in the tree.
file_contents
The (UTF-8 encoded) contents of the new file.
is_executable
If ``True``, the ... | [
"Add",
"a",
"file",
"to",
"a",
"tree",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L115-L144 |
251,278 | jtpaasch/simplygithub | simplygithub/files.py | get_files_in_branch | def get_files_in_branch(profile, branch_sha):
"""Get all files in a branch's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | python | def get_files_in_branch(profile, branch_sha):
"""Get all files in a branch's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
... | [
"def",
"get_files_in_branch",
"(",
"profile",
",",
"branch_sha",
")",
":",
"tree_sha",
"=",
"get_commit_tree",
"(",
"profile",
",",
"branch_sha",
")",
"files",
"=",
"get_files_in_tree",
"(",
"profile",
",",
"tree_sha",
")",
"tree",
"=",
"[",
"prepare",
"(",
... | Get all files in a branch's tree.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
branch_sha
The SHA a branch's HE... | [
"Get",
"all",
"files",
"in",
"a",
"branch",
"s",
"tree",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L147-L167 |
251,279 | jtpaasch/simplygithub | simplygithub/files.py | add_file | def add_file(
profile,
branch,
file_path,
file_contents,
is_executable=False,
commit_message=None):
"""Add a file to a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this... | python | def add_file(
profile,
branch,
file_path,
file_contents,
is_executable=False,
commit_message=None):
"""Add a file to a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this... | [
"def",
"add_file",
"(",
"profile",
",",
"branch",
",",
"file_path",
",",
"file_contents",
",",
"is_executable",
"=",
"False",
",",
"commit_message",
"=",
"None",
")",
":",
"branch_sha",
"=",
"get_branch_sha",
"(",
"profile",
",",
"branch",
")",
"tree",
"=",
... | Add a file to a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
branch
The name of a branch.
file... | [
"Add",
"a",
"file",
"to",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L191-L239 |
251,280 | jtpaasch/simplygithub | simplygithub/files.py | remove_file | def remove_file(profile, branch, file_path, commit_message=None):
"""Remove a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to... | python | def remove_file(profile, branch, file_path, commit_message=None):
"""Remove a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to... | [
"def",
"remove_file",
"(",
"profile",
",",
"branch",
",",
"file_path",
",",
"commit_message",
"=",
"None",
")",
":",
"branch_sha",
"=",
"get_branch_sha",
"(",
"profile",
",",
"branch",
")",
"tree",
"=",
"get_files_in_branch",
"(",
"profile",
",",
"branch_sha",... | Remove a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
branch
The name of a branch.
... | [
"Remove",
"a",
"file",
"from",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L242-L277 |
251,281 | jtpaasch/simplygithub | simplygithub/files.py | get_file | def get_file(profile, branch, file_path):
"""Get a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
bra... | python | def get_file(profile, branch, file_path):
"""Get a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
bra... | [
"def",
"get_file",
"(",
"profile",
",",
"branch",
",",
"file_path",
")",
":",
"branch_sha",
"=",
"get_branch_sha",
"(",
"profile",
",",
"branch",
")",
"tree",
"=",
"get_files_in_branch",
"(",
"profile",
",",
"branch_sha",
")",
"match",
"=",
"None",
"for",
... | Get a file from a branch.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
branch
The name of a branch.
fi... | [
"Get",
"a",
"file",
"from",
"a",
"branch",
"."
] | b77506275ec276ce90879bf1ea9299a79448b903 | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/files.py#L280-L311 |
251,282 | djtaylor/python-lsbinit | lsbinit/lock.py | _LSBLockHandler.make | def make(self):
"""
Make the lock file.
"""
try:
# Create the lock file
self.mkfile(self.lock_file)
except Exception as e:
self.die('Failed to generate lock file: {}'.format(str(e))) | python | def make(self):
"""
Make the lock file.
"""
try:
# Create the lock file
self.mkfile(self.lock_file)
except Exception as e:
self.die('Failed to generate lock file: {}'.format(str(e))) | [
"def",
"make",
"(",
"self",
")",
":",
"try",
":",
"# Create the lock file",
"self",
".",
"mkfile",
"(",
"self",
".",
"lock_file",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"die",
"(",
"'Failed to generate lock file: {}'",
".",
"format",
"(",
... | Make the lock file. | [
"Make",
"the",
"lock",
"file",
"."
] | a41fc551226f61ac2bf1b8b0f3f5395db85e75a2 | https://github.com/djtaylor/python-lsbinit/blob/a41fc551226f61ac2bf1b8b0f3f5395db85e75a2/lsbinit/lock.py#L36-L45 |
251,283 | jkenlooper/chill | src/chill/api.py | _short_circuit | def _short_circuit(value=None):
"""
Add the `value` to the `collection` by modifying the collection to be
either a dict or list depending on what is already in the collection and
value.
Returns the collection with the value added to it.
Clean up by removing single item array and single key dict... | python | def _short_circuit(value=None):
"""
Add the `value` to the `collection` by modifying the collection to be
either a dict or list depending on what is already in the collection and
value.
Returns the collection with the value added to it.
Clean up by removing single item array and single key dict... | [
"def",
"_short_circuit",
"(",
"value",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"return",
"value",
"if",
"len",
"(",
"value",
")",
"==",
"0",
":",
"return",
"value",
"if",
"len",
"(",
"value",
")",
"=="... | Add the `value` to the `collection` by modifying the collection to be
either a dict or list depending on what is already in the collection and
value.
Returns the collection with the value added to it.
Clean up by removing single item array and single key dict.
['abc'] -> 'abc'
[['abc']] -> 'abc... | [
"Add",
"the",
"value",
"to",
"the",
"collection",
"by",
"modifying",
"the",
"collection",
"to",
"be",
"either",
"a",
"dict",
"or",
"list",
"depending",
"on",
"what",
"is",
"already",
"in",
"the",
"collection",
"and",
"value",
".",
"Returns",
"the",
"collec... | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L8-L49 |
251,284 | jkenlooper/chill | src/chill/api.py | _query | def _query(_node_id, value=None, **kw):
"Look up value by using Query table"
query_result = []
try:
query_result = db.execute(text(fetch_query_string('select_query_from_node.sql')), **kw).fetchall()
except DatabaseError as err:
current_app.logger.error("DatabaseError: %s, %s", err, kw)
... | python | def _query(_node_id, value=None, **kw):
"Look up value by using Query table"
query_result = []
try:
query_result = db.execute(text(fetch_query_string('select_query_from_node.sql')), **kw).fetchall()
except DatabaseError as err:
current_app.logger.error("DatabaseError: %s, %s", err, kw)
... | [
"def",
"_query",
"(",
"_node_id",
",",
"value",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"query_result",
"=",
"[",
"]",
"try",
":",
"query_result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'select_query_from_node.sql'",
... | Look up value by using Query table | [
"Look",
"up",
"value",
"by",
"using",
"Query",
"table"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L53-L97 |
251,285 | jkenlooper/chill | src/chill/api.py | _template | def _template(node_id, value=None):
"Check if a template is assigned to it and render that with the value"
result = []
select_template_from_node = fetch_query_string('select_template_from_node.sql')
try:
result = db.execute(text(select_template_from_node), node_id=node_id)
template_resul... | python | def _template(node_id, value=None):
"Check if a template is assigned to it and render that with the value"
result = []
select_template_from_node = fetch_query_string('select_template_from_node.sql')
try:
result = db.execute(text(select_template_from_node), node_id=node_id)
template_resul... | [
"def",
"_template",
"(",
"node_id",
",",
"value",
"=",
"None",
")",
":",
"result",
"=",
"[",
"]",
"select_template_from_node",
"=",
"fetch_query_string",
"(",
"'select_template_from_node.sql'",
")",
"try",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",... | Check if a template is assigned to it and render that with the value | [
"Check",
"if",
"a",
"template",
"is",
"assigned",
"to",
"it",
"and",
"render",
"that",
"with",
"the",
"value"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L99-L118 |
251,286 | jkenlooper/chill | src/chill/api.py | render_node | def render_node(_node_id, value=None, noderequest={}, **kw):
"Recursively render a node's value"
if value == None:
kw.update( noderequest )
results = _query(_node_id, **kw)
current_app.logger.debug("results: %s", results)
if results:
values = []
for (resul... | python | def render_node(_node_id, value=None, noderequest={}, **kw):
"Recursively render a node's value"
if value == None:
kw.update( noderequest )
results = _query(_node_id, **kw)
current_app.logger.debug("results: %s", results)
if results:
values = []
for (resul... | [
"def",
"render_node",
"(",
"_node_id",
",",
"value",
"=",
"None",
",",
"noderequest",
"=",
"{",
"}",
",",
"*",
"*",
"kw",
")",
":",
"if",
"value",
"==",
"None",
":",
"kw",
".",
"update",
"(",
"noderequest",
")",
"results",
"=",
"_query",
"(",
"_nod... | Recursively render a node's value | [
"Recursively",
"render",
"a",
"node",
"s",
"value"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L120-L154 |
251,287 | heikomuller/sco-client | scocli/experiment.py | ExperimentHandle.create | def create(url, name, subject_id, image_group_id, properties):
"""Create a new experiment using the given SCO-API create experiment Url.
Parameters
----------
url : string
Url to POST experiment create request
name : string
User-defined name for experimen... | python | def create(url, name, subject_id, image_group_id, properties):
"""Create a new experiment using the given SCO-API create experiment Url.
Parameters
----------
url : string
Url to POST experiment create request
name : string
User-defined name for experimen... | [
"def",
"create",
"(",
"url",
",",
"name",
",",
"subject_id",
",",
"image_group_id",
",",
"properties",
")",
":",
"# Create list of key,value-pairs representing experiment properties for",
"# request. The given name overrides the name in properties (if present).",
"obj_props",
"=",
... | Create a new experiment using the given SCO-API create experiment Url.
Parameters
----------
url : string
Url to POST experiment create request
name : string
User-defined name for experiment
subject_id : string
Unique identifier for subject at... | [
"Create",
"a",
"new",
"experiment",
"using",
"the",
"given",
"SCO",
"-",
"API",
"create",
"experiment",
"Url",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/experiment.py#L62-L108 |
251,288 | heikomuller/sco-client | scocli/experiment.py | ExperimentHandle.runs | def runs(self, offset=0, limit=-1, properties=None):
"""Get a list of run descriptors associated with this expriment.
Parameters
----------
offset : int, optional
Starting offset for returned list items
limit : int, optional
Limit the number of items in t... | python | def runs(self, offset=0, limit=-1, properties=None):
"""Get a list of run descriptors associated with this expriment.
Parameters
----------
offset : int, optional
Starting offset for returned list items
limit : int, optional
Limit the number of items in t... | [
"def",
"runs",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"limit",
"=",
"-",
"1",
",",
"properties",
"=",
"None",
")",
":",
"return",
"get_run_listing",
"(",
"self",
".",
"runs_url",
",",
"offset",
"=",
"offset",
",",
"limit",
"=",
"limit",
",",
"p... | Get a list of run descriptors associated with this expriment.
Parameters
----------
offset : int, optional
Starting offset for returned list items
limit : int, optional
Limit the number of items in the result
properties : List(string)
List of ... | [
"Get",
"a",
"list",
"of",
"run",
"descriptors",
"associated",
"with",
"this",
"expriment",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/experiment.py#L163-L186 |
251,289 | hweickert/itermate | itermate/__init__.py | imapchain | def imapchain(*a, **kwa):
""" Like map but also chains the results. """
imap_results = map( *a, **kwa )
return itertools.chain( *imap_results ) | python | def imapchain(*a, **kwa):
""" Like map but also chains the results. """
imap_results = map( *a, **kwa )
return itertools.chain( *imap_results ) | [
"def",
"imapchain",
"(",
"*",
"a",
",",
"*",
"*",
"kwa",
")",
":",
"imap_results",
"=",
"map",
"(",
"*",
"a",
",",
"*",
"*",
"kwa",
")",
"return",
"itertools",
".",
"chain",
"(",
"*",
"imap_results",
")"
] | Like map but also chains the results. | [
"Like",
"map",
"but",
"also",
"chains",
"the",
"results",
"."
] | 501cb4c31c6435b2f99703eb516aca2886d513b6 | https://github.com/hweickert/itermate/blob/501cb4c31c6435b2f99703eb516aca2886d513b6/itermate/__init__.py#L13-L17 |
251,290 | hweickert/itermate | itermate/__init__.py | iskip | def iskip( value, iterable ):
""" Skips all values in 'iterable' matching the given 'value'. """
for e in iterable:
if value is None:
if e is None:
continue
elif e == value:
continue
yield e | python | def iskip( value, iterable ):
""" Skips all values in 'iterable' matching the given 'value'. """
for e in iterable:
if value is None:
if e is None:
continue
elif e == value:
continue
yield e | [
"def",
"iskip",
"(",
"value",
",",
"iterable",
")",
":",
"for",
"e",
"in",
"iterable",
":",
"if",
"value",
"is",
"None",
":",
"if",
"e",
"is",
"None",
":",
"continue",
"elif",
"e",
"==",
"value",
":",
"continue",
"yield",
"e"
] | Skips all values in 'iterable' matching the given 'value'. | [
"Skips",
"all",
"values",
"in",
"iterable",
"matching",
"the",
"given",
"value",
"."
] | 501cb4c31c6435b2f99703eb516aca2886d513b6 | https://github.com/hweickert/itermate/blob/501cb4c31c6435b2f99703eb516aca2886d513b6/itermate/__init__.py#L33-L42 |
251,291 | rorr73/LifeSOSpy | lifesospy/command.py | Command.format | def format(self, password: str = '') -> str:
"""Format command along with any arguments, ready to be sent."""
return MARKER_START + \
self.name + \
self.action + \
self.args + \
password + \
MARKER_END | python | def format(self, password: str = '') -> str:
"""Format command along with any arguments, ready to be sent."""
return MARKER_START + \
self.name + \
self.action + \
self.args + \
password + \
MARKER_END | [
"def",
"format",
"(",
"self",
",",
"password",
":",
"str",
"=",
"''",
")",
"->",
"str",
":",
"return",
"MARKER_START",
"+",
"self",
".",
"name",
"+",
"self",
".",
"action",
"+",
"self",
".",
"args",
"+",
"password",
"+",
"MARKER_END"
] | Format command along with any arguments, ready to be sent. | [
"Format",
"command",
"along",
"with",
"any",
"arguments",
"ready",
"to",
"be",
"sent",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/command.py#L38-L45 |
251,292 | rackerlabs/silverberg | scripts/python-lint.py | lint | def lint(to_lint):
"""
Run all linters against a list of files.
:param to_lint: a list of files to lint.
"""
exit_code = 0
for linter, options in (('pyflakes', []), ('pep8', [])):
try:
output = local[linter](*(options + to_lint))
except commands.ProcessExecutionErro... | python | def lint(to_lint):
"""
Run all linters against a list of files.
:param to_lint: a list of files to lint.
"""
exit_code = 0
for linter, options in (('pyflakes', []), ('pep8', [])):
try:
output = local[linter](*(options + to_lint))
except commands.ProcessExecutionErro... | [
"def",
"lint",
"(",
"to_lint",
")",
":",
"exit_code",
"=",
"0",
"for",
"linter",
",",
"options",
"in",
"(",
"(",
"'pyflakes'",
",",
"[",
"]",
")",
",",
"(",
"'pep8'",
",",
"[",
"]",
")",
")",
":",
"try",
":",
"output",
"=",
"local",
"[",
"linte... | Run all linters against a list of files.
:param to_lint: a list of files to lint. | [
"Run",
"all",
"linters",
"against",
"a",
"list",
"of",
"files",
"."
] | c6fae78923a019f1615e9516ab30fa105c72a542 | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/scripts/python-lint.py#L24-L49 |
251,293 | rackerlabs/silverberg | scripts/python-lint.py | hacked_pep257 | def hacked_pep257(to_lint):
"""
Check for the presence of docstrings, but ignore some of the options
"""
def ignore(*args, **kwargs):
pass
pep257.check_blank_before_after_class = ignore
pep257.check_blank_after_last_paragraph = ignore
pep257.check_blank_after_summary = ignore
pe... | python | def hacked_pep257(to_lint):
"""
Check for the presence of docstrings, but ignore some of the options
"""
def ignore(*args, **kwargs):
pass
pep257.check_blank_before_after_class = ignore
pep257.check_blank_after_last_paragraph = ignore
pep257.check_blank_after_summary = ignore
pe... | [
"def",
"hacked_pep257",
"(",
"to_lint",
")",
":",
"def",
"ignore",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pass",
"pep257",
".",
"check_blank_before_after_class",
"=",
"ignore",
"pep257",
".",
"check_blank_after_last_paragraph",
"=",
"ignore",
"p... | Check for the presence of docstrings, but ignore some of the options | [
"Check",
"for",
"the",
"presence",
"of",
"docstrings",
"but",
"ignore",
"some",
"of",
"the",
"options"
] | c6fae78923a019f1615e9516ab30fa105c72a542 | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/scripts/python-lint.py#L52-L84 |
251,294 | rackerlabs/silverberg | scripts/python-lint.py | Lint.main | def main(self, *directories):
"""
The actual logic that runs the linters
"""
if not self.git and len(directories) == 0:
print ("ERROR: At least one directory must be provided (or the "
"--git-precommit flag must be passed.\n")
self.help()
... | python | def main(self, *directories):
"""
The actual logic that runs the linters
"""
if not self.git and len(directories) == 0:
print ("ERROR: At least one directory must be provided (or the "
"--git-precommit flag must be passed.\n")
self.help()
... | [
"def",
"main",
"(",
"self",
",",
"*",
"directories",
")",
":",
"if",
"not",
"self",
".",
"git",
"and",
"len",
"(",
"directories",
")",
"==",
"0",
":",
"print",
"(",
"\"ERROR: At least one directory must be provided (or the \"",
"\"--git-precommit flag must be passed... | The actual logic that runs the linters | [
"The",
"actual",
"logic",
"that",
"runs",
"the",
"linters"
] | c6fae78923a019f1615e9516ab30fa105c72a542 | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/scripts/python-lint.py#L97-L133 |
251,295 | 20tab/twentytab-tree | tree/template_context/context_processors.py | set_meta | def set_meta(request):
"""
This context processor returns meta informations contained in cached files.
If there aren't cache it calculates dictionary to return
"""
context_extras = {}
if not request.is_ajax() and hasattr(request, 'upy_context') and request.upy_context['PAGE']:
context_e... | python | def set_meta(request):
"""
This context processor returns meta informations contained in cached files.
If there aren't cache it calculates dictionary to return
"""
context_extras = {}
if not request.is_ajax() and hasattr(request, 'upy_context') and request.upy_context['PAGE']:
context_e... | [
"def",
"set_meta",
"(",
"request",
")",
":",
"context_extras",
"=",
"{",
"}",
"if",
"not",
"request",
".",
"is_ajax",
"(",
")",
"and",
"hasattr",
"(",
"request",
",",
"'upy_context'",
")",
"and",
"request",
".",
"upy_context",
"[",
"'PAGE'",
"]",
":",
... | This context processor returns meta informations contained in cached files.
If there aren't cache it calculates dictionary to return | [
"This",
"context",
"processor",
"returns",
"meta",
"informations",
"contained",
"in",
"cached",
"files",
".",
"If",
"there",
"aren",
"t",
"cache",
"it",
"calculates",
"dictionary",
"to",
"return"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/template_context/context_processors.py#L1-L10 |
251,296 | necrolyte2/bootstrap_vi | bootstrap_vi.py | download_virtualenv | def download_virtualenv(version, dldir=None):
'''
Download virtualenv package from pypi and return response that can be
read and written to file
:param str version: version to download or latest version if None
:param str dldir: directory to download into or None for cwd
'''
dl_url = PYPI_D... | python | def download_virtualenv(version, dldir=None):
'''
Download virtualenv package from pypi and return response that can be
read and written to file
:param str version: version to download or latest version if None
:param str dldir: directory to download into or None for cwd
'''
dl_url = PYPI_D... | [
"def",
"download_virtualenv",
"(",
"version",
",",
"dldir",
"=",
"None",
")",
":",
"dl_url",
"=",
"PYPI_DL_URL",
".",
"format",
"(",
"VER",
"=",
"version",
")",
"filename",
"=",
"basename",
"(",
"dl_url",
")",
"if",
"dldir",
":",
"dl_path",
"=",
"join",
... | Download virtualenv package from pypi and return response that can be
read and written to file
:param str version: version to download or latest version if None
:param str dldir: directory to download into or None for cwd | [
"Download",
"virtualenv",
"package",
"from",
"pypi",
"and",
"return",
"response",
"that",
"can",
"be",
"read",
"and",
"written",
"to",
"file"
] | cde96df76ecea1850cd26c2234ac13b3420d64dd | https://github.com/necrolyte2/bootstrap_vi/blob/cde96df76ecea1850cd26c2234ac13b3420d64dd/bootstrap_vi.py#L74-L91 |
251,297 | necrolyte2/bootstrap_vi | bootstrap_vi.py | create_virtualenv | def create_virtualenv(venvpath, venvargs=None):
'''
Run virtualenv from downloaded venvpath using venvargs
If venvargs is None, then 'venv' will be used as the virtualenv directory
:param str venvpath: Path to root downloaded virtualenv package(must contain
virtualenv.py)
:param list venvar... | python | def create_virtualenv(venvpath, venvargs=None):
'''
Run virtualenv from downloaded venvpath using venvargs
If venvargs is None, then 'venv' will be used as the virtualenv directory
:param str venvpath: Path to root downloaded virtualenv package(must contain
virtualenv.py)
:param list venvar... | [
"def",
"create_virtualenv",
"(",
"venvpath",
",",
"venvargs",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"join",
"(",
"venvpath",
",",
"'virtualenv.py'",
")",
"]",
"venv_path",
"=",
"None",
"if",
"venvargs",
":",
"cmd",
"+=",
"venvargs",
"venv_path",
"=",
"... | Run virtualenv from downloaded venvpath using venvargs
If venvargs is None, then 'venv' will be used as the virtualenv directory
:param str venvpath: Path to root downloaded virtualenv package(must contain
virtualenv.py)
:param list venvargs: Virtualenv arguments to pass to virtualenv.py | [
"Run",
"virtualenv",
"from",
"downloaded",
"venvpath",
"using",
"venvargs",
"If",
"venvargs",
"is",
"None",
"then",
"venv",
"will",
"be",
"used",
"as",
"the",
"virtualenv",
"directory"
] | cde96df76ecea1850cd26c2234ac13b3420d64dd | https://github.com/necrolyte2/bootstrap_vi/blob/cde96df76ecea1850cd26c2234ac13b3420d64dd/bootstrap_vi.py#L93-L110 |
251,298 | necrolyte2/bootstrap_vi | bootstrap_vi.py | bootstrap_vi | def bootstrap_vi(version=None, venvargs=None):
'''
Bootstrap virtualenv into current directory
:param str version: Virtualenv version like 13.1.0 or None for latest version
:param list venvargs: argv list for virtualenv.py or None for default
'''
if not version:
version = get_latest_vir... | python | def bootstrap_vi(version=None, venvargs=None):
'''
Bootstrap virtualenv into current directory
:param str version: Virtualenv version like 13.1.0 or None for latest version
:param list venvargs: argv list for virtualenv.py or None for default
'''
if not version:
version = get_latest_vir... | [
"def",
"bootstrap_vi",
"(",
"version",
"=",
"None",
",",
"venvargs",
"=",
"None",
")",
":",
"if",
"not",
"version",
":",
"version",
"=",
"get_latest_virtualenv_version",
"(",
")",
"tarball",
"=",
"download_virtualenv",
"(",
"version",
")",
"p",
"=",
"subproc... | Bootstrap virtualenv into current directory
:param str version: Virtualenv version like 13.1.0 or None for latest version
:param list venvargs: argv list for virtualenv.py or None for default | [
"Bootstrap",
"virtualenv",
"into",
"current",
"directory"
] | cde96df76ecea1850cd26c2234ac13b3420d64dd | https://github.com/necrolyte2/bootstrap_vi/blob/cde96df76ecea1850cd26c2234ac13b3420d64dd/bootstrap_vi.py#L112-L125 |
251,299 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/web_tools.py | compose_path | def compose_path(pub, uuid_url=False):
"""
Compose absolute path for given `pub`.
Args:
pub (obj): :class:`.DBPublication` instance.
uuid_url (bool, default False): Compose URL using UUID.
Returns:
str: Absolute url-path of the publication, without server's address \
... | python | def compose_path(pub, uuid_url=False):
"""
Compose absolute path for given `pub`.
Args:
pub (obj): :class:`.DBPublication` instance.
uuid_url (bool, default False): Compose URL using UUID.
Returns:
str: Absolute url-path of the publication, without server's address \
... | [
"def",
"compose_path",
"(",
"pub",
",",
"uuid_url",
"=",
"False",
")",
":",
"if",
"uuid_url",
":",
"return",
"join",
"(",
"\"/\"",
",",
"UUID_DOWNLOAD_KEY",
",",
"str",
"(",
"pub",
".",
"uuid",
")",
")",
"return",
"join",
"(",
"\"/\"",
",",
"DOWNLOAD_K... | Compose absolute path for given `pub`.
Args:
pub (obj): :class:`.DBPublication` instance.
uuid_url (bool, default False): Compose URL using UUID.
Returns:
str: Absolute url-path of the publication, without server's address \
and protocol.
Raises:
PrivatePublic... | [
"Compose",
"absolute",
"path",
"for",
"given",
"pub",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/web_tools.py#L31-L58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.