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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,200 | opereto/pyopereto | pyopereto/client.py | OperetoClient.get_process_log | def get_process_log(self, pid=None, start=0, limit=1000):
'''
get_process_log(self, pid=None, start=0, limit=1000
Get process logs
:Parameters:
* *pid* (`string`) -- Identifier of an existing process
* *pid* (`string`) -- start index to retrieve logs from
* *pid... | python | def get_process_log(self, pid=None, start=0, limit=1000):
'''
get_process_log(self, pid=None, start=0, limit=1000
Get process logs
:Parameters:
* *pid* (`string`) -- Identifier of an existing process
* *pid* (`string`) -- start index to retrieve logs from
* *pid... | [
"def",
"get_process_log",
"(",
"self",
",",
"pid",
"=",
"None",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"1000",
")",
":",
"pid",
"=",
"self",
".",
"_get_pid",
"(",
"pid",
")",
"data",
"=",
"self",
".",
"_call_rest_api",
"(",
"'get'",
",",
"'/pro... | get_process_log(self, pid=None, start=0, limit=1000
Get process logs
:Parameters:
* *pid* (`string`) -- Identifier of an existing process
* *pid* (`string`) -- start index to retrieve logs from
* *pid* (`string`) -- maximum number of entities to retrieve
:return: Proce... | [
"get_process_log",
"(",
"self",
"pid",
"=",
"None",
"start",
"=",
"0",
"limit",
"=",
"1000"
] | 16ca987738a7e1b82b52b0b099794a74ed557223 | https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L1178-L1194 |
39,201 | standage/tag | tag/writer.py | GFF3Writer.write | def write(self):
"""Pull features from the instream and write them to the output."""
for entry in self._instream:
if isinstance(entry, Feature):
for feature in entry:
if feature.num_children > 0 or feature.is_multi:
if feature.is_mu... | python | def write(self):
"""Pull features from the instream and write them to the output."""
for entry in self._instream:
if isinstance(entry, Feature):
for feature in entry:
if feature.num_children > 0 or feature.is_multi:
if feature.is_mu... | [
"def",
"write",
"(",
"self",
")",
":",
"for",
"entry",
"in",
"self",
".",
"_instream",
":",
"if",
"isinstance",
"(",
"entry",
",",
"Feature",
")",
":",
"for",
"feature",
"in",
"entry",
":",
"if",
"feature",
".",
"num_children",
">",
"0",
"or",
"featu... | Pull features from the instream and write them to the output. | [
"Pull",
"features",
"from",
"the",
"instream",
"and",
"write",
"them",
"to",
"the",
"output",
"."
] | 94686adf57115cea1c5235e99299e691f80ba10b | https://github.com/standage/tag/blob/94686adf57115cea1c5235e99299e691f80ba10b/tag/writer.py#L55-L72 |
39,202 | scivision/sciencedates | sciencedates/__init__.py | date2doy | def date2doy(time: Union[str, datetime.datetime]) -> Tuple[int, int]:
"""
< 366 for leap year too. normal year 0..364. Leap 0..365.
"""
T = np.atleast_1d(time)
year = np.empty(T.size, dtype=int)
doy = np.empty_like(year)
for i, t in enumerate(T):
yd = str(datetime2yeardoy(t)[0])
... | python | def date2doy(time: Union[str, datetime.datetime]) -> Tuple[int, int]:
"""
< 366 for leap year too. normal year 0..364. Leap 0..365.
"""
T = np.atleast_1d(time)
year = np.empty(T.size, dtype=int)
doy = np.empty_like(year)
for i, t in enumerate(T):
yd = str(datetime2yeardoy(t)[0])
... | [
"def",
"date2doy",
"(",
"time",
":",
"Union",
"[",
"str",
",",
"datetime",
".",
"datetime",
"]",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"T",
"=",
"np",
".",
"atleast_1d",
"(",
"time",
")",
"year",
"=",
"np",
".",
"empty",
"(",
"T... | < 366 for leap year too. normal year 0..364. Leap 0..365. | [
"<",
"366",
"for",
"leap",
"year",
"too",
".",
"normal",
"year",
"0",
"..",
"364",
".",
"Leap",
"0",
"..",
"365",
"."
] | a713389e027b42d26875cf227450a5d7c6696000 | https://github.com/scivision/sciencedates/blob/a713389e027b42d26875cf227450a5d7c6696000/sciencedates/__init__.py#L75-L93 |
39,203 | scivision/sciencedates | sciencedates/__init__.py | randomdate | def randomdate(year: int) -> datetime.date:
""" gives random date in year"""
if calendar.isleap(year):
doy = random.randrange(366)
else:
doy = random.randrange(365)
return datetime.date(year, 1, 1) + datetime.timedelta(days=doy) | python | def randomdate(year: int) -> datetime.date:
""" gives random date in year"""
if calendar.isleap(year):
doy = random.randrange(366)
else:
doy = random.randrange(365)
return datetime.date(year, 1, 1) + datetime.timedelta(days=doy) | [
"def",
"randomdate",
"(",
"year",
":",
"int",
")",
"->",
"datetime",
".",
"date",
":",
"if",
"calendar",
".",
"isleap",
"(",
"year",
")",
":",
"doy",
"=",
"random",
".",
"randrange",
"(",
"366",
")",
"else",
":",
"doy",
"=",
"random",
".",
"randran... | gives random date in year | [
"gives",
"random",
"date",
"in",
"year"
] | a713389e027b42d26875cf227450a5d7c6696000 | https://github.com/scivision/sciencedates/blob/a713389e027b42d26875cf227450a5d7c6696000/sciencedates/__init__.py#L210-L217 |
39,204 | iskandr/serializable | serializable/helpers.py | function_to_serializable_representation | def function_to_serializable_representation(fn):
"""
Converts a Python function into a serializable representation. Does not
currently work for methods or functions with closure data.
"""
if type(fn) not in (FunctionType, BuiltinFunctionType):
raise ValueError(
"Can't serialize %... | python | def function_to_serializable_representation(fn):
"""
Converts a Python function into a serializable representation. Does not
currently work for methods or functions with closure data.
"""
if type(fn) not in (FunctionType, BuiltinFunctionType):
raise ValueError(
"Can't serialize %... | [
"def",
"function_to_serializable_representation",
"(",
"fn",
")",
":",
"if",
"type",
"(",
"fn",
")",
"not",
"in",
"(",
"FunctionType",
",",
"BuiltinFunctionType",
")",
":",
"raise",
"ValueError",
"(",
"\"Can't serialize %s : %s, must be globally defined function\"",
"%"... | Converts a Python function into a serializable representation. Does not
currently work for methods or functions with closure data. | [
"Converts",
"a",
"Python",
"function",
"into",
"a",
"serializable",
"representation",
".",
"Does",
"not",
"currently",
"work",
"for",
"methods",
"or",
"functions",
"with",
"closure",
"data",
"."
] | 6807dfd582567b3bda609910806b7429d8d53b44 | https://github.com/iskandr/serializable/blob/6807dfd582567b3bda609910806b7429d8d53b44/serializable/helpers.py#L120-L133 |
39,205 | iskandr/serializable | serializable/helpers.py | from_serializable_dict | def from_serializable_dict(x):
"""
Reconstruct a dictionary by recursively reconstructing all its keys and
values.
This is the most hackish part since we rely on key names such as
__name__, __class__, __module__ as metadata about how to reconstruct
an object.
TODO: It would be cleaner to a... | python | def from_serializable_dict(x):
"""
Reconstruct a dictionary by recursively reconstructing all its keys and
values.
This is the most hackish part since we rely on key names such as
__name__, __class__, __module__ as metadata about how to reconstruct
an object.
TODO: It would be cleaner to a... | [
"def",
"from_serializable_dict",
"(",
"x",
")",
":",
"if",
"\"__name__\"",
"in",
"x",
":",
"return",
"_lookup_value",
"(",
"x",
".",
"pop",
"(",
"\"__module__\"",
")",
",",
"x",
".",
"pop",
"(",
"\"__name__\"",
")",
")",
"non_string_key_objects",
"=",
"[",... | Reconstruct a dictionary by recursively reconstructing all its keys and
values.
This is the most hackish part since we rely on key names such as
__name__, __class__, __module__ as metadata about how to reconstruct
an object.
TODO: It would be cleaner to always wrap each object in a layer of type
... | [
"Reconstruct",
"a",
"dictionary",
"by",
"recursively",
"reconstructing",
"all",
"its",
"keys",
"and",
"values",
"."
] | 6807dfd582567b3bda609910806b7429d8d53b44 | https://github.com/iskandr/serializable/blob/6807dfd582567b3bda609910806b7429d8d53b44/serializable/helpers.py#L188-L224 |
39,206 | iskandr/serializable | serializable/helpers.py | to_serializable_repr | def to_serializable_repr(x):
"""
Convert an instance of Serializable or a primitive collection containing
such instances into serializable types.
"""
t = type(x)
if isinstance(x, list):
return list_to_serializable_repr(x)
elif t in (set, tuple):
return {
"__class_... | python | def to_serializable_repr(x):
"""
Convert an instance of Serializable or a primitive collection containing
such instances into serializable types.
"""
t = type(x)
if isinstance(x, list):
return list_to_serializable_repr(x)
elif t in (set, tuple):
return {
"__class_... | [
"def",
"to_serializable_repr",
"(",
"x",
")",
":",
"t",
"=",
"type",
"(",
"x",
")",
"if",
"isinstance",
"(",
"x",
",",
"list",
")",
":",
"return",
"list_to_serializable_repr",
"(",
"x",
")",
"elif",
"t",
"in",
"(",
"set",
",",
"tuple",
")",
":",
"r... | Convert an instance of Serializable or a primitive collection containing
such instances into serializable types. | [
"Convert",
"an",
"instance",
"of",
"Serializable",
"or",
"a",
"primitive",
"collection",
"containing",
"such",
"instances",
"into",
"serializable",
"types",
"."
] | 6807dfd582567b3bda609910806b7429d8d53b44 | https://github.com/iskandr/serializable/blob/6807dfd582567b3bda609910806b7429d8d53b44/serializable/helpers.py#L247-L270 |
39,207 | GeorgeArgyros/symautomata | symautomata/pdastring.py | PdaString._combine_rest_push | def _combine_rest_push(self):
"""Combining Rest and Push States"""
new = []
change = 0
# DEBUG
# logging.debug('Combining Rest and Push')
i = 0
examinetypes = self.quickresponse_types[3]
for state in examinetypes:
if state.type == 3:
... | python | def _combine_rest_push(self):
"""Combining Rest and Push States"""
new = []
change = 0
# DEBUG
# logging.debug('Combining Rest and Push')
i = 0
examinetypes = self.quickresponse_types[3]
for state in examinetypes:
if state.type == 3:
... | [
"def",
"_combine_rest_push",
"(",
"self",
")",
":",
"new",
"=",
"[",
"]",
"change",
"=",
"0",
"# DEBUG",
"# logging.debug('Combining Rest and Push')",
"i",
"=",
"0",
"examinetypes",
"=",
"self",
".",
"quickresponse_types",
"[",
"3",
"]",
"for",
"state",
"in",
... | Combining Rest and Push States | [
"Combining",
"Rest",
"and",
"Push",
"States"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdastring.py#L18-L82 |
39,208 | GeorgeArgyros/symautomata | symautomata/pdastring.py | PdaString._check | def _check(self, accepted):
"""_check for string existence"""
# logging.debug('A check is now happening...')
# for key in self.statediag[1].trans:
# logging.debug('transition to '+`key`+" with "+self.statediag[1].trans[key][0])
total = []
if 1 in self.quickresponse:
... | python | def _check(self, accepted):
"""_check for string existence"""
# logging.debug('A check is now happening...')
# for key in self.statediag[1].trans:
# logging.debug('transition to '+`key`+" with "+self.statediag[1].trans[key][0])
total = []
if 1 in self.quickresponse:
... | [
"def",
"_check",
"(",
"self",
",",
"accepted",
")",
":",
"# logging.debug('A check is now happening...')",
"# for key in self.statediag[1].trans:",
"# logging.debug('transition to '+`key`+\" with \"+self.statediag[1].trans[key][0])",
"total",
"=",
"[",
"]",
"if",
"1",
"in",
"s... | _check for string existence | [
"_check",
"for",
"string",
"existence"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdastring.py#L414-L435 |
39,209 | GeorgeArgyros/symautomata | symautomata/pdastring.py | PdaString._stage | def _stage(self, accepted, count=0):
"""This is a repeated state in the state removal algorithm"""
new5 = self._combine_rest_push()
new1 = self._combine_push_pop()
new2 = self._combine_push_rest()
new3 = self._combine_pop_rest()
new4 = self._combine_rest_rest()
ne... | python | def _stage(self, accepted, count=0):
"""This is a repeated state in the state removal algorithm"""
new5 = self._combine_rest_push()
new1 = self._combine_push_pop()
new2 = self._combine_push_rest()
new3 = self._combine_pop_rest()
new4 = self._combine_rest_rest()
ne... | [
"def",
"_stage",
"(",
"self",
",",
"accepted",
",",
"count",
"=",
"0",
")",
":",
"new5",
"=",
"self",
".",
"_combine_rest_push",
"(",
")",
"new1",
"=",
"self",
".",
"_combine_push_pop",
"(",
")",
"new2",
"=",
"self",
".",
"_combine_push_rest",
"(",
")"... | This is a repeated state in the state removal algorithm | [
"This",
"is",
"a",
"repeated",
"state",
"in",
"the",
"state",
"removal",
"algorithm"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdastring.py#L437-L501 |
39,210 | GeorgeArgyros/symautomata | symautomata/pdastring.py | PdaString.printer | def printer(self):
"""Visualizes the current state"""
for key in self.statediag:
if key.trans is not None and len(key.trans) > 0:
print '****** ' + repr(key.id) + '(' + repr(key.type)\
+ ' on sym ' + repr(key.sym) + ') ******'
print key.t... | python | def printer(self):
"""Visualizes the current state"""
for key in self.statediag:
if key.trans is not None and len(key.trans) > 0:
print '****** ' + repr(key.id) + '(' + repr(key.type)\
+ ' on sym ' + repr(key.sym) + ') ******'
print key.t... | [
"def",
"printer",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"statediag",
":",
"if",
"key",
".",
"trans",
"is",
"not",
"None",
"and",
"len",
"(",
"key",
".",
"trans",
")",
">",
"0",
":",
"print",
"'****** '",
"+",
"repr",
"(",
"key",... | Visualizes the current state | [
"Visualizes",
"the",
"current",
"state"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdastring.py#L503-L509 |
39,211 | GeorgeArgyros/symautomata | symautomata/pdastring.py | PdaString.init | def init(self, states, accepted):
"""Initialization of the indexing dictionaries"""
self.statediag = []
for key in states:
self.statediag.append(states[key])
self.quickresponse = {}
self.quickresponse_types = {}
self.quickresponse_types[0] = []
self.qu... | python | def init(self, states, accepted):
"""Initialization of the indexing dictionaries"""
self.statediag = []
for key in states:
self.statediag.append(states[key])
self.quickresponse = {}
self.quickresponse_types = {}
self.quickresponse_types[0] = []
self.qu... | [
"def",
"init",
"(",
"self",
",",
"states",
",",
"accepted",
")",
":",
"self",
".",
"statediag",
"=",
"[",
"]",
"for",
"key",
"in",
"states",
":",
"self",
".",
"statediag",
".",
"append",
"(",
"states",
"[",
"key",
"]",
")",
"self",
".",
"quickrespo... | Initialization of the indexing dictionaries | [
"Initialization",
"of",
"the",
"indexing",
"dictionaries"
] | f5d66533573b27e155bec3f36b8c00b8e3937cb3 | https://github.com/GeorgeArgyros/symautomata/blob/f5d66533573b27e155bec3f36b8c00b8e3937cb3/symautomata/pdastring.py#L511-L531 |
39,212 | hollenstein/maspy | maspy_resources/cluster.py | execute | def execute(filelocation, outpath, executable, args=None, switchArgs=None):
"""Executes the dinosaur tool on Windows operating systems.
:param filelocation: either a single mgf file path or a list of file paths.
:param outpath: path of the output file, file must not exist
:param executable: must specif... | python | def execute(filelocation, outpath, executable, args=None, switchArgs=None):
"""Executes the dinosaur tool on Windows operating systems.
:param filelocation: either a single mgf file path or a list of file paths.
:param outpath: path of the output file, file must not exist
:param executable: must specif... | [
"def",
"execute",
"(",
"filelocation",
",",
"outpath",
",",
"executable",
",",
"args",
"=",
"None",
",",
"switchArgs",
"=",
"None",
")",
":",
"procArgs",
"=",
"[",
"'java'",
",",
"'-jar'",
",",
"executable",
"]",
"procArgs",
".",
"extend",
"(",
"[",
"'... | Executes the dinosaur tool on Windows operating systems.
:param filelocation: either a single mgf file path or a list of file paths.
:param outpath: path of the output file, file must not exist
:param executable: must specify the complete file path of the
spectra-cluster-cli.jar file, supported ver... | [
"Executes",
"the",
"dinosaur",
"tool",
"on",
"Windows",
"operating",
"systems",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy_resources/cluster.py#L41-L75 |
39,213 | kevinconway/confpy | confpy/cmd.py | generate_example | def generate_example():
"""Generate a configuration file example.
This utility will load some number of Python modules which are assumed
to register options with confpy and generate an example configuration file
based on those options.
"""
cmd_args = sys.argv[1:]
parser = argparse.ArgumentP... | python | def generate_example():
"""Generate a configuration file example.
This utility will load some number of Python modules which are assumed
to register options with confpy and generate an example configuration file
based on those options.
"""
cmd_args = sys.argv[1:]
parser = argparse.ArgumentP... | [
"def",
"generate_example",
"(",
")",
":",
"cmd_args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Confpy example generator.'",
")",
"parser",
".",
"add_argument",
"(",
"'--module'",
... | Generate a configuration file example.
This utility will load some number of Python modules which are assumed
to register options with confpy and generate an example configuration file
based on those options. | [
"Generate",
"a",
"configuration",
"file",
"example",
"."
] | 1ee8afcab46ac6915a5ff4184180434ac7b84a60 | https://github.com/kevinconway/confpy/blob/1ee8afcab46ac6915a5ff4184180434ac7b84a60/confpy/cmd.py#L16-L54 |
39,214 | diamondman/proteusisc | proteusisc/bittypes.py | CompositeBitarray.count | def count(self, val=True):
"""Get the number of bits in the array with the specified value.
Args:
val: A boolean value to check against the array's value.
Returns:
An integer of the number of bits in the array equal to val.
"""
return sum((elem.count(val... | python | def count(self, val=True):
"""Get the number of bits in the array with the specified value.
Args:
val: A boolean value to check against the array's value.
Returns:
An integer of the number of bits in the array equal to val.
"""
return sum((elem.count(val... | [
"def",
"count",
"(",
"self",
",",
"val",
"=",
"True",
")",
":",
"return",
"sum",
"(",
"(",
"elem",
".",
"count",
"(",
"val",
")",
"for",
"elem",
"in",
"self",
".",
"_iter_components",
"(",
")",
")",
")"
] | Get the number of bits in the array with the specified value.
Args:
val: A boolean value to check against the array's value.
Returns:
An integer of the number of bits in the array equal to val. | [
"Get",
"the",
"number",
"of",
"bits",
"in",
"the",
"array",
"with",
"the",
"specified",
"value",
"."
] | 7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c | https://github.com/diamondman/proteusisc/blob/7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c/proteusisc/bittypes.py#L673-L682 |
39,215 | LeastAuthority/txkube | src/txkube/_memory.py | _api_group_for_type | def _api_group_for_type(cls):
"""
Determine which Kubernetes API group a particular PClass is likely to
belong with.
This is basically nonsense. The question being asked is wrong. An
abstraction has failed somewhere. Fixing that will get rid of the need
for this.
"""
_groups = {
... | python | def _api_group_for_type(cls):
"""
Determine which Kubernetes API group a particular PClass is likely to
belong with.
This is basically nonsense. The question being asked is wrong. An
abstraction has failed somewhere. Fixing that will get rid of the need
for this.
"""
_groups = {
... | [
"def",
"_api_group_for_type",
"(",
"cls",
")",
":",
"_groups",
"=",
"{",
"(",
"u\"v1beta1\"",
",",
"u\"Deployment\"",
")",
":",
"u\"extensions\"",
",",
"(",
"u\"v1beta1\"",
",",
"u\"DeploymentList\"",
")",
":",
"u\"extensions\"",
",",
"(",
"u\"v1beta1\"",
",",
... | Determine which Kubernetes API group a particular PClass is likely to
belong with.
This is basically nonsense. The question being asked is wrong. An
abstraction has failed somewhere. Fixing that will get rid of the need
for this. | [
"Determine",
"which",
"Kubernetes",
"API",
"group",
"a",
"particular",
"PClass",
"is",
"likely",
"to",
"belong",
"with",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_memory.py#L141-L161 |
39,216 | LeastAuthority/txkube | src/txkube/_memory.py | response | def response(request, status, obj):
"""
Generate a response.
:param IRequest request: The request being responsed to.
:param int status: The response status code to set.
:param obj: Something JSON-dumpable to write into the response body.
:return bytes: The response body to write out. eg, ret... | python | def response(request, status, obj):
"""
Generate a response.
:param IRequest request: The request being responsed to.
:param int status: The response status code to set.
:param obj: Something JSON-dumpable to write into the response body.
:return bytes: The response body to write out. eg, ret... | [
"def",
"response",
"(",
"request",
",",
"status",
",",
"obj",
")",
":",
"request",
".",
"setResponseCode",
"(",
"status",
")",
"request",
".",
"responseHeaders",
".",
"setRawHeaders",
"(",
"u\"content-type\"",
",",
"[",
"u\"application/json\"",
"]",
",",
")",
... | Generate a response.
:param IRequest request: The request being responsed to.
:param int status: The response status code to set.
:param obj: Something JSON-dumpable to write into the response body.
:return bytes: The response body to write out. eg, return this from a
*render_* method. | [
"Generate",
"a",
"response",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_memory.py#L384-L400 |
39,217 | LeastAuthority/txkube | src/txkube/_memory.py | _KubernetesState.create | def create(self, collection_name, obj):
"""
Create a new object in the named collection.
:param unicode collection_name: The name of the collection in which to
create the object.
:param IObject obj: A description of the object to create.
:return _KubernetesState: A... | python | def create(self, collection_name, obj):
"""
Create a new object in the named collection.
:param unicode collection_name: The name of the collection in which to
create the object.
:param IObject obj: A description of the object to create.
:return _KubernetesState: A... | [
"def",
"create",
"(",
"self",
",",
"collection_name",
",",
"obj",
")",
":",
"obj",
"=",
"self",
".",
"agency",
".",
"before_create",
"(",
"self",
",",
"obj",
")",
"new",
"=",
"self",
".",
"agency",
".",
"after_create",
"(",
"self",
",",
"obj",
")",
... | Create a new object in the named collection.
:param unicode collection_name: The name of the collection in which to
create the object.
:param IObject obj: A description of the object to create.
:return _KubernetesState: A new state based on the current state but
also c... | [
"Create",
"a",
"new",
"object",
"in",
"the",
"named",
"collection",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_memory.py#L320-L338 |
39,218 | LeastAuthority/txkube | src/txkube/_memory.py | _KubernetesState.replace | def replace(self, collection_name, old, new):
"""
Replace an existing object with a new version of it.
:param unicode collection_name: The name of the collection in which to
replace an object.
:param IObject old: A description of the object being replaced.
:param I... | python | def replace(self, collection_name, old, new):
"""
Replace an existing object with a new version of it.
:param unicode collection_name: The name of the collection in which to
replace an object.
:param IObject old: A description of the object being replaced.
:param I... | [
"def",
"replace",
"(",
"self",
",",
"collection_name",
",",
"old",
",",
"new",
")",
":",
"self",
".",
"agency",
".",
"before_replace",
"(",
"self",
",",
"old",
",",
"new",
")",
"updated",
"=",
"self",
".",
"transform",
"(",
"[",
"collection_name",
"]",... | Replace an existing object with a new version of it.
:param unicode collection_name: The name of the collection in which to
replace an object.
:param IObject old: A description of the object being replaced.
:param IObject new: A description of the object to take the place of
... | [
"Replace",
"an",
"existing",
"object",
"with",
"a",
"new",
"version",
"of",
"it",
"."
] | a7e555d00535ff787d4b1204c264780da40cf736 | https://github.com/LeastAuthority/txkube/blob/a7e555d00535ff787d4b1204c264780da40cf736/src/txkube/_memory.py#L341-L361 |
39,219 | sprockets/sprockets.clients.statsd | sprockets/clients/statsd/__init__.py | execution_timer | def execution_timer(value):
"""The ``execution_timer`` decorator allows for easy instrumentation of
the duration of function calls, using the method name in the key.
The following example would add duration timing with the key ``my_function``
.. code: python
@statsd.execution_timer
de... | python | def execution_timer(value):
"""The ``execution_timer`` decorator allows for easy instrumentation of
the duration of function calls, using the method name in the key.
The following example would add duration timing with the key ``my_function``
.. code: python
@statsd.execution_timer
de... | [
"def",
"execution_timer",
"(",
"value",
")",
":",
"def",
"_invoke",
"(",
"method",
",",
"key_arg_position",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"result",
"=",
"method",
"(",
"*",
"arg... | The ``execution_timer`` decorator allows for easy instrumentation of
the duration of function calls, using the method name in the key.
The following example would add duration timing with the key ``my_function``
.. code: python
@statsd.execution_timer
def my_function(foo):
pas... | [
"The",
"execution_timer",
"decorator",
"allows",
"for",
"easy",
"instrumentation",
"of",
"the",
"duration",
"of",
"function",
"calls",
"using",
"the",
"method",
"name",
"in",
"the",
"key",
"."
] | 34daf6972ebdc5ed1e8fde2ff85b3443b9c04d2c | https://github.com/sprockets/sprockets.clients.statsd/blob/34daf6972ebdc5ed1e8fde2ff85b3443b9c04d2c/sprockets/clients/statsd/__init__.py#L67-L112 |
39,220 | jplusplus/statscraper | statscraper/scrapers/StatistikcentralenScraper.py | Statistikcentralen._get_lang | def _get_lang(self, *args, **kwargs):
""" Let users select language
"""
if "lang" in kwargs:
if kwargs["lang"] in self._available_languages:
self.lang = kwargs["lang"] | python | def _get_lang(self, *args, **kwargs):
""" Let users select language
"""
if "lang" in kwargs:
if kwargs["lang"] in self._available_languages:
self.lang = kwargs["lang"] | [
"def",
"_get_lang",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"lang\"",
"in",
"kwargs",
":",
"if",
"kwargs",
"[",
"\"lang\"",
"]",
"in",
"self",
".",
"_available_languages",
":",
"self",
".",
"lang",
"=",
"kwargs",
"["... | Let users select language | [
"Let",
"users",
"select",
"language"
] | 932ec048b23d15b3dbdaf829facc55fd78ec0109 | https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/scrapers/StatistikcentralenScraper.py#L25-L30 |
39,221 | achiku/hipnotify | hipnotify/hipnotify.py | Room.notify | def notify(self, msg, color='green', notify='true', message_format='text'):
"""Send notification to specified HipChat room"""
self.message_dict = {
'message': msg,
'color': color,
'notify': notify,
'message_format': message_format,
}
if not... | python | def notify(self, msg, color='green', notify='true', message_format='text'):
"""Send notification to specified HipChat room"""
self.message_dict = {
'message': msg,
'color': color,
'notify': notify,
'message_format': message_format,
}
if not... | [
"def",
"notify",
"(",
"self",
",",
"msg",
",",
"color",
"=",
"'green'",
",",
"notify",
"=",
"'true'",
",",
"message_format",
"=",
"'text'",
")",
":",
"self",
".",
"message_dict",
"=",
"{",
"'message'",
":",
"msg",
",",
"'color'",
":",
"color",
",",
"... | Send notification to specified HipChat room | [
"Send",
"notification",
"to",
"specified",
"HipChat",
"room"
] | 749f5dba25c8a5a9f9d8318b720671be3e6dd7ac | https://github.com/achiku/hipnotify/blob/749f5dba25c8a5a9f9d8318b720671be3e6dd7ac/hipnotify/hipnotify.py#L24-L40 |
39,222 | sporsh/carnifex | fabfile.py | trial | def trial(path=TESTS_PATH, coverage=False):
"""Run tests using trial
"""
args = ['trial']
if coverage:
args.append('--coverage')
args.append(path)
print args
local(' '.join(args)) | python | def trial(path=TESTS_PATH, coverage=False):
"""Run tests using trial
"""
args = ['trial']
if coverage:
args.append('--coverage')
args.append(path)
print args
local(' '.join(args)) | [
"def",
"trial",
"(",
"path",
"=",
"TESTS_PATH",
",",
"coverage",
"=",
"False",
")",
":",
"args",
"=",
"[",
"'trial'",
"]",
"if",
"coverage",
":",
"args",
".",
"append",
"(",
"'--coverage'",
")",
"args",
".",
"append",
"(",
"path",
")",
"print",
"args... | Run tests using trial | [
"Run",
"tests",
"using",
"trial"
] | 82dd3bd2bc134dfb69a78f43171e227f2127060b | https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/fabfile.py#L22-L30 |
39,223 | Equitable/trump | trump/tools/reprobj.py | ReprObjType.process_result_value | def process_result_value(self, value, dialect):
"""
When SQLAlchemy gets the string representation from a ReprObjType
column, it converts it to the python equivalent via exec.
"""
if value is not None:
cmd = "value = {}".format(value)
exec(cmd)
ret... | python | def process_result_value(self, value, dialect):
"""
When SQLAlchemy gets the string representation from a ReprObjType
column, it converts it to the python equivalent via exec.
"""
if value is not None:
cmd = "value = {}".format(value)
exec(cmd)
ret... | [
"def",
"process_result_value",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"cmd",
"=",
"\"value = {}\"",
".",
"format",
"(",
"value",
")",
"exec",
"(",
"cmd",
")",
"return",
"value"
] | When SQLAlchemy gets the string representation from a ReprObjType
column, it converts it to the python equivalent via exec. | [
"When",
"SQLAlchemy",
"gets",
"the",
"string",
"representation",
"from",
"a",
"ReprObjType",
"column",
"it",
"converts",
"it",
"to",
"the",
"python",
"equivalent",
"via",
"exec",
"."
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/tools/reprobj.py#L43-L51 |
39,224 | Cadasta/django-tutelary | tutelary/engine.py | make_regex | def make_regex(separator):
"""Utility function to create regexp for matching escaped separators
in strings.
"""
return re.compile(r'(?:' + re.escape(separator) + r')?((?:[^' +
re.escape(separator) + r'\\]|\\.)+)') | python | def make_regex(separator):
"""Utility function to create regexp for matching escaped separators
in strings.
"""
return re.compile(r'(?:' + re.escape(separator) + r')?((?:[^' +
re.escape(separator) + r'\\]|\\.)+)') | [
"def",
"make_regex",
"(",
"separator",
")",
":",
"return",
"re",
".",
"compile",
"(",
"r'(?:'",
"+",
"re",
".",
"escape",
"(",
"separator",
")",
"+",
"r')?((?:[^'",
"+",
"re",
".",
"escape",
"(",
"separator",
")",
"+",
"r'\\\\]|\\\\.)+)'",
")"
] | Utility function to create regexp for matching escaped separators
in strings. | [
"Utility",
"function",
"to",
"create",
"regexp",
"for",
"matching",
"escaped",
"separators",
"in",
"strings",
"."
] | 66bb05de7098777c0a383410c287bf48433cde87 | https://github.com/Cadasta/django-tutelary/blob/66bb05de7098777c0a383410c287bf48433cde87/tutelary/engine.py#L309-L315 |
39,225 | Cadasta/django-tutelary | tutelary/engine.py | strip_comments | def strip_comments(text):
"""Comment stripper for JSON.
"""
regex = r'\s*(#|\/{2}).*$'
regex_inline = r'(:?(?:\s)*([A-Za-z\d\.{}]*)|((?<=\").*\"),?)(?:\s)*(((#|(\/{2})).*)|)$' # noqa
lines = text.split('\n')
for index, line in enumerate(lines):
if re.search(regex, line):
i... | python | def strip_comments(text):
"""Comment stripper for JSON.
"""
regex = r'\s*(#|\/{2}).*$'
regex_inline = r'(:?(?:\s)*([A-Za-z\d\.{}]*)|((?<=\").*\"),?)(?:\s)*(((#|(\/{2})).*)|)$' # noqa
lines = text.split('\n')
for index, line in enumerate(lines):
if re.search(regex, line):
i... | [
"def",
"strip_comments",
"(",
"text",
")",
":",
"regex",
"=",
"r'\\s*(#|\\/{2}).*$'",
"regex_inline",
"=",
"r'(:?(?:\\s)*([A-Za-z\\d\\.{}]*)|((?<=\\\").*\\\"),?)(?:\\s)*(((#|(\\/{2})).*)|)$'",
"# noqa",
"lines",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
"for",
"index"... | Comment stripper for JSON. | [
"Comment",
"stripper",
"for",
"JSON",
"."
] | 66bb05de7098777c0a383410c287bf48433cde87 | https://github.com/Cadasta/django-tutelary/blob/66bb05de7098777c0a383410c287bf48433cde87/tutelary/engine.py#L332-L347 |
39,226 | Cadasta/django-tutelary | tutelary/engine.py | Action.register | def register(action):
"""Action registration is used to support generating lists of
permitted actions from a permission set and an object pattern.
Only registered actions will be returned by such queries.
"""
if isinstance(action, str):
Action.register(Action(action)... | python | def register(action):
"""Action registration is used to support generating lists of
permitted actions from a permission set and an object pattern.
Only registered actions will be returned by such queries.
"""
if isinstance(action, str):
Action.register(Action(action)... | [
"def",
"register",
"(",
"action",
")",
":",
"if",
"isinstance",
"(",
"action",
",",
"str",
")",
":",
"Action",
".",
"register",
"(",
"Action",
"(",
"action",
")",
")",
"elif",
"isinstance",
"(",
"action",
",",
"Action",
")",
":",
"Action",
".",
"regi... | Action registration is used to support generating lists of
permitted actions from a permission set and an object pattern.
Only registered actions will be returned by such queries. | [
"Action",
"registration",
"is",
"used",
"to",
"support",
"generating",
"lists",
"of",
"permitted",
"actions",
"from",
"a",
"permission",
"set",
"and",
"an",
"object",
"pattern",
".",
"Only",
"registered",
"actions",
"will",
"be",
"returned",
"by",
"such",
"que... | 66bb05de7098777c0a383410c287bf48433cde87 | https://github.com/Cadasta/django-tutelary/blob/66bb05de7098777c0a383410c287bf48433cde87/tutelary/engine.py#L108-L120 |
39,227 | Cadasta/django-tutelary | tutelary/engine.py | PermissionTree.allow | def allow(self, act, obj=None):
"""Determine where a given action on a given object is allowed.
"""
objc = obj.components if obj is not None else []
try:
return self.tree[act.components + objc] == 'allow'
except KeyError:
return False | python | def allow(self, act, obj=None):
"""Determine where a given action on a given object is allowed.
"""
objc = obj.components if obj is not None else []
try:
return self.tree[act.components + objc] == 'allow'
except KeyError:
return False | [
"def",
"allow",
"(",
"self",
",",
"act",
",",
"obj",
"=",
"None",
")",
":",
"objc",
"=",
"obj",
".",
"components",
"if",
"obj",
"is",
"not",
"None",
"else",
"[",
"]",
"try",
":",
"return",
"self",
".",
"tree",
"[",
"act",
".",
"components",
"+",
... | Determine where a given action on a given object is allowed. | [
"Determine",
"where",
"a",
"given",
"action",
"on",
"a",
"given",
"object",
"is",
"allowed",
"."
] | 66bb05de7098777c0a383410c287bf48433cde87 | https://github.com/Cadasta/django-tutelary/blob/66bb05de7098777c0a383410c287bf48433cde87/tutelary/engine.py#L286-L294 |
39,228 | Cadasta/django-tutelary | tutelary/engine.py | PermissionTree.permitted_actions | def permitted_actions(self, obj=None):
"""Determine permitted actions for a given object pattern.
"""
return [a for a in Action.registered
if self.allow(a, obj(str(a)) if obj is not None else None)] | python | def permitted_actions(self, obj=None):
"""Determine permitted actions for a given object pattern.
"""
return [a for a in Action.registered
if self.allow(a, obj(str(a)) if obj is not None else None)] | [
"def",
"permitted_actions",
"(",
"self",
",",
"obj",
"=",
"None",
")",
":",
"return",
"[",
"a",
"for",
"a",
"in",
"Action",
".",
"registered",
"if",
"self",
".",
"allow",
"(",
"a",
",",
"obj",
"(",
"str",
"(",
"a",
")",
")",
"if",
"obj",
"is",
... | Determine permitted actions for a given object pattern. | [
"Determine",
"permitted",
"actions",
"for",
"a",
"given",
"object",
"pattern",
"."
] | 66bb05de7098777c0a383410c287bf48433cde87 | https://github.com/Cadasta/django-tutelary/blob/66bb05de7098777c0a383410c287bf48433cde87/tutelary/engine.py#L296-L301 |
39,229 | debugloop/saltobserver | saltobserver/websockets.py | subscribe | def subscribe(ws):
"""WebSocket endpoint, used for liveupdates"""
while ws is not None:
gevent.sleep(0.1)
try:
message = ws.receive() # expect function name to subscribe to
if message:
stream.register(ws, message)
except WebSocketError:
... | python | def subscribe(ws):
"""WebSocket endpoint, used for liveupdates"""
while ws is not None:
gevent.sleep(0.1)
try:
message = ws.receive() # expect function name to subscribe to
if message:
stream.register(ws, message)
except WebSocketError:
... | [
"def",
"subscribe",
"(",
"ws",
")",
":",
"while",
"ws",
"is",
"not",
"None",
":",
"gevent",
".",
"sleep",
"(",
"0.1",
")",
"try",
":",
"message",
"=",
"ws",
".",
"receive",
"(",
")",
"# expect function name to subscribe to",
"if",
"message",
":",
"stream... | WebSocket endpoint, used for liveupdates | [
"WebSocket",
"endpoint",
"used",
"for",
"liveupdates"
] | 55ff20aa2d2504fb85fa2f63cc9b52934245b849 | https://github.com/debugloop/saltobserver/blob/55ff20aa2d2504fb85fa2f63cc9b52934245b849/saltobserver/websockets.py#L11-L20 |
39,230 | botstory/botstory | botstory/ast/story_context/__init__.py | StoryContext.could_scope_out | def could_scope_out(self):
"""
could bubble up from current scope
:return:
"""
return not self.waiting_for or \
isinstance(self.waiting_for, callable.EndOfStory) or \
self.is_breaking_a_loop() | python | def could_scope_out(self):
"""
could bubble up from current scope
:return:
"""
return not self.waiting_for or \
isinstance(self.waiting_for, callable.EndOfStory) or \
self.is_breaking_a_loop() | [
"def",
"could_scope_out",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"waiting_for",
"or",
"isinstance",
"(",
"self",
".",
"waiting_for",
",",
"callable",
".",
"EndOfStory",
")",
"or",
"self",
".",
"is_breaking_a_loop",
"(",
")"
] | could bubble up from current scope
:return: | [
"could",
"bubble",
"up",
"from",
"current",
"scope"
] | 9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3 | https://github.com/botstory/botstory/blob/9c5b2fc7f7a14dbd467d70f60d5ba855ef89dac3/botstory/ast/story_context/__init__.py#L41-L49 |
39,231 | rogerhil/thegamesdb | thegamesdb/item.py | BaseItem.alias | def alias(self):
""" If the _alias cache is None, just build the alias from the item
name.
"""
if self._alias is None:
if self.name in self.aliases_fix:
self._alias = self.aliases_fix[self.name]
else:
self._alias = self.name.lower()... | python | def alias(self):
""" If the _alias cache is None, just build the alias from the item
name.
"""
if self._alias is None:
if self.name in self.aliases_fix:
self._alias = self.aliases_fix[self.name]
else:
self._alias = self.name.lower()... | [
"def",
"alias",
"(",
"self",
")",
":",
"if",
"self",
".",
"_alias",
"is",
"None",
":",
"if",
"self",
".",
"name",
"in",
"self",
".",
"aliases_fix",
":",
"self",
".",
"_alias",
"=",
"self",
".",
"aliases_fix",
"[",
"self",
".",
"name",
"]",
"else",
... | If the _alias cache is None, just build the alias from the item
name. | [
"If",
"the",
"_alias",
"cache",
"is",
"None",
"just",
"build",
"the",
"alias",
"from",
"the",
"item",
"name",
"."
] | 795314215f9ee73697c7520dea4ddecfb23ca8e6 | https://github.com/rogerhil/thegamesdb/blob/795314215f9ee73697c7520dea4ddecfb23ca8e6/thegamesdb/item.py#L99-L111 |
39,232 | xtream1101/cutil | cutil/config.py | Config.load_configs | def load_configs(self, conf_file):
"""
Assumes that the config file does not have any sections, so throw it all in global
"""
with open(conf_file) as stream:
lines = itertools.chain(("[global]",), stream)
self._config.read_file(lines)
return self._config['... | python | def load_configs(self, conf_file):
"""
Assumes that the config file does not have any sections, so throw it all in global
"""
with open(conf_file) as stream:
lines = itertools.chain(("[global]",), stream)
self._config.read_file(lines)
return self._config['... | [
"def",
"load_configs",
"(",
"self",
",",
"conf_file",
")",
":",
"with",
"open",
"(",
"conf_file",
")",
"as",
"stream",
":",
"lines",
"=",
"itertools",
".",
"chain",
"(",
"(",
"\"[global]\"",
",",
")",
",",
"stream",
")",
"self",
".",
"_config",
".",
... | Assumes that the config file does not have any sections, so throw it all in global | [
"Assumes",
"that",
"the",
"config",
"file",
"does",
"not",
"have",
"any",
"sections",
"so",
"throw",
"it",
"all",
"in",
"global"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/config.py#L12-L19 |
39,233 | xtream1101/cutil | cutil/config.py | Config.remove_quotes | def remove_quotes(self, configs):
"""
Because some values are wraped in single quotes
"""
for key in configs:
value = configs[key]
if value[0] == "'" and value[-1] == "'":
configs[key] = value[1:-1]
return configs | python | def remove_quotes(self, configs):
"""
Because some values are wraped in single quotes
"""
for key in configs:
value = configs[key]
if value[0] == "'" and value[-1] == "'":
configs[key] = value[1:-1]
return configs | [
"def",
"remove_quotes",
"(",
"self",
",",
"configs",
")",
":",
"for",
"key",
"in",
"configs",
":",
"value",
"=",
"configs",
"[",
"key",
"]",
"if",
"value",
"[",
"0",
"]",
"==",
"\"'\"",
"and",
"value",
"[",
"-",
"1",
"]",
"==",
"\"'\"",
":",
"con... | Because some values are wraped in single quotes | [
"Because",
"some",
"values",
"are",
"wraped",
"in",
"single",
"quotes"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/config.py#L21-L29 |
39,234 | xtream1101/cutil | cutil/__init__.py | chunks_of | def chunks_of(max_chunk_size, list_to_chunk):
"""
Yields the list with a max size of max_chunk_size
"""
for i in range(0, len(list_to_chunk), max_chunk_size):
yield list_to_chunk[i:i + max_chunk_size] | python | def chunks_of(max_chunk_size, list_to_chunk):
"""
Yields the list with a max size of max_chunk_size
"""
for i in range(0, len(list_to_chunk), max_chunk_size):
yield list_to_chunk[i:i + max_chunk_size] | [
"def",
"chunks_of",
"(",
"max_chunk_size",
",",
"list_to_chunk",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"list_to_chunk",
")",
",",
"max_chunk_size",
")",
":",
"yield",
"list_to_chunk",
"[",
"i",
":",
"i",
"+",
"max_chunk_size",
"... | Yields the list with a max size of max_chunk_size | [
"Yields",
"the",
"list",
"with",
"a",
"max",
"size",
"of",
"max_chunk_size"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/__init__.py#L216-L221 |
39,235 | xtream1101/cutil | cutil/__init__.py | split_into | def split_into(max_num_chunks, list_to_chunk):
"""
Yields the list with a max total size of max_num_chunks
"""
max_chunk_size = math.ceil(len(list_to_chunk) / max_num_chunks)
return chunks_of(max_chunk_size, list_to_chunk) | python | def split_into(max_num_chunks, list_to_chunk):
"""
Yields the list with a max total size of max_num_chunks
"""
max_chunk_size = math.ceil(len(list_to_chunk) / max_num_chunks)
return chunks_of(max_chunk_size, list_to_chunk) | [
"def",
"split_into",
"(",
"max_num_chunks",
",",
"list_to_chunk",
")",
":",
"max_chunk_size",
"=",
"math",
".",
"ceil",
"(",
"len",
"(",
"list_to_chunk",
")",
"/",
"max_num_chunks",
")",
"return",
"chunks_of",
"(",
"max_chunk_size",
",",
"list_to_chunk",
")"
] | Yields the list with a max total size of max_num_chunks | [
"Yields",
"the",
"list",
"with",
"a",
"max",
"total",
"size",
"of",
"max_num_chunks"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/__init__.py#L224-L229 |
39,236 | xtream1101/cutil | cutil/__init__.py | get_proxy_parts | def get_proxy_parts(proxy):
"""
Take a proxy url and break it up to its parts
"""
proxy_parts = {'schema': None,
'user': None,
'password': None,
'host': None,
'port': None,
}
# Find parts
results = re.... | python | def get_proxy_parts(proxy):
"""
Take a proxy url and break it up to its parts
"""
proxy_parts = {'schema': None,
'user': None,
'password': None,
'host': None,
'port': None,
}
# Find parts
results = re.... | [
"def",
"get_proxy_parts",
"(",
"proxy",
")",
":",
"proxy_parts",
"=",
"{",
"'schema'",
":",
"None",
",",
"'user'",
":",
"None",
",",
"'password'",
":",
"None",
",",
"'host'",
":",
"None",
",",
"'port'",
":",
"None",
",",
"}",
"# Find parts",
"results",
... | Take a proxy url and break it up to its parts | [
"Take",
"a",
"proxy",
"url",
"and",
"break",
"it",
"up",
"to",
"its",
"parts"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/__init__.py#L501-L524 |
39,237 | xtream1101/cutil | cutil/__init__.py | remove_html_tag | def remove_html_tag(input_str='', tag=None):
"""
Returns a string with the html tag and all its contents from a string
"""
result = input_str
if tag is not None:
pattern = re.compile('<{tag}[\s\S]+?/{tag}>'.format(tag=tag))
result = re.sub(pattern, '', str(input_str))
return res... | python | def remove_html_tag(input_str='', tag=None):
"""
Returns a string with the html tag and all its contents from a string
"""
result = input_str
if tag is not None:
pattern = re.compile('<{tag}[\s\S]+?/{tag}>'.format(tag=tag))
result = re.sub(pattern, '', str(input_str))
return res... | [
"def",
"remove_html_tag",
"(",
"input_str",
"=",
"''",
",",
"tag",
"=",
"None",
")",
":",
"result",
"=",
"input_str",
"if",
"tag",
"is",
"not",
"None",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"'<{tag}[\\s\\S]+?/{tag}>'",
".",
"format",
"(",
"tag"... | Returns a string with the html tag and all its contents from a string | [
"Returns",
"a",
"string",
"with",
"the",
"html",
"tag",
"and",
"all",
"its",
"contents",
"from",
"a",
"string"
] | 2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8 | https://github.com/xtream1101/cutil/blob/2e4d1f00e66154b44d4ccffb9b1db3f37e87f2e8/cutil/__init__.py#L527-L536 |
39,238 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | ip_between | def ip_between(ip, start, finish):
"""Checks to see if IP is between start and finish"""
if is_IPv4Address(ip) and is_IPv4Address(start) and is_IPv4Address(finish):
return IPAddress(ip) in IPRange(start, finish)
else:
return False | python | def ip_between(ip, start, finish):
"""Checks to see if IP is between start and finish"""
if is_IPv4Address(ip) and is_IPv4Address(start) and is_IPv4Address(finish):
return IPAddress(ip) in IPRange(start, finish)
else:
return False | [
"def",
"ip_between",
"(",
"ip",
",",
"start",
",",
"finish",
")",
":",
"if",
"is_IPv4Address",
"(",
"ip",
")",
"and",
"is_IPv4Address",
"(",
"start",
")",
"and",
"is_IPv4Address",
"(",
"finish",
")",
":",
"return",
"IPAddress",
"(",
"ip",
")",
"in",
"I... | Checks to see if IP is between start and finish | [
"Checks",
"to",
"see",
"if",
"IP",
"is",
"between",
"start",
"and",
"finish"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L75-L81 |
39,239 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | is_rfc1918 | def is_rfc1918(ip):
"""Checks to see if an IP address is used for local communications within
a private network as specified by RFC 1918
"""
if ip_between(ip, "10.0.0.0", "10.255.255.255"):
return True
elif ip_between(ip, "172.16.0.0", "172.31.255.255"):
return True
elif ip_betwe... | python | def is_rfc1918(ip):
"""Checks to see if an IP address is used for local communications within
a private network as specified by RFC 1918
"""
if ip_between(ip, "10.0.0.0", "10.255.255.255"):
return True
elif ip_between(ip, "172.16.0.0", "172.31.255.255"):
return True
elif ip_betwe... | [
"def",
"is_rfc1918",
"(",
"ip",
")",
":",
"if",
"ip_between",
"(",
"ip",
",",
"\"10.0.0.0\"",
",",
"\"10.255.255.255\"",
")",
":",
"return",
"True",
"elif",
"ip_between",
"(",
"ip",
",",
"\"172.16.0.0\"",
",",
"\"172.31.255.255\"",
")",
":",
"return",
"True"... | Checks to see if an IP address is used for local communications within
a private network as specified by RFC 1918 | [
"Checks",
"to",
"see",
"if",
"an",
"IP",
"address",
"is",
"used",
"for",
"local",
"communications",
"within",
"a",
"private",
"network",
"as",
"specified",
"by",
"RFC",
"1918"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L84-L95 |
39,240 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | is_reserved | def is_reserved(ip):
"""Checks to see if an IP address is reserved for special purposes. This includes
all of the RFC 1918 addresses as well as other blocks that are reserved by
IETF, and IANA for various reasons.
https://en.wikipedia.org/wiki/Reserved_IP_addresses
"""
if ip_between(ip, "0.0.0.... | python | def is_reserved(ip):
"""Checks to see if an IP address is reserved for special purposes. This includes
all of the RFC 1918 addresses as well as other blocks that are reserved by
IETF, and IANA for various reasons.
https://en.wikipedia.org/wiki/Reserved_IP_addresses
"""
if ip_between(ip, "0.0.0.... | [
"def",
"is_reserved",
"(",
"ip",
")",
":",
"if",
"ip_between",
"(",
"ip",
",",
"\"0.0.0.0\"",
",",
"\"0.255.255.255\"",
")",
":",
"return",
"True",
"elif",
"ip_between",
"(",
"ip",
",",
"\"10.0.0.0\"",
",",
"\"10.255.255.255\"",
")",
":",
"return",
"True",
... | Checks to see if an IP address is reserved for special purposes. This includes
all of the RFC 1918 addresses as well as other blocks that are reserved by
IETF, and IANA for various reasons.
https://en.wikipedia.org/wiki/Reserved_IP_addresses | [
"Checks",
"to",
"see",
"if",
"an",
"IP",
"address",
"is",
"reserved",
"for",
"special",
"purposes",
".",
"This",
"includes",
"all",
"of",
"the",
"RFC",
"1918",
"addresses",
"as",
"well",
"as",
"other",
"blocks",
"that",
"are",
"reserved",
"by",
"IETF",
"... | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L98-L134 |
39,241 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | is_hash | def is_hash(fhash):
"""Returns true for valid hashes, false for invalid."""
# Intentionally doing if/else statement for ease of testing and reading
if re.match(re_md5, fhash):
return True
elif re.match(re_sha1, fhash):
return True
elif re.match(re_sha256, fhash):
return True... | python | def is_hash(fhash):
"""Returns true for valid hashes, false for invalid."""
# Intentionally doing if/else statement for ease of testing and reading
if re.match(re_md5, fhash):
return True
elif re.match(re_sha1, fhash):
return True
elif re.match(re_sha256, fhash):
return True... | [
"def",
"is_hash",
"(",
"fhash",
")",
":",
"# Intentionally doing if/else statement for ease of testing and reading",
"if",
"re",
".",
"match",
"(",
"re_md5",
",",
"fhash",
")",
":",
"return",
"True",
"elif",
"re",
".",
"match",
"(",
"re_sha1",
",",
"fhash",
")",... | Returns true for valid hashes, false for invalid. | [
"Returns",
"true",
"for",
"valid",
"hashes",
"false",
"for",
"invalid",
"."
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L172-L187 |
39,242 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | reverse_dns_sna | def reverse_dns_sna(ipaddress):
"""Returns a list of the dns names that point to a given ipaddress using StatDNS API"""
r = requests.get("http://api.statdns.com/x/%s" % ipaddress)
if r.status_code == 200:
names = []
for item in r.json()['answer']:
name = str(item['rdata']).str... | python | def reverse_dns_sna(ipaddress):
"""Returns a list of the dns names that point to a given ipaddress using StatDNS API"""
r = requests.get("http://api.statdns.com/x/%s" % ipaddress)
if r.status_code == 200:
names = []
for item in r.json()['answer']:
name = str(item['rdata']).str... | [
"def",
"reverse_dns_sna",
"(",
"ipaddress",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"\"http://api.statdns.com/x/%s\"",
"%",
"ipaddress",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"names",
"=",
"[",
"]",
"for",
"item",
"in",
"r",
".",... | Returns a list of the dns names that point to a given ipaddress using StatDNS API | [
"Returns",
"a",
"list",
"of",
"the",
"dns",
"names",
"that",
"point",
"to",
"a",
"given",
"ipaddress",
"using",
"StatDNS",
"API"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L259-L274 |
39,243 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | vt_ip_check | def vt_ip_check(ip, vt_api):
"""Checks VirusTotal for occurrences of an IP address"""
if not is_IPv4Address(ip):
return None
url = 'https://www.virustotal.com/vtapi/v2/ip-address/report'
parameters = {'ip': ip, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try:
... | python | def vt_ip_check(ip, vt_api):
"""Checks VirusTotal for occurrences of an IP address"""
if not is_IPv4Address(ip):
return None
url = 'https://www.virustotal.com/vtapi/v2/ip-address/report'
parameters = {'ip': ip, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try:
... | [
"def",
"vt_ip_check",
"(",
"ip",
",",
"vt_api",
")",
":",
"if",
"not",
"is_IPv4Address",
"(",
"ip",
")",
":",
"return",
"None",
"url",
"=",
"'https://www.virustotal.com/vtapi/v2/ip-address/report'",
"parameters",
"=",
"{",
"'ip'",
":",
"ip",
",",
"'apikey'",
"... | Checks VirusTotal for occurrences of an IP address | [
"Checks",
"VirusTotal",
"for",
"occurrences",
"of",
"an",
"IP",
"address"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L284-L295 |
39,244 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | vt_name_check | def vt_name_check(domain, vt_api):
"""Checks VirusTotal for occurrences of a domain name"""
if not is_fqdn(domain):
return None
url = 'https://www.virustotal.com/vtapi/v2/domain/report'
parameters = {'domain': domain, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try... | python | def vt_name_check(domain, vt_api):
"""Checks VirusTotal for occurrences of a domain name"""
if not is_fqdn(domain):
return None
url = 'https://www.virustotal.com/vtapi/v2/domain/report'
parameters = {'domain': domain, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try... | [
"def",
"vt_name_check",
"(",
"domain",
",",
"vt_api",
")",
":",
"if",
"not",
"is_fqdn",
"(",
"domain",
")",
":",
"return",
"None",
"url",
"=",
"'https://www.virustotal.com/vtapi/v2/domain/report'",
"parameters",
"=",
"{",
"'domain'",
":",
"domain",
",",
"'apikey... | Checks VirusTotal for occurrences of a domain name | [
"Checks",
"VirusTotal",
"for",
"occurrences",
"of",
"a",
"domain",
"name"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L298-L309 |
39,245 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | vt_hash_check | def vt_hash_check(fhash, vt_api):
"""Checks VirusTotal for occurrences of a file hash"""
if not is_hash(fhash):
return None
url = 'https://www.virustotal.com/vtapi/v2/file/report'
parameters = {'resource': fhash, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try:
... | python | def vt_hash_check(fhash, vt_api):
"""Checks VirusTotal for occurrences of a file hash"""
if not is_hash(fhash):
return None
url = 'https://www.virustotal.com/vtapi/v2/file/report'
parameters = {'resource': fhash, 'apikey': vt_api}
response = requests.get(url, params=parameters)
try:
... | [
"def",
"vt_hash_check",
"(",
"fhash",
",",
"vt_api",
")",
":",
"if",
"not",
"is_hash",
"(",
"fhash",
")",
":",
"return",
"None",
"url",
"=",
"'https://www.virustotal.com/vtapi/v2/file/report'",
"parameters",
"=",
"{",
"'resource'",
":",
"fhash",
",",
"'apikey'",... | Checks VirusTotal for occurrences of a file hash | [
"Checks",
"VirusTotal",
"for",
"occurrences",
"of",
"a",
"file",
"hash"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L312-L323 |
39,246 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | ipinfo_ip_check | def ipinfo_ip_check(ip):
"""Checks ipinfo.io for basic WHOIS-type data on an IP address"""
if not is_IPv4Address(ip):
return None
response = requests.get('http://ipinfo.io/%s/json' % ip)
return response.json() | python | def ipinfo_ip_check(ip):
"""Checks ipinfo.io for basic WHOIS-type data on an IP address"""
if not is_IPv4Address(ip):
return None
response = requests.get('http://ipinfo.io/%s/json' % ip)
return response.json() | [
"def",
"ipinfo_ip_check",
"(",
"ip",
")",
":",
"if",
"not",
"is_IPv4Address",
"(",
"ip",
")",
":",
"return",
"None",
"response",
"=",
"requests",
".",
"get",
"(",
"'http://ipinfo.io/%s/json'",
"%",
"ip",
")",
"return",
"response",
".",
"json",
"(",
")"
] | Checks ipinfo.io for basic WHOIS-type data on an IP address | [
"Checks",
"ipinfo",
".",
"io",
"for",
"basic",
"WHOIS",
"-",
"type",
"data",
"on",
"an",
"IP",
"address"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L326-L332 |
39,247 | yolothreat/utilitybelt | utilitybelt/utilitybelt.py | dshield_ip_check | def dshield_ip_check(ip):
"""Checks dshield for info on an IP address"""
if not is_IPv4Address(ip):
return None
headers = {'User-Agent': useragent}
url = 'https://isc.sans.edu/api/ip/'
response = requests.get('{0}{1}?json'.format(url, ip), headers=headers)
return response.json() | python | def dshield_ip_check(ip):
"""Checks dshield for info on an IP address"""
if not is_IPv4Address(ip):
return None
headers = {'User-Agent': useragent}
url = 'https://isc.sans.edu/api/ip/'
response = requests.get('{0}{1}?json'.format(url, ip), headers=headers)
return response.json() | [
"def",
"dshield_ip_check",
"(",
"ip",
")",
":",
"if",
"not",
"is_IPv4Address",
"(",
"ip",
")",
":",
"return",
"None",
"headers",
"=",
"{",
"'User-Agent'",
":",
"useragent",
"}",
"url",
"=",
"'https://isc.sans.edu/api/ip/'",
"response",
"=",
"requests",
".",
... | Checks dshield for info on an IP address | [
"Checks",
"dshield",
"for",
"info",
"on",
"an",
"IP",
"address"
] | 55ac6c31f87963d5e97be0402a4343c84846d118 | https://github.com/yolothreat/utilitybelt/blob/55ac6c31f87963d5e97be0402a4343c84846d118/utilitybelt/utilitybelt.py#L394-L402 |
39,248 | e7dal/bubble3 | bubble3/commands/cmd_push.py | cli | def cli(ctx,
amount,
index,
stage):
"""Push data to Target Service Client"""
if not ctx.bubble:
ctx.say_yellow('There is no bubble present, will not push')
raise click.Abort()
TGT = None
transformed = True
STAGE = None
if stage in STAGES and stage in ... | python | def cli(ctx,
amount,
index,
stage):
"""Push data to Target Service Client"""
if not ctx.bubble:
ctx.say_yellow('There is no bubble present, will not push')
raise click.Abort()
TGT = None
transformed = True
STAGE = None
if stage in STAGES and stage in ... | [
"def",
"cli",
"(",
"ctx",
",",
"amount",
",",
"index",
",",
"stage",
")",
":",
"if",
"not",
"ctx",
".",
"bubble",
":",
"ctx",
".",
"say_yellow",
"(",
"'There is no bubble present, will not push'",
")",
"raise",
"click",
".",
"Abort",
"(",
")",
"TGT",
"="... | Push data to Target Service Client | [
"Push",
"data",
"to",
"Target",
"Service",
"Client"
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/commands/cmd_push.py#L48-L132 |
39,249 | davgeo/clear | clear/util.py | RemoveEmptyDirectoryTree | def RemoveEmptyDirectoryTree(path, silent = False, recursion = 0):
"""
Delete tree of empty directories.
Parameters
----------
path : string
Path to root of directory tree.
silent : boolean [optional: default = False]
Turn off log output.
recursion : int [optional: default = 0]
... | python | def RemoveEmptyDirectoryTree(path, silent = False, recursion = 0):
"""
Delete tree of empty directories.
Parameters
----------
path : string
Path to root of directory tree.
silent : boolean [optional: default = False]
Turn off log output.
recursion : int [optional: default = 0]
... | [
"def",
"RemoveEmptyDirectoryTree",
"(",
"path",
",",
"silent",
"=",
"False",
",",
"recursion",
"=",
"0",
")",
":",
"if",
"not",
"silent",
"and",
"recursion",
"is",
"0",
":",
"goodlogging",
".",
"Log",
".",
"Info",
"(",
"\"UTIL\"",
",",
"\"Starting removal ... | Delete tree of empty directories.
Parameters
----------
path : string
Path to root of directory tree.
silent : boolean [optional: default = False]
Turn off log output.
recursion : int [optional: default = 0]
Indicates level of recursion. | [
"Delete",
"tree",
"of",
"empty",
"directories",
"."
] | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L17-L43 |
39,250 | davgeo/clear | clear/util.py | ValidUserResponse | def ValidUserResponse(response, validList):
"""
Check if user response is in a list of valid entires.
If an invalid response is given re-prompt user to enter
one of the valid options. Do not proceed until a valid entry
is given.
Parameters
----------
response : string
Response string to check.
... | python | def ValidUserResponse(response, validList):
"""
Check if user response is in a list of valid entires.
If an invalid response is given re-prompt user to enter
one of the valid options. Do not proceed until a valid entry
is given.
Parameters
----------
response : string
Response string to check.
... | [
"def",
"ValidUserResponse",
"(",
"response",
",",
"validList",
")",
":",
"if",
"response",
"in",
"validList",
":",
"return",
"response",
"else",
":",
"prompt",
"=",
"\"Unknown response given - please reenter one of [{0}]: \"",
".",
"format",
"(",
"'/'",
".",
"join",... | Check if user response is in a list of valid entires.
If an invalid response is given re-prompt user to enter
one of the valid options. Do not proceed until a valid entry
is given.
Parameters
----------
response : string
Response string to check.
validList : list
A list of valid response... | [
"Check",
"if",
"user",
"response",
"is",
"in",
"a",
"list",
"of",
"valid",
"entires",
".",
"If",
"an",
"invalid",
"response",
"is",
"given",
"re",
"-",
"prompt",
"user",
"to",
"enter",
"one",
"of",
"the",
"valid",
"options",
".",
"Do",
"not",
"proceed"... | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L132-L157 |
39,251 | davgeo/clear | clear/util.py | UserAcceptance | def UserAcceptance(
matchList,
recursiveLookup = True,
promptComment = None,
promptOnly = False,
xStrOverride = "to skip this selection"
):
"""
Prompt user to select a entry from a given match list or to enter a new
string to look up. If the match list is empty user must enter a new string
or exit.
... | python | def UserAcceptance(
matchList,
recursiveLookup = True,
promptComment = None,
promptOnly = False,
xStrOverride = "to skip this selection"
):
"""
Prompt user to select a entry from a given match list or to enter a new
string to look up. If the match list is empty user must enter a new string
or exit.
... | [
"def",
"UserAcceptance",
"(",
"matchList",
",",
"recursiveLookup",
"=",
"True",
",",
"promptComment",
"=",
"None",
",",
"promptOnly",
"=",
"False",
",",
"xStrOverride",
"=",
"\"to skip this selection\"",
")",
":",
"matchString",
"=",
"', '",
".",
"join",
"(",
... | Prompt user to select a entry from a given match list or to enter a new
string to look up. If the match list is empty user must enter a new string
or exit.
Parameters
----------
matchList : list
A list of entries which the user can select a valid match from.
recursiveLookup : boolean [optional: ... | [
"Prompt",
"user",
"to",
"select",
"a",
"entry",
"from",
"a",
"given",
"match",
"list",
"or",
"to",
"enter",
"a",
"new",
"string",
"to",
"look",
"up",
".",
"If",
"the",
"match",
"list",
"is",
"empty",
"user",
"must",
"enter",
"a",
"new",
"string",
"or... | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L162-L240 |
39,252 | davgeo/clear | clear/util.py | GetBestMatch | def GetBestMatch(target, matchList):
"""
Finds the elements of matchList which best match the target string.
Note that this searches substrings so "abc" will have a 100% match in
both "this is the abc", "abcde" and "abc".
The return from this function is a list of potention matches which shared
the same h... | python | def GetBestMatch(target, matchList):
"""
Finds the elements of matchList which best match the target string.
Note that this searches substrings so "abc" will have a 100% match in
both "this is the abc", "abcde" and "abc".
The return from this function is a list of potention matches which shared
the same h... | [
"def",
"GetBestMatch",
"(",
"target",
",",
"matchList",
")",
":",
"bestMatchList",
"=",
"[",
"]",
"if",
"len",
"(",
"matchList",
")",
">",
"0",
":",
"ratioMatch",
"=",
"[",
"]",
"for",
"item",
"in",
"matchList",
":",
"ratioMatch",
".",
"append",
"(",
... | Finds the elements of matchList which best match the target string.
Note that this searches substrings so "abc" will have a 100% match in
both "this is the abc", "abcde" and "abc".
The return from this function is a list of potention matches which shared
the same highest match score. If any exact match is fou... | [
"Finds",
"the",
"elements",
"of",
"matchList",
"which",
"best",
"match",
"the",
"target",
"string",
"."
] | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L245-L288 |
39,253 | davgeo/clear | clear/util.py | GetBestStringMatchValue | def GetBestStringMatchValue(string1, string2):
"""
Return the value of the highest matching substrings between two strings.
Parameters
----------
string1 : string
First string.
string2 : string
Second string.
Returns
----------
int
Integer value representing the best match f... | python | def GetBestStringMatchValue(string1, string2):
"""
Return the value of the highest matching substrings between two strings.
Parameters
----------
string1 : string
First string.
string2 : string
Second string.
Returns
----------
int
Integer value representing the best match f... | [
"def",
"GetBestStringMatchValue",
"(",
"string1",
",",
"string2",
")",
":",
"# Ignore case",
"string1",
"=",
"string1",
".",
"lower",
"(",
")",
"string2",
"=",
"string2",
".",
"lower",
"(",
")",
"# Ignore non-alphanumeric characters",
"string1",
"=",
"''",
".",
... | Return the value of the highest matching substrings between two strings.
Parameters
----------
string1 : string
First string.
string2 : string
Second string.
Returns
----------
int
Integer value representing the best match found
between string1 and string2. | [
"Return",
"the",
"value",
"of",
"the",
"highest",
"matching",
"substrings",
"between",
"two",
"strings",
"."
] | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L293-L342 |
39,254 | davgeo/clear | clear/util.py | WebLookup | def WebLookup(url, urlQuery=None, utf8=True):
"""
Look up webpage at given url with optional query string
Parameters
----------
url : string
Web url.
urlQuery : dictionary [optional: default = None]
Parameter to be passed to GET method of requests module
utf8 : boolean [optional: defa... | python | def WebLookup(url, urlQuery=None, utf8=True):
"""
Look up webpage at given url with optional query string
Parameters
----------
url : string
Web url.
urlQuery : dictionary [optional: default = None]
Parameter to be passed to GET method of requests module
utf8 : boolean [optional: defa... | [
"def",
"WebLookup",
"(",
"url",
",",
"urlQuery",
"=",
"None",
",",
"utf8",
"=",
"True",
")",
":",
"goodlogging",
".",
"Log",
".",
"Info",
"(",
"\"UTIL\"",
",",
"\"Looking up info from URL:{0} with QUERY:{1})\"",
".",
"format",
"(",
"url",
",",
"urlQuery",
")... | Look up webpage at given url with optional query string
Parameters
----------
url : string
Web url.
urlQuery : dictionary [optional: default = None]
Parameter to be passed to GET method of requests module
utf8 : boolean [optional: default = True]
Set response encoding
Returns
-... | [
"Look",
"up",
"webpage",
"at",
"given",
"url",
"with",
"optional",
"query",
"string"
] | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L347-L376 |
39,255 | davgeo/clear | clear/util.py | ArchiveProcessedFile | def ArchiveProcessedFile(filePath, archiveDir):
"""
Move file from given file path to archive directory. Note the archive
directory is relative to the file path directory.
Parameters
----------
filePath : string
File path
archiveDir : string
Name of archive directory
"""
targetDir = ... | python | def ArchiveProcessedFile(filePath, archiveDir):
"""
Move file from given file path to archive directory. Note the archive
directory is relative to the file path directory.
Parameters
----------
filePath : string
File path
archiveDir : string
Name of archive directory
"""
targetDir = ... | [
"def",
"ArchiveProcessedFile",
"(",
"filePath",
",",
"archiveDir",
")",
":",
"targetDir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"filePath",
")",
",",
"archiveDir",
")",
"goodlogging",
".",
"Log",
".",
"Info",
... | Move file from given file path to archive directory. Note the archive
directory is relative to the file path directory.
Parameters
----------
filePath : string
File path
archiveDir : string
Name of archive directory | [
"Move",
"file",
"from",
"given",
"file",
"path",
"to",
"archive",
"directory",
".",
"Note",
"the",
"archive",
"directory",
"is",
"relative",
"to",
"the",
"file",
"path",
"directory",
"."
] | 5ec85d27efd28afddfcd4c3f44df17f0115a77aa | https://github.com/davgeo/clear/blob/5ec85d27efd28afddfcd4c3f44df17f0115a77aa/clear/util.py#L382-L406 |
39,256 | shblythe/python2-pilite | pilite.py | PiLite.send_wait | def send_wait(self,text):
"""Send a string to the PiLite, sleep until the message has been
displayed (based on an estimate of the speed of the display.
Due to the font not being monotype, this will wait too long in most
cases"""
self.send(text)
time.sleep(len(text)*PiLite.COLS_PER_CHAR*self.speed/1000.0) | python | def send_wait(self,text):
"""Send a string to the PiLite, sleep until the message has been
displayed (based on an estimate of the speed of the display.
Due to the font not being monotype, this will wait too long in most
cases"""
self.send(text)
time.sleep(len(text)*PiLite.COLS_PER_CHAR*self.speed/1000.0) | [
"def",
"send_wait",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"send",
"(",
"text",
")",
"time",
".",
"sleep",
"(",
"len",
"(",
"text",
")",
"*",
"PiLite",
".",
"COLS_PER_CHAR",
"*",
"self",
".",
"speed",
"/",
"1000.0",
")"
] | Send a string to the PiLite, sleep until the message has been
displayed (based on an estimate of the speed of the display.
Due to the font not being monotype, this will wait too long in most
cases | [
"Send",
"a",
"string",
"to",
"the",
"PiLite",
"sleep",
"until",
"the",
"message",
"has",
"been",
"displayed",
"(",
"based",
"on",
"an",
"estimate",
"of",
"the",
"speed",
"of",
"the",
"display",
".",
"Due",
"to",
"the",
"font",
"not",
"being",
"monotype",... | 6ce5b8920c472077e81a9ebaff7dec1e15d2516c | https://github.com/shblythe/python2-pilite/blob/6ce5b8920c472077e81a9ebaff7dec1e15d2516c/pilite.py#L48-L54 |
39,257 | shblythe/python2-pilite | pilite.py | PiLite.set_speed | def set_speed(self,speed):
"""Set the display speed. The parameters is the number of milliseconds
between each column scrolling off the display"""
self.speed=speed
self.send_cmd("SPEED"+str(speed)) | python | def set_speed(self,speed):
"""Set the display speed. The parameters is the number of milliseconds
between each column scrolling off the display"""
self.speed=speed
self.send_cmd("SPEED"+str(speed)) | [
"def",
"set_speed",
"(",
"self",
",",
"speed",
")",
":",
"self",
".",
"speed",
"=",
"speed",
"self",
".",
"send_cmd",
"(",
"\"SPEED\"",
"+",
"str",
"(",
"speed",
")",
")"
] | Set the display speed. The parameters is the number of milliseconds
between each column scrolling off the display | [
"Set",
"the",
"display",
"speed",
".",
"The",
"parameters",
"is",
"the",
"number",
"of",
"milliseconds",
"between",
"each",
"column",
"scrolling",
"off",
"the",
"display"
] | 6ce5b8920c472077e81a9ebaff7dec1e15d2516c | https://github.com/shblythe/python2-pilite/blob/6ce5b8920c472077e81a9ebaff7dec1e15d2516c/pilite.py#L69-L73 |
39,258 | shblythe/python2-pilite | pilite.py | PiLite.set_fb_random | def set_fb_random(self):
"""Set the "frame buffer" to a random pattern"""
pattern=''.join([random.choice(['0','1']) for i in xrange(14*9)])
self.set_fb(pattern) | python | def set_fb_random(self):
"""Set the "frame buffer" to a random pattern"""
pattern=''.join([random.choice(['0','1']) for i in xrange(14*9)])
self.set_fb(pattern) | [
"def",
"set_fb_random",
"(",
"self",
")",
":",
"pattern",
"=",
"''",
".",
"join",
"(",
"[",
"random",
".",
"choice",
"(",
"[",
"'0'",
",",
"'1'",
"]",
")",
"for",
"i",
"in",
"xrange",
"(",
"14",
"*",
"9",
")",
"]",
")",
"self",
".",
"set_fb",
... | Set the "frame buffer" to a random pattern | [
"Set",
"the",
"frame",
"buffer",
"to",
"a",
"random",
"pattern"
] | 6ce5b8920c472077e81a9ebaff7dec1e15d2516c | https://github.com/shblythe/python2-pilite/blob/6ce5b8920c472077e81a9ebaff7dec1e15d2516c/pilite.py#L95-L98 |
39,259 | shblythe/python2-pilite | pilite.py | PiLite.set_pixel | def set_pixel(self,x,y,state):
"""Set pixel at "x,y" to "state" where state can be one of "ON", "OFF"
or "TOGGLE"
"""
self.send_cmd("P"+str(x+1)+","+str(y+1)+","+state) | python | def set_pixel(self,x,y,state):
"""Set pixel at "x,y" to "state" where state can be one of "ON", "OFF"
or "TOGGLE"
"""
self.send_cmd("P"+str(x+1)+","+str(y+1)+","+state) | [
"def",
"set_pixel",
"(",
"self",
",",
"x",
",",
"y",
",",
"state",
")",
":",
"self",
".",
"send_cmd",
"(",
"\"P\"",
"+",
"str",
"(",
"x",
"+",
"1",
")",
"+",
"\",\"",
"+",
"str",
"(",
"y",
"+",
"1",
")",
"+",
"\",\"",
"+",
"state",
")"
] | Set pixel at "x,y" to "state" where state can be one of "ON", "OFF"
or "TOGGLE" | [
"Set",
"pixel",
"at",
"x",
"y",
"to",
"state",
"where",
"state",
"can",
"be",
"one",
"of",
"ON",
"OFF",
"or",
"TOGGLE"
] | 6ce5b8920c472077e81a9ebaff7dec1e15d2516c | https://github.com/shblythe/python2-pilite/blob/6ce5b8920c472077e81a9ebaff7dec1e15d2516c/pilite.py#L115-L119 |
39,260 | shblythe/python2-pilite | pilite.py | PiLite.display_char | def display_char(self,x,y,char):
"""Display character "char" with its top left at "x,y"
"""
self.send_cmd("T"+str(x+1)+","+str(y+1)+","+char) | python | def display_char(self,x,y,char):
"""Display character "char" with its top left at "x,y"
"""
self.send_cmd("T"+str(x+1)+","+str(y+1)+","+char) | [
"def",
"display_char",
"(",
"self",
",",
"x",
",",
"y",
",",
"char",
")",
":",
"self",
".",
"send_cmd",
"(",
"\"T\"",
"+",
"str",
"(",
"x",
"+",
"1",
")",
"+",
"\",\"",
"+",
"str",
"(",
"y",
"+",
"1",
")",
"+",
"\",\"",
"+",
"char",
")"
] | Display character "char" with its top left at "x,y" | [
"Display",
"character",
"char",
"with",
"its",
"top",
"left",
"at",
"x",
"y"
] | 6ce5b8920c472077e81a9ebaff7dec1e15d2516c | https://github.com/shblythe/python2-pilite/blob/6ce5b8920c472077e81a9ebaff7dec1e15d2516c/pilite.py#L152-L155 |
39,261 | hollenstein/maspy | maspy_resources/peptide_mapping.py | the_magic_mapping_function | def the_magic_mapping_function(peptides, fastaPath, importAttributes=None,
ignoreUnmapped=True):
"""Returns a dictionary mapping peptides to protein group leading proteins.
:param peptides: a set of peptide sequences
:param fastaPath: FASTA file path
:param importAttributes: dict, can be used t... | python | def the_magic_mapping_function(peptides, fastaPath, importAttributes=None,
ignoreUnmapped=True):
"""Returns a dictionary mapping peptides to protein group leading proteins.
:param peptides: a set of peptide sequences
:param fastaPath: FASTA file path
:param importAttributes: dict, can be used t... | [
"def",
"the_magic_mapping_function",
"(",
"peptides",
",",
"fastaPath",
",",
"importAttributes",
"=",
"None",
",",
"ignoreUnmapped",
"=",
"True",
")",
":",
"missedCleavage",
"=",
"max",
"(",
"[",
"p",
".",
"count",
"(",
"'K'",
")",
"+",
"p",
".",
"count",
... | Returns a dictionary mapping peptides to protein group leading proteins.
:param peptides: a set of peptide sequences
:param fastaPath: FASTA file path
:param importAttributes: dict, can be used to override default parameters
passed to the function maspy.proteindb.importProteinDatabase().
De... | [
"Returns",
"a",
"dictionary",
"mapping",
"peptides",
"to",
"protein",
"group",
"leading",
"proteins",
"."
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy_resources/peptide_mapping.py#L38-L98 |
39,262 | bitesofcode/projex | projex/text.py | truncate | def truncate(text, length=50, ellipsis='...'):
"""
Returns a truncated version of the inputted text.
:param text | <str>
length | <int>
ellipsis | <str>
:return <str>
"""
text = nativestring(text)
return text[:length] + (text[length:] and ellipsis) | python | def truncate(text, length=50, ellipsis='...'):
"""
Returns a truncated version of the inputted text.
:param text | <str>
length | <int>
ellipsis | <str>
:return <str>
"""
text = nativestring(text)
return text[:length] + (text[length:] and ellipsis) | [
"def",
"truncate",
"(",
"text",
",",
"length",
"=",
"50",
",",
"ellipsis",
"=",
"'...'",
")",
":",
"text",
"=",
"nativestring",
"(",
"text",
")",
"return",
"text",
"[",
":",
"length",
"]",
"+",
"(",
"text",
"[",
"length",
":",
"]",
"and",
"ellipsis... | Returns a truncated version of the inputted text.
:param text | <str>
length | <int>
ellipsis | <str>
:return <str> | [
"Returns",
"a",
"truncated",
"version",
"of",
"the",
"inputted",
"text",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/text.py#L707-L718 |
39,263 | sharibarboza/py_zap | py_zap/utils.py | to_json | def to_json(data):
"""Return data as a JSON string."""
return json.dumps(data, default=lambda x: x.__dict__, sort_keys=True, indent=4) | python | def to_json(data):
"""Return data as a JSON string."""
return json.dumps(data, default=lambda x: x.__dict__, sort_keys=True, indent=4) | [
"def",
"to_json",
"(",
"data",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"data",
",",
"default",
"=",
"lambda",
"x",
":",
"x",
".",
"__dict__",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
")"
] | Return data as a JSON string. | [
"Return",
"data",
"as",
"a",
"JSON",
"string",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L30-L32 |
39,264 | sharibarboza/py_zap | py_zap/utils.py | convert_string | def convert_string(string, chars=None):
"""Remove certain characters from a string."""
if chars is None:
chars = [',', '.', '-', '/', ':', ' ']
for ch in chars:
if ch in string:
string = string.replace(ch, ' ')
return string | python | def convert_string(string, chars=None):
"""Remove certain characters from a string."""
if chars is None:
chars = [',', '.', '-', '/', ':', ' ']
for ch in chars:
if ch in string:
string = string.replace(ch, ' ')
return string | [
"def",
"convert_string",
"(",
"string",
",",
"chars",
"=",
"None",
")",
":",
"if",
"chars",
"is",
"None",
":",
"chars",
"=",
"[",
"','",
",",
"'.'",
",",
"'-'",
",",
"'/'",
",",
"':'",
",",
"' '",
"]",
"for",
"ch",
"in",
"chars",
":",
"if",
"c... | Remove certain characters from a string. | [
"Remove",
"certain",
"characters",
"from",
"a",
"string",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L34-L42 |
39,265 | sharibarboza/py_zap | py_zap/utils.py | convert_time | def convert_time(time):
"""Convert a time string into 24-hour time."""
split_time = time.split()
try:
# Get rid of period in a.m./p.m.
am_pm = split_time[1].replace('.', '')
time_str = '{0} {1}'.format(split_time[0], am_pm)
except IndexError:
return time
try:
... | python | def convert_time(time):
"""Convert a time string into 24-hour time."""
split_time = time.split()
try:
# Get rid of period in a.m./p.m.
am_pm = split_time[1].replace('.', '')
time_str = '{0} {1}'.format(split_time[0], am_pm)
except IndexError:
return time
try:
... | [
"def",
"convert_time",
"(",
"time",
")",
":",
"split_time",
"=",
"time",
".",
"split",
"(",
")",
"try",
":",
"# Get rid of period in a.m./p.m.",
"am_pm",
"=",
"split_time",
"[",
"1",
"]",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
"time_str",
"=",
"'{0}... | Convert a time string into 24-hour time. | [
"Convert",
"a",
"time",
"string",
"into",
"24",
"-",
"hour",
"time",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L51-L65 |
39,266 | sharibarboza/py_zap | py_zap/utils.py | convert_month | def convert_month(date, shorten=True, cable=True):
"""Replace month by shortening or lengthening it.
:param shorten: Set to True to shorten month name.
:param cable: Set to True if category is Cable.
"""
month = date.split()[0].lower()
if 'sept' in month:
shorten = False if cable else T... | python | def convert_month(date, shorten=True, cable=True):
"""Replace month by shortening or lengthening it.
:param shorten: Set to True to shorten month name.
:param cable: Set to True if category is Cable.
"""
month = date.split()[0].lower()
if 'sept' in month:
shorten = False if cable else T... | [
"def",
"convert_month",
"(",
"date",
",",
"shorten",
"=",
"True",
",",
"cable",
"=",
"True",
")",
":",
"month",
"=",
"date",
".",
"split",
"(",
")",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"if",
"'sept'",
"in",
"month",
":",
"shorten",
"=",
"False... | Replace month by shortening or lengthening it.
:param shorten: Set to True to shorten month name.
:param cable: Set to True if category is Cable. | [
"Replace",
"month",
"by",
"shortening",
"or",
"lengthening",
"it",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L71-L89 |
39,267 | sharibarboza/py_zap | py_zap/utils.py | convert_date | def convert_date(date):
"""Convert string to datetime object."""
date = convert_month(date, shorten=False)
clean_string = convert_string(date)
return datetime.strptime(clean_string, DATE_FMT.replace('-','')) | python | def convert_date(date):
"""Convert string to datetime object."""
date = convert_month(date, shorten=False)
clean_string = convert_string(date)
return datetime.strptime(clean_string, DATE_FMT.replace('-','')) | [
"def",
"convert_date",
"(",
"date",
")",
":",
"date",
"=",
"convert_month",
"(",
"date",
",",
"shorten",
"=",
"False",
")",
"clean_string",
"=",
"convert_string",
"(",
"date",
")",
"return",
"datetime",
".",
"strptime",
"(",
"clean_string",
",",
"DATE_FMT",
... | Convert string to datetime object. | [
"Convert",
"string",
"to",
"datetime",
"object",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L91-L95 |
39,268 | sharibarboza/py_zap | py_zap/utils.py | date_in_range | def date_in_range(date1, date2, range):
"""Check if two date objects are within a specific range"""
date_obj1 = convert_date(date1)
date_obj2 = convert_date(date2)
return (date_obj2 - date_obj1).days <= range | python | def date_in_range(date1, date2, range):
"""Check if two date objects are within a specific range"""
date_obj1 = convert_date(date1)
date_obj2 = convert_date(date2)
return (date_obj2 - date_obj1).days <= range | [
"def",
"date_in_range",
"(",
"date1",
",",
"date2",
",",
"range",
")",
":",
"date_obj1",
"=",
"convert_date",
"(",
"date1",
")",
"date_obj2",
"=",
"convert_date",
"(",
"date2",
")",
"return",
"(",
"date_obj2",
"-",
"date_obj1",
")",
".",
"days",
"<=",
"r... | Check if two date objects are within a specific range | [
"Check",
"if",
"two",
"date",
"objects",
"are",
"within",
"a",
"specific",
"range"
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L101-L105 |
39,269 | sharibarboza/py_zap | py_zap/utils.py | inc_date | def inc_date(date_obj, num, date_fmt):
"""Increment the date by a certain number and return date object.
as the specific string format.
"""
return (date_obj + timedelta(days=num)).strftime(date_fmt) | python | def inc_date(date_obj, num, date_fmt):
"""Increment the date by a certain number and return date object.
as the specific string format.
"""
return (date_obj + timedelta(days=num)).strftime(date_fmt) | [
"def",
"inc_date",
"(",
"date_obj",
",",
"num",
",",
"date_fmt",
")",
":",
"return",
"(",
"date_obj",
"+",
"timedelta",
"(",
"days",
"=",
"num",
")",
")",
".",
"strftime",
"(",
"date_fmt",
")"
] | Increment the date by a certain number and return date object.
as the specific string format. | [
"Increment",
"the",
"date",
"by",
"a",
"certain",
"number",
"and",
"return",
"date",
"object",
".",
"as",
"the",
"specific",
"string",
"format",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L107-L111 |
39,270 | sharibarboza/py_zap | py_zap/utils.py | get_soup | def get_soup(url):
"""Request the page and return the soup."""
html = requests.get(url, stream=True, headers=HEADERS)
if html.status_code != 404:
return BeautifulSoup(html.content, 'html.parser')
else:
return None | python | def get_soup(url):
"""Request the page and return the soup."""
html = requests.get(url, stream=True, headers=HEADERS)
if html.status_code != 404:
return BeautifulSoup(html.content, 'html.parser')
else:
return None | [
"def",
"get_soup",
"(",
"url",
")",
":",
"html",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
",",
"headers",
"=",
"HEADERS",
")",
"if",
"html",
".",
"status_code",
"!=",
"404",
":",
"return",
"BeautifulSoup",
"(",
"html",
"."... | Request the page and return the soup. | [
"Request",
"the",
"page",
"and",
"return",
"the",
"soup",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L127-L133 |
39,271 | sharibarboza/py_zap | py_zap/utils.py | match_list | def match_list(query_list, string):
"""Return True if all words in a word list are in the string.
:param query_list: list of words to match
:param string: the word or words to be matched against
"""
# Get rid of 'the' word to ease string matching
match = False
index = 0
string = ' '.joi... | python | def match_list(query_list, string):
"""Return True if all words in a word list are in the string.
:param query_list: list of words to match
:param string: the word or words to be matched against
"""
# Get rid of 'the' word to ease string matching
match = False
index = 0
string = ' '.joi... | [
"def",
"match_list",
"(",
"query_list",
",",
"string",
")",
":",
"# Get rid of 'the' word to ease string matching",
"match",
"=",
"False",
"index",
"=",
"0",
"string",
"=",
"' '",
".",
"join",
"(",
"filter_stopwords",
"(",
"string",
")",
")",
"if",
"not",
"isi... | Return True if all words in a word list are in the string.
:param query_list: list of words to match
:param string: the word or words to be matched against | [
"Return",
"True",
"if",
"all",
"words",
"in",
"a",
"word",
"list",
"are",
"in",
"the",
"string",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L135-L158 |
39,272 | sharibarboza/py_zap | py_zap/utils.py | filter_stopwords | def filter_stopwords(phrase):
"""Filter out stop words and return as a list of words"""
if not isinstance(phrase, list):
phrase = phrase.split()
stopwords = ['the', 'a', 'in', 'to']
return [word.lower() for word in phrase if word.lower() not in stopwords] | python | def filter_stopwords(phrase):
"""Filter out stop words and return as a list of words"""
if not isinstance(phrase, list):
phrase = phrase.split()
stopwords = ['the', 'a', 'in', 'to']
return [word.lower() for word in phrase if word.lower() not in stopwords] | [
"def",
"filter_stopwords",
"(",
"phrase",
")",
":",
"if",
"not",
"isinstance",
"(",
"phrase",
",",
"list",
")",
":",
"phrase",
"=",
"phrase",
".",
"split",
"(",
")",
"stopwords",
"=",
"[",
"'the'",
",",
"'a'",
",",
"'in'",
",",
"'to'",
"]",
"return",... | Filter out stop words and return as a list of words | [
"Filter",
"out",
"stop",
"words",
"and",
"return",
"as",
"a",
"list",
"of",
"words"
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L160-L166 |
39,273 | sharibarboza/py_zap | py_zap/utils.py | safe_unicode | def safe_unicode(string):
"""If Python 2, replace non-ascii characters and return encoded string."""
if not PY3:
uni = string.replace(u'\u2019', "'")
return uni.encode('utf-8')
return string | python | def safe_unicode(string):
"""If Python 2, replace non-ascii characters and return encoded string."""
if not PY3:
uni = string.replace(u'\u2019', "'")
return uni.encode('utf-8')
return string | [
"def",
"safe_unicode",
"(",
"string",
")",
":",
"if",
"not",
"PY3",
":",
"uni",
"=",
"string",
".",
"replace",
"(",
"u'\\u2019'",
",",
"\"'\"",
")",
"return",
"uni",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"string"
] | If Python 2, replace non-ascii characters and return encoded string. | [
"If",
"Python",
"2",
"replace",
"non",
"-",
"ascii",
"characters",
"and",
"return",
"encoded",
"string",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L174-L180 |
39,274 | sharibarboza/py_zap | py_zap/utils.py | get_strings | def get_strings(soup, tag):
"""Get all the string children from an html tag."""
tags = soup.find_all(tag)
strings = [s.string for s in tags if s.string]
return strings | python | def get_strings(soup, tag):
"""Get all the string children from an html tag."""
tags = soup.find_all(tag)
strings = [s.string for s in tags if s.string]
return strings | [
"def",
"get_strings",
"(",
"soup",
",",
"tag",
")",
":",
"tags",
"=",
"soup",
".",
"find_all",
"(",
"tag",
")",
"strings",
"=",
"[",
"s",
".",
"string",
"for",
"s",
"in",
"tags",
"if",
"s",
".",
"string",
"]",
"return",
"strings"
] | Get all the string children from an html tag. | [
"Get",
"all",
"the",
"string",
"children",
"from",
"an",
"html",
"tag",
"."
] | ce90853efcad66d3e28b8f1ac910f275349d016c | https://github.com/sharibarboza/py_zap/blob/ce90853efcad66d3e28b8f1ac910f275349d016c/py_zap/utils.py#L182-L186 |
39,275 | e7dal/bubble3 | bubble3/commands/cmd_init.py | cli | def cli(ctx, given_name, demo):
"""Initializes a bubble."""
path = None
if path is None:
path = ctx.home
bubble_file_name = path + '/.bubble'
config_file = path + '/config/config.yaml'
if os.path.exists(bubble_file_name) and os.path.isfile(bubble_file_name):
ctx.... | python | def cli(ctx, given_name, demo):
"""Initializes a bubble."""
path = None
if path is None:
path = ctx.home
bubble_file_name = path + '/.bubble'
config_file = path + '/config/config.yaml'
if os.path.exists(bubble_file_name) and os.path.isfile(bubble_file_name):
ctx.... | [
"def",
"cli",
"(",
"ctx",
",",
"given_name",
",",
"demo",
")",
":",
"path",
"=",
"None",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"ctx",
".",
"home",
"bubble_file_name",
"=",
"path",
"+",
"'/.bubble'",
"config_file",
"=",
"path",
"+",
"'/config/co... | Initializes a bubble. | [
"Initializes",
"a",
"bubble",
"."
] | 59c735281a95b44f6263a25f4d6ce24fca520082 | https://github.com/e7dal/bubble3/blob/59c735281a95b44f6263a25f4d6ce24fca520082/bubble3/commands/cmd_init.py#L28-L92 |
39,276 | Equitable/trump | trump/templating/munging_helpers.py | mixin_pab._bld_op | def _bld_op(self, op, num, **kwargs):
"""implements pandas an operator"""
kwargs['other'] = num
setattr(self, op, {'mtype': pab, 'kwargs': kwargs}) | python | def _bld_op(self, op, num, **kwargs):
"""implements pandas an operator"""
kwargs['other'] = num
setattr(self, op, {'mtype': pab, 'kwargs': kwargs}) | [
"def",
"_bld_op",
"(",
"self",
",",
"op",
",",
"num",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'other'",
"]",
"=",
"num",
"setattr",
"(",
"self",
",",
"op",
",",
"{",
"'mtype'",
":",
"pab",
",",
"'kwargs'",
":",
"kwargs",
"}",
")"
] | implements pandas an operator | [
"implements",
"pandas",
"an",
"operator"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/munging_helpers.py#L29-L32 |
39,277 | Equitable/trump | trump/templating/munging_helpers.py | mixin_pab._bld_pab_generic | def _bld_pab_generic(self, funcname, **kwargs):
"""
implements a generic version of an attribute based pandas function
"""
margs = {'mtype': pab, 'kwargs': kwargs}
setattr(self, funcname, margs) | python | def _bld_pab_generic(self, funcname, **kwargs):
"""
implements a generic version of an attribute based pandas function
"""
margs = {'mtype': pab, 'kwargs': kwargs}
setattr(self, funcname, margs) | [
"def",
"_bld_pab_generic",
"(",
"self",
",",
"funcname",
",",
"*",
"*",
"kwargs",
")",
":",
"margs",
"=",
"{",
"'mtype'",
":",
"pab",
",",
"'kwargs'",
":",
"kwargs",
"}",
"setattr",
"(",
"self",
",",
"funcname",
",",
"margs",
")"
] | implements a generic version of an attribute based pandas function | [
"implements",
"a",
"generic",
"version",
"of",
"an",
"attribute",
"based",
"pandas",
"function"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/munging_helpers.py#L42-L47 |
39,278 | Equitable/trump | trump/templating/munging_helpers.py | mixin_pnab._bld_pnab_generic | def _bld_pnab_generic(self, funcname, **kwargs):
"""
implement's a generic version of a non-attribute based pandas function
"""
margs = {'mtype': pnab, 'kwargs': kwargs}
setattr(self, funcname, margs) | python | def _bld_pnab_generic(self, funcname, **kwargs):
"""
implement's a generic version of a non-attribute based pandas function
"""
margs = {'mtype': pnab, 'kwargs': kwargs}
setattr(self, funcname, margs) | [
"def",
"_bld_pnab_generic",
"(",
"self",
",",
"funcname",
",",
"*",
"*",
"kwargs",
")",
":",
"margs",
"=",
"{",
"'mtype'",
":",
"pnab",
",",
"'kwargs'",
":",
"kwargs",
"}",
"setattr",
"(",
"self",
",",
"funcname",
",",
"margs",
")"
] | implement's a generic version of a non-attribute based pandas function | [
"implement",
"s",
"a",
"generic",
"version",
"of",
"a",
"non",
"-",
"attribute",
"based",
"pandas",
"function"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/templating/munging_helpers.py#L58-L63 |
39,279 | codenerix/django-codenerix-invoicing | codenerix_invoicing/views_sales.py | ShoppingCartManagement.get | def get(self, request, *args, **kwargs):
"""
List all products in the shopping cart
"""
cart = ShoppingCartProxy(request)
return JsonResponse(cart.get_products(onlypublic=request.GET.get('onlypublic', True))) | python | def get(self, request, *args, **kwargs):
"""
List all products in the shopping cart
"""
cart = ShoppingCartProxy(request)
return JsonResponse(cart.get_products(onlypublic=request.GET.get('onlypublic', True))) | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cart",
"=",
"ShoppingCartProxy",
"(",
"request",
")",
"return",
"JsonResponse",
"(",
"cart",
".",
"get_products",
"(",
"onlypublic",
"=",
"request",
".",
"... | List all products in the shopping cart | [
"List",
"all",
"products",
"in",
"the",
"shopping",
"cart"
] | 7db5c62f335f9215a8b308603848625208b48698 | https://github.com/codenerix/django-codenerix-invoicing/blob/7db5c62f335f9215a8b308603848625208b48698/codenerix_invoicing/views_sales.py#L1842-L1847 |
39,280 | codenerix/django-codenerix-invoicing | codenerix_invoicing/views_sales.py | ShoppingCartManagement.post | def post(self, request, *args, **kwargs):
"""
Adds new product to the current shopping cart
"""
POST = json.loads(request.body.decode('utf-8'))
if 'product_pk' in POST and 'quantity' in POST:
cart = ShoppingCartProxy(request)
cart.add(
pro... | python | def post(self, request, *args, **kwargs):
"""
Adds new product to the current shopping cart
"""
POST = json.loads(request.body.decode('utf-8'))
if 'product_pk' in POST and 'quantity' in POST:
cart = ShoppingCartProxy(request)
cart.add(
pro... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"POST",
"=",
"json",
".",
"loads",
"(",
"request",
".",
"body",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"if",
"'product_pk'",
"in",
"POST",
"and",
"... | Adds new product to the current shopping cart | [
"Adds",
"new",
"product",
"to",
"the",
"current",
"shopping",
"cart"
] | 7db5c62f335f9215a8b308603848625208b48698 | https://github.com/codenerix/django-codenerix-invoicing/blob/7db5c62f335f9215a8b308603848625208b48698/codenerix_invoicing/views_sales.py#L1849-L1863 |
39,281 | todstoychev/signal-dispatcher | signal_dispatcher/signal_dispatcher.py | SignalDispatcher.register_signal | def register_signal(alias: str, signal: pyqtSignal):
"""
Used to register signal at the dispatcher. Note that you can not use alias that already exists.
:param alias: Alias of the signal. String.
:param signal: Signal itself. Usually pyqtSignal instance.
:return:
"""
... | python | def register_signal(alias: str, signal: pyqtSignal):
"""
Used to register signal at the dispatcher. Note that you can not use alias that already exists.
:param alias: Alias of the signal. String.
:param signal: Signal itself. Usually pyqtSignal instance.
:return:
"""
... | [
"def",
"register_signal",
"(",
"alias",
":",
"str",
",",
"signal",
":",
"pyqtSignal",
")",
":",
"if",
"SignalDispatcher",
".",
"signal_alias_exists",
"(",
"alias",
")",
":",
"raise",
"SignalDispatcherError",
"(",
"'Alias \"'",
"+",
"alias",
"+",
"'\" for signal ... | Used to register signal at the dispatcher. Note that you can not use alias that already exists.
:param alias: Alias of the signal. String.
:param signal: Signal itself. Usually pyqtSignal instance.
:return: | [
"Used",
"to",
"register",
"signal",
"at",
"the",
"dispatcher",
".",
"Note",
"that",
"you",
"can",
"not",
"use",
"alias",
"that",
"already",
"exists",
"."
] | 77131d119045973d65434abbcd6accdfa9cc327a | https://github.com/todstoychev/signal-dispatcher/blob/77131d119045973d65434abbcd6accdfa9cc327a/signal_dispatcher/signal_dispatcher.py#L12-L23 |
39,282 | todstoychev/signal-dispatcher | signal_dispatcher/signal_dispatcher.py | SignalDispatcher.register_handler | def register_handler(alias: str, handler: callable):
"""
Used to register handler at the dispatcher.
:param alias: Signal alias to match handler to.
:param handler: Handler. Some callable.
:return:
"""
if SignalDispatcher.handlers.get(alias) is None:
... | python | def register_handler(alias: str, handler: callable):
"""
Used to register handler at the dispatcher.
:param alias: Signal alias to match handler to.
:param handler: Handler. Some callable.
:return:
"""
if SignalDispatcher.handlers.get(alias) is None:
... | [
"def",
"register_handler",
"(",
"alias",
":",
"str",
",",
"handler",
":",
"callable",
")",
":",
"if",
"SignalDispatcher",
".",
"handlers",
".",
"get",
"(",
"alias",
")",
"is",
"None",
":",
"SignalDispatcher",
".",
"handlers",
"[",
"alias",
"]",
"=",
"[",... | Used to register handler at the dispatcher.
:param alias: Signal alias to match handler to.
:param handler: Handler. Some callable.
:return: | [
"Used",
"to",
"register",
"handler",
"at",
"the",
"dispatcher",
"."
] | 77131d119045973d65434abbcd6accdfa9cc327a | https://github.com/todstoychev/signal-dispatcher/blob/77131d119045973d65434abbcd6accdfa9cc327a/signal_dispatcher/signal_dispatcher.py#L26-L37 |
39,283 | todstoychev/signal-dispatcher | signal_dispatcher/signal_dispatcher.py | SignalDispatcher.dispatch | def dispatch():
"""
This methods runs the wheel. It is used to connect signal with their handlers, based on the aliases.
:return:
"""
aliases = SignalDispatcher.signals.keys()
for alias in aliases:
handlers = SignalDispatcher.handlers.get(alias)
... | python | def dispatch():
"""
This methods runs the wheel. It is used to connect signal with their handlers, based on the aliases.
:return:
"""
aliases = SignalDispatcher.signals.keys()
for alias in aliases:
handlers = SignalDispatcher.handlers.get(alias)
... | [
"def",
"dispatch",
"(",
")",
":",
"aliases",
"=",
"SignalDispatcher",
".",
"signals",
".",
"keys",
"(",
")",
"for",
"alias",
"in",
"aliases",
":",
"handlers",
"=",
"SignalDispatcher",
".",
"handlers",
".",
"get",
"(",
"alias",
")",
"signal",
"=",
"Signal... | This methods runs the wheel. It is used to connect signal with their handlers, based on the aliases.
:return: | [
"This",
"methods",
"runs",
"the",
"wheel",
".",
"It",
"is",
"used",
"to",
"connect",
"signal",
"with",
"their",
"handlers",
"based",
"on",
"the",
"aliases",
"."
] | 77131d119045973d65434abbcd6accdfa9cc327a | https://github.com/todstoychev/signal-dispatcher/blob/77131d119045973d65434abbcd6accdfa9cc327a/signal_dispatcher/signal_dispatcher.py#L40-L56 |
39,284 | paltman-archive/nashvegas | nashvegas/management/commands/upgradedb.py | Command._get_rev | def _get_rev(self, fpath):
"""
Get an SCM version number. Try svn and git.
"""
rev = None
try:
cmd = ["git", "log", "-n1", "--pretty=format:\"%h\"", fpath]
rev = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()[0]
except:
pas... | python | def _get_rev(self, fpath):
"""
Get an SCM version number. Try svn and git.
"""
rev = None
try:
cmd = ["git", "log", "-n1", "--pretty=format:\"%h\"", fpath]
rev = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()[0]
except:
pas... | [
"def",
"_get_rev",
"(",
"self",
",",
"fpath",
")",
":",
"rev",
"=",
"None",
"try",
":",
"cmd",
"=",
"[",
"\"git\"",
",",
"\"log\"",
",",
"\"-n1\"",
",",
"\"--pretty=format:\\\"%h\\\"\"",
",",
"fpath",
"]",
"rev",
"=",
"Popen",
"(",
"cmd",
",",
"stdout"... | Get an SCM version number. Try svn and git. | [
"Get",
"an",
"SCM",
"version",
"number",
".",
"Try",
"svn",
"and",
"git",
"."
] | 14e904a3f5b87e878cd053b554e76e85943d1c11 | https://github.com/paltman-archive/nashvegas/blob/14e904a3f5b87e878cd053b554e76e85943d1c11/nashvegas/management/commands/upgradedb.py#L90-L115 |
39,285 | paltman-archive/nashvegas | nashvegas/management/commands/upgradedb.py | Command.execute_migrations | def execute_migrations(self, show_traceback=True):
"""
Executes all pending migrations across all capable
databases
"""
all_migrations = get_pending_migrations(self.path, self.databases)
if not len(all_migrations):
sys.stdout.write("There are no migra... | python | def execute_migrations(self, show_traceback=True):
"""
Executes all pending migrations across all capable
databases
"""
all_migrations = get_pending_migrations(self.path, self.databases)
if not len(all_migrations):
sys.stdout.write("There are no migra... | [
"def",
"execute_migrations",
"(",
"self",
",",
"show_traceback",
"=",
"True",
")",
":",
"all_migrations",
"=",
"get_pending_migrations",
"(",
"self",
".",
"path",
",",
"self",
".",
"databases",
")",
"if",
"not",
"len",
"(",
"all_migrations",
")",
":",
"sys",... | Executes all pending migrations across all capable
databases | [
"Executes",
"all",
"pending",
"migrations",
"across",
"all",
"capable",
"databases"
] | 14e904a3f5b87e878cd053b554e76e85943d1c11 | https://github.com/paltman-archive/nashvegas/blob/14e904a3f5b87e878cd053b554e76e85943d1c11/nashvegas/management/commands/upgradedb.py#L270-L317 |
39,286 | paltman-archive/nashvegas | nashvegas/management/commands/upgradedb.py | Command.handle | def handle(self, *args, **options):
"""
Upgrades the database.
Executes SQL scripts that haven't already been applied to the
database.
"""
self.do_list = options.get("do_list")
self.do_execute = options.get("do_execute")
self.do_create = options.g... | python | def handle(self, *args, **options):
"""
Upgrades the database.
Executes SQL scripts that haven't already been applied to the
database.
"""
self.do_list = options.get("do_list")
self.do_execute = options.get("do_execute")
self.do_create = options.g... | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"do_list",
"=",
"options",
".",
"get",
"(",
"\"do_list\"",
")",
"self",
".",
"do_execute",
"=",
"options",
".",
"get",
"(",
"\"do_execute\"",
")",
"self"... | Upgrades the database.
Executes SQL scripts that haven't already been applied to the
database. | [
"Upgrades",
"the",
"database",
".",
"Executes",
"SQL",
"scripts",
"that",
"haven",
"t",
"already",
"been",
"applied",
"to",
"the",
"database",
"."
] | 14e904a3f5b87e878cd053b554e76e85943d1c11 | https://github.com/paltman-archive/nashvegas/blob/14e904a3f5b87e878cd053b554e76e85943d1c11/nashvegas/management/commands/upgradedb.py#L377-L427 |
39,287 | Equitable/trump | docs/diagrams/tsadisplay/render.py | plantuml | def plantuml(desc):
"""Generate plantuml class diagram
:param desc: result of sadisplay.describe function
Return plantuml class diagram string
"""
classes, relations, inherits = desc
result = [
'@startuml',
'skinparam defaultFontName Courier',
]
for cls in classes:
... | python | def plantuml(desc):
"""Generate plantuml class diagram
:param desc: result of sadisplay.describe function
Return plantuml class diagram string
"""
classes, relations, inherits = desc
result = [
'@startuml',
'skinparam defaultFontName Courier',
]
for cls in classes:
... | [
"def",
"plantuml",
"(",
"desc",
")",
":",
"classes",
",",
"relations",
",",
"inherits",
"=",
"desc",
"result",
"=",
"[",
"'@startuml'",
",",
"'skinparam defaultFontName Courier'",
",",
"]",
"for",
"cls",
"in",
"classes",
":",
"# issue #11 - tabular output of class... | Generate plantuml class diagram
:param desc: result of sadisplay.describe function
Return plantuml class diagram string | [
"Generate",
"plantuml",
"class",
"diagram"
] | a2802692bc642fa32096374159eea7ceca2947b4 | https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/docs/diagrams/tsadisplay/render.py#L15-L61 |
39,288 | pauleveritt/kaybee | kaybee/plugins/references/base_reference.py | is_reference_target | def is_reference_target(resource, rtype, label):
""" Return true if the resource has this rtype with this label """
prop = resource.props.references.get(rtype, False)
if prop:
return label in prop | python | def is_reference_target(resource, rtype, label):
""" Return true if the resource has this rtype with this label """
prop = resource.props.references.get(rtype, False)
if prop:
return label in prop | [
"def",
"is_reference_target",
"(",
"resource",
",",
"rtype",
",",
"label",
")",
":",
"prop",
"=",
"resource",
".",
"props",
".",
"references",
".",
"get",
"(",
"rtype",
",",
"False",
")",
"if",
"prop",
":",
"return",
"label",
"in",
"prop"
] | Return true if the resource has this rtype with this label | [
"Return",
"true",
"if",
"the",
"resource",
"has",
"this",
"rtype",
"with",
"this",
"label"
] | a00a718aaaa23b2d12db30dfacb6b2b6ec84459c | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/references/base_reference.py#L7-L12 |
39,289 | pauleveritt/kaybee | kaybee/plugins/references/base_reference.py | BaseReference.get_sources | def get_sources(self, resources):
""" Filter resources based on which have this reference """
rtype = self.rtype # E.g. category
label = self.props.label # E.g. category1
result = [
resource
for resource in resources.values()
if is_reference_target(... | python | def get_sources(self, resources):
""" Filter resources based on which have this reference """
rtype = self.rtype # E.g. category
label = self.props.label # E.g. category1
result = [
resource
for resource in resources.values()
if is_reference_target(... | [
"def",
"get_sources",
"(",
"self",
",",
"resources",
")",
":",
"rtype",
"=",
"self",
".",
"rtype",
"# E.g. category",
"label",
"=",
"self",
".",
"props",
".",
"label",
"# E.g. category1",
"result",
"=",
"[",
"resource",
"for",
"resource",
"in",
"resources",
... | Filter resources based on which have this reference | [
"Filter",
"resources",
"based",
"on",
"which",
"have",
"this",
"reference"
] | a00a718aaaa23b2d12db30dfacb6b2b6ec84459c | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/references/base_reference.py#L23-L33 |
39,290 | pauleveritt/kaybee | kaybee/__init__.py | setup | def setup(app: Sphinx):
""" Initialize Kaybee as a Sphinx extension """
# Scan for directives, first in the system, second in the docs project
importscan.scan(plugins)
dectate.commit(kb)
app.add_config_value('kaybee_settings', KaybeeSettings(), 'html')
bridge = 'kaybee.plugins.postrenderer.con... | python | def setup(app: Sphinx):
""" Initialize Kaybee as a Sphinx extension """
# Scan for directives, first in the system, second in the docs project
importscan.scan(plugins)
dectate.commit(kb)
app.add_config_value('kaybee_settings', KaybeeSettings(), 'html')
bridge = 'kaybee.plugins.postrenderer.con... | [
"def",
"setup",
"(",
"app",
":",
"Sphinx",
")",
":",
"# Scan for directives, first in the system, second in the docs project",
"importscan",
".",
"scan",
"(",
"plugins",
")",
"dectate",
".",
"commit",
"(",
"kb",
")",
"app",
".",
"add_config_value",
"(",
"'kaybee_set... | Initialize Kaybee as a Sphinx extension | [
"Initialize",
"Kaybee",
"as",
"a",
"Sphinx",
"extension"
] | a00a718aaaa23b2d12db30dfacb6b2b6ec84459c | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/__init__.py#L20-L101 |
39,291 | bitesofcode/projex | projex/plugin.py | PluginProxy.loadInstance | def loadInstance(self):
"""
Loads the plugin from the proxy information that was created from the
registry file.
"""
if self._loaded:
return
self._loaded = True
module_path = self.modulePath()
package = projex.packageFromPath(module_path)
... | python | def loadInstance(self):
"""
Loads the plugin from the proxy information that was created from the
registry file.
"""
if self._loaded:
return
self._loaded = True
module_path = self.modulePath()
package = projex.packageFromPath(module_path)
... | [
"def",
"loadInstance",
"(",
"self",
")",
":",
"if",
"self",
".",
"_loaded",
":",
"return",
"self",
".",
"_loaded",
"=",
"True",
"module_path",
"=",
"self",
".",
"modulePath",
"(",
")",
"package",
"=",
"projex",
".",
"packageFromPath",
"(",
"module_path",
... | Loads the plugin from the proxy information that was created from the
registry file. | [
"Loads",
"the",
"plugin",
"from",
"the",
"proxy",
"information",
"that",
"was",
"created",
"from",
"the",
"registry",
"file",
"."
] | d31743ec456a41428709968ab11a2cf6c6c76247 | https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/plugin.py#L593-L627 |
39,292 | pauleveritt/kaybee | kaybee/plugins/articles/jsoncatalog.py | clean_resource_json | def clean_resource_json(resource_json):
""" The catalog wants to be smaller, let's drop some stuff """
for a in ('parent_docname', 'parent', 'template', 'repr', 'series'):
if a in resource_json:
del resource_json[a]
props = resource_json['props']
for prop in (
'acquired... | python | def clean_resource_json(resource_json):
""" The catalog wants to be smaller, let's drop some stuff """
for a in ('parent_docname', 'parent', 'template', 'repr', 'series'):
if a in resource_json:
del resource_json[a]
props = resource_json['props']
for prop in (
'acquired... | [
"def",
"clean_resource_json",
"(",
"resource_json",
")",
":",
"for",
"a",
"in",
"(",
"'parent_docname'",
",",
"'parent'",
",",
"'template'",
",",
"'repr'",
",",
"'series'",
")",
":",
"if",
"a",
"in",
"resource_json",
":",
"del",
"resource_json",
"[",
"a",
... | The catalog wants to be smaller, let's drop some stuff | [
"The",
"catalog",
"wants",
"to",
"be",
"smaller",
"let",
"s",
"drop",
"some",
"stuff"
] | a00a718aaaa23b2d12db30dfacb6b2b6ec84459c | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/articles/jsoncatalog.py#L18-L32 |
39,293 | MacHu-GWU/crawlib-project | crawlib/downloader/requests_downloader.py | RequestsDownloader.get | def get(self,
url,
params=None,
cache_cb=None,
**kwargs):
"""
Make http get request.
:param url:
:param params:
:param cache_cb: (optional) a function that taking requests.Response
as input, and returns a bool flag, ind... | python | def get(self,
url,
params=None,
cache_cb=None,
**kwargs):
"""
Make http get request.
:param url:
:param params:
:param cache_cb: (optional) a function that taking requests.Response
as input, and returns a bool flag, ind... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"cache_cb",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"use_random_user_agent",
":",
"headers",
"=",
"kwargs",
".",
"get",
"(",
"\"headers\"",
",",
"dict"... | Make http get request.
:param url:
:param params:
:param cache_cb: (optional) a function that taking requests.Response
as input, and returns a bool flag, indicate whether should update the cache.
:param cache_expire: (optional).
:param kwargs: optional arguments. | [
"Make",
"http",
"get",
"request",
"."
] | 241516f2a7a0a32c692f7af35a1f44064e8ce1ab | https://github.com/MacHu-GWU/crawlib-project/blob/241516f2a7a0a32c692f7af35a1f44064e8ce1ab/crawlib/downloader/requests_downloader.py#L103-L138 |
39,294 | MacHu-GWU/crawlib-project | crawlib/downloader/requests_downloader.py | RequestsDownloader.download | def download(self,
url,
dst,
params=None,
cache_cb=None,
overwrite=False,
stream=False,
minimal_size=-1,
maximum_size=1024 ** 6,
**kwargs):
"""
Downloa... | python | def download(self,
url,
dst,
params=None,
cache_cb=None,
overwrite=False,
stream=False,
minimal_size=-1,
maximum_size=1024 ** 6,
**kwargs):
"""
Downloa... | [
"def",
"download",
"(",
"self",
",",
"url",
",",
"dst",
",",
"params",
"=",
"None",
",",
"cache_cb",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"stream",
"=",
"False",
",",
"minimal_size",
"=",
"-",
"1",
",",
"maximum_size",
"=",
"1024",
"**",... | Download binary content to destination.
:param url: binary content url
:param dst: path to the 'save_as' file
:param cache_cb: (optional) a function that taking requests.Response
as input, and returns a bool flag, indicate whether should update the cache.
:param overwrite: b... | [
"Download",
"binary",
"content",
"to",
"destination",
"."
] | 241516f2a7a0a32c692f7af35a1f44064e8ce1ab | https://github.com/MacHu-GWU/crawlib-project/blob/241516f2a7a0a32c692f7af35a1f44064e8ce1ab/crawlib/downloader/requests_downloader.py#L176-L233 |
39,295 | nicferrier/md | src/mdlib/cmdln.py | option | def option(*args, **kwargs):
"""Decorator to add an option to the optparser argument of a Cmdln
subcommand
To add a toplevel option, apply the decorator on the class itself. (see
p4.py for an example)
Example:
@cmdln.option("-E", dest="environment_path")
class MyShell(cmdln.Cmd... | python | def option(*args, **kwargs):
"""Decorator to add an option to the optparser argument of a Cmdln
subcommand
To add a toplevel option, apply the decorator on the class itself. (see
p4.py for an example)
Example:
@cmdln.option("-E", dest="environment_path")
class MyShell(cmdln.Cmd... | [
"def",
"option",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorate_sub_command",
"(",
"method",
")",
":",
"\"\"\"create and add sub-command options\"\"\"",
"if",
"not",
"hasattr",
"(",
"method",
",",
"\"optparser\"",
")",
":",
"method",
"."... | Decorator to add an option to the optparser argument of a Cmdln
subcommand
To add a toplevel option, apply the decorator on the class itself. (see
p4.py for an example)
Example:
@cmdln.option("-E", dest="environment_path")
class MyShell(cmdln.Cmdln):
@cmdln.option("-f",... | [
"Decorator",
"to",
"add",
"an",
"option",
"to",
"the",
"optparser",
"argument",
"of",
"a",
"Cmdln",
"subcommand"
] | 302ca8882dae060fb15bd5ae470d8e661fb67ec4 | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cmdln.py#L1056-L1090 |
39,296 | nicferrier/md | src/mdlib/cmdln.py | _inherit_attr | def _inherit_attr(klass, attr, default, cp):
"""Inherit the attribute from the base class
Copy `attr` from base class (otherwise use `default`). Copying is done using
the passed `cp` function.
The motivation behind writing this function is to allow inheritance among
Cmdln classes where base classe... | python | def _inherit_attr(klass, attr, default, cp):
"""Inherit the attribute from the base class
Copy `attr` from base class (otherwise use `default`). Copying is done using
the passed `cp` function.
The motivation behind writing this function is to allow inheritance among
Cmdln classes where base classe... | [
"def",
"_inherit_attr",
"(",
"klass",
",",
"attr",
",",
"default",
",",
"cp",
")",
":",
"if",
"attr",
"not",
"in",
"klass",
".",
"__dict__",
":",
"if",
"hasattr",
"(",
"klass",
",",
"attr",
")",
":",
"value",
"=",
"cp",
"(",
"getattr",
"(",
"klass"... | Inherit the attribute from the base class
Copy `attr` from base class (otherwise use `default`). Copying is done using
the passed `cp` function.
The motivation behind writing this function is to allow inheritance among
Cmdln classes where base classes set 'common' options using the
`@cmdln.option`... | [
"Inherit",
"the",
"attribute",
"from",
"the",
"base",
"class"
] | 302ca8882dae060fb15bd5ae470d8e661fb67ec4 | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cmdln.py#L1314-L1330 |
39,297 | nicferrier/md | src/mdlib/cmdln.py | _forgiving_issubclass | def _forgiving_issubclass(derived_class, base_class):
"""Forgiving version of ``issubclass``
Does not throw any exception when arguments are not of class type
"""
return (type(derived_class) is ClassType and \
type(base_class) is ClassType and \
issubclass(derived_class, base_cl... | python | def _forgiving_issubclass(derived_class, base_class):
"""Forgiving version of ``issubclass``
Does not throw any exception when arguments are not of class type
"""
return (type(derived_class) is ClassType and \
type(base_class) is ClassType and \
issubclass(derived_class, base_cl... | [
"def",
"_forgiving_issubclass",
"(",
"derived_class",
",",
"base_class",
")",
":",
"return",
"(",
"type",
"(",
"derived_class",
")",
"is",
"ClassType",
"and",
"type",
"(",
"base_class",
")",
"is",
"ClassType",
"and",
"issubclass",
"(",
"derived_class",
",",
"b... | Forgiving version of ``issubclass``
Does not throw any exception when arguments are not of class type | [
"Forgiving",
"version",
"of",
"issubclass"
] | 302ca8882dae060fb15bd5ae470d8e661fb67ec4 | https://github.com/nicferrier/md/blob/302ca8882dae060fb15bd5ae470d8e661fb67ec4/src/mdlib/cmdln.py#L1332-L1339 |
39,298 | hollenstein/maspy | maspy/calib.py | timecalMs1DataMedian | def timecalMs1DataMedian(msrunContainer, specfile, calibrationData,
minDataPoints=50, deviationKey='relDev'):
"""Generates a calibration value for each MS1 scan by calculating the median
deviation
:param msrunContainer: intance of :class:`maspy.core.MsrunContainer`
:param specf... | python | def timecalMs1DataMedian(msrunContainer, specfile, calibrationData,
minDataPoints=50, deviationKey='relDev'):
"""Generates a calibration value for each MS1 scan by calculating the median
deviation
:param msrunContainer: intance of :class:`maspy.core.MsrunContainer`
:param specf... | [
"def",
"timecalMs1DataMedian",
"(",
"msrunContainer",
",",
"specfile",
",",
"calibrationData",
",",
"minDataPoints",
"=",
"50",
",",
"deviationKey",
"=",
"'relDev'",
")",
":",
"corrData",
"=",
"dict",
"(",
")",
"_posDict",
"=",
"dict",
"(",
")",
"pos",
"=",
... | Generates a calibration value for each MS1 scan by calculating the median
deviation
:param msrunContainer: intance of :class:`maspy.core.MsrunContainer`
:param specfile: filename of an ms-run file, used to generate an calibration
value for each MS1 spectrum item.
:param calibrationData: a dicti... | [
"Generates",
"a",
"calibration",
"value",
"for",
"each",
"MS1",
"scan",
"by",
"calculating",
"the",
"median",
"deviation"
] | f15fcfd24df306d8420540460d902aa3073ec133 | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/calib.py#L182-L254 |
39,299 | pauleveritt/kaybee | kaybee/plugins/genericpage/action.py | GenericpageAction.get_genericpage | def get_genericpage(cls, kb_app):
""" Return the one class if configured, otherwise default """
# Presumes the registry has been committed
q = dectate.Query('genericpage')
klasses = sorted(q(kb_app), key=lambda args: args[0].order)
if not klasses:
# The site doesn't ... | python | def get_genericpage(cls, kb_app):
""" Return the one class if configured, otherwise default """
# Presumes the registry has been committed
q = dectate.Query('genericpage')
klasses = sorted(q(kb_app), key=lambda args: args[0].order)
if not klasses:
# The site doesn't ... | [
"def",
"get_genericpage",
"(",
"cls",
",",
"kb_app",
")",
":",
"# Presumes the registry has been committed",
"q",
"=",
"dectate",
".",
"Query",
"(",
"'genericpage'",
")",
"klasses",
"=",
"sorted",
"(",
"q",
"(",
"kb_app",
")",
",",
"key",
"=",
"lambda",
"arg... | Return the one class if configured, otherwise default | [
"Return",
"the",
"one",
"class",
"if",
"configured",
"otherwise",
"default"
] | a00a718aaaa23b2d12db30dfacb6b2b6ec84459c | https://github.com/pauleveritt/kaybee/blob/a00a718aaaa23b2d12db30dfacb6b2b6ec84459c/kaybee/plugins/genericpage/action.py#L29-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.