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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
249,400 | bmweiner/skillful | skillful/interface.py | ResponseBody.set_reprompt_ssml | def set_reprompt_ssml(self, ssml):
"""Set response reprompt output speech as SSML type.
Args:
ssml: str. Response speech used when type is 'SSML', should be formatted
with Speech Synthesis Markup Language. Cannot exceed 8,000
characters.
"""
s... | python | def set_reprompt_ssml(self, ssml):
"""Set response reprompt output speech as SSML type.
Args:
ssml: str. Response speech used when type is 'SSML', should be formatted
with Speech Synthesis Markup Language. Cannot exceed 8,000
characters.
"""
s... | [
"def",
"set_reprompt_ssml",
"(",
"self",
",",
"ssml",
")",
":",
"self",
".",
"response",
".",
"reprompt",
".",
"outputSpeech",
".",
"type",
"=",
"'SSML'",
"self",
".",
"response",
".",
"reprompt",
".",
"outputSpeech",
".",
"ssml",
"=",
"ssml"
] | Set response reprompt output speech as SSML type.
Args:
ssml: str. Response speech used when type is 'SSML', should be formatted
with Speech Synthesis Markup Language. Cannot exceed 8,000
characters. | [
"Set",
"response",
"reprompt",
"output",
"speech",
"as",
"SSML",
"type",
"."
] | 8646f54faf62cb63f165f7699b8ace5b4a08233c | https://github.com/bmweiner/skillful/blob/8646f54faf62cb63f165f7699b8ace5b4a08233c/skillful/interface.py#L435-L444 |
249,401 | salimm/httpoutpustream | httpoutputstream/stream.py | HttpBufferedOutstream.flush | def flush(self):
'''
Flushes the buffer to socket. Only call when the write is done. Calling flush after each write will prevent the buffer to act as efficiently as possible
'''
# return if empty
if self.__bufferidx == 0:
return
# send here the data
s... | python | def flush(self):
'''
Flushes the buffer to socket. Only call when the write is done. Calling flush after each write will prevent the buffer to act as efficiently as possible
'''
# return if empty
if self.__bufferidx == 0:
return
# send here the data
s... | [
"def",
"flush",
"(",
"self",
")",
":",
"# return if empty",
"if",
"self",
".",
"__bufferidx",
"==",
"0",
":",
"return",
"# send here the data",
"self",
".",
"conn",
".",
"send",
"(",
"\"%s\\r\\n\"",
"%",
"hex",
"(",
"self",
".",
"__bufferidx",
")",
"[",
... | Flushes the buffer to socket. Only call when the write is done. Calling flush after each write will prevent the buffer to act as efficiently as possible | [
"Flushes",
"the",
"buffer",
"to",
"socket",
".",
"Only",
"call",
"when",
"the",
"write",
"is",
"done",
".",
"Calling",
"flush",
"after",
"each",
"write",
"will",
"prevent",
"the",
"buffer",
"to",
"act",
"as",
"efficiently",
"as",
"possible"
] | c3c785e3c6faf6348494b742669cd8025659f763 | https://github.com/salimm/httpoutpustream/blob/c3c785e3c6faf6348494b742669cd8025659f763/httpoutputstream/stream.py#L92-L103 |
249,402 | salimm/httpoutpustream | httpoutputstream/stream.py | HttpBufferedOutstream.close | def close(self):
'''
Closes the stream to output. It destroys the buffer and the buffer pointer. However, it will not close the the client connection
'''
#write all that is remained in buffer
self.flush()
# delete buffer
self.__buffer = None
#reset buffer ... | python | def close(self):
'''
Closes the stream to output. It destroys the buffer and the buffer pointer. However, it will not close the the client connection
'''
#write all that is remained in buffer
self.flush()
# delete buffer
self.__buffer = None
#reset buffer ... | [
"def",
"close",
"(",
"self",
")",
":",
"#write all that is remained in buffer",
"self",
".",
"flush",
"(",
")",
"# delete buffer",
"self",
".",
"__buffer",
"=",
"None",
"#reset buffer index to -1 to indicate no where",
"self",
".",
"__bufferidx",
"=",
"-",
"1",
"#wr... | Closes the stream to output. It destroys the buffer and the buffer pointer. However, it will not close the the client connection | [
"Closes",
"the",
"stream",
"to",
"output",
".",
"It",
"destroys",
"the",
"buffer",
"and",
"the",
"buffer",
"pointer",
".",
"However",
"it",
"will",
"not",
"close",
"the",
"the",
"client",
"connection"
] | c3c785e3c6faf6348494b742669cd8025659f763 | https://github.com/salimm/httpoutpustream/blob/c3c785e3c6faf6348494b742669cd8025659f763/httpoutputstream/stream.py#L106-L121 |
249,403 | cfobel/clutter-webcam-viewer | clutter_webcam_viewer/warp_control.py | WarpControl.create_ui | def create_ui(self):
'''
Create UI elements and connect signals.
'''
box = Gtk.Box()
rotate_left = Gtk.Button('Rotate left')
rotate_right = Gtk.Button('Rotate right')
flip_horizontal = Gtk.Button('Flip horizontal')
flip_vertical = Gtk.Button('Flip vertical... | python | def create_ui(self):
'''
Create UI elements and connect signals.
'''
box = Gtk.Box()
rotate_left = Gtk.Button('Rotate left')
rotate_right = Gtk.Button('Rotate right')
flip_horizontal = Gtk.Button('Flip horizontal')
flip_vertical = Gtk.Button('Flip vertical... | [
"def",
"create_ui",
"(",
"self",
")",
":",
"box",
"=",
"Gtk",
".",
"Box",
"(",
")",
"rotate_left",
"=",
"Gtk",
".",
"Button",
"(",
"'Rotate left'",
")",
"rotate_right",
"=",
"Gtk",
".",
"Button",
"(",
"'Rotate right'",
")",
"flip_horizontal",
"=",
"Gtk",... | Create UI elements and connect signals. | [
"Create",
"UI",
"elements",
"and",
"connect",
"signals",
"."
] | b227d2ae02d750194e65c13bcf178550755c3afc | https://github.com/cfobel/clutter-webcam-viewer/blob/b227d2ae02d750194e65c13bcf178550755c3afc/clutter_webcam_viewer/warp_control.py#L15-L55 |
249,404 | cfobel/clutter-webcam-viewer | clutter_webcam_viewer/warp_control.py | WarpControl.save | def save(self):
'''
Save warp projection settings to HDF file.
'''
response = pu.open(title='Save perspective warp', patterns=['*.h5'])
if response is not None:
self.warp_actor.save(response) | python | def save(self):
'''
Save warp projection settings to HDF file.
'''
response = pu.open(title='Save perspective warp', patterns=['*.h5'])
if response is not None:
self.warp_actor.save(response) | [
"def",
"save",
"(",
"self",
")",
":",
"response",
"=",
"pu",
".",
"open",
"(",
"title",
"=",
"'Save perspective warp'",
",",
"patterns",
"=",
"[",
"'*.h5'",
"]",
")",
"if",
"response",
"is",
"not",
"None",
":",
"self",
".",
"warp_actor",
".",
"save",
... | Save warp projection settings to HDF file. | [
"Save",
"warp",
"projection",
"settings",
"to",
"HDF",
"file",
"."
] | b227d2ae02d750194e65c13bcf178550755c3afc | https://github.com/cfobel/clutter-webcam-viewer/blob/b227d2ae02d750194e65c13bcf178550755c3afc/clutter_webcam_viewer/warp_control.py#L57-L63 |
249,405 | cfobel/clutter-webcam-viewer | clutter_webcam_viewer/warp_control.py | WarpControl.load | def load(self):
'''
Load warp projection settings from HDF file.
'''
response = pu.open(title='Load perspective warp', patterns=['*.h5'])
if response is not None:
self.warp_actor.load(response) | python | def load(self):
'''
Load warp projection settings from HDF file.
'''
response = pu.open(title='Load perspective warp', patterns=['*.h5'])
if response is not None:
self.warp_actor.load(response) | [
"def",
"load",
"(",
"self",
")",
":",
"response",
"=",
"pu",
".",
"open",
"(",
"title",
"=",
"'Load perspective warp'",
",",
"patterns",
"=",
"[",
"'*.h5'",
"]",
")",
"if",
"response",
"is",
"not",
"None",
":",
"self",
".",
"warp_actor",
".",
"load",
... | Load warp projection settings from HDF file. | [
"Load",
"warp",
"projection",
"settings",
"from",
"HDF",
"file",
"."
] | b227d2ae02d750194e65c13bcf178550755c3afc | https://github.com/cfobel/clutter-webcam-viewer/blob/b227d2ae02d750194e65c13bcf178550755c3afc/clutter_webcam_viewer/warp_control.py#L65-L71 |
249,406 | tbobm/devscripts | devscripts/logs.py | simple_logger | def simple_logger(**kwargs):
"""
Creates a simple logger
:param str name: The logger's name ('api', 'back'...)
:param int base_level: Lowest level allowed to log (Default: DEBUG)
:param str log_format: Logging format used for STDOUT
(Default: logs.FORMAT)
:param bool... | python | def simple_logger(**kwargs):
"""
Creates a simple logger
:param str name: The logger's name ('api', 'back'...)
:param int base_level: Lowest level allowed to log (Default: DEBUG)
:param str log_format: Logging format used for STDOUT
(Default: logs.FORMAT)
:param bool... | [
"def",
"simple_logger",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Args",
"logger_name",
"=",
"kwargs",
".",
"get",
"(",
"'name'",
")",
"base_level",
"=",
"kwargs",
".",
"get",
"(",
"'base_level'",
",",
"logging",
".",
"DEBUG",
")",
"should_stdout",
"=",
"kwa... | Creates a simple logger
:param str name: The logger's name ('api', 'back'...)
:param int base_level: Lowest level allowed to log (Default: DEBUG)
:param str log_format: Logging format used for STDOUT
(Default: logs.FORMAT)
:param bool should_stdout: Allows to log to stdout (... | [
"Creates",
"a",
"simple",
"logger"
] | beb23371ba80739afb5474766e8049ead3837925 | https://github.com/tbobm/devscripts/blob/beb23371ba80739afb5474766e8049ead3837925/devscripts/logs.py#L12-L49 |
249,407 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | compare_dicts | def compare_dicts(d1, d2):
"""
Returns a diff string of the two dicts.
"""
a = json.dumps(d1, indent=4, sort_keys=True)
b = json.dumps(d2, indent=4, sort_keys=True)
# stolen from cpython
# https://github.com/python/cpython/blob/01fd68752e2d2d0a5f90ae8944ca35df0a5ddeaa/Lib/unittest/case.py#L1... | python | def compare_dicts(d1, d2):
"""
Returns a diff string of the two dicts.
"""
a = json.dumps(d1, indent=4, sort_keys=True)
b = json.dumps(d2, indent=4, sort_keys=True)
# stolen from cpython
# https://github.com/python/cpython/blob/01fd68752e2d2d0a5f90ae8944ca35df0a5ddeaa/Lib/unittest/case.py#L1... | [
"def",
"compare_dicts",
"(",
"d1",
",",
"d2",
")",
":",
"a",
"=",
"json",
".",
"dumps",
"(",
"d1",
",",
"indent",
"=",
"4",
",",
"sort_keys",
"=",
"True",
")",
"b",
"=",
"json",
".",
"dumps",
"(",
"d2",
",",
"indent",
"=",
"4",
",",
"sort_keys"... | Returns a diff string of the two dicts. | [
"Returns",
"a",
"diff",
"string",
"of",
"the",
"two",
"dicts",
"."
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L13-L24 |
249,408 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | diff_analysis | def diff_analysis(using):
"""
Returns a diff string comparing the analysis defined in ES, with
the analysis defined in Python land for the connection `using`
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
return compare_dicts(es_analysis, python_analysis... | python | def diff_analysis(using):
"""
Returns a diff string comparing the analysis defined in ES, with
the analysis defined in Python land for the connection `using`
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
return compare_dicts(es_analysis, python_analysis... | [
"def",
"diff_analysis",
"(",
"using",
")",
":",
"python_analysis",
"=",
"collect_analysis",
"(",
"using",
")",
"es_analysis",
"=",
"existing_analysis",
"(",
"using",
")",
"return",
"compare_dicts",
"(",
"es_analysis",
",",
"python_analysis",
")"
] | Returns a diff string comparing the analysis defined in ES, with
the analysis defined in Python land for the connection `using` | [
"Returns",
"a",
"diff",
"string",
"comparing",
"the",
"analysis",
"defined",
"in",
"ES",
"with",
"the",
"analysis",
"defined",
"in",
"Python",
"land",
"for",
"the",
"connection",
"using"
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L42-L49 |
249,409 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | collect_analysis | def collect_analysis(using):
"""
generate the analysis settings from Python land
"""
python_analysis = defaultdict(dict)
for index in registry.indexes_for_connection(using):
python_analysis.update(index._doc_type.mapping._collect_analysis())
return stringer(python_analysis) | python | def collect_analysis(using):
"""
generate the analysis settings from Python land
"""
python_analysis = defaultdict(dict)
for index in registry.indexes_for_connection(using):
python_analysis.update(index._doc_type.mapping._collect_analysis())
return stringer(python_analysis) | [
"def",
"collect_analysis",
"(",
"using",
")",
":",
"python_analysis",
"=",
"defaultdict",
"(",
"dict",
")",
"for",
"index",
"in",
"registry",
".",
"indexes_for_connection",
"(",
"using",
")",
":",
"python_analysis",
".",
"update",
"(",
"index",
".",
"_doc_type... | generate the analysis settings from Python land | [
"generate",
"the",
"analysis",
"settings",
"from",
"Python",
"land"
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L52-L60 |
249,410 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | existing_analysis | def existing_analysis(using):
"""
Get the existing analysis for the `using` Elasticsearch connection
"""
es = connections.get_connection(using)
index_name = settings.ELASTICSEARCH_CONNECTIONS[using]['index_name']
if es.indices.exists(index=index_name):
return stringer(es.indices.get_sett... | python | def existing_analysis(using):
"""
Get the existing analysis for the `using` Elasticsearch connection
"""
es = connections.get_connection(using)
index_name = settings.ELASTICSEARCH_CONNECTIONS[using]['index_name']
if es.indices.exists(index=index_name):
return stringer(es.indices.get_sett... | [
"def",
"existing_analysis",
"(",
"using",
")",
":",
"es",
"=",
"connections",
".",
"get_connection",
"(",
"using",
")",
"index_name",
"=",
"settings",
".",
"ELASTICSEARCH_CONNECTIONS",
"[",
"using",
"]",
"[",
"'index_name'",
"]",
"if",
"es",
".",
"indices",
... | Get the existing analysis for the `using` Elasticsearch connection | [
"Get",
"the",
"existing",
"analysis",
"for",
"the",
"using",
"Elasticsearch",
"connection"
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L63-L71 |
249,411 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | is_analysis_compatible | def is_analysis_compatible(using):
"""
Returns True if the analysis defined in Python land and ES for the connection `using` are compatible
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
if es_analysis == DOES_NOT_EXIST:
return True
# we want to... | python | def is_analysis_compatible(using):
"""
Returns True if the analysis defined in Python land and ES for the connection `using` are compatible
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
if es_analysis == DOES_NOT_EXIST:
return True
# we want to... | [
"def",
"is_analysis_compatible",
"(",
"using",
")",
":",
"python_analysis",
"=",
"collect_analysis",
"(",
"using",
")",
"es_analysis",
"=",
"existing_analysis",
"(",
"using",
")",
"if",
"es_analysis",
"==",
"DOES_NOT_EXIST",
":",
"return",
"True",
"# we want to ensu... | Returns True if the analysis defined in Python land and ES for the connection `using` are compatible | [
"Returns",
"True",
"if",
"the",
"analysis",
"defined",
"in",
"Python",
"land",
"and",
"ES",
"for",
"the",
"connection",
"using",
"are",
"compatible"
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L74-L102 |
249,412 | PSU-OIT-ARC/elasticmodels | elasticmodels/analysis.py | combined_analysis | def combined_analysis(using):
"""
Combine the analysis in ES with the analysis defined in Python. The one in
Python takes precedence
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
if es_analysis == DOES_NOT_EXIST:
return python_analysis
# we... | python | def combined_analysis(using):
"""
Combine the analysis in ES with the analysis defined in Python. The one in
Python takes precedence
"""
python_analysis = collect_analysis(using)
es_analysis = existing_analysis(using)
if es_analysis == DOES_NOT_EXIST:
return python_analysis
# we... | [
"def",
"combined_analysis",
"(",
"using",
")",
":",
"python_analysis",
"=",
"collect_analysis",
"(",
"using",
")",
"es_analysis",
"=",
"existing_analysis",
"(",
"using",
")",
"if",
"es_analysis",
"==",
"DOES_NOT_EXIST",
":",
"return",
"python_analysis",
"# we want t... | Combine the analysis in ES with the analysis defined in Python. The one in
Python takes precedence | [
"Combine",
"the",
"analysis",
"in",
"ES",
"with",
"the",
"analysis",
"defined",
"in",
"Python",
".",
"The",
"one",
"in",
"Python",
"takes",
"precedence"
] | 67870508096f66123ef10b89789bbac06571cc80 | https://github.com/PSU-OIT-ARC/elasticmodels/blob/67870508096f66123ef10b89789bbac06571cc80/elasticmodels/analysis.py#L105-L126 |
249,413 | xethorn/oto | oto/adaptors/flask.py | flaskify | def flaskify(response, headers=None, encoder=None):
"""Format the response to be consumeable by flask.
The api returns mostly JSON responses. The format method converts the dicts
into a json object (as a string), and the right response is returned (with
the valid mimetype, charset and status.)
Arg... | python | def flaskify(response, headers=None, encoder=None):
"""Format the response to be consumeable by flask.
The api returns mostly JSON responses. The format method converts the dicts
into a json object (as a string), and the right response is returned (with
the valid mimetype, charset and status.)
Arg... | [
"def",
"flaskify",
"(",
"response",
",",
"headers",
"=",
"None",
",",
"encoder",
"=",
"None",
")",
":",
"status_code",
"=",
"response",
".",
"status",
"data",
"=",
"response",
".",
"errors",
"or",
"response",
".",
"message",
"mimetype",
"=",
"'text/plain'"... | Format the response to be consumeable by flask.
The api returns mostly JSON responses. The format method converts the dicts
into a json object (as a string), and the right response is returned (with
the valid mimetype, charset and status.)
Args:
response (Response): The dictionary object to co... | [
"Format",
"the",
"response",
"to",
"be",
"consumeable",
"by",
"flask",
"."
] | 2a76d374ccc4c85fdf81ae1c43698a94c0594d7b | https://github.com/xethorn/oto/blob/2a76d374ccc4c85fdf81ae1c43698a94c0594d7b/oto/adaptors/flask.py#L6-L34 |
249,414 | hitchtest/hitchserve | hitchserve/service_handle.py | ServiceHandle.stop | def stop(self):
"""Ask politely, first, with SIGINT and SIGQUIT."""
if hasattr(self, 'process'):
if self.process is not None:
try:
is_running = self.process.poll() is None
except AttributeError:
is_running = False
... | python | def stop(self):
"""Ask politely, first, with SIGINT and SIGQUIT."""
if hasattr(self, 'process'):
if self.process is not None:
try:
is_running = self.process.poll() is None
except AttributeError:
is_running = False
... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'process'",
")",
":",
"if",
"self",
".",
"process",
"is",
"not",
"None",
":",
"try",
":",
"is_running",
"=",
"self",
".",
"process",
".",
"poll",
"(",
")",
"is",
"None",
"e... | Ask politely, first, with SIGINT and SIGQUIT. | [
"Ask",
"politely",
"first",
"with",
"SIGINT",
"and",
"SIGQUIT",
"."
] | a2def19979264186d283e76f7f0c88f3ed97f2e0 | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_handle.py#L101-L133 |
249,415 | hitchtest/hitchserve | hitchserve/service_handle.py | ServiceHandle.kill | def kill(self):
"""Murder the children of this service in front of it, and then murder the service itself."""
if not self.is_dead():
self.bundle_engine.warnline("{0} did not shut down cleanly, killing.".format(self.service.name))
try:
if hasattr(self.process, 'pid... | python | def kill(self):
"""Murder the children of this service in front of it, and then murder the service itself."""
if not self.is_dead():
self.bundle_engine.warnline("{0} did not shut down cleanly, killing.".format(self.service.name))
try:
if hasattr(self.process, 'pid... | [
"def",
"kill",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_dead",
"(",
")",
":",
"self",
".",
"bundle_engine",
".",
"warnline",
"(",
"\"{0} did not shut down cleanly, killing.\"",
".",
"format",
"(",
"self",
".",
"service",
".",
"name",
")",
")",
... | Murder the children of this service in front of it, and then murder the service itself. | [
"Murder",
"the",
"children",
"of",
"this",
"service",
"in",
"front",
"of",
"it",
"and",
"then",
"murder",
"the",
"service",
"itself",
"."
] | a2def19979264186d283e76f7f0c88f3ed97f2e0 | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_handle.py#L144-L154 |
249,416 | abe-winter/pg13-py | pg13/pgmock.py | TablesDict.cascade_delete | def cascade_delete(self, name):
"this fails under diamond inheritance"
for child in self[name].child_tables:
self.cascade_delete(child.name)
del self[name] | python | def cascade_delete(self, name):
"this fails under diamond inheritance"
for child in self[name].child_tables:
self.cascade_delete(child.name)
del self[name] | [
"def",
"cascade_delete",
"(",
"self",
",",
"name",
")",
":",
"for",
"child",
"in",
"self",
"[",
"name",
"]",
".",
"child_tables",
":",
"self",
".",
"cascade_delete",
"(",
"child",
".",
"name",
")",
"del",
"self",
"[",
"name",
"]"
] | this fails under diamond inheritance | [
"this",
"fails",
"under",
"diamond",
"inheritance"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pgmock.py#L66-L70 |
249,417 | abe-winter/pg13-py | pg13/pgmock.py | TablesDict.create | def create(self, ex):
"helper for apply_sql in CreateX case"
if ex.name in self:
if ex.nexists: return
raise ValueError('table_exists',ex.name)
if any(c.pkey for c in ex.cols):
if ex.pkey:
raise sqparse2.SQLSyntaxError("don't mix table-level and column-level pkeys",ex)
... | python | def create(self, ex):
"helper for apply_sql in CreateX case"
if ex.name in self:
if ex.nexists: return
raise ValueError('table_exists',ex.name)
if any(c.pkey for c in ex.cols):
if ex.pkey:
raise sqparse2.SQLSyntaxError("don't mix table-level and column-level pkeys",ex)
... | [
"def",
"create",
"(",
"self",
",",
"ex",
")",
":",
"if",
"ex",
".",
"name",
"in",
"self",
":",
"if",
"ex",
".",
"nexists",
":",
"return",
"raise",
"ValueError",
"(",
"'table_exists'",
",",
"ex",
".",
"name",
")",
"if",
"any",
"(",
"c",
".",
"pkey... | helper for apply_sql in CreateX case | [
"helper",
"for",
"apply_sql",
"in",
"CreateX",
"case"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pgmock.py#L72-L90 |
249,418 | abe-winter/pg13-py | pg13/pgmock.py | TablesDict.drop | def drop(self, ex):
"helper for apply_sql in DropX case"
# todo: factor out inheritance logic (for readability)
if ex.name not in self:
if ex.ifexists: return
raise KeyError(ex.name)
table_ = self[ex.name]
parent = table_.parent_table
if table_.child_tables:
if not ex.... | python | def drop(self, ex):
"helper for apply_sql in DropX case"
# todo: factor out inheritance logic (for readability)
if ex.name not in self:
if ex.ifexists: return
raise KeyError(ex.name)
table_ = self[ex.name]
parent = table_.parent_table
if table_.child_tables:
if not ex.... | [
"def",
"drop",
"(",
"self",
",",
"ex",
")",
":",
"# todo: factor out inheritance logic (for readability)\r",
"if",
"ex",
".",
"name",
"not",
"in",
"self",
":",
"if",
"ex",
".",
"ifexists",
":",
"return",
"raise",
"KeyError",
"(",
"ex",
".",
"name",
")",
"t... | helper for apply_sql in DropX case | [
"helper",
"for",
"apply_sql",
"in",
"DropX",
"case"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/pgmock.py#L92-L105 |
249,419 | amcfague/webunit2 | webunit2/framework.py | Framework._prepare_uri | def _prepare_uri(self, path, query_params={}):
"""
Prepares a full URI with the selected information.
``path``:
Path can be in one of two formats:
- If :attr:`server` was defined, the ``path`` will be appended
to the existing host, or
... | python | def _prepare_uri(self, path, query_params={}):
"""
Prepares a full URI with the selected information.
``path``:
Path can be in one of two formats:
- If :attr:`server` was defined, the ``path`` will be appended
to the existing host, or
... | [
"def",
"_prepare_uri",
"(",
"self",
",",
"path",
",",
"query_params",
"=",
"{",
"}",
")",
":",
"query_str",
"=",
"urllib",
".",
"urlencode",
"(",
"query_params",
")",
"# If we have a relative path (as opposed to a full URL), build it of",
"# the connection info",
"if",
... | Prepares a full URI with the selected information.
``path``:
Path can be in one of two formats:
- If :attr:`server` was defined, the ``path`` will be appended
to the existing host, or
- an absolute URL
``query_params``:
Used to ... | [
"Prepares",
"a",
"full",
"URI",
"with",
"the",
"selected",
"information",
"."
] | 3157e5837aad0810800628c1383f1fe11ee3e513 | https://github.com/amcfague/webunit2/blob/3157e5837aad0810800628c1383f1fe11ee3e513/webunit2/framework.py#L69-L97 |
249,420 | amcfague/webunit2 | webunit2/framework.py | Framework.retrieve_page | def retrieve_page(self, method, path, post_params={}, headers={},
status=200, username=None, password=None,
*args, **kwargs):
"""
Makes the actual request. This will also go through and generate the
needed steps to make the request, i.e. basic auth.
... | python | def retrieve_page(self, method, path, post_params={}, headers={},
status=200, username=None, password=None,
*args, **kwargs):
"""
Makes the actual request. This will also go through and generate the
needed steps to make the request, i.e. basic auth.
... | [
"def",
"retrieve_page",
"(",
"self",
",",
"method",
",",
"path",
",",
"post_params",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
",",
"status",
"=",
"200",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"*",
"args",
",",
"*",
... | Makes the actual request. This will also go through and generate the
needed steps to make the request, i.e. basic auth.
``method``:
Any supported HTTP methods defined in :rfc:`2616`.
``path``:
Absolute or relative path. See :meth:`_prepare_uri` for more
deta... | [
"Makes",
"the",
"actual",
"request",
".",
"This",
"will",
"also",
"go",
"through",
"and",
"generate",
"the",
"needed",
"steps",
"to",
"make",
"the",
"request",
"i",
".",
"e",
".",
"basic",
"auth",
"."
] | 3157e5837aad0810800628c1383f1fe11ee3e513 | https://github.com/amcfague/webunit2/blob/3157e5837aad0810800628c1383f1fe11ee3e513/webunit2/framework.py#L122-L179 |
249,421 | ojake/django-tracked-model | tracked_model/control.py | create_track_token | def create_track_token(request):
"""Returns ``TrackToken``.
``TrackToken' contains request and user making changes.
It can be passed to ``TrackedModel.save`` instead of ``request``.
It is intended to be used when passing ``request`` is not possible
e.g. when ``TrackedModel.save`` will be called fro... | python | def create_track_token(request):
"""Returns ``TrackToken``.
``TrackToken' contains request and user making changes.
It can be passed to ``TrackedModel.save`` instead of ``request``.
It is intended to be used when passing ``request`` is not possible
e.g. when ``TrackedModel.save`` will be called fro... | [
"def",
"create_track_token",
"(",
"request",
")",
":",
"from",
"tracked_model",
".",
"models",
"import",
"RequestInfo",
"request_pk",
"=",
"RequestInfo",
".",
"create_or_get_from_request",
"(",
"request",
")",
".",
"pk",
"user_pk",
"=",
"None",
"if",
"request",
... | Returns ``TrackToken``.
``TrackToken' contains request and user making changes.
It can be passed to ``TrackedModel.save`` instead of ``request``.
It is intended to be used when passing ``request`` is not possible
e.g. when ``TrackedModel.save`` will be called from celery task. | [
"Returns",
"TrackToken",
".",
"TrackToken",
"contains",
"request",
"and",
"user",
"making",
"changes",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/control.py#L7-L21 |
249,422 | ojake/django-tracked-model | tracked_model/control.py | TrackedModelMixin.save | def save(self, *args, **kwargs):
"""Saves changes made on model instance if ``request`` or
``track_token`` keyword are provided.
"""
from tracked_model.models import History, RequestInfo
if self.pk:
action = ActionType.UPDATE
changes = None
else:
... | python | def save(self, *args, **kwargs):
"""Saves changes made on model instance if ``request`` or
``track_token`` keyword are provided.
"""
from tracked_model.models import History, RequestInfo
if self.pk:
action = ActionType.UPDATE
changes = None
else:
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"tracked_model",
".",
"models",
"import",
"History",
",",
"RequestInfo",
"if",
"self",
".",
"pk",
":",
"action",
"=",
"ActionType",
".",
"UPDATE",
"changes",
"=",
... | Saves changes made on model instance if ``request`` or
``track_token`` keyword are provided. | [
"Saves",
"changes",
"made",
"on",
"model",
"instance",
"if",
"request",
"or",
"track_token",
"keyword",
"are",
"provided",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/control.py#L38-L76 |
249,423 | ojake/django-tracked-model | tracked_model/control.py | TrackedModelMixin._tracked_model_diff | def _tracked_model_diff(self):
"""Returns changes made to model instance.
Returns None if no changes were made.
"""
initial_state = self._tracked_model_initial_state
current_state = serializer.dump_model(self)
if current_state == initial_state:
return None
... | python | def _tracked_model_diff(self):
"""Returns changes made to model instance.
Returns None if no changes were made.
"""
initial_state = self._tracked_model_initial_state
current_state = serializer.dump_model(self)
if current_state == initial_state:
return None
... | [
"def",
"_tracked_model_diff",
"(",
"self",
")",
":",
"initial_state",
"=",
"self",
".",
"_tracked_model_initial_state",
"current_state",
"=",
"serializer",
".",
"dump_model",
"(",
"self",
")",
"if",
"current_state",
"==",
"initial_state",
":",
"return",
"None",
"c... | Returns changes made to model instance.
Returns None if no changes were made. | [
"Returns",
"changes",
"made",
"to",
"model",
"instance",
".",
"Returns",
"None",
"if",
"no",
"changes",
"were",
"made",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/control.py#L103-L124 |
249,424 | ojake/django-tracked-model | tracked_model/control.py | TrackedModelMixin.tracked_model_history | def tracked_model_history(self):
"""Returns history of a tracked object"""
from tracked_model.models import History
return History.objects.filter(
table_name=self._meta.db_table, table_id=self.pk) | python | def tracked_model_history(self):
"""Returns history of a tracked object"""
from tracked_model.models import History
return History.objects.filter(
table_name=self._meta.db_table, table_id=self.pk) | [
"def",
"tracked_model_history",
"(",
"self",
")",
":",
"from",
"tracked_model",
".",
"models",
"import",
"History",
"return",
"History",
".",
"objects",
".",
"filter",
"(",
"table_name",
"=",
"self",
".",
"_meta",
".",
"db_table",
",",
"table_id",
"=",
"self... | Returns history of a tracked object | [
"Returns",
"history",
"of",
"a",
"tracked",
"object"
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/control.py#L126-L130 |
249,425 | foliant-docs/foliantcontrib.init | foliant/cli/init/__init__.py | replace_placeholders | def replace_placeholders(path: Path, properties: Dict[str, str]):
'''Replace placeholders in a file with the values from the mapping.'''
with open(path, encoding='utf8') as file:
file_content = Template(file.read())
with open(path, 'w', encoding='utf8') as file:
file.write(file_content.saf... | python | def replace_placeholders(path: Path, properties: Dict[str, str]):
'''Replace placeholders in a file with the values from the mapping.'''
with open(path, encoding='utf8') as file:
file_content = Template(file.read())
with open(path, 'w', encoding='utf8') as file:
file.write(file_content.saf... | [
"def",
"replace_placeholders",
"(",
"path",
":",
"Path",
",",
"properties",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
":",
"with",
"open",
"(",
"path",
",",
"encoding",
"=",
"'utf8'",
")",
"as",
"file",
":",
"file_content",
"=",
"Template",
"(",
... | Replace placeholders in a file with the values from the mapping. | [
"Replace",
"placeholders",
"in",
"a",
"file",
"with",
"the",
"values",
"from",
"the",
"mapping",
"."
] | 39aa38949b6270a750c800b79b4e71dd827f28d8 | https://github.com/foliant-docs/foliantcontrib.init/blob/39aa38949b6270a750c800b79b4e71dd827f28d8/foliant/cli/init/__init__.py#L41-L48 |
249,426 | foliant-docs/foliantcontrib.init | foliant/cli/init/__init__.py | BuiltinTemplateValidator.validate | def validate(self, document):
'''Check if the selected template exists.'''
template = document.text
if template not in self.builtin_templates:
raise ValidationError(
message=f'Template {template} not found. '
+ f'Available templates are: {", ".join(s... | python | def validate(self, document):
'''Check if the selected template exists.'''
template = document.text
if template not in self.builtin_templates:
raise ValidationError(
message=f'Template {template} not found. '
+ f'Available templates are: {", ".join(s... | [
"def",
"validate",
"(",
"self",
",",
"document",
")",
":",
"template",
"=",
"document",
".",
"text",
"if",
"template",
"not",
"in",
"self",
".",
"builtin_templates",
":",
"raise",
"ValidationError",
"(",
"message",
"=",
"f'Template {template} not found. '",
"+",... | Check if the selected template exists. | [
"Check",
"if",
"the",
"selected",
"template",
"exists",
"."
] | 39aa38949b6270a750c800b79b4e71dd827f28d8 | https://github.com/foliant-docs/foliantcontrib.init/blob/39aa38949b6270a750c800b79b4e71dd827f28d8/foliant/cli/init/__init__.py#L28-L38 |
249,427 | aptiko/simpletail | simpletail/__init__.py | ropen.get_start_of_line | def get_start_of_line(self):
"""Return index of start of last line stored in self.buf.
This function never fetches more data from the file; therefore,
if it returns zero, meaning the line starts at the beginning of the
buffer, the caller should then fetch more data and retry.
"""... | python | def get_start_of_line(self):
"""Return index of start of last line stored in self.buf.
This function never fetches more data from the file; therefore,
if it returns zero, meaning the line starts at the beginning of the
buffer, the caller should then fetch more data and retry.
"""... | [
"def",
"get_start_of_line",
"(",
"self",
")",
":",
"if",
"self",
".",
"newline",
"in",
"(",
"'\\r'",
",",
"'\\n'",
",",
"'\\r\\n'",
")",
":",
"return",
"self",
".",
"buf",
".",
"rfind",
"(",
"self",
".",
"newline",
".",
"encode",
"(",
"'ascii'",
")",... | Return index of start of last line stored in self.buf.
This function never fetches more data from the file; therefore,
if it returns zero, meaning the line starts at the beginning of the
buffer, the caller should then fetch more data and retry. | [
"Return",
"index",
"of",
"start",
"of",
"last",
"line",
"stored",
"in",
"self",
".",
"buf",
".",
"This",
"function",
"never",
"fetches",
"more",
"data",
"from",
"the",
"file",
";",
"therefore",
"if",
"it",
"returns",
"zero",
"meaning",
"the",
"line",
"st... | 4ebe31950c9a3b7fac243dc83afd915894ce678f | https://github.com/aptiko/simpletail/blob/4ebe31950c9a3b7fac243dc83afd915894ce678f/simpletail/__init__.py#L59-L76 |
249,428 | aptiko/simpletail | simpletail/__init__.py | ropen.read_next_into_buf | def read_next_into_buf(self):
"""Read data from the file in self.bufsize chunks until we're
certain we have a full line in the buffer.
"""
file_pos = self.fileobject.tell()
if (file_pos == 0) and (self.buf == b''):
raise StopIteration
while file_pos and (se... | python | def read_next_into_buf(self):
"""Read data from the file in self.bufsize chunks until we're
certain we have a full line in the buffer.
"""
file_pos = self.fileobject.tell()
if (file_pos == 0) and (self.buf == b''):
raise StopIteration
while file_pos and (se... | [
"def",
"read_next_into_buf",
"(",
"self",
")",
":",
"file_pos",
"=",
"self",
".",
"fileobject",
".",
"tell",
"(",
")",
"if",
"(",
"file_pos",
"==",
"0",
")",
"and",
"(",
"self",
".",
"buf",
"==",
"b''",
")",
":",
"raise",
"StopIteration",
"while",
"f... | Read data from the file in self.bufsize chunks until we're
certain we have a full line in the buffer. | [
"Read",
"data",
"from",
"the",
"file",
"in",
"self",
".",
"bufsize",
"chunks",
"until",
"we",
"re",
"certain",
"we",
"have",
"a",
"full",
"line",
"in",
"the",
"buffer",
"."
] | 4ebe31950c9a3b7fac243dc83afd915894ce678f | https://github.com/aptiko/simpletail/blob/4ebe31950c9a3b7fac243dc83afd915894ce678f/simpletail/__init__.py#L78-L91 |
249,429 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler._add_to | def _add_to(self, db, index, item, default=OOSet):
"""
Add `item` to `db` under `index`. If `index` is not yet in `db`, create
it using `default`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
... | python | def _add_to(self, db, index, item, default=OOSet):
"""
Add `item` to `db` under `index`. If `index` is not yet in `db`, create
it using `default`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
... | [
"def",
"_add_to",
"(",
"self",
",",
"db",
",",
"index",
",",
"item",
",",
"default",
"=",
"OOSet",
")",
":",
"row",
"=",
"db",
".",
"get",
"(",
"index",
",",
"None",
")",
"if",
"row",
"is",
"None",
":",
"row",
"=",
"default",
"(",
")",
"db",
... | Add `item` to `db` under `index`. If `index` is not yet in `db`, create
it using `default`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
item (obj): Persistent object, which may be stored in DB.
... | [
"Add",
"item",
"to",
"db",
"under",
"index",
".",
"If",
"index",
"is",
"not",
"yet",
"in",
"db",
"create",
"it",
"using",
"default",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L73-L92 |
249,430 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler.add_tree | def add_tree(self, tree, parent=None):
"""
Add `tree` into database.
Args:
tree (obj): :class:`.Tree` instance.
parent (ref, default None): Reference to parent tree. This is used
for all sub-trees in recursive call.
"""
if tree.path in sel... | python | def add_tree(self, tree, parent=None):
"""
Add `tree` into database.
Args:
tree (obj): :class:`.Tree` instance.
parent (ref, default None): Reference to parent tree. This is used
for all sub-trees in recursive call.
"""
if tree.path in sel... | [
"def",
"add_tree",
"(",
"self",
",",
"tree",
",",
"parent",
"=",
"None",
")",
":",
"if",
"tree",
".",
"path",
"in",
"self",
".",
"path_db",
":",
"self",
".",
"remove_tree_by_path",
"(",
"tree",
".",
"path",
")",
"# index all indexable attributes",
"for",
... | Add `tree` into database.
Args:
tree (obj): :class:`.Tree` instance.
parent (ref, default None): Reference to parent tree. This is used
for all sub-trees in recursive call. | [
"Add",
"tree",
"into",
"database",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L95-L126 |
249,431 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler.remove_tree_by_path | def remove_tree_by_path(self, path):
"""
Remove the tree from database by given `path`.
Args:
path (str): Path of the tree.
"""
with transaction.manager:
trees = self.path_db.get(path, None)
if not trees:
return
for tree in t... | python | def remove_tree_by_path(self, path):
"""
Remove the tree from database by given `path`.
Args:
path (str): Path of the tree.
"""
with transaction.manager:
trees = self.path_db.get(path, None)
if not trees:
return
for tree in t... | [
"def",
"remove_tree_by_path",
"(",
"self",
",",
"path",
")",
":",
"with",
"transaction",
".",
"manager",
":",
"trees",
"=",
"self",
".",
"path_db",
".",
"get",
"(",
"path",
",",
"None",
")",
"if",
"not",
"trees",
":",
"return",
"for",
"tree",
"in",
"... | Remove the tree from database by given `path`.
Args:
path (str): Path of the tree. | [
"Remove",
"the",
"tree",
"from",
"database",
"by",
"given",
"path",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L128-L142 |
249,432 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler._remove_from | def _remove_from(self, db, index, item):
"""
Remove `item` from `db` at `index`.
Note:
This function is inverse to :meth:`._add_to`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
... | python | def _remove_from(self, db, index, item):
"""
Remove `item` from `db` at `index`.
Note:
This function is inverse to :meth:`._add_to`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
... | [
"def",
"_remove_from",
"(",
"self",
",",
"db",
",",
"index",
",",
"item",
")",
":",
"with",
"transaction",
".",
"manager",
":",
"row",
"=",
"db",
".",
"get",
"(",
"index",
",",
"None",
")",
"if",
"row",
"is",
"None",
":",
"return",
"with",
"transac... | Remove `item` from `db` at `index`.
Note:
This function is inverse to :meth:`._add_to`.
Args:
db (dict-obj): Dict-like object used to connect to database.
index (str): Index used to look in `db`.
item (obj): Persistent object, which may be stored in DB. | [
"Remove",
"item",
"from",
"db",
"at",
"index",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L153-L177 |
249,433 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler._remove_tree | def _remove_tree(self, tree, parent=None):
"""
Really remove the tree identified by `tree` instance from all indexes
from database.
Args:
tree (obj): :class:`.Tree` instance.
parent (obj, default None): Reference to parent.
"""
# remove sub-trees
... | python | def _remove_tree(self, tree, parent=None):
"""
Really remove the tree identified by `tree` instance from all indexes
from database.
Args:
tree (obj): :class:`.Tree` instance.
parent (obj, default None): Reference to parent.
"""
# remove sub-trees
... | [
"def",
"_remove_tree",
"(",
"self",
",",
"tree",
",",
"parent",
"=",
"None",
")",
":",
"# remove sub-trees",
"for",
"sub_tree",
"in",
"tree",
".",
"sub_trees",
":",
"self",
".",
"_remove_tree",
"(",
"sub_tree",
",",
"parent",
"=",
"tree",
")",
"# remove it... | Really remove the tree identified by `tree` instance from all indexes
from database.
Args:
tree (obj): :class:`.Tree` instance.
parent (obj, default None): Reference to parent. | [
"Really",
"remove",
"the",
"tree",
"identified",
"by",
"tree",
"instance",
"from",
"all",
"indexes",
"from",
"database",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L180-L207 |
249,434 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler.trees_by_issn | def trees_by_issn(self, issn):
"""
Search trees by `issn`.
Args:
issn (str): :attr:`.Tree.issn` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances.
"""
return set(
self.issn_db.get(issn, OOSet()).keys()
... | python | def trees_by_issn(self, issn):
"""
Search trees by `issn`.
Args:
issn (str): :attr:`.Tree.issn` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances.
"""
return set(
self.issn_db.get(issn, OOSet()).keys()
... | [
"def",
"trees_by_issn",
"(",
"self",
",",
"issn",
")",
":",
"return",
"set",
"(",
"self",
".",
"issn_db",
".",
"get",
"(",
"issn",
",",
"OOSet",
"(",
")",
")",
".",
"keys",
"(",
")",
")"
] | Search trees by `issn`.
Args:
issn (str): :attr:`.Tree.issn` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances. | [
"Search",
"trees",
"by",
"issn",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L210-L222 |
249,435 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler.trees_by_path | def trees_by_path(self, path):
"""
Search trees by `path`.
Args:
path (str): :attr:`.Tree.path` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances.
"""
return set(
self.path_db.get(path, OOSet()).keys()
... | python | def trees_by_path(self, path):
"""
Search trees by `path`.
Args:
path (str): :attr:`.Tree.path` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances.
"""
return set(
self.path_db.get(path, OOSet()).keys()
... | [
"def",
"trees_by_path",
"(",
"self",
",",
"path",
")",
":",
"return",
"set",
"(",
"self",
".",
"path_db",
".",
"get",
"(",
"path",
",",
"OOSet",
"(",
")",
")",
".",
"keys",
"(",
")",
")"
] | Search trees by `path`.
Args:
path (str): :attr:`.Tree.path` property of :class:`.Tree`.
Returns:
set: Set of matching :class:`Tree` instances. | [
"Search",
"trees",
"by",
"path",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L225-L237 |
249,436 | edeposit/edeposit.amqp.storage | src/edeposit/amqp/storage/tree_handler.py | TreeHandler.get_parent | def get_parent(self, tree, alt=None):
"""
Get parent for given `tree` or `alt` if not found.
Args:
tree (obj): :class:`.Tree` instance, which is already stored in DB.
alt (obj, default None): Alternative value returned when `tree` is
not found.
R... | python | def get_parent(self, tree, alt=None):
"""
Get parent for given `tree` or `alt` if not found.
Args:
tree (obj): :class:`.Tree` instance, which is already stored in DB.
alt (obj, default None): Alternative value returned when `tree` is
not found.
R... | [
"def",
"get_parent",
"(",
"self",
",",
"tree",
",",
"alt",
"=",
"None",
")",
":",
"parent",
"=",
"self",
".",
"parent_db",
".",
"get",
"(",
"tree",
".",
"path",
")",
"if",
"not",
"parent",
":",
"return",
"alt",
"return",
"list",
"(",
"parent",
")",... | Get parent for given `tree` or `alt` if not found.
Args:
tree (obj): :class:`.Tree` instance, which is already stored in DB.
alt (obj, default None): Alternative value returned when `tree` is
not found.
Returns:
obj: :class:`.Tree` parent to given `t... | [
"Get",
"parent",
"for",
"given",
"tree",
"or",
"alt",
"if",
"not",
"found",
"."
] | fb6bd326249847de04b17b64e856c878665cea92 | https://github.com/edeposit/edeposit.amqp.storage/blob/fb6bd326249847de04b17b64e856c878665cea92/src/edeposit/amqp/storage/tree_handler.py#L261-L278 |
249,437 | ulf1/oxyba | oxyba/yearfrac_365q.py | yearfrac_365q | def yearfrac_365q(d1, d2):
"""date difference "d1-d2" as year fractional"""
# import modules
from datetime import date
from oxyba import date_to_datetime
# define yearfrac formula
# toyf = lambda a,b: (a - b).days / 365.2425
def toyf(a, b):
a = date_to_datetime(a) if isinstance(a, ... | python | def yearfrac_365q(d1, d2):
"""date difference "d1-d2" as year fractional"""
# import modules
from datetime import date
from oxyba import date_to_datetime
# define yearfrac formula
# toyf = lambda a,b: (a - b).days / 365.2425
def toyf(a, b):
a = date_to_datetime(a) if isinstance(a, ... | [
"def",
"yearfrac_365q",
"(",
"d1",
",",
"d2",
")",
":",
"# import modules",
"from",
"datetime",
"import",
"date",
"from",
"oxyba",
"import",
"date_to_datetime",
"# define yearfrac formula",
"# toyf = lambda a,b: (a - b).days / 365.2425",
"def",
"toyf",
"(",
"a",
",",
... | date difference "d1-d2" as year fractional | [
"date",
"difference",
"d1",
"-",
"d2",
"as",
"year",
"fractional"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/yearfrac_365q.py#L2-L30 |
249,438 | opieters/DynamicNumber | languages/python/dn.py | dn.add | def add(self, name, value, unit=None):
"""Add symbolic link to Dynamic Number list.
name -- name of the symbolic link
value -- value of the link (if not a string, conversion is done with str())
unit -- if value is a numerical value, a unit can be added to invoke the \unit{}{} LaTeX co... | python | def add(self, name, value, unit=None):
"""Add symbolic link to Dynamic Number list.
name -- name of the symbolic link
value -- value of the link (if not a string, conversion is done with str())
unit -- if value is a numerical value, a unit can be added to invoke the \unit{}{} LaTeX co... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"value",
",",
"unit",
"=",
"None",
")",
":",
"# check if unit provided",
"if",
"unit",
"is",
"not",
"None",
":",
"add_unit",
"=",
"True",
"unit",
"=",
"str",
"(",
"unit",
")",
"else",
":",
"add_unit",
"=",... | Add symbolic link to Dynamic Number list.
name -- name of the symbolic link
value -- value of the link (if not a string, conversion is done with str())
unit -- if value is a numerical value, a unit can be added to invoke the \unit{}{} LaTeX command | [
"Add",
"symbolic",
"link",
"to",
"Dynamic",
"Number",
"list",
"."
] | 433679e9f772a4d0e633e73bd1243ce912bb8dfc | https://github.com/opieters/DynamicNumber/blob/433679e9f772a4d0e633e73bd1243ce912bb8dfc/languages/python/dn.py#L38-L61 |
249,439 | Bystroushaak/zeo_connector | src/zeo_connector/zeo_wrapper_prototype.py | _init_zeo | def _init_zeo():
"""
Start asyncore thread.
"""
if not _ASYNCORE_RUNNING:
def _run_asyncore_loop():
asyncore.loop()
thread.start_new_thread(_run_asyncore_loop, ())
global _ASYNCORE_RUNNING
_ASYNCORE_RUNNING = True | python | def _init_zeo():
"""
Start asyncore thread.
"""
if not _ASYNCORE_RUNNING:
def _run_asyncore_loop():
asyncore.loop()
thread.start_new_thread(_run_asyncore_loop, ())
global _ASYNCORE_RUNNING
_ASYNCORE_RUNNING = True | [
"def",
"_init_zeo",
"(",
")",
":",
"if",
"not",
"_ASYNCORE_RUNNING",
":",
"def",
"_run_asyncore_loop",
"(",
")",
":",
"asyncore",
".",
"loop",
"(",
")",
"thread",
".",
"start_new_thread",
"(",
"_run_asyncore_loop",
",",
"(",
")",
")",
"global",
"_ASYNCORE_RU... | Start asyncore thread. | [
"Start",
"asyncore",
"thread",
"."
] | 93f86447204efc8e33d3112907cd221daf6bce3b | https://github.com/Bystroushaak/zeo_connector/blob/93f86447204efc8e33d3112907cd221daf6bce3b/src/zeo_connector/zeo_wrapper_prototype.py#L21-L32 |
249,440 | Bystroushaak/zeo_connector | src/zeo_connector/zeo_wrapper_prototype.py | retry_and_reset | def retry_and_reset(fn):
"""
Decorator used to make sure, that operation on ZEO object will be retried,
if there is ``ConnectionStateError`` exception.
"""
@wraps(fn)
def retry_and_reset_decorator(*args, **kwargs):
obj = kwargs.get("self", None)
if not obj:
obj = arg... | python | def retry_and_reset(fn):
"""
Decorator used to make sure, that operation on ZEO object will be retried,
if there is ``ConnectionStateError`` exception.
"""
@wraps(fn)
def retry_and_reset_decorator(*args, **kwargs):
obj = kwargs.get("self", None)
if not obj:
obj = arg... | [
"def",
"retry_and_reset",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"retry_and_reset_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"kwargs",
".",
"get",
"(",
"\"self\"",
",",
"None",
")",
"if",
"not",
... | Decorator used to make sure, that operation on ZEO object will be retried,
if there is ``ConnectionStateError`` exception. | [
"Decorator",
"used",
"to",
"make",
"sure",
"that",
"operation",
"on",
"ZEO",
"object",
"will",
"be",
"retried",
"if",
"there",
"is",
"ConnectionStateError",
"exception",
"."
] | 93f86447204efc8e33d3112907cd221daf6bce3b | https://github.com/Bystroushaak/zeo_connector/blob/93f86447204efc8e33d3112907cd221daf6bce3b/src/zeo_connector/zeo_wrapper_prototype.py#L35-L54 |
249,441 | Bystroushaak/zeo_connector | src/zeo_connector/zeo_wrapper_prototype.py | ZEOWrapperPrototype._init_zeo_root | def _init_zeo_root(self, attempts=3):
"""
Get and initialize the ZEO root object.
Args:
attempts (int, default 3): How many times to try, if the connection
was lost.
"""
try:
db_root = self._connection.root()
except ConnectionState... | python | def _init_zeo_root(self, attempts=3):
"""
Get and initialize the ZEO root object.
Args:
attempts (int, default 3): How many times to try, if the connection
was lost.
"""
try:
db_root = self._connection.root()
except ConnectionState... | [
"def",
"_init_zeo_root",
"(",
"self",
",",
"attempts",
"=",
"3",
")",
":",
"try",
":",
"db_root",
"=",
"self",
".",
"_connection",
".",
"root",
"(",
")",
"except",
"ConnectionStateError",
":",
"if",
"attempts",
"<=",
"0",
":",
"raise",
"self",
".",
"_o... | Get and initialize the ZEO root object.
Args:
attempts (int, default 3): How many times to try, if the connection
was lost. | [
"Get",
"and",
"initialize",
"the",
"ZEO",
"root",
"object",
"."
] | 93f86447204efc8e33d3112907cd221daf6bce3b | https://github.com/Bystroushaak/zeo_connector/blob/93f86447204efc8e33d3112907cd221daf6bce3b/src/zeo_connector/zeo_wrapper_prototype.py#L120-L142 |
249,442 | ariebovenberg/valuable | valuable/load.py | create_dataclass_loader | def create_dataclass_loader(cls, registry, field_getters):
"""create a loader for a dataclass type"""
fields = cls.__dataclass_fields__
item_loaders = map(registry, map(attrgetter('type'), fields.values()))
getters = map(field_getters.__getitem__, fields)
loaders = list(starmap(compose, zip(item_loa... | python | def create_dataclass_loader(cls, registry, field_getters):
"""create a loader for a dataclass type"""
fields = cls.__dataclass_fields__
item_loaders = map(registry, map(attrgetter('type'), fields.values()))
getters = map(field_getters.__getitem__, fields)
loaders = list(starmap(compose, zip(item_loa... | [
"def",
"create_dataclass_loader",
"(",
"cls",
",",
"registry",
",",
"field_getters",
")",
":",
"fields",
"=",
"cls",
".",
"__dataclass_fields__",
"item_loaders",
"=",
"map",
"(",
"registry",
",",
"map",
"(",
"attrgetter",
"(",
"'type'",
")",
",",
"fields",
"... | create a loader for a dataclass type | [
"create",
"a",
"loader",
"for",
"a",
"dataclass",
"type"
] | 72ac98b5a044233f13d14a9b9f273ce3a237d9ae | https://github.com/ariebovenberg/valuable/blob/72ac98b5a044233f13d14a9b9f273ce3a237d9ae/valuable/load.py#L145-L155 |
249,443 | coghost/izen | izen/helper.py | rand_block | def rand_block(minimum, scale, maximum=1):
"""
block current thread at random pareto time ``minimum < block < 15`` and return the sleep time ``seconds``
:param minimum:
:type minimum:
:param scale:
:type scale:
:param slow_mode: a tuple e.g.(2, 5)
:type slow_mode: tuple
:return:... | python | def rand_block(minimum, scale, maximum=1):
"""
block current thread at random pareto time ``minimum < block < 15`` and return the sleep time ``seconds``
:param minimum:
:type minimum:
:param scale:
:type scale:
:param slow_mode: a tuple e.g.(2, 5)
:type slow_mode: tuple
:return:... | [
"def",
"rand_block",
"(",
"minimum",
",",
"scale",
",",
"maximum",
"=",
"1",
")",
":",
"t",
"=",
"min",
"(",
"rand_pareto_float",
"(",
"minimum",
",",
"scale",
")",
",",
"maximum",
")",
"time",
".",
"sleep",
"(",
"t",
")",
"return",
"t"
] | block current thread at random pareto time ``minimum < block < 15`` and return the sleep time ``seconds``
:param minimum:
:type minimum:
:param scale:
:type scale:
:param slow_mode: a tuple e.g.(2, 5)
:type slow_mode: tuple
:return: | [
"block",
"current",
"thread",
"at",
"random",
"pareto",
"time",
"minimum",
"<",
"block",
"<",
"15",
"and",
"return",
"the",
"sleep",
"time",
"seconds"
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1267-L1281 |
249,444 | coghost/izen | izen/helper.py | TermTable._print_divide | def _print_divide(self):
"""Prints all those table line dividers."""
for space in self.AttributesLength:
self.StrTable += "+ " + "- " * space
self.StrTable += "+" + "\n" | python | def _print_divide(self):
"""Prints all those table line dividers."""
for space in self.AttributesLength:
self.StrTable += "+ " + "- " * space
self.StrTable += "+" + "\n" | [
"def",
"_print_divide",
"(",
"self",
")",
":",
"for",
"space",
"in",
"self",
".",
"AttributesLength",
":",
"self",
".",
"StrTable",
"+=",
"\"+ \"",
"+",
"\"- \"",
"*",
"space",
"self",
".",
"StrTable",
"+=",
"\"+\"",
"+",
"\"\\n\""
] | Prints all those table line dividers. | [
"Prints",
"all",
"those",
"table",
"line",
"dividers",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1150-L1154 |
249,445 | coghost/izen | izen/helper.py | TermTable._create_table | def _create_table(self):
"""
Creates a pretty-printed string representation of the table as
``self.StrTable``.
"""
self.StrTable = ""
self.AttributesLength = []
self.Lines_num = 0
# Prepare some values..
for col in self.Table:
# Updates... | python | def _create_table(self):
"""
Creates a pretty-printed string representation of the table as
``self.StrTable``.
"""
self.StrTable = ""
self.AttributesLength = []
self.Lines_num = 0
# Prepare some values..
for col in self.Table:
# Updates... | [
"def",
"_create_table",
"(",
"self",
")",
":",
"self",
".",
"StrTable",
"=",
"\"\"",
"self",
".",
"AttributesLength",
"=",
"[",
"]",
"self",
".",
"Lines_num",
"=",
"0",
"# Prepare some values..",
"for",
"col",
"in",
"self",
".",
"Table",
":",
"# Updates th... | Creates a pretty-printed string representation of the table as
``self.StrTable``. | [
"Creates",
"a",
"pretty",
"-",
"printed",
"string",
"representation",
"of",
"the",
"table",
"as",
"self",
".",
"StrTable",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1182-L1202 |
249,446 | coghost/izen | izen/helper.py | TermTable._print_head | def _print_head(self):
"""Generates the table header."""
self._print_divide()
self.StrTable += "| "
for colwidth, attr in zip(self.AttributesLength, self.Attributes):
self.StrTable += self._pad_string(attr, colwidth * 2)
self.StrTable += "| "
self.StrTable... | python | def _print_head(self):
"""Generates the table header."""
self._print_divide()
self.StrTable += "| "
for colwidth, attr in zip(self.AttributesLength, self.Attributes):
self.StrTable += self._pad_string(attr, colwidth * 2)
self.StrTable += "| "
self.StrTable... | [
"def",
"_print_head",
"(",
"self",
")",
":",
"self",
".",
"_print_divide",
"(",
")",
"self",
".",
"StrTable",
"+=",
"\"| \"",
"for",
"colwidth",
",",
"attr",
"in",
"zip",
"(",
"self",
".",
"AttributesLength",
",",
"self",
".",
"Attributes",
")",
":",
"... | Generates the table header. | [
"Generates",
"the",
"table",
"header",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1204-L1212 |
249,447 | coghost/izen | izen/helper.py | TermTable._print_value | def _print_value(self):
"""Generates the table values."""
for line in range(self.Lines_num):
for col, length in zip(self.Table, self.AttributesLength):
vals = list(col.values())[0]
val = vals[line] if len(vals) != 0 and line < len(vals) else ''
... | python | def _print_value(self):
"""Generates the table values."""
for line in range(self.Lines_num):
for col, length in zip(self.Table, self.AttributesLength):
vals = list(col.values())[0]
val = vals[line] if len(vals) != 0 and line < len(vals) else ''
... | [
"def",
"_print_value",
"(",
"self",
")",
":",
"for",
"line",
"in",
"range",
"(",
"self",
".",
"Lines_num",
")",
":",
"for",
"col",
",",
"length",
"in",
"zip",
"(",
"self",
".",
"Table",
",",
"self",
".",
"AttributesLength",
")",
":",
"vals",
"=",
"... | Generates the table values. | [
"Generates",
"the",
"table",
"values",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1214-L1223 |
249,448 | coghost/izen | izen/helper.py | TermTable._pad_string | def _pad_string(self, str, colwidth):
"""Center-pads a string to the given column width using spaces."""
width = self._disp_width(str)
prefix = (colwidth - 1 - width) // 2
suffix = colwidth - prefix - width
return ' ' * prefix + str + ' ' * suffix | python | def _pad_string(self, str, colwidth):
"""Center-pads a string to the given column width using spaces."""
width = self._disp_width(str)
prefix = (colwidth - 1 - width) // 2
suffix = colwidth - prefix - width
return ' ' * prefix + str + ' ' * suffix | [
"def",
"_pad_string",
"(",
"self",
",",
"str",
",",
"colwidth",
")",
":",
"width",
"=",
"self",
".",
"_disp_width",
"(",
"str",
")",
"prefix",
"=",
"(",
"colwidth",
"-",
"1",
"-",
"width",
")",
"//",
"2",
"suffix",
"=",
"colwidth",
"-",
"prefix",
"... | Center-pads a string to the given column width using spaces. | [
"Center",
"-",
"pads",
"a",
"string",
"to",
"the",
"given",
"column",
"width",
"using",
"spaces",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/helper.py#L1242-L1247 |
249,449 | eallik/spinoff | spinoff/util/http.py | basic_auth_string | def basic_auth_string(username, password):
"""
Encode a username and password for use in an HTTP Basic Authentication
header
"""
b64 = base64.encodestring('%s:%s' % (username, password)).strip()
return 'Basic %s' % b64 | python | def basic_auth_string(username, password):
"""
Encode a username and password for use in an HTTP Basic Authentication
header
"""
b64 = base64.encodestring('%s:%s' % (username, password)).strip()
return 'Basic %s' % b64 | [
"def",
"basic_auth_string",
"(",
"username",
",",
"password",
")",
":",
"b64",
"=",
"base64",
".",
"encodestring",
"(",
"'%s:%s'",
"%",
"(",
"username",
",",
"password",
")",
")",
".",
"strip",
"(",
")",
"return",
"'Basic %s'",
"%",
"b64"
] | Encode a username and password for use in an HTTP Basic Authentication
header | [
"Encode",
"a",
"username",
"and",
"password",
"for",
"use",
"in",
"an",
"HTTP",
"Basic",
"Authentication",
"header"
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/util/http.py#L80-L86 |
249,450 | laysakura/relshell | relshell/type.py | Type.equivalent_relshell_type | def equivalent_relshell_type(val):
"""Returns `val`'s relshell compatible type.
:param val: value to check relshell equivalent type
:raises: `NotImplementedError` if val's relshell compatible type is not implemented.
"""
builtin_type = type(val)
if builtin_type not ... | python | def equivalent_relshell_type(val):
"""Returns `val`'s relshell compatible type.
:param val: value to check relshell equivalent type
:raises: `NotImplementedError` if val's relshell compatible type is not implemented.
"""
builtin_type = type(val)
if builtin_type not ... | [
"def",
"equivalent_relshell_type",
"(",
"val",
")",
":",
"builtin_type",
"=",
"type",
"(",
"val",
")",
"if",
"builtin_type",
"not",
"in",
"Type",
".",
"_typemap",
":",
"raise",
"NotImplementedError",
"(",
"\"builtin type %s is not convertible to relshell type\"",
"%",... | Returns `val`'s relshell compatible type.
:param val: value to check relshell equivalent type
:raises: `NotImplementedError` if val's relshell compatible type is not implemented. | [
"Returns",
"val",
"s",
"relshell",
"compatible",
"type",
"."
] | 9ca5c03a34c11cb763a4a75595f18bf4383aa8cc | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/type.py#L53-L64 |
249,451 | 20c/twentyc.tools | twentyc/tools/thread.py | RunInThread.start | def start(self, *args, **kwargs):
"""
Set the arguments for the callback function and start the
thread
"""
self.runArgs = args
self.runKwargs = kwargs
Thread.start(self) | python | def start(self, *args, **kwargs):
"""
Set the arguments for the callback function and start the
thread
"""
self.runArgs = args
self.runKwargs = kwargs
Thread.start(self) | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"runArgs",
"=",
"args",
"self",
".",
"runKwargs",
"=",
"kwargs",
"Thread",
".",
"start",
"(",
"self",
")"
] | Set the arguments for the callback function and start the
thread | [
"Set",
"the",
"arguments",
"for",
"the",
"callback",
"function",
"and",
"start",
"the",
"thread"
] | f8f681e64f58d449bfc32646ba8bcc57db90a233 | https://github.com/20c/twentyc.tools/blob/f8f681e64f58d449bfc32646ba8bcc57db90a233/twentyc/tools/thread.py#L46-L55 |
249,452 | ckcollab/brains-cli | brains.py | init | def init(name, languages, run):
"""Initializes your CONFIG_FILE for the current submission"""
contents = [file_name for file_name in glob.glob("*.*") if file_name != "brains.yaml"]
with open(CONFIG_FILE, "w") as output:
output.write(yaml.safe_dump({
"run": run,
"name": name,... | python | def init(name, languages, run):
"""Initializes your CONFIG_FILE for the current submission"""
contents = [file_name for file_name in glob.glob("*.*") if file_name != "brains.yaml"]
with open(CONFIG_FILE, "w") as output:
output.write(yaml.safe_dump({
"run": run,
"name": name,... | [
"def",
"init",
"(",
"name",
",",
"languages",
",",
"run",
")",
":",
"contents",
"=",
"[",
"file_name",
"for",
"file_name",
"in",
"glob",
".",
"glob",
"(",
"\"*.*\"",
")",
"if",
"file_name",
"!=",
"\"brains.yaml\"",
"]",
"with",
"open",
"(",
"CONFIG_FILE"... | Initializes your CONFIG_FILE for the current submission | [
"Initializes",
"your",
"CONFIG_FILE",
"for",
"the",
"current",
"submission"
] | 8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e | https://github.com/ckcollab/brains-cli/blob/8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e/brains.py#L59-L77 |
249,453 | ckcollab/brains-cli | brains.py | push | def push(description, datasets, wait, verbose):
"""Publish your submission to brains"""
# Loading config
config = _get_config()
file_patterns = config["contents"]
if not isinstance(file_patterns, type([])):
# put it into an array so we can iterate it, if it isn't already an array
fil... | python | def push(description, datasets, wait, verbose):
"""Publish your submission to brains"""
# Loading config
config = _get_config()
file_patterns = config["contents"]
if not isinstance(file_patterns, type([])):
# put it into an array so we can iterate it, if it isn't already an array
fil... | [
"def",
"push",
"(",
"description",
",",
"datasets",
",",
"wait",
",",
"verbose",
")",
":",
"# Loading config",
"config",
"=",
"_get_config",
"(",
")",
"file_patterns",
"=",
"config",
"[",
"\"contents\"",
"]",
"if",
"not",
"isinstance",
"(",
"file_patterns",
... | Publish your submission to brains | [
"Publish",
"your",
"submission",
"to",
"brains"
] | 8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e | https://github.com/ckcollab/brains-cli/blob/8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e/brains.py#L85-L180 |
249,454 | ckcollab/brains-cli | brains.py | run | def run(dataset):
"""Run brain locally"""
config = _get_config()
if dataset:
_print("getting dataset from brains...")
cprint("done", 'green')
# check dataset cache for dataset
# if not exists
# r = requests.get('https://api.github.com/events', stream=True)
#... | python | def run(dataset):
"""Run brain locally"""
config = _get_config()
if dataset:
_print("getting dataset from brains...")
cprint("done", 'green')
# check dataset cache for dataset
# if not exists
# r = requests.get('https://api.github.com/events', stream=True)
#... | [
"def",
"run",
"(",
"dataset",
")",
":",
"config",
"=",
"_get_config",
"(",
")",
"if",
"dataset",
":",
"_print",
"(",
"\"getting dataset from brains...\"",
")",
"cprint",
"(",
"\"done\"",
",",
"'green'",
")",
"# check dataset cache for dataset",
"# if not exists",
... | Run brain locally | [
"Run",
"brain",
"locally"
] | 8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e | https://github.com/ckcollab/brains-cli/blob/8dc512c32fc83ecc3a80bf7fa2b474d142d99b0e/brains.py#L185-L201 |
249,455 | smetj/wishbone-input-disk | wishbone_input_disk/diskin.py | DiskIn.diskMonitor | def diskMonitor(self):
'''Primitive monitor which checks whether new data is added to disk.'''
while self.loop():
try:
newest = max(glob.iglob("%s/*" % (self.kwargs.directory)), key=os.path.getmtime)
except Exception:
pass
else:
... | python | def diskMonitor(self):
'''Primitive monitor which checks whether new data is added to disk.'''
while self.loop():
try:
newest = max(glob.iglob("%s/*" % (self.kwargs.directory)), key=os.path.getmtime)
except Exception:
pass
else:
... | [
"def",
"diskMonitor",
"(",
"self",
")",
":",
"while",
"self",
".",
"loop",
"(",
")",
":",
"try",
":",
"newest",
"=",
"max",
"(",
"glob",
".",
"iglob",
"(",
"\"%s/*\"",
"%",
"(",
"self",
".",
"kwargs",
".",
"directory",
")",
")",
",",
"key",
"=",
... | Primitive monitor which checks whether new data is added to disk. | [
"Primitive",
"monitor",
"which",
"checks",
"whether",
"new",
"data",
"is",
"added",
"to",
"disk",
"."
] | c19b0df932adbbe7c04f0b76a72cee8a42463a82 | https://github.com/smetj/wishbone-input-disk/blob/c19b0df932adbbe7c04f0b76a72cee8a42463a82/wishbone_input_disk/diskin.py#L105-L118 |
249,456 | exekias/droplet | droplet/models.py | ModelQuerySet.update | def update(self, **kwargs):
"""
Update selected objects with the given keyword parameters
and mark them as changed
"""
super(ModelQuerySet, self).update(_changed=True, **kwargs) | python | def update(self, **kwargs):
"""
Update selected objects with the given keyword parameters
and mark them as changed
"""
super(ModelQuerySet, self).update(_changed=True, **kwargs) | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"ModelQuerySet",
",",
"self",
")",
".",
"update",
"(",
"_changed",
"=",
"True",
",",
"*",
"*",
"kwargs",
")"
] | Update selected objects with the given keyword parameters
and mark them as changed | [
"Update",
"selected",
"objects",
"with",
"the",
"given",
"keyword",
"parameters",
"and",
"mark",
"them",
"as",
"changed"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/models.py#L31-L36 |
249,457 | exekias/droplet | droplet/network/models.py | Interface.update | def update(cls):
"""
Update rows to include known network interfaces
"""
ifaddrs = getifaddrs()
# Create new interfaces
for ifname in ifaddrs.keys():
if filter(ifname.startswith, cls.NAME_FILTER):
cls.objects.get_or_create(name=ifname)
... | python | def update(cls):
"""
Update rows to include known network interfaces
"""
ifaddrs = getifaddrs()
# Create new interfaces
for ifname in ifaddrs.keys():
if filter(ifname.startswith, cls.NAME_FILTER):
cls.objects.get_or_create(name=ifname)
... | [
"def",
"update",
"(",
"cls",
")",
":",
"ifaddrs",
"=",
"getifaddrs",
"(",
")",
"# Create new interfaces",
"for",
"ifname",
"in",
"ifaddrs",
".",
"keys",
"(",
")",
":",
"if",
"filter",
"(",
"ifname",
".",
"startswith",
",",
"cls",
".",
"NAME_FILTER",
")",... | Update rows to include known network interfaces | [
"Update",
"rows",
"to",
"include",
"known",
"network",
"interfaces"
] | aeac573a2c1c4b774e99d5414a1c79b1bb734941 | https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/network/models.py#L56-L67 |
249,458 | minhhoit/yacms | yacms/pages/views.py | admin_page_ordering | def admin_page_ordering(request):
"""
Updates the ordering of pages via AJAX from within the admin.
"""
def get_id(s):
s = s.split("_")[-1]
return int(s) if s.isdigit() else None
page = get_object_or_404(Page, id=get_id(request.POST['id']))
old_parent_id = page.parent_id
new... | python | def admin_page_ordering(request):
"""
Updates the ordering of pages via AJAX from within the admin.
"""
def get_id(s):
s = s.split("_")[-1]
return int(s) if s.isdigit() else None
page = get_object_or_404(Page, id=get_id(request.POST['id']))
old_parent_id = page.parent_id
new... | [
"def",
"admin_page_ordering",
"(",
"request",
")",
":",
"def",
"get_id",
"(",
"s",
")",
":",
"s",
"=",
"s",
".",
"split",
"(",
"\"_\"",
")",
"[",
"-",
"1",
"]",
"return",
"int",
"(",
"s",
")",
"if",
"s",
".",
"isdigit",
"(",
")",
"else",
"None"... | Updates the ordering of pages via AJAX from within the admin. | [
"Updates",
"the",
"ordering",
"of",
"pages",
"via",
"AJAX",
"from",
"within",
"the",
"admin",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/views.py#L16-L47 |
249,459 | minhhoit/yacms | yacms/pages/views.py | page | def page(request, slug, template=u"pages/page.html", extra_context=None):
"""
Select a template for a page and render it. The request
object should have a ``page`` attribute that's added via
``yacms.pages.middleware.PageMiddleware``. The page is loaded
earlier via middleware to perform various other... | python | def page(request, slug, template=u"pages/page.html", extra_context=None):
"""
Select a template for a page and render it. The request
object should have a ``page`` attribute that's added via
``yacms.pages.middleware.PageMiddleware``. The page is loaded
earlier via middleware to perform various other... | [
"def",
"page",
"(",
"request",
",",
"slug",
",",
"template",
"=",
"u\"pages/page.html\"",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"yacms",
".",
"pages",
".",
"middleware",
"import",
"PageMiddleware",
"if",
"not",
"PageMiddleware",
".",
"installed"... | Select a template for a page and render it. The request
object should have a ``page`` attribute that's added via
``yacms.pages.middleware.PageMiddleware``. The page is loaded
earlier via middleware to perform various other functions.
The urlpattern that maps to this view is a catch-all pattern, in
w... | [
"Select",
"a",
"template",
"for",
"a",
"page",
"and",
"render",
"it",
".",
"The",
"request",
"object",
"should",
"have",
"a",
"page",
"attribute",
"that",
"s",
"added",
"via",
"yacms",
".",
"pages",
".",
"middleware",
".",
"PageMiddleware",
".",
"The",
"... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/views.py#L50-L100 |
249,460 | eddiejessup/spatious | spatious/vector.py | vector_unit_nonull | def vector_unit_nonull(v):
"""Return unit vectors.
Any null vectors raise an Exception.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v
"""
if v.size == 0:
... | python | def vector_unit_nonull(v):
"""Return unit vectors.
Any null vectors raise an Exception.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v
"""
if v.size == 0:
... | [
"def",
"vector_unit_nonull",
"(",
"v",
")",
":",
"if",
"v",
".",
"size",
"==",
"0",
":",
"return",
"v",
"return",
"v",
"/",
"vector_mag",
"(",
"v",
")",
"[",
"...",
",",
"np",
".",
"newaxis",
"]"
] | Return unit vectors.
Any null vectors raise an Exception.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v | [
"Return",
"unit",
"vectors",
".",
"Any",
"null",
"vectors",
"raise",
"an",
"Exception",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L40-L55 |
249,461 | eddiejessup/spatious | spatious/vector.py | vector_unit_nullnull | def vector_unit_nullnull(v):
"""Return unit vectors.
Any null vectors remain null vectors.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v
"""
if v.size == 0:
... | python | def vector_unit_nullnull(v):
"""Return unit vectors.
Any null vectors remain null vectors.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v
"""
if v.size == 0:
... | [
"def",
"vector_unit_nullnull",
"(",
"v",
")",
":",
"if",
"v",
".",
"size",
"==",
"0",
":",
"return",
"v",
"mag",
"=",
"vector_mag",
"(",
"v",
")",
"v_new",
"=",
"v",
".",
"copy",
"(",
")",
"v_new",
"[",
"mag",
">",
"0.0",
"]",
"/=",
"mag",
"[",... | Return unit vectors.
Any null vectors remain null vectors.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v | [
"Return",
"unit",
"vectors",
".",
"Any",
"null",
"vectors",
"remain",
"null",
"vectors",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L58-L76 |
249,462 | eddiejessup/spatious | spatious/vector.py | vector_unit_nullrand | def vector_unit_nullrand(v, rng=None):
"""Return unit vectors.
Any null vectors are mapped to a uniformly picked unit vector.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of ... | python | def vector_unit_nullrand(v, rng=None):
"""Return unit vectors.
Any null vectors are mapped to a uniformly picked unit vector.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of ... | [
"def",
"vector_unit_nullrand",
"(",
"v",
",",
"rng",
"=",
"None",
")",
":",
"if",
"v",
".",
"size",
"==",
"0",
":",
"return",
"v",
"mag",
"=",
"vector_mag",
"(",
"v",
")",
"v_new",
"=",
"v",
".",
"copy",
"(",
")",
"v_new",
"[",
"mag",
"==",
"0.... | Return unit vectors.
Any null vectors are mapped to a uniformly picked unit vector.
Parameters
----------
v: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
v_new: array, shape of v | [
"Return",
"unit",
"vectors",
".",
"Any",
"null",
"vectors",
"are",
"mapped",
"to",
"a",
"uniformly",
"picked",
"unit",
"vector",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L79-L98 |
249,463 | eddiejessup/spatious | spatious/vector.py | polar_to_cart | def polar_to_cart(arr_p):
"""Return polar vectors in their cartesian representation.
Parameters
----------
arr_p: array, shape (a1, a2, ..., d)
Polar vectors, with last axis indexing the dimension,
using (radius, inclination, azimuth) convention.
Returns
-------
arr_c: arra... | python | def polar_to_cart(arr_p):
"""Return polar vectors in their cartesian representation.
Parameters
----------
arr_p: array, shape (a1, a2, ..., d)
Polar vectors, with last axis indexing the dimension,
using (radius, inclination, azimuth) convention.
Returns
-------
arr_c: arra... | [
"def",
"polar_to_cart",
"(",
"arr_p",
")",
":",
"if",
"arr_p",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"1",
":",
"arr_c",
"=",
"arr_p",
".",
"copy",
"(",
")",
"elif",
"arr_p",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"2",
":",
"arr_c",
"=",
"n... | Return polar vectors in their cartesian representation.
Parameters
----------
arr_p: array, shape (a1, a2, ..., d)
Polar vectors, with last axis indexing the dimension,
using (radius, inclination, azimuth) convention.
Returns
-------
arr_c: array, shape of arr_p
Cartesi... | [
"Return",
"polar",
"vectors",
"in",
"their",
"cartesian",
"representation",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L124-L153 |
249,464 | eddiejessup/spatious | spatious/vector.py | cart_to_polar | def cart_to_polar(arr_c):
"""Return cartesian vectors in their polar representation.
Parameters
----------
arr_c: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
arr_p: array, shape of arr_c
Polar vectors, using (radiu... | python | def cart_to_polar(arr_c):
"""Return cartesian vectors in their polar representation.
Parameters
----------
arr_c: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
arr_p: array, shape of arr_c
Polar vectors, using (radiu... | [
"def",
"cart_to_polar",
"(",
"arr_c",
")",
":",
"if",
"arr_c",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"1",
":",
"arr_p",
"=",
"arr_c",
".",
"copy",
"(",
")",
"elif",
"arr_c",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"2",
":",
"arr_p",
"=",
"n... | Return cartesian vectors in their polar representation.
Parameters
----------
arr_c: array, shape (a1, a2, ..., d)
Cartesian vectors, with last axis indexing the dimension.
Returns
-------
arr_p: array, shape of arr_c
Polar vectors, using (radius, inclination, azimuth) conventi... | [
"Return",
"cartesian",
"vectors",
"in",
"their",
"polar",
"representation",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L156-L182 |
249,465 | eddiejessup/spatious | spatious/vector.py | sphere_pick_polar | def sphere_pick_polar(d, n=1, rng=None):
"""Return vectors uniformly picked on the unit sphere.
Vectors are in a polar representation.
Parameters
----------
d: float
The number of dimensions of the space in which the sphere lives.
n: integer
Number of samples to pick.
Retur... | python | def sphere_pick_polar(d, n=1, rng=None):
"""Return vectors uniformly picked on the unit sphere.
Vectors are in a polar representation.
Parameters
----------
d: float
The number of dimensions of the space in which the sphere lives.
n: integer
Number of samples to pick.
Retur... | [
"def",
"sphere_pick_polar",
"(",
"d",
",",
"n",
"=",
"1",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"np",
".",
"random",
"a",
"=",
"np",
".",
"empty",
"(",
"[",
"n",
",",
"d",
"]",
")",
"if",
"d",
"==",
... | Return vectors uniformly picked on the unit sphere.
Vectors are in a polar representation.
Parameters
----------
d: float
The number of dimensions of the space in which the sphere lives.
n: integer
Number of samples to pick.
Returns
-------
r: array, shape (n, d)
... | [
"Return",
"vectors",
"uniformly",
"picked",
"on",
"the",
"unit",
"sphere",
".",
"Vectors",
"are",
"in",
"a",
"polar",
"representation",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L185-L216 |
249,466 | eddiejessup/spatious | spatious/vector.py | rejection_pick | def rejection_pick(L, n, d, valid, rng=None):
"""Return cartesian vectors uniformly picked in a space with an arbitrary
number of dimensions, which is fully enclosed by a cube of finite length,
using a supplied function which should evaluate whether a picked point lies
within this space.
The pickin... | python | def rejection_pick(L, n, d, valid, rng=None):
"""Return cartesian vectors uniformly picked in a space with an arbitrary
number of dimensions, which is fully enclosed by a cube of finite length,
using a supplied function which should evaluate whether a picked point lies
within this space.
The pickin... | [
"def",
"rejection_pick",
"(",
"L",
",",
"n",
",",
"d",
",",
"valid",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"np",
".",
"random",
"rs",
"=",
"[",
"]",
"while",
"len",
"(",
"rs",
")",
"<",
"n",
":",
"r"... | Return cartesian vectors uniformly picked in a space with an arbitrary
number of dimensions, which is fully enclosed by a cube of finite length,
using a supplied function which should evaluate whether a picked point lies
within this space.
The picking is done by rejection sampling in the cube.
Par... | [
"Return",
"cartesian",
"vectors",
"uniformly",
"picked",
"in",
"a",
"space",
"with",
"an",
"arbitrary",
"number",
"of",
"dimensions",
"which",
"is",
"fully",
"enclosed",
"by",
"a",
"cube",
"of",
"finite",
"length",
"using",
"a",
"supplied",
"function",
"which"... | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L238-L267 |
249,467 | eddiejessup/spatious | spatious/vector.py | ball_pick | def ball_pick(n, d, rng=None):
"""Return cartesian vectors uniformly picked on the unit ball in an
arbitrary number of dimensions.
The unit ball is the space enclosed by the unit sphere.
The picking is done by rejection sampling in the unit cube.
In 3-dimensional space, the fraction `\pi / 6 \sim... | python | def ball_pick(n, d, rng=None):
"""Return cartesian vectors uniformly picked on the unit ball in an
arbitrary number of dimensions.
The unit ball is the space enclosed by the unit sphere.
The picking is done by rejection sampling in the unit cube.
In 3-dimensional space, the fraction `\pi / 6 \sim... | [
"def",
"ball_pick",
"(",
"n",
",",
"d",
",",
"rng",
"=",
"None",
")",
":",
"def",
"valid",
"(",
"r",
")",
":",
"return",
"vector_mag_sq",
"(",
"r",
")",
"<",
"1.0",
"return",
"rejection_pick",
"(",
"L",
"=",
"2.0",
",",
"n",
"=",
"n",
",",
"d",... | Return cartesian vectors uniformly picked on the unit ball in an
arbitrary number of dimensions.
The unit ball is the space enclosed by the unit sphere.
The picking is done by rejection sampling in the unit cube.
In 3-dimensional space, the fraction `\pi / 6 \sim 0.52` points are valid.
Paramete... | [
"Return",
"cartesian",
"vectors",
"uniformly",
"picked",
"on",
"the",
"unit",
"ball",
"in",
"an",
"arbitrary",
"number",
"of",
"dimensions",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L270-L294 |
249,468 | eddiejessup/spatious | spatious/vector.py | disk_pick_polar | def disk_pick_polar(n=1, rng=None):
"""Return vectors uniformly picked on the unit disk.
The unit disk is the space enclosed by the unit circle.
Vectors are in a polar representation.
Parameters
----------
n: integer
Number of points to return.
Returns
-------
r: array, sha... | python | def disk_pick_polar(n=1, rng=None):
"""Return vectors uniformly picked on the unit disk.
The unit disk is the space enclosed by the unit circle.
Vectors are in a polar representation.
Parameters
----------
n: integer
Number of points to return.
Returns
-------
r: array, sha... | [
"def",
"disk_pick_polar",
"(",
"n",
"=",
"1",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
":",
"rng",
"=",
"np",
".",
"random",
"a",
"=",
"np",
".",
"zeros",
"(",
"[",
"n",
",",
"2",
"]",
",",
"dtype",
"=",
"np",
".",
"flo... | Return vectors uniformly picked on the unit disk.
The unit disk is the space enclosed by the unit circle.
Vectors are in a polar representation.
Parameters
----------
n: integer
Number of points to return.
Returns
-------
r: array, shape (n, 2)
Sample vectors. | [
"Return",
"vectors",
"uniformly",
"picked",
"on",
"the",
"unit",
"disk",
".",
"The",
"unit",
"disk",
"is",
"the",
"space",
"enclosed",
"by",
"the",
"unit",
"circle",
".",
"Vectors",
"are",
"in",
"a",
"polar",
"representation",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L297-L317 |
249,469 | eddiejessup/spatious | spatious/vector.py | smallest_signed_angle | def smallest_signed_angle(source, target):
"""Find the smallest angle going from angle `source` to angle `target`."""
dth = target - source
dth = (dth + np.pi) % (2.0 * np.pi) - np.pi
return dth | python | def smallest_signed_angle(source, target):
"""Find the smallest angle going from angle `source` to angle `target`."""
dth = target - source
dth = (dth + np.pi) % (2.0 * np.pi) - np.pi
return dth | [
"def",
"smallest_signed_angle",
"(",
"source",
",",
"target",
")",
":",
"dth",
"=",
"target",
"-",
"source",
"dth",
"=",
"(",
"dth",
"+",
"np",
".",
"pi",
")",
"%",
"(",
"2.0",
"*",
"np",
".",
"pi",
")",
"-",
"np",
".",
"pi",
"return",
"dth"
] | Find the smallest angle going from angle `source` to angle `target`. | [
"Find",
"the",
"smallest",
"angle",
"going",
"from",
"angle",
"source",
"to",
"angle",
"target",
"."
] | b7ae91bec029e85a45a7f303ee184076433723cd | https://github.com/eddiejessup/spatious/blob/b7ae91bec029e85a45a7f303ee184076433723cd/spatious/vector.py#L343-L347 |
249,470 | cbrand/vpnchooser | src/vpnchooser/resources/vpn.py | VpnResource.put | def put(self, vpn_id: int) -> Vpn:
"""
Updates the Vpn Resource with the
name.
"""
vpn = self._get_or_abort(vpn_id)
self.update(vpn)
session.commit()
return vpn | python | def put(self, vpn_id: int) -> Vpn:
"""
Updates the Vpn Resource with the
name.
"""
vpn = self._get_or_abort(vpn_id)
self.update(vpn)
session.commit()
return vpn | [
"def",
"put",
"(",
"self",
",",
"vpn_id",
":",
"int",
")",
"->",
"Vpn",
":",
"vpn",
"=",
"self",
".",
"_get_or_abort",
"(",
"vpn_id",
")",
"self",
".",
"update",
"(",
"vpn",
")",
"session",
".",
"commit",
"(",
")",
"return",
"vpn"
] | Updates the Vpn Resource with the
name. | [
"Updates",
"the",
"Vpn",
"Resource",
"with",
"the",
"name",
"."
] | d153e3d05555c23cf5e8e15e507eecad86465923 | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/vpn.py#L88-L96 |
249,471 | cbrand/vpnchooser | src/vpnchooser/resources/vpn.py | VpnListResource.post | def post(self) -> Vpn:
"""
Creates the vpn with the given data.
"""
vpn = Vpn()
session.add(vpn)
self.update(vpn)
session.flush()
session.commit()
return vpn, 201, {
'Location': url_for('vpn', vpn_id=vpn.id)
} | python | def post(self) -> Vpn:
"""
Creates the vpn with the given data.
"""
vpn = Vpn()
session.add(vpn)
self.update(vpn)
session.flush()
session.commit()
return vpn, 201, {
'Location': url_for('vpn', vpn_id=vpn.id)
} | [
"def",
"post",
"(",
"self",
")",
"->",
"Vpn",
":",
"vpn",
"=",
"Vpn",
"(",
")",
"session",
".",
"add",
"(",
"vpn",
")",
"self",
".",
"update",
"(",
"vpn",
")",
"session",
".",
"flush",
"(",
")",
"session",
".",
"commit",
"(",
")",
"return",
"vp... | Creates the vpn with the given data. | [
"Creates",
"the",
"vpn",
"with",
"the",
"given",
"data",
"."
] | d153e3d05555c23cf5e8e15e507eecad86465923 | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/vpn.py#L121-L132 |
249,472 | tBaxter/tango-comments | build/lib/tango_comments/templatetags/comments.py | RenderCommentListNode.handle_token | def handle_token(cls, parser, token):
"""Class method to parse render_comment_list and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% render_comment_list ... | python | def handle_token(cls, parser, token):
"""Class method to parse render_comment_list and return a Node."""
tokens = token.contents.split()
if tokens[1] != 'for':
raise template.TemplateSyntaxError("Second argument in %r tag must be 'for'" % tokens[0])
# {% render_comment_list ... | [
"def",
"handle_token",
"(",
"cls",
",",
"parser",
",",
"token",
")",
":",
"tokens",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"tokens",
"[",
"1",
"]",
"!=",
"'for'",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"\"Secon... | Class method to parse render_comment_list and return a Node. | [
"Class",
"method",
"to",
"parse",
"render_comment_list",
"and",
"return",
"a",
"Node",
"."
] | 1fd335c6fc9e81bba158e42e1483f1a149622ab4 | https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/templatetags/comments.py#L188-L203 |
249,473 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.get_current_data | def get_current_data(self):
"""Return the calibration data for the current IMU, if any."""
if self.current_imuid in self.calibration_data:
return self.calibration_data[self.current_imuid]
return {} | python | def get_current_data(self):
"""Return the calibration data for the current IMU, if any."""
if self.current_imuid in self.calibration_data:
return self.calibration_data[self.current_imuid]
return {} | [
"def",
"get_current_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"current_imuid",
"in",
"self",
".",
"calibration_data",
":",
"return",
"self",
".",
"calibration_data",
"[",
"self",
".",
"current_imuid",
"]",
"return",
"{",
"}"
] | Return the calibration data for the current IMU, if any. | [
"Return",
"the",
"calibration",
"data",
"for",
"the",
"current",
"IMU",
"if",
"any",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L271-L276 |
249,474 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.update_battery | def update_battery(self):
"""Updates the battery level in the UI for the connected SK8, if any"""
if self.sk8 is None:
return
battery = self.sk8.get_battery_level()
self.lblBattery.setText('Battery: {}%'.format(battery)) | python | def update_battery(self):
"""Updates the battery level in the UI for the connected SK8, if any"""
if self.sk8 is None:
return
battery = self.sk8.get_battery_level()
self.lblBattery.setText('Battery: {}%'.format(battery)) | [
"def",
"update_battery",
"(",
"self",
")",
":",
"if",
"self",
".",
"sk8",
"is",
"None",
":",
"return",
"battery",
"=",
"self",
".",
"sk8",
".",
"get_battery_level",
"(",
")",
"self",
".",
"lblBattery",
".",
"setText",
"(",
"'Battery: {}%'",
".",
"format"... | Updates the battery level in the UI for the connected SK8, if any | [
"Updates",
"the",
"battery",
"level",
"in",
"the",
"UI",
"for",
"the",
"connected",
"SK8",
"if",
"any"
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L278-L283 |
249,475 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.imu_changed | def imu_changed(self, val):
"""Handle clicks on the IMU index spinner."""
self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val)
self.update_data_display(self.get_current_data()) | python | def imu_changed(self, val):
"""Handle clicks on the IMU index spinner."""
self.current_imuid = '{}_IMU{}'.format(self.sk8.get_device_name(), val)
self.update_data_display(self.get_current_data()) | [
"def",
"imu_changed",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"current_imuid",
"=",
"'{}_IMU{}'",
".",
"format",
"(",
"self",
".",
"sk8",
".",
"get_device_name",
"(",
")",
",",
"val",
")",
"self",
".",
"update_data_display",
"(",
"self",
".",
"... | Handle clicks on the IMU index spinner. | [
"Handle",
"clicks",
"on",
"the",
"IMU",
"index",
"spinner",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L285-L288 |
249,476 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.accel_calibration | def accel_calibration(self):
"""Perform accelerometer calibration for current IMU."""
self.calibration_state = self.CAL_ACC
self.acc_dialog = SK8AccDialog(self.sk8.get_imu(self.spinIMU.value()), self)
if self.acc_dialog.exec_() == QDialog.Rejected:
return
sel... | python | def accel_calibration(self):
"""Perform accelerometer calibration for current IMU."""
self.calibration_state = self.CAL_ACC
self.acc_dialog = SK8AccDialog(self.sk8.get_imu(self.spinIMU.value()), self)
if self.acc_dialog.exec_() == QDialog.Rejected:
return
sel... | [
"def",
"accel_calibration",
"(",
"self",
")",
":",
"self",
".",
"calibration_state",
"=",
"self",
".",
"CAL_ACC",
"self",
".",
"acc_dialog",
"=",
"SK8AccDialog",
"(",
"self",
".",
"sk8",
".",
"get_imu",
"(",
"self",
".",
"spinIMU",
".",
"value",
"(",
")"... | Perform accelerometer calibration for current IMU. | [
"Perform",
"accelerometer",
"calibration",
"for",
"current",
"IMU",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L290-L297 |
249,477 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.gyro_calibration | def gyro_calibration(self):
"""Perform gyroscope calibration for current IMU."""
QtWidgets.QMessageBox.information(self, 'Gyro calibration', 'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\'t move the the IMU for a few seconds')
self.calibration_state = self.CAL_GY... | python | def gyro_calibration(self):
"""Perform gyroscope calibration for current IMU."""
QtWidgets.QMessageBox.information(self, 'Gyro calibration', 'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\'t move the the IMU for a few seconds')
self.calibration_state = self.CAL_GY... | [
"def",
"gyro_calibration",
"(",
"self",
")",
":",
"QtWidgets",
".",
"QMessageBox",
".",
"information",
"(",
"self",
",",
"'Gyro calibration'",
",",
"'Ensure the selected IMU is in a stable, unmoving position, then click OK. Don\\'t move the the IMU for a few seconds'",
")",
"self... | Perform gyroscope calibration for current IMU. | [
"Perform",
"gyroscope",
"calibration",
"for",
"current",
"IMU",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L299-L307 |
249,478 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.mag_calibration | def mag_calibration(self):
"""Perform magnetometer calibration for current IMU."""
self.calibration_state = self.CAL_MAG
self.mag_dialog = SK8MagDialog(self.sk8.get_imu(self.spinIMU.value()), self)
if self.mag_dialog.exec_() == QDialog.Rejected:
return
self.calculate... | python | def mag_calibration(self):
"""Perform magnetometer calibration for current IMU."""
self.calibration_state = self.CAL_MAG
self.mag_dialog = SK8MagDialog(self.sk8.get_imu(self.spinIMU.value()), self)
if self.mag_dialog.exec_() == QDialog.Rejected:
return
self.calculate... | [
"def",
"mag_calibration",
"(",
"self",
")",
":",
"self",
".",
"calibration_state",
"=",
"self",
".",
"CAL_MAG",
"self",
".",
"mag_dialog",
"=",
"SK8MagDialog",
"(",
"self",
".",
"sk8",
".",
"get_imu",
"(",
"self",
".",
"spinIMU",
".",
"value",
"(",
")",
... | Perform magnetometer calibration for current IMU. | [
"Perform",
"magnetometer",
"calibration",
"for",
"current",
"IMU",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L309-L316 |
249,479 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.calculate_gyro_calibration | def calculate_gyro_calibration(self, gyro_samples):
"""Performs a basic gyroscope bias calculation.
Takes a list of (x, y, z) samples and averages over each axis to calculate
the bias values, and stores them in the calibration data structure for the
currently connected SK8"""
... | python | def calculate_gyro_calibration(self, gyro_samples):
"""Performs a basic gyroscope bias calculation.
Takes a list of (x, y, z) samples and averages over each axis to calculate
the bias values, and stores them in the calibration data structure for the
currently connected SK8"""
... | [
"def",
"calculate_gyro_calibration",
"(",
"self",
",",
"gyro_samples",
")",
":",
"totals",
"=",
"[",
"0",
",",
"0",
",",
"0",
"]",
"for",
"gs",
"in",
"gyro_samples",
":",
"totals",
"[",
"0",
"]",
"+=",
"gs",
"[",
"0",
"]",
"totals",
"[",
"1",
"]",
... | Performs a basic gyroscope bias calculation.
Takes a list of (x, y, z) samples and averages over each axis to calculate
the bias values, and stores them in the calibration data structure for the
currently connected SK8 | [
"Performs",
"a",
"basic",
"gyroscope",
"bias",
"calculation",
"."
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L357-L380 |
249,480 | andrewramsay/sk8-drivers | pysk8/calibration/sk8_calibration_gui.py | SK8Calibration.device_selected | def device_selected(self, index):
"""Handler for selecting a device from the list in the UI"""
device = self.devicelist_model.itemFromIndex(index)
print(device.device.addr)
self.btnConnect.setEnabled(True) | python | def device_selected(self, index):
"""Handler for selecting a device from the list in the UI"""
device = self.devicelist_model.itemFromIndex(index)
print(device.device.addr)
self.btnConnect.setEnabled(True) | [
"def",
"device_selected",
"(",
"self",
",",
"index",
")",
":",
"device",
"=",
"self",
".",
"devicelist_model",
".",
"itemFromIndex",
"(",
"index",
")",
"print",
"(",
"device",
".",
"device",
".",
"addr",
")",
"self",
".",
"btnConnect",
".",
"setEnabled",
... | Handler for selecting a device from the list in the UI | [
"Handler",
"for",
"selecting",
"a",
"device",
"from",
"the",
"list",
"in",
"the",
"UI"
] | 67347a71762fb421f5ae65a595def5c7879e8b0c | https://github.com/andrewramsay/sk8-drivers/blob/67347a71762fb421f5ae65a595def5c7879e8b0c/pysk8/calibration/sk8_calibration_gui.py#L475-L479 |
249,481 | xtrementl/focus | focus/plugin/modules/sites.py | SiteBlock._handle_block | def _handle_block(self, task, disable=False):
""" Handles blocking domains using hosts file.
`task`
``Task`` instance.
`disable`
Set to ``True``, to turn off blocking and restore hosts file;
otherwise, ``False`` will enable blocking by up... | python | def _handle_block(self, task, disable=False):
""" Handles blocking domains using hosts file.
`task`
``Task`` instance.
`disable`
Set to ``True``, to turn off blocking and restore hosts file;
otherwise, ``False`` will enable blocking by up... | [
"def",
"_handle_block",
"(",
"self",
",",
"task",
",",
"disable",
"=",
"False",
")",
":",
"backup_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"task",
".",
"task_dir",
",",
"'.hosts.bak'",
")",
"self",
".",
"orig_data",
"=",
"self",
".",
"orig_data... | Handles blocking domains using hosts file.
`task`
``Task`` instance.
`disable`
Set to ``True``, to turn off blocking and restore hosts file;
otherwise, ``False`` will enable blocking by updating hosts
file.
Returns bo... | [
"Handles",
"blocking",
"domains",
"using",
"hosts",
"file",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sites.py#L51-L137 |
249,482 | xtrementl/focus | focus/plugin/modules/sites.py | SiteBlock.parse_option | def parse_option(self, option, block_name, *values):
""" Parse domain values for option.
"""
_extra_subs = ('www', 'm', 'mobile')
if len(values) == 0: # expect some values here..
raise ValueError
for value in values:
value = value.lower()
... | python | def parse_option(self, option, block_name, *values):
""" Parse domain values for option.
"""
_extra_subs = ('www', 'm', 'mobile')
if len(values) == 0: # expect some values here..
raise ValueError
for value in values:
value = value.lower()
... | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"_extra_subs",
"=",
"(",
"'www'",
",",
"'m'",
",",
"'mobile'",
")",
"if",
"len",
"(",
"values",
")",
"==",
"0",
":",
"# expect some values here..",
"raise... | Parse domain values for option. | [
"Parse",
"domain",
"values",
"for",
"option",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sites.py#L139-L174 |
249,483 | tomokinakamaru/mapletree | mapletree/helpers/signing.py | Signing.sign | def sign(self, data):
""" Create url-safe signed token.
:param data: Data to sign
:type data: object
"""
try:
jsonstr = json.dumps(data, separators=(',', ':'))
except TypeError as e:
raise DataSignError(e.args[0])
else:
signa... | python | def sign(self, data):
""" Create url-safe signed token.
:param data: Data to sign
:type data: object
"""
try:
jsonstr = json.dumps(data, separators=(',', ':'))
except TypeError as e:
raise DataSignError(e.args[0])
else:
signa... | [
"def",
"sign",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"jsonstr",
"=",
"json",
".",
"dumps",
"(",
"data",
",",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
")",
"except",
"TypeError",
"as",
"e",
":",
"raise",
"DataSignError",
"(",
"e",
... | Create url-safe signed token.
:param data: Data to sign
:type data: object | [
"Create",
"url",
"-",
"safe",
"signed",
"token",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/helpers/signing.py#L22-L36 |
249,484 | tomokinakamaru/mapletree | mapletree/helpers/signing.py | Signing.unsign | def unsign(self, b64msg):
""" Retrieves data from signed token.
:param b64msg: Token to unsign
:type b64msg: str
"""
msg = self._b64decode(b64msg)
try:
body, signature = msg.rsplit('.', 1)
except ValueError as e:
raise MalformedSigendMess... | python | def unsign(self, b64msg):
""" Retrieves data from signed token.
:param b64msg: Token to unsign
:type b64msg: str
"""
msg = self._b64decode(b64msg)
try:
body, signature = msg.rsplit('.', 1)
except ValueError as e:
raise MalformedSigendMess... | [
"def",
"unsign",
"(",
"self",
",",
"b64msg",
")",
":",
"msg",
"=",
"self",
".",
"_b64decode",
"(",
"b64msg",
")",
"try",
":",
"body",
",",
"signature",
"=",
"msg",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
"as",
"e",
":",
... | Retrieves data from signed token.
:param b64msg: Token to unsign
:type b64msg: str | [
"Retrieves",
"data",
"from",
"signed",
"token",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/helpers/signing.py#L38-L60 |
249,485 | fred49/linshare-api | linshareapi/core.py | extract_file_name | def extract_file_name(content_dispo):
"""Extract file name from the input request body"""
# print type(content_dispo)
# print repr(content_dispo)
# convertion of escape string (str type) from server
# to unicode object
content_dispo = content_dispo.decode('unicode-escape').strip('"')
file_na... | python | def extract_file_name(content_dispo):
"""Extract file name from the input request body"""
# print type(content_dispo)
# print repr(content_dispo)
# convertion of escape string (str type) from server
# to unicode object
content_dispo = content_dispo.decode('unicode-escape').strip('"')
file_na... | [
"def",
"extract_file_name",
"(",
"content_dispo",
")",
":",
"# print type(content_dispo)",
"# print repr(content_dispo)",
"# convertion of escape string (str type) from server",
"# to unicode object",
"content_dispo",
"=",
"content_dispo",
".",
"decode",
"(",
"'unicode-escape'",
")... | Extract file name from the input request body | [
"Extract",
"file",
"name",
"from",
"the",
"input",
"request",
"body"
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L59-L72 |
249,486 | fred49/linshare-api | linshareapi/core.py | CoreCli.download | def download(self, uuid, url, forced_file_name=None,
progress_bar=True, chunk_size=256,
directory=None, overwrite=False):
""" download a file from LinShare using its rest api.
This method could throw exceptions like urllib2.HTTPError."""
self.last_req_time = Non... | python | def download(self, uuid, url, forced_file_name=None,
progress_bar=True, chunk_size=256,
directory=None, overwrite=False):
""" download a file from LinShare using its rest api.
This method could throw exceptions like urllib2.HTTPError."""
self.last_req_time = Non... | [
"def",
"download",
"(",
"self",
",",
"uuid",
",",
"url",
",",
"forced_file_name",
"=",
"None",
",",
"progress_bar",
"=",
"True",
",",
"chunk_size",
"=",
"256",
",",
"directory",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"self",
".",
"last_... | download a file from LinShare using its rest api.
This method could throw exceptions like urllib2.HTTPError. | [
"download",
"a",
"file",
"from",
"LinShare",
"using",
"its",
"rest",
"api",
".",
"This",
"method",
"could",
"throw",
"exceptions",
"like",
"urllib2",
".",
"HTTPError",
"."
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L558-L632 |
249,487 | fred49/linshare-api | linshareapi/core.py | ResourceBuilder.add_field | def add_field(self, field, arg=None, value=None, extended=False,
hidden=False, e_type=str, required=None):
"""Add a new field to the current ResourceBuilder.
Keyword arguments:
field -- field name
arg -- name of the attribute name in arg object (argpar... | python | def add_field(self, field, arg=None, value=None, extended=False,
hidden=False, e_type=str, required=None):
"""Add a new field to the current ResourceBuilder.
Keyword arguments:
field -- field name
arg -- name of the attribute name in arg object (argpar... | [
"def",
"add_field",
"(",
"self",
",",
"field",
",",
"arg",
"=",
"None",
",",
"value",
"=",
"None",
",",
"extended",
"=",
"False",
",",
"hidden",
"=",
"False",
",",
"e_type",
"=",
"str",
",",
"required",
"=",
"None",
")",
":",
"if",
"required",
"is"... | Add a new field to the current ResourceBuilder.
Keyword arguments:
field -- field name
arg -- name of the attribute name in arg object (argparse)
value -- a default for this field, used for resource creation.
extended -- If set to true, the current fiel... | [
"Add",
"a",
"new",
"field",
"to",
"the",
"current",
"ResourceBuilder",
"."
] | be646c25aa8ba3718abb6869c620b157d53d6e41 | https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/core.py#L658-L686 |
249,488 | laysakura/relshell | relshell/daemon_shelloperator.py | DaemonShellOperator.kill | def kill(self):
"""Kill instantiated process
:raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_
"""
BaseShellOperator._close_process_input_stdin(self._batcmd.batch_to_file_s)
BaseShellOpera... | python | def kill(self):
"""Kill instantiated process
:raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_
"""
BaseShellOperator._close_process_input_stdin(self._batcmd.batch_to_file_s)
BaseShellOpera... | [
"def",
"kill",
"(",
"self",
")",
":",
"BaseShellOperator",
".",
"_close_process_input_stdin",
"(",
"self",
".",
"_batcmd",
".",
"batch_to_file_s",
")",
"BaseShellOperator",
".",
"_wait_process",
"(",
"self",
".",
"_process",
",",
"self",
".",
"_batcmd",
".",
"... | Kill instantiated process
:raises: `AttributeError` if instantiated process doesn't seem to satisfy `constraints <relshell.daemon_shelloperator.DaemonShellOperator>`_ | [
"Kill",
"instantiated",
"process"
] | 9ca5c03a34c11cb763a4a75595f18bf4383aa8cc | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/daemon_shelloperator.py#L120-L128 |
249,489 | simpleenergy/env-excavator | excavator/utils.py | env_timestamp | def env_timestamp(name, required=False, default=empty):
"""Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be a
timestamp in the form of a float.
If the name is not present in the environment and no default is... | python | def env_timestamp(name, required=False, default=empty):
"""Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be a
timestamp in the form of a float.
If the name is not present in the environment and no default is... | [
"def",
"env_timestamp",
"(",
"name",
",",
"required",
"=",
"False",
",",
"default",
"=",
"empty",
")",
":",
"if",
"required",
"and",
"default",
"is",
"not",
"empty",
":",
"raise",
"ValueError",
"(",
"\"Using `default` with `required=True` is invalid\"",
")",
"va... | Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be a
timestamp in the form of a float.
If the name is not present in the environment and no default is specified
then a ``ValueError`` will be raised.
:para... | [
"Pulls",
"an",
"environment",
"variable",
"out",
"of",
"the",
"environment",
"and",
"parses",
"it",
"to",
"a",
"datetime",
".",
"datetime",
"object",
".",
"The",
"environment",
"variable",
"is",
"expected",
"to",
"be",
"a",
"timestamp",
"in",
"the",
"form",
... | 2bce66396f0c92fefa2b39ea458965174e478faf | https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L179-L213 |
249,490 | simpleenergy/env-excavator | excavator/utils.py | env_iso8601 | def env_iso8601(name, required=False, default=empty):
"""Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be an
iso8601 formatted string.
If the name is not present in the environment and no default is specifie... | python | def env_iso8601(name, required=False, default=empty):
"""Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be an
iso8601 formatted string.
If the name is not present in the environment and no default is specifie... | [
"def",
"env_iso8601",
"(",
"name",
",",
"required",
"=",
"False",
",",
"default",
"=",
"empty",
")",
":",
"try",
":",
"import",
"iso8601",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'Parsing iso8601 datetime strings requires the iso8601 library'",
"... | Pulls an environment variable out of the environment and parses it to a
``datetime.datetime`` object. The environment variable is expected to be an
iso8601 formatted string.
If the name is not present in the environment and no default is specified
then a ``ValueError`` will be raised.
:param name:... | [
"Pulls",
"an",
"environment",
"variable",
"out",
"of",
"the",
"environment",
"and",
"parses",
"it",
"to",
"a",
"datetime",
".",
"datetime",
"object",
".",
"The",
"environment",
"variable",
"is",
"expected",
"to",
"be",
"an",
"iso8601",
"formatted",
"string",
... | 2bce66396f0c92fefa2b39ea458965174e478faf | https://github.com/simpleenergy/env-excavator/blob/2bce66396f0c92fefa2b39ea458965174e478faf/excavator/utils.py#L216-L255 |
249,491 | KnowledgeLinks/rdfframework | rdfframework/search/esloaders.py | EsRdfBulkLoader._set_es_workers | def _set_es_workers(self, **kwargs):
"""
Creates index worker instances for each class to index
kwargs:
-------
idx_only_base[bool]: True will only index the base class
"""
def make_es_worker(search_conn, es_index, es_doc_type, class_name):
"""
... | python | def _set_es_workers(self, **kwargs):
"""
Creates index worker instances for each class to index
kwargs:
-------
idx_only_base[bool]: True will only index the base class
"""
def make_es_worker(search_conn, es_index, es_doc_type, class_name):
"""
... | [
"def",
"_set_es_workers",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"make_es_worker",
"(",
"search_conn",
",",
"es_index",
",",
"es_doc_type",
",",
"class_name",
")",
":",
"\"\"\"\n Returns a new es_worker instance\n\n args:\n ... | Creates index worker instances for each class to index
kwargs:
-------
idx_only_base[bool]: True will only index the base class | [
"Creates",
"index",
"worker",
"instances",
"for",
"each",
"class",
"to",
"index"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L74-L123 |
249,492 | KnowledgeLinks/rdfframework | rdfframework/search/esloaders.py | EsRdfBulkLoader._index_sub | def _index_sub(self, uri_list, num, batch_num):
"""
Converts a list of uris to elasticsearch json objects
args:
uri_list: list of uris to convert
num: the ending count within the batch
batch_num: the batch number
"""
bname = '%s-%s' % (batch_n... | python | def _index_sub(self, uri_list, num, batch_num):
"""
Converts a list of uris to elasticsearch json objects
args:
uri_list: list of uris to convert
num: the ending count within the batch
batch_num: the batch number
"""
bname = '%s-%s' % (batch_n... | [
"def",
"_index_sub",
"(",
"self",
",",
"uri_list",
",",
"num",
",",
"batch_num",
")",
":",
"bname",
"=",
"'%s-%s'",
"%",
"(",
"batch_num",
",",
"num",
")",
"log",
".",
"debug",
"(",
"\"batch_num '%s' starting es_json conversion\"",
",",
"bname",
")",
"qry_da... | Converts a list of uris to elasticsearch json objects
args:
uri_list: list of uris to convert
num: the ending count within the batch
batch_num: the batch number | [
"Converts",
"a",
"list",
"of",
"uris",
"to",
"elasticsearch",
"json",
"objects"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L125-L168 |
249,493 | KnowledgeLinks/rdfframework | rdfframework/search/esloaders.py | EsRdfBulkLoader.delete_idx_status | def delete_idx_status(self, rdf_class):
"""
Removes all of the index status triples from the datastore
Args:
-----
rdf_class: The class of items to remove the status from
"""
sparql_template = """
DELETE
{{
?s kds:esIn... | python | def delete_idx_status(self, rdf_class):
"""
Removes all of the index status triples from the datastore
Args:
-----
rdf_class: The class of items to remove the status from
"""
sparql_template = """
DELETE
{{
?s kds:esIn... | [
"def",
"delete_idx_status",
"(",
"self",
",",
"rdf_class",
")",
":",
"sparql_template",
"=",
"\"\"\"\n DELETE\n {{\n ?s kds:esIndexTime ?esTime .\n ?s kds:esIndexError ?esError .\n }}\n WHERE\n {{\n\n ... | Removes all of the index status triples from the datastore
Args:
-----
rdf_class: The class of items to remove the status from | [
"Removes",
"all",
"of",
"the",
"index",
"status",
"triples",
"from",
"the",
"datastore"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L430-L463 |
249,494 | KnowledgeLinks/rdfframework | rdfframework/search/esloaders.py | EsRdfBulkLoader.get_es_ids | def get_es_ids(self):
"""
reads all the elasticssearch ids for an index
"""
search = self.search.source(['uri']).sort(['uri'])
es_ids = [item.meta.id for item in search.scan()]
return es_ids | python | def get_es_ids(self):
"""
reads all the elasticssearch ids for an index
"""
search = self.search.source(['uri']).sort(['uri'])
es_ids = [item.meta.id for item in search.scan()]
return es_ids | [
"def",
"get_es_ids",
"(",
"self",
")",
":",
"search",
"=",
"self",
".",
"search",
".",
"source",
"(",
"[",
"'uri'",
"]",
")",
".",
"sort",
"(",
"[",
"'uri'",
"]",
")",
"es_ids",
"=",
"[",
"item",
".",
"meta",
".",
"id",
"for",
"item",
"in",
"se... | reads all the elasticssearch ids for an index | [
"reads",
"all",
"the",
"elasticssearch",
"ids",
"for",
"an",
"index"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L465-L471 |
249,495 | KnowledgeLinks/rdfframework | rdfframework/search/esloaders.py | EsRdfBulkLoader.validate_index | def validate_index(self, rdf_class):
"""
Will compare the triplestore and elasticsearch index to ensure that
that elasticsearch and triplestore items match. elasticsearch records
that are not in the triplestore will be deleteed
"""
es_ids = set(self.get_es_ids())
... | python | def validate_index(self, rdf_class):
"""
Will compare the triplestore and elasticsearch index to ensure that
that elasticsearch and triplestore items match. elasticsearch records
that are not in the triplestore will be deleteed
"""
es_ids = set(self.get_es_ids())
... | [
"def",
"validate_index",
"(",
"self",
",",
"rdf_class",
")",
":",
"es_ids",
"=",
"set",
"(",
"self",
".",
"get_es_ids",
"(",
")",
")",
"tstore_ids",
"=",
"set",
"(",
"[",
"item",
"[",
"1",
"]",
"for",
"item",
"in",
"self",
".",
"get_uri_list",
"(",
... | Will compare the triplestore and elasticsearch index to ensure that
that elasticsearch and triplestore items match. elasticsearch records
that are not in the triplestore will be deleteed | [
"Will",
"compare",
"the",
"triplestore",
"and",
"elasticsearch",
"index",
"to",
"ensure",
"that",
"that",
"elasticsearch",
"and",
"triplestore",
"items",
"match",
".",
"elasticsearch",
"records",
"that",
"are",
"not",
"in",
"the",
"triplestore",
"will",
"be",
"d... | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esloaders.py#L473-L487 |
249,496 | anti1869/sunhead | src/sunhead/metrics/factory.py | Metrics._disable_prometheus_process_collector | def _disable_prometheus_process_collector(self) -> None:
"""
There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which
its process_collector will fail.
See https://github.com/prometheus/client_python/issues/80
"""
logger.info("Remo... | python | def _disable_prometheus_process_collector(self) -> None:
"""
There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which
its process_collector will fail.
See https://github.com/prometheus/client_python/issues/80
"""
logger.info("Remo... | [
"def",
"_disable_prometheus_process_collector",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"\"Removing prometheus process collector\"",
")",
"try",
":",
"core",
".",
"REGISTRY",
".",
"unregister",
"(",
"PROCESS_COLLECTOR",
")",
"except",
"KeyEr... | There is a bug in SDC' Docker implementation and intolerable prometheus_client code, due to which
its process_collector will fail.
See https://github.com/prometheus/client_python/issues/80 | [
"There",
"is",
"a",
"bug",
"in",
"SDC",
"Docker",
"implementation",
"and",
"intolerable",
"prometheus_client",
"code",
"due",
"to",
"which",
"its",
"process_collector",
"will",
"fail",
"."
] | 5117ec797a38eb82d955241d20547d125efe80f3 | https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/metrics/factory.py#L63-L74 |
249,497 | rackerlabs/silverberg | silverberg/thrift_client.py | OnDemandThriftClient.connection | def connection(self, handshake=None):
"""
Connects if necessary, returns existing one if it can.
:param handshake: A function to be called with the client
to complete the handshake.
:returns: thrift connection, deferred if necessary
"""
if sel... | python | def connection(self, handshake=None):
"""
Connects if necessary, returns existing one if it can.
:param handshake: A function to be called with the client
to complete the handshake.
:returns: thrift connection, deferred if necessary
"""
if sel... | [
"def",
"connection",
"(",
"self",
",",
"handshake",
"=",
"None",
")",
":",
"if",
"self",
".",
"_state",
"==",
"_State",
".",
"CONNECTED",
":",
"return",
"succeed",
"(",
"self",
".",
"_current_client",
")",
"elif",
"self",
".",
"_state",
"==",
"_State",
... | Connects if necessary, returns existing one if it can.
:param handshake: A function to be called with the client
to complete the handshake.
:returns: thrift connection, deferred if necessary | [
"Connects",
"if",
"necessary",
"returns",
"existing",
"one",
"if",
"it",
"can",
"."
] | c6fae78923a019f1615e9516ab30fa105c72a542 | https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/thrift_client.py#L184-L204 |
249,498 | pavelsof/ipatok | ipatok/ipa.py | ensure_single_char | def ensure_single_char(func):
"""
Decorator that ensures that the first argument of the decorated function is
a single character, i.e. a string of length one.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not isinstance(args[0], str) or len(args[0]) != 1:
raise ValueError((
'This function s... | python | def ensure_single_char(func):
"""
Decorator that ensures that the first argument of the decorated function is
a single character, i.e. a string of length one.
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not isinstance(args[0], str) or len(args[0]) != 1:
raise ValueError((
'This function s... | [
"def",
"ensure_single_char",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"str",
")",
"... | Decorator that ensures that the first argument of the decorated function is
a single character, i.e. a string of length one. | [
"Decorator",
"that",
"ensures",
"that",
"the",
"first",
"argument",
"of",
"the",
"decorated",
"function",
"is",
"a",
"single",
"character",
"i",
".",
"e",
".",
"a",
"string",
"of",
"length",
"one",
"."
] | fde3c334b8573315fd1073f14341b71f50f7f006 | https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L79-L92 |
249,499 | pavelsof/ipatok | ipatok/ipa.py | is_vowel | def is_vowel(char):
"""
Check whether the character is a vowel letter.
"""
if is_letter(char, strict=True):
return char in chart.vowels
return False | python | def is_vowel(char):
"""
Check whether the character is a vowel letter.
"""
if is_letter(char, strict=True):
return char in chart.vowels
return False | [
"def",
"is_vowel",
"(",
"char",
")",
":",
"if",
"is_letter",
"(",
"char",
",",
"strict",
"=",
"True",
")",
":",
"return",
"char",
"in",
"chart",
".",
"vowels",
"return",
"False"
] | Check whether the character is a vowel letter. | [
"Check",
"whether",
"the",
"character",
"is",
"a",
"vowel",
"letter",
"."
] | fde3c334b8573315fd1073f14341b71f50f7f006 | https://github.com/pavelsof/ipatok/blob/fde3c334b8573315fd1073f14341b71f50f7f006/ipatok/ipa.py#L113-L120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.