nwo stringlengths 5 106 | sha stringlengths 40 40 | path stringlengths 4 174 | language stringclasses 1
value | identifier stringlengths 1 140 | parameters stringlengths 0 87.7k | argument_list stringclasses 1
value | return_statement stringlengths 0 426k | docstring stringlengths 0 64.3k | docstring_summary stringlengths 0 26.3k | docstring_tokens list | function stringlengths 18 4.83M | function_tokens list | url stringlengths 83 304 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
openedx/edx-platform | 68dd185a0ab45862a2a61e0f803d7e03d2be71b5 | lms/djangoapps/discussion/rest_api/pagination.py | python | DiscussionAPIPagination.get_previous_link | (self) | return previous_url | Returns absolute url of the previous page if there's a previous page available
otherwise returns None | Returns absolute url of the previous page if there's a previous page available
otherwise returns None | [
"Returns",
"absolute",
"url",
"of",
"the",
"previous",
"page",
"if",
"there",
"s",
"a",
"previous",
"page",
"available",
"otherwise",
"returns",
"None"
] | def get_previous_link(self):
"""
Returns absolute url of the previous page if there's a previous page available
otherwise returns None
"""
previous_url = None
if self.page.has_previous():
previous_url = replace_query_param(self.base_url, "page", self.page.prev... | [
"def",
"get_previous_link",
"(",
"self",
")",
":",
"previous_url",
"=",
"None",
"if",
"self",
".",
"page",
".",
"has_previous",
"(",
")",
":",
"previous_url",
"=",
"replace_query_param",
"(",
"self",
".",
"base_url",
",",
"\"page\"",
",",
"self",
".",
"pag... | https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/lms/djangoapps/discussion/rest_api/pagination.py#L78-L86 | |
Amulet-Team/Amulet-Map-Editor | e99619ba6aab855173b9f7c203455944ab97f89a | amulet_map_editor/programs/edit/api/ui/tool_manager.py | python | ToolManagerSizer.disable | (self) | Disable the active tool. | Disable the active tool. | [
"Disable",
"the",
"active",
"tool",
"."
] | def disable(self):
"""Disable the active tool."""
if self._active_tool is not None:
self._active_tool.disable() | [
"def",
"disable",
"(",
"self",
")",
":",
"if",
"self",
".",
"_active_tool",
"is",
"not",
"None",
":",
"self",
".",
"_active_tool",
".",
"disable",
"(",
")"
] | https://github.com/Amulet-Team/Amulet-Map-Editor/blob/e99619ba6aab855173b9f7c203455944ab97f89a/amulet_map_editor/programs/edit/api/ui/tool_manager.py#L88-L91 | ||
Cog-Creators/Red-DiscordBot | b05933274a11fb097873ab0d1b246d37b06aa306 | redbot/core/commands/commands.py | python | Command.error | (self, coro) | return super().error(coro) | A decorator that registers a coroutine as a local error handler.
A local error handler is an :func:`.on_command_error` event limited to
a single command.
The on_command_error event is still dispatched
for commands with a dedicated error handler.
Red's global error handler will... | A decorator that registers a coroutine as a local error handler. | [
"A",
"decorator",
"that",
"registers",
"a",
"coroutine",
"as",
"a",
"local",
"error",
"handler",
"."
] | def error(self, coro):
"""
A decorator that registers a coroutine as a local error handler.
A local error handler is an :func:`.on_command_error` event limited to
a single command.
The on_command_error event is still dispatched
for commands with a dedicated error handle... | [
"def",
"error",
"(",
"self",
",",
"coro",
")",
":",
"return",
"super",
"(",
")",
".",
"error",
"(",
"coro",
")"
] | https://github.com/Cog-Creators/Red-DiscordBot/blob/b05933274a11fb097873ab0d1b246d37b06aa306/redbot/core/commands/commands.py#L639-L680 | |
topydo/topydo | 57d7577c987515d4b49d5500f666da29080ca3c2 | topydo/lib/TodoListBase.py | python | TodoListBase.replace | (self, p_todos) | Replaces whole todolist with todo objects supplied as p_todos. | Replaces whole todolist with todo objects supplied as p_todos. | [
"Replaces",
"whole",
"todolist",
"with",
"todo",
"objects",
"supplied",
"as",
"p_todos",
"."
] | def replace(self, p_todos):
""" Replaces whole todolist with todo objects supplied as p_todos. """
self.erase()
self.add_todos(p_todos)
self.dirty = True | [
"def",
"replace",
"(",
"self",
",",
"p_todos",
")",
":",
"self",
".",
"erase",
"(",
")",
"self",
".",
"add_todos",
"(",
"p_todos",
")",
"self",
".",
"dirty",
"=",
"True"
] | https://github.com/topydo/topydo/blob/57d7577c987515d4b49d5500f666da29080ca3c2/topydo/lib/TodoListBase.py#L190-L194 | ||
misterch0c/shadowbroker | e3a069bea47a2c1009697941ac214adc6f90aa8d | windows/Resources/Python/Core/Lib/lib-tk/Tkinter.py | python | Canvas.scan_dragto | (self, x, y, gain=10) | Adjust the view of the canvas to GAIN times the
difference between X and Y and the coordinates given in
scan_mark. | Adjust the view of the canvas to GAIN times the
difference between X and Y and the coordinates given in
scan_mark. | [
"Adjust",
"the",
"view",
"of",
"the",
"canvas",
"to",
"GAIN",
"times",
"the",
"difference",
"between",
"X",
"and",
"Y",
"and",
"the",
"coordinates",
"given",
"in",
"scan_mark",
"."
] | def scan_dragto(self, x, y, gain=10):
"""Adjust the view of the canvas to GAIN times the
difference between X and Y and the coordinates given in
scan_mark."""
self.tk.call(self._w, 'scan', 'dragto', x, y, gain) | [
"def",
"scan_dragto",
"(",
"self",
",",
"x",
",",
"y",
",",
"gain",
"=",
"10",
")",
":",
"self",
".",
"tk",
".",
"call",
"(",
"self",
".",
"_w",
",",
"'scan'",
",",
"'dragto'",
",",
"x",
",",
"y",
",",
"gain",
")"
] | https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/lib-tk/Tkinter.py#L2576-L2580 | ||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/python/lib/python2.7/site-packages/psutil-0.6.1-py2.7-linux-x86_64.egg/psutil/_psosx.py | python | Process.get_process_threads | (self) | return retlist | Return the number of threads belonging to the process. | Return the number of threads belonging to the process. | [
"Return",
"the",
"number",
"of",
"threads",
"belonging",
"to",
"the",
"process",
"."
] | def get_process_threads(self):
"""Return the number of threads belonging to the process."""
rawlist = _psutil_osx.get_process_threads(self.pid)
retlist = []
for thread_id, utime, stime in rawlist:
ntuple = nt_thread(thread_id, utime, stime)
retlist.append(ntuple)
... | [
"def",
"get_process_threads",
"(",
"self",
")",
":",
"rawlist",
"=",
"_psutil_osx",
".",
"get_process_threads",
"(",
"self",
".",
"pid",
")",
"retlist",
"=",
"[",
"]",
"for",
"thread_id",
",",
"utime",
",",
"stime",
"in",
"rawlist",
":",
"ntuple",
"=",
"... | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/psutil-0.6.1-py2.7-linux-x86_64.egg/psutil/_psosx.py#L277-L284 | |
ayoolaolafenwa/PixelLib | ae56003c416a98780141a1170c9d888fe9a31317 | pixellib/torchbackend/instance/engine/hooks.py | python | IterationTimer.__init__ | (self, warmup_iter=3) | Args:
warmup_iter (int): the number of iterations at the beginning to exclude
from timing. | Args:
warmup_iter (int): the number of iterations at the beginning to exclude
from timing. | [
"Args",
":",
"warmup_iter",
"(",
"int",
")",
":",
"the",
"number",
"of",
"iterations",
"at",
"the",
"beginning",
"to",
"exclude",
"from",
"timing",
"."
] | def __init__(self, warmup_iter=3):
"""
Args:
warmup_iter (int): the number of iterations at the beginning to exclude
from timing.
"""
self._warmup_iter = warmup_iter
self._step_timer = Timer()
self._start_time = time.perf_counter()
self... | [
"def",
"__init__",
"(",
"self",
",",
"warmup_iter",
"=",
"3",
")",
":",
"self",
".",
"_warmup_iter",
"=",
"warmup_iter",
"self",
".",
"_step_timer",
"=",
"Timer",
"(",
")",
"self",
".",
"_start_time",
"=",
"time",
".",
"perf_counter",
"(",
")",
"self",
... | https://github.com/ayoolaolafenwa/PixelLib/blob/ae56003c416a98780141a1170c9d888fe9a31317/pixellib/torchbackend/instance/engine/hooks.py#L90-L99 | ||
toxygen-project/toxygen | 0a54012cf5ee72434b923bcde7d8f1a4e575ce2f | toxygen/profile.py | python | Profile.update_filtration | (self) | Update list of contacts when 1 of friends change connection status | Update list of contacts when 1 of friends change connection status | [
"Update",
"list",
"of",
"contacts",
"when",
"1",
"of",
"friends",
"change",
"connection",
"status"
] | def update_filtration(self):
"""
Update list of contacts when 1 of friends change connection status
"""
self.filtration_and_sorting(self._sorting, self._filter_string) | [
"def",
"update_filtration",
"(",
"self",
")",
":",
"self",
".",
"filtration_and_sorting",
"(",
"self",
".",
"_sorting",
",",
"self",
".",
"_filter_string",
")"
] | https://github.com/toxygen-project/toxygen/blob/0a54012cf5ee72434b923bcde7d8f1a4e575ce2f/toxygen/profile.py#L174-L178 | ||
SteveDoyle2/pyNastran | eda651ac2d4883d95a34951f8a002ff94f642a1a | pyNastran/dev/bdf_vectorized/bdf.py | python | BDF._prepare_dmix | (self, class_obj, add_method, card_obj, comment='') | adds a DMIx | adds a DMIx | [
"adds",
"a",
"DMIx"
] | def _prepare_dmix(self, class_obj, add_method, card_obj, comment=''):
"""adds a DMIx"""
#elif card_name in ['DMI', 'DMIJ', 'DMIJI', 'DMIK']:
field2 = integer(card_obj, 2, 'flag')
if field2 == 0:
add_method(class_obj(card_obj, comment=comment))
else:
name =... | [
"def",
"_prepare_dmix",
"(",
"self",
",",
"class_obj",
",",
"add_method",
",",
"card_obj",
",",
"comment",
"=",
"''",
")",
":",
"#elif card_name in ['DMI', 'DMIJ', 'DMIJI', 'DMIK']:",
"field2",
"=",
"integer",
"(",
"card_obj",
",",
"2",
",",
"'flag'",
")",
"if",... | https://github.com/SteveDoyle2/pyNastran/blob/eda651ac2d4883d95a34951f8a002ff94f642a1a/pyNastran/dev/bdf_vectorized/bdf.py#L2092-L2100 | ||
MrH0wl/Cloudmare | 65e5bc9888f9d362ab2abfb103ea6c1e869d67aa | thirdparty/xlsxwriter/worksheet.py | python | Worksheet.write_row | (self, row, col, data, cell_format=None) | return 0 | Write a row of data starting from (row, col).
Args:
row: The cell row (zero indexed).
col: The cell column (zero indexed).
data: A list of tokens to be written with write().
format: An optional cell Format object.
Returns:
0: Success.... | Write a row of data starting from (row, col). | [
"Write",
"a",
"row",
"of",
"data",
"starting",
"from",
"(",
"row",
"col",
")",
"."
] | def write_row(self, row, col, data, cell_format=None):
"""
Write a row of data starting from (row, col).
Args:
row: The cell row (zero indexed).
col: The cell column (zero indexed).
data: A list of tokens to be written with write().
format... | [
"def",
"write_row",
"(",
"self",
",",
"row",
",",
"col",
",",
"data",
",",
"cell_format",
"=",
"None",
")",
":",
"for",
"token",
"in",
"data",
":",
"error",
"=",
"self",
".",
"_write",
"(",
"row",
",",
"col",
",",
"token",
",",
"cell_format",
")",
... | https://github.com/MrH0wl/Cloudmare/blob/65e5bc9888f9d362ab2abfb103ea6c1e869d67aa/thirdparty/xlsxwriter/worksheet.py#L1126-L1146 | |
AutodeskRoboticsLab/Mimic | 85447f0d346be66988303a6a054473d92f1ed6f4 | mimic/scripts/extern/pyqtgraph_0_11_0_dev0/pyqtgraph/graphicsItems/ViewBox/ViewBox.py | python | ViewBox.setXLink | (self, view) | Link this view's X axis to another view. (see LinkView) | Link this view's X axis to another view. (see LinkView) | [
"Link",
"this",
"view",
"s",
"X",
"axis",
"to",
"another",
"view",
".",
"(",
"see",
"LinkView",
")"
] | def setXLink(self, view):
"""Link this view's X axis to another view. (see LinkView)"""
self.linkView(self.XAxis, view) | [
"def",
"setXLink",
"(",
"self",
",",
"view",
")",
":",
"self",
".",
"linkView",
"(",
"self",
".",
"XAxis",
",",
"view",
")"
] | https://github.com/AutodeskRoboticsLab/Mimic/blob/85447f0d346be66988303a6a054473d92f1ed6f4/mimic/scripts/extern/pyqtgraph_0_11_0_dev0/pyqtgraph/graphicsItems/ViewBox/ViewBox.py#L860-L862 | ||
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/tia/v20180226/models.py | python | QueryLogsResponse.__init__ | (self) | r"""
:param Context: 日志查询上下文,用于加载更多日志
:type Context: str
:param Logs: 日志内容列表
:type Logs: list of Log
:param Listover: 是否已经返回所有符合条件的日志
:type Listover: bool
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | r"""
:param Context: 日志查询上下文,用于加载更多日志
:type Context: str
:param Logs: 日志内容列表
:type Logs: list of Log
:param Listover: 是否已经返回所有符合条件的日志
:type Listover: bool
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type RequestId: str | [
"r",
":",
"param",
"Context",
":",
"日志查询上下文,用于加载更多日志",
":",
"type",
"Context",
":",
"str",
":",
"param",
"Logs",
":",
"日志内容列表",
":",
"type",
"Logs",
":",
"list",
"of",
"Log",
":",
"param",
"Listover",
":",
"是否已经返回所有符合条件的日志",
":",
"type",
"Listover",
":",... | def __init__(self):
r"""
:param Context: 日志查询上下文,用于加载更多日志
:type Context: str
:param Logs: 日志内容列表
:type Logs: list of Log
:param Listover: 是否已经返回所有符合条件的日志
:type Listover: bool
:param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
:type Reques... | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"Context",
"=",
"None",
"self",
".",
"Logs",
"=",
"None",
"self",
".",
"Listover",
"=",
"None",
"self",
".",
"RequestId",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tia/v20180226/models.py#L874-L888 | ||
Netflix/metaflow | 25887ae77494f818d76bfa5f1560cf103cd15604 | metaflow/datastore/content_addressed_store.py | python | ContentAddressedStore.save_blobs | (self, blob_iter, raw=False, len_hint=0) | return results | Saves blobs of data to the datastore
The blobs of data are saved as is if raw is True. If raw is False, the
datastore may process the blobs and they should then only be loaded
using load_blob
NOTE: The idea here is that there are two modes to access the file once
it is saved to... | Saves blobs of data to the datastore | [
"Saves",
"blobs",
"of",
"data",
"to",
"the",
"datastore"
] | def save_blobs(self, blob_iter, raw=False, len_hint=0):
"""
Saves blobs of data to the datastore
The blobs of data are saved as is if raw is True. If raw is False, the
datastore may process the blobs and they should then only be loaded
using load_blob
NOTE: The idea her... | [
"def",
"save_blobs",
"(",
"self",
",",
"blob_iter",
",",
"raw",
"=",
"False",
",",
"len_hint",
"=",
"0",
")",
":",
"results",
"=",
"[",
"]",
"def",
"packing_iter",
"(",
")",
":",
"for",
"blob",
"in",
"blob_iter",
":",
"sha",
"=",
"sha1",
"(",
"blob... | https://github.com/Netflix/metaflow/blob/25887ae77494f818d76bfa5f1560cf103cd15604/metaflow/datastore/content_addressed_store.py#L41-L101 | |
caiiiac/Machine-Learning-with-Python | 1a26c4467da41ca4ebc3d5bd789ea942ef79422f | MachineLearning/venv/lib/python3.5/site-packages/sklearn/feature_extraction/image.py | python | reconstruct_from_patches_2d | (patches, image_size) | return img | Reconstruct the image from all of its patches.
Patches are assumed to overlap and the image is constructed by filling in
the patches from left to right, top to bottom, averaging the overlapping
regions.
Read more in the :ref:`User Guide <image_feature_extraction>`.
Parameters
----------
p... | Reconstruct the image from all of its patches. | [
"Reconstruct",
"the",
"image",
"from",
"all",
"of",
"its",
"patches",
"."
] | def reconstruct_from_patches_2d(patches, image_size):
"""Reconstruct the image from all of its patches.
Patches are assumed to overlap and the image is constructed by filling in
the patches from left to right, top to bottom, averaging the overlapping
regions.
Read more in the :ref:`User Guide <ima... | [
"def",
"reconstruct_from_patches_2d",
"(",
"patches",
",",
"image_size",
")",
":",
"i_h",
",",
"i_w",
"=",
"image_size",
"[",
":",
"2",
"]",
"p_h",
",",
"p_w",
"=",
"patches",
".",
"shape",
"[",
"1",
":",
"3",
"]",
"img",
"=",
"np",
".",
"zeros",
"... | https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/sklearn/feature_extraction/image.py#L393-L435 | |
Komodo/KomodoEdit | 61edab75dce2bdb03943b387b0608ea36f548e8e | contrib/ecdsa/ecdsa/numbertheory.py | python | gcd | ( *a ) | return a[0] | Greatest common divisor.
Usage: gcd( [ 2, 4, 6 ] )
or: gcd( 2, 4, 6 ) | Greatest common divisor. | [
"Greatest",
"common",
"divisor",
"."
] | def gcd( *a ):
"""Greatest common divisor.
Usage: gcd( [ 2, 4, 6 ] )
or: gcd( 2, 4, 6 )
"""
if len( a ) > 1: return reduce( gcd2, a )
if hasattr( a[0], "__iter__" ): return reduce( gcd2, a[0] )
return a[0] | [
"def",
"gcd",
"(",
"*",
"a",
")",
":",
"if",
"len",
"(",
"a",
")",
">",
"1",
":",
"return",
"reduce",
"(",
"gcd2",
",",
"a",
")",
"if",
"hasattr",
"(",
"a",
"[",
"0",
"]",
",",
"\"__iter__\"",
")",
":",
"return",
"reduce",
"(",
"gcd2",
",",
... | https://github.com/Komodo/KomodoEdit/blob/61edab75dce2bdb03943b387b0608ea36f548e8e/contrib/ecdsa/ecdsa/numbertheory.py#L214-L223 | |
emesene/emesene | 4548a4098310e21b16437bb36223a7f632a4f7bc | emesene/e3/xmpp/Session.py | python | Session.set_social_token | (self, raw_token) | store the social service token.
raw_token is the raw uri to be processed internally | store the social service token.
raw_token is the raw uri to be processed internally | [
"store",
"the",
"social",
"service",
"token",
".",
"raw_token",
"is",
"the",
"raw",
"uri",
"to",
"be",
"processed",
"internally"
] | def set_social_token(self, raw_token):
'''store the social service token.
raw_token is the raw uri to be processed internally'''
def get_token(token_url):
'''strips the access token from an url'''
if token_url is None:
return token_url
if toke... | [
"def",
"set_social_token",
"(",
"self",
",",
"raw_token",
")",
":",
"def",
"get_token",
"(",
"token_url",
")",
":",
"'''strips the access token from an url'''",
"if",
"token_url",
"is",
"None",
":",
"return",
"token_url",
"if",
"token_url",
".",
"find",
"(",
"\"... | https://github.com/emesene/emesene/blob/4548a4098310e21b16437bb36223a7f632a4f7bc/emesene/e3/xmpp/Session.py#L170-L189 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/min/platform.py | python | uname_result.__reduce__ | (self) | return uname_result, tuple(self)[:len(self._fields)] | [] | def __reduce__(self):
return uname_result, tuple(self)[:len(self._fields)] | [
"def",
"__reduce__",
"(",
"self",
")",
":",
"return",
"uname_result",
",",
"tuple",
"(",
"self",
")",
"[",
":",
"len",
"(",
"self",
".",
"_fields",
")",
"]"
] | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/min/platform.py#L805-L806 | |||
galaxyproject/galaxy | 4c03520f05062e0f4a1b3655dc0b7452fda69943 | lib/galaxy/managers/collections.py | python | DatasetCollectionManager.copy | (self, trans, parent, source, encoded_source_id, copy_elements=False, dataset_instance_attributes=None) | return new_hdca | PRECONDITION: security checks on ability to add to parent occurred
during load. | PRECONDITION: security checks on ability to add to parent occurred
during load. | [
"PRECONDITION",
":",
"security",
"checks",
"on",
"ability",
"to",
"add",
"to",
"parent",
"occurred",
"during",
"load",
"."
] | def copy(self, trans, parent, source, encoded_source_id, copy_elements=False, dataset_instance_attributes=None):
"""
PRECONDITION: security checks on ability to add to parent occurred
during load.
"""
assert source == "hdca" # for now
source_hdca = self.__get_history_col... | [
"def",
"copy",
"(",
"self",
",",
"trans",
",",
"parent",
",",
"source",
",",
"encoded_source_id",
",",
"copy_elements",
"=",
"False",
",",
"dataset_instance_attributes",
"=",
"None",
")",
":",
"assert",
"source",
"==",
"\"hdca\"",
"# for now",
"source_hdca",
"... | https://github.com/galaxyproject/galaxy/blob/4c03520f05062e0f4a1b3655dc0b7452fda69943/lib/galaxy/managers/collections.py#L339-L356 | |
uber-research/UPSNet | aa8434e5a721ed217849607815304f68dfd7720a | upsnet/models/resnet.py | python | get_params | (model, prefixs, suffixes, exclude=None) | This generator returns all the parameters of the net except for
the last classification layer. Note that for each batchnorm layer,
requires_grad is set to False in deeplab_resnet.py, therefore this function does not return
any batchnorm parameter | This generator returns all the parameters of the net except for
the last classification layer. Note that for each batchnorm layer,
requires_grad is set to False in deeplab_resnet.py, therefore this function does not return
any batchnorm parameter | [
"This",
"generator",
"returns",
"all",
"the",
"parameters",
"of",
"the",
"net",
"except",
"for",
"the",
"last",
"classification",
"layer",
".",
"Note",
"that",
"for",
"each",
"batchnorm",
"layer",
"requires_grad",
"is",
"set",
"to",
"False",
"in",
"deeplab_res... | def get_params(model, prefixs, suffixes, exclude=None):
"""
This generator returns all the parameters of the net except for
the last classification layer. Note that for each batchnorm layer,
requires_grad is set to False in deeplab_resnet.py, therefore this function does not return
any batchnorm par... | [
"def",
"get_params",
"(",
"model",
",",
"prefixs",
",",
"suffixes",
",",
"exclude",
"=",
"None",
")",
":",
"for",
"name",
",",
"module",
"in",
"model",
".",
"named_modules",
"(",
")",
":",
"for",
"prefix",
"in",
"prefixs",
":",
"if",
"name",
"==",
"p... | https://github.com/uber-research/UPSNet/blob/aa8434e5a721ed217849607815304f68dfd7720a/upsnet/models/resnet.py#L31-L51 | ||
FrancescoCeruti/linux-show-player | 39aba4674d9a2caa365687906640d192e2b47e0f | lisp/core/fade_functions.py | python | ntime | (time, begin, duration) | return (time - begin) / (duration - begin) | Return normalized time. | Return normalized time. | [
"Return",
"normalized",
"time",
"."
] | def ntime(time, begin, duration):
"""Return normalized time."""
return (time - begin) / (duration - begin) | [
"def",
"ntime",
"(",
"time",
",",
"begin",
",",
"duration",
")",
":",
"return",
"(",
"time",
"-",
"begin",
")",
"/",
"(",
"duration",
"-",
"begin",
")"
] | https://github.com/FrancescoCeruti/linux-show-player/blob/39aba4674d9a2caa365687906640d192e2b47e0f/lisp/core/fade_functions.py#L62-L64 | |
google-research/tensor2robot | 484a15ee63df412f1f7e53861c936630ad31124b | meta_learning/meta_tfdata.py | python | multi_batch_apply | (f, num_batch_dims, *args, **kwargs) | return expand_batch_dims(outputs, batch_sizes) | Vectorized application of f on tensors with multiple batch dims.
Batch dims must be the same for every tensor in args/kwargs.
Args:
f: Callable, needs only expect one batch dim in input tensors.
num_batch_dims: Integer, the number of batch dims.
*args: Args passed into f (tensors will be reshaped to 1... | Vectorized application of f on tensors with multiple batch dims. | [
"Vectorized",
"application",
"of",
"f",
"on",
"tensors",
"with",
"multiple",
"batch",
"dims",
"."
] | def multi_batch_apply(f, num_batch_dims, *args, **kwargs):
"""Vectorized application of f on tensors with multiple batch dims.
Batch dims must be the same for every tensor in args/kwargs.
Args:
f: Callable, needs only expect one batch dim in input tensors.
num_batch_dims: Integer, the number of batch di... | [
"def",
"multi_batch_apply",
"(",
"f",
",",
"num_batch_dims",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"flattened_inputs",
"=",
"nest",
".",
"flatten",
"(",
"args",
")",
"+",
"nest",
".",
"flatten",
"(",
"kwargs",
")",
"tensor_inputs",
"=",
... | https://github.com/google-research/tensor2robot/blob/484a15ee63df412f1f7e53861c936630ad31124b/meta_learning/meta_tfdata.py#L261-L281 | |
imatge-upc/skiprnn-2017-telecombcn | 63f93a539a3f2c7a713089fdd2c38bb7b0c581ca | src/rnn_cells/basic_rnn_cells.py | python | BasicGRUCell.__init__ | (self, num_units, activation=tf.tanh, layer_norm=False) | Initialize the basic GRU cell
:param num_units: int, the number of units in the LSTM cell
:param activation: activation function of the inner states
:param layer_norm: bool, whether to use layer normalization | Initialize the basic GRU cell
:param num_units: int, the number of units in the LSTM cell
:param activation: activation function of the inner states
:param layer_norm: bool, whether to use layer normalization | [
"Initialize",
"the",
"basic",
"GRU",
"cell",
":",
"param",
"num_units",
":",
"int",
"the",
"number",
"of",
"units",
"in",
"the",
"LSTM",
"cell",
":",
"param",
"activation",
":",
"activation",
"function",
"of",
"the",
"inner",
"states",
":",
"param",
"layer... | def __init__(self, num_units, activation=tf.tanh, layer_norm=False):
"""
Initialize the basic GRU cell
:param num_units: int, the number of units in the LSTM cell
:param activation: activation function of the inner states
:param layer_norm: bool, whether to use layer normalizatio... | [
"def",
"__init__",
"(",
"self",
",",
"num_units",
",",
"activation",
"=",
"tf",
".",
"tanh",
",",
"layer_norm",
"=",
"False",
")",
":",
"self",
".",
"_num_units",
"=",
"num_units",
"self",
".",
"_activation",
"=",
"activation",
"self",
".",
"_layer_norm",
... | https://github.com/imatge-upc/skiprnn-2017-telecombcn/blob/63f93a539a3f2c7a713089fdd2c38bb7b0c581ca/src/rnn_cells/basic_rnn_cells.py#L93-L102 | ||
rembo10/headphones | b3199605be1ebc83a7a8feab6b1e99b64014187c | headphones/api.py | python | Api._getAlbumArt | (self, **kwargs) | [] | def _getAlbumArt(self, **kwargs):
if 'id' not in kwargs:
self.data = 'Missing parameter: id'
return
else:
self.id = kwargs['id']
self.data = cache.getArtwork(AlbumID=self.id) | [
"def",
"_getAlbumArt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'id'",
"not",
"in",
"kwargs",
":",
"self",
".",
"data",
"=",
"'Missing parameter: id'",
"return",
"else",
":",
"self",
".",
"id",
"=",
"kwargs",
"[",
"'id'",
"]",
"self",
"... | https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/headphones/api.py#L380-L388 | ||||
theotherp/nzbhydra | 4b03d7f769384b97dfc60dade4806c0fc987514e | libs/cmd.py | python | Cmd.complete | (self, text, state) | Return the next possible completion for 'text'.
If a command has not been entered, then complete against command list.
Otherwise try to call complete_<command> to get list of completions. | Return the next possible completion for 'text'. | [
"Return",
"the",
"next",
"possible",
"completion",
"for",
"text",
"."
] | def complete(self, text, state):
"""Return the next possible completion for 'text'.
If a command has not been entered, then complete against command list.
Otherwise try to call complete_<command> to get list of completions.
"""
if state == 0:
import readline
... | [
"def",
"complete",
"(",
"self",
",",
"text",
",",
"state",
")",
":",
"if",
"state",
"==",
"0",
":",
"import",
"readline",
"origline",
"=",
"readline",
".",
"get_line_buffer",
"(",
")",
"line",
"=",
"origline",
".",
"lstrip",
"(",
")",
"stripped",
"=",
... | https://github.com/theotherp/nzbhydra/blob/4b03d7f769384b97dfc60dade4806c0fc987514e/libs/cmd.py#L255-L283 | ||
LeapBeyond/scrubadub | ab199f0b3cc3ca11f646aabb05ebe124d2757ea5 | scrubadub/scrubbers.py | python | Scrubber.remove_detector | (self, detector: Union[Detector, Type[Detector], str]) | Remove a ``Detector`` from a Scrubber
You can remove a detector from a ``Scrubber`` by passing one of three objects to this function:
1. the uninitalised class to this function, which removes the initalised detector of the same name.
2. an instance of a ``Detector`` class, which remove... | Remove a ``Detector`` from a Scrubber | [
"Remove",
"a",
"Detector",
"from",
"a",
"Scrubber"
] | def remove_detector(self, detector: Union[Detector, Type[Detector], str]):
"""Remove a ``Detector`` from a Scrubber
You can remove a detector from a ``Scrubber`` by passing one of three objects to this function:
1. the uninitalised class to this function, which removes the initalised detec... | [
"def",
"remove_detector",
"(",
"self",
",",
"detector",
":",
"Union",
"[",
"Detector",
",",
"Type",
"[",
"Detector",
"]",
",",
"str",
"]",
")",
":",
"if",
"isinstance",
"(",
"detector",
",",
"type",
")",
":",
"self",
".",
"_detectors",
".",
"pop",
"(... | https://github.com/LeapBeyond/scrubadub/blob/ab199f0b3cc3ca11f646aabb05ebe124d2757ea5/scrubadub/scrubbers.py#L107-L133 | ||
metabrainz/picard | 535bf8c7d9363ffc7abb3f69418ec11823c38118 | picard/ui/options/releases.py | python | TipSlider.round_value | (self, value) | [] | def round_value(self, value):
step = max(1, int(self._step))
if step > 1:
super().setValue(int(value / step) * step) | [
"def",
"round_value",
"(",
"self",
",",
"value",
")",
":",
"step",
"=",
"max",
"(",
"1",
",",
"int",
"(",
"self",
".",
"_step",
")",
")",
"if",
"step",
">",
"1",
":",
"super",
"(",
")",
".",
"setValue",
"(",
"int",
"(",
"value",
"/",
"step",
... | https://github.com/metabrainz/picard/blob/535bf8c7d9363ffc7abb3f69418ec11823c38118/picard/ui/options/releases.py#L103-L106 | ||||
BlackLight/platypush | a6b552504e2ac327c94f3a28b607061b6b60cf36 | platypush/plugins/esp/__init__.py | python | disable_irq | (self, **kwargs) | return self.execute(code, **kwargs).output | Disable interrupt requests.
:param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`. | Disable interrupt requests. | [
"Disable",
"interrupt",
"requests",
"."
] | def disable_irq(self, **kwargs):
"""
Disable interrupt requests.
:param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`.
"""
code = '''
import machine
machine.disable_irq()
'''
return self.execute(code, **kwargs).output | [
"def",
"disable_irq",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"code",
"=",
"'''\nimport machine\nmachine.disable_irq()\n'''",
"return",
"self",
".",
"execute",
"(",
"code",
",",
"*",
"*",
"kwargs",
")",
".",
"output"
] | https://github.com/BlackLight/platypush/blob/a6b552504e2ac327c94f3a28b607061b6b60cf36/platypush/plugins/esp/__init__.py#L917-L927 | |
1040003585/WebScrapingWithPython | a770fa5b03894076c8c9539b1ffff34424ffc016 | portia_examle/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.py | python | ExFileObject.__iter__ | (self) | Get an iterator over the file's lines. | Get an iterator over the file's lines. | [
"Get",
"an",
"iterator",
"over",
"the",
"file",
"s",
"lines",
"."
] | def __iter__(self):
"""Get an iterator over the file's lines.
"""
while True:
line = self.readline()
if not line:
break
yield line | [
"def",
"__iter__",
"(",
"self",
")",
":",
"while",
"True",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"break",
"yield",
"line"
] | https://github.com/1040003585/WebScrapingWithPython/blob/a770fa5b03894076c8c9539b1ffff34424ffc016/portia_examle/lib/python2.7/site-packages/pip/_vendor/distlib/_backport/tarfile.py#L910-L917 | ||
bruderstein/PythonScript | df9f7071ddf3a079e3a301b9b53a6dc78cf1208f | PythonLib/min/turtle.py | python | TurtleScreen.onclick | (self, fun, btn=1, add=None) | Bind fun to mouse-click event on canvas.
Arguments:
fun -- a function with two arguments, the coordinates of the
clicked point on the canvas.
btn -- the number of the mouse-button, defaults to 1
Example (for a TurtleScreen instance named screen)
>>> screen.oncli... | Bind fun to mouse-click event on canvas. | [
"Bind",
"fun",
"to",
"mouse",
"-",
"click",
"event",
"on",
"canvas",
"."
] | def onclick(self, fun, btn=1, add=None):
"""Bind fun to mouse-click event on canvas.
Arguments:
fun -- a function with two arguments, the coordinates of the
clicked point on the canvas.
btn -- the number of the mouse-button, defaults to 1
Example (for a TurtleScr... | [
"def",
"onclick",
"(",
"self",
",",
"fun",
",",
"btn",
"=",
"1",
",",
"add",
"=",
"None",
")",
":",
"self",
".",
"_onscreenclick",
"(",
"fun",
",",
"btn",
",",
"add",
")"
] | https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/min/turtle.py#L1350-L1365 | ||
bayespy/bayespy | 0e6e6130c888a4295cc9421d61d4ad27b2960ebb | bayespy/inference/vmp/nodes/gp.py | python | gp_cov_delta | (N) | return np.identity(N) | [] | def gp_cov_delta(N):
return np.identity(N) | [
"def",
"gp_cov_delta",
"(",
"N",
")",
":",
"return",
"np",
".",
"identity",
"(",
"N",
")"
] | https://github.com/bayespy/bayespy/blob/0e6e6130c888a4295cc9421d61d4ad27b2960ebb/bayespy/inference/vmp/nodes/gp.py#L156-L157 | |||
mozillazg/pypy | 2ff5cd960c075c991389f842c6d59e71cf0cb7d0 | lib-python/2.7/dummy_thread.py | python | allocate_lock | () | return LockType() | Dummy implementation of thread.allocate_lock(). | Dummy implementation of thread.allocate_lock(). | [
"Dummy",
"implementation",
"of",
"thread",
".",
"allocate_lock",
"()",
"."
] | def allocate_lock():
"""Dummy implementation of thread.allocate_lock()."""
return LockType() | [
"def",
"allocate_lock",
"(",
")",
":",
"return",
"LockType",
"(",
")"
] | https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/dummy_thread.py#L71-L73 | |
entropy1337/infernal-twin | 10995cd03312e39a48ade0f114ebb0ae3a711bb8 | Modules/build/reportlab/build/lib.linux-i686-2.7/reportlab/pdfgen/pdfgeom.py | python | bezierArc | (x1,y1, x2,y2, startAng=0, extent=90) | return pointList | bezierArc(x1,y1, x2,y2, startAng=0, extent=90) --> List of Bezier
curve control points.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. The
coordinate system has coordinates that increase to the right and down.
Angles, measured in degress, start with 0 to the right (the positive X
axis) and increase... | bezierArc(x1,y1, x2,y2, startAng=0, extent=90) --> List of Bezier
curve control points. | [
"bezierArc",
"(",
"x1",
"y1",
"x2",
"y2",
"startAng",
"=",
"0",
"extent",
"=",
"90",
")",
"--",
">",
"List",
"of",
"Bezier",
"curve",
"control",
"points",
"."
] | def bezierArc(x1,y1, x2,y2, startAng=0, extent=90):
"""bezierArc(x1,y1, x2,y2, startAng=0, extent=90) --> List of Bezier
curve control points.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. The
coordinate system has coordinates that increase to the right and down.
Angles, measured in degress, s... | [
"def",
"bezierArc",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"startAng",
"=",
"0",
",",
"extent",
"=",
"90",
")",
":",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"min",
"(",
"x1",
",",
"x2",
")",
",",
"max",
"(",
"y1",
",",
"y2",... | https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/reportlab/build/lib.linux-i686-2.7/reportlab/pdfgen/pdfgeom.py#L15-L77 | |
mozilla/zamboni | 14b1a44658e47b9f048962fa52dbf00a3beaaf30 | mkt/site/models.py | python | use_master | () | Within this context, all queries go to the master. | Within this context, all queries go to the master. | [
"Within",
"this",
"context",
"all",
"queries",
"go",
"to",
"the",
"master",
"."
] | def use_master():
"""Within this context, all queries go to the master."""
old = getattr(multidb.pinning._locals, 'pinned', False)
multidb.pinning.pin_this_thread()
try:
yield
finally:
multidb.pinning._locals.pinned = old | [
"def",
"use_master",
"(",
")",
":",
"old",
"=",
"getattr",
"(",
"multidb",
".",
"pinning",
".",
"_locals",
",",
"'pinned'",
",",
"False",
")",
"multidb",
".",
"pinning",
".",
"pin_this_thread",
"(",
")",
"try",
":",
"yield",
"finally",
":",
"multidb",
... | https://github.com/mozilla/zamboni/blob/14b1a44658e47b9f048962fa52dbf00a3beaaf30/mkt/site/models.py#L62-L69 | ||
stepjam/RLBench | 3aa9bb3ad534d8fcdeb93d3f5ff1d161ce5c8fe6 | rlbench/backend/task.py | python | Task.decorate_observation | (self, observation: Observation) | return observation | Can be used for tasks that want to modify the observations.
Usually not used. Perhpas cabn be used to model
:param observation: The Observation for this time step.
:return: The modified Observation. | Can be used for tasks that want to modify the observations. | [
"Can",
"be",
"used",
"for",
"tasks",
"that",
"want",
"to",
"modify",
"the",
"observations",
"."
] | def decorate_observation(self, observation: Observation) -> Observation:
"""Can be used for tasks that want to modify the observations.
Usually not used. Perhpas cabn be used to model
:param observation: The Observation for this time step.
:return: The modified Observation.
"""... | [
"def",
"decorate_observation",
"(",
"self",
",",
"observation",
":",
"Observation",
")",
"->",
"Observation",
":",
"return",
"observation"
] | https://github.com/stepjam/RLBench/blob/3aa9bb3ad534d8fcdeb93d3f5ff1d161ce5c8fe6/rlbench/backend/task.py#L150-L158 | |
MycroftAI/mycroft-core | 3d963cee402e232174850f36918313e87313fb13 | mycroft/util/file_utils.py | python | _get_cache_entries | (directory) | return ((stat[ST_MTIME], stat[ST_SIZE], path)
for stat, path in entries if S_ISREG(stat[ST_MODE])) | Get information tuple for all regular files in directory.
Args:
directory (str): path to directory to check
Returns:
(tuple) (modification time, size, filepath) | Get information tuple for all regular files in directory. | [
"Get",
"information",
"tuple",
"for",
"all",
"regular",
"files",
"in",
"directory",
"."
] | def _get_cache_entries(directory):
"""Get information tuple for all regular files in directory.
Args:
directory (str): path to directory to check
Returns:
(tuple) (modification time, size, filepath)
"""
entries = (os.path.join(directory, fn) for fn in os.listdir(directory))
ent... | [
"def",
"_get_cache_entries",
"(",
"directory",
")",
":",
"entries",
"=",
"(",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"fn",
")",
"for",
"fn",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
")",
"entries",
"=",
"(",
"(",
"os",
"."... | https://github.com/MycroftAI/mycroft-core/blob/3d963cee402e232174850f36918313e87313fb13/mycroft/util/file_utils.py#L147-L161 | |
sassoftware/python-dlpy | 6082b1eeaab7406cce22715a35a1f4308943d522 | dlpy/network.py | python | extract_rpn_layer | (layer_table) | return layer | Extract layer configuration from a Region proposal layer table
Parameters
----------
layer_table : table
Specifies the selection of table containing the information
for the layer.
Returns
-------
:class:`dict`
Options that can be passed to layer definition | Extract layer configuration from a Region proposal layer table | [
"Extract",
"layer",
"configuration",
"from",
"a",
"Region",
"proposal",
"layer",
"table"
] | def extract_rpn_layer(layer_table):
'''
Extract layer configuration from a Region proposal layer table
Parameters
----------
layer_table : table
Specifies the selection of table containing the information
for the layer.
Returns
-------
:class:`dict`
Options that... | [
"def",
"extract_rpn_layer",
"(",
"layer_table",
")",
":",
"num_keys",
"=",
"[",
"'base_anchor_size'",
",",
"'max_label_per_image'",
",",
"'roi_train_sample_num'",
",",
"'do_RPN_only'",
",",
"'proposed_roi_num_train'",
",",
"'proposed_roi_num_score'",
",",
"'anchor_num_to_sa... | https://github.com/sassoftware/python-dlpy/blob/6082b1eeaab7406cce22715a35a1f4308943d522/dlpy/network.py#L2877-L2928 | |
frappe/erpnext | 9d36e30ef7043b391b5ed2523b8288bf46c45d18 | erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py | python | get_columns | () | return columns | return columns | return columns | [
"return",
"columns"
] | def get_columns():
"""return columns"""
columns = [
_("Item") + ":Link/Item:150",
_("Description") + "::300",
_("BOM Qty") + ":Float:160",
_("BOM UoM") + "::160",
_("Required Qty") + ":Float:120",
_("In Stock Qty") + ":Float:120",
_("Enough Parts to Build") + ":Float:200",
]
return columns | [
"def",
"get_columns",
"(",
")",
":",
"columns",
"=",
"[",
"_",
"(",
"\"Item\"",
")",
"+",
"\":Link/Item:150\"",
",",
"_",
"(",
"\"Description\"",
")",
"+",
"\"::300\"",
",",
"_",
"(",
"\"BOM Qty\"",
")",
"+",
"\":Float:160\"",
",",
"_",
"(",
"\"BOM UoM\"... | https://github.com/frappe/erpnext/blob/9d36e30ef7043b391b5ed2523b8288bf46c45d18/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py#L18-L30 | |
CLUEbenchmark/CLUEPretrainedModels | b384fd41665a8261f9c689c940cf750b3bc21fce | baselines/models/bert/extract_features.py | python | _truncate_seq_pair | (tokens_a, tokens_b, max_length) | Truncates a sequence pair in place to the maximum length. | Truncates a sequence pair in place to the maximum length. | [
"Truncates",
"a",
"sequence",
"pair",
"in",
"place",
"to",
"the",
"maximum",
"length",
"."
] | def _truncate_seq_pair(tokens_a, tokens_b, max_length):
"""Truncates a sequence pair in place to the maximum length."""
# This is a simple heuristic which will always truncate the longer sequence
# one token at a time. This makes more sense than truncating an equal percent
# of tokens from each, since if one s... | [
"def",
"_truncate_seq_pair",
"(",
"tokens_a",
",",
"tokens_b",
",",
"max_length",
")",
":",
"# This is a simple heuristic which will always truncate the longer sequence",
"# one token at a time. This makes more sense than truncating an equal percent",
"# of tokens from each, since if one seq... | https://github.com/CLUEbenchmark/CLUEPretrainedModels/blob/b384fd41665a8261f9c689c940cf750b3bc21fce/baselines/models/bert/extract_features.py#L302-L316 | ||
pgq/skytools-legacy | 8b7e6c118572a605d28b7a3403c96aeecfd0d272 | python/skytools/tnetstrings.py | python | dump | (data) | [] | def dump(data):
if type(data) is long or type(data) is int:
out = str(data)
return '%d:%s#' % (len(out), out)
elif type(data) is float:
out = '%f' % data
return '%d:%s^' % (len(out), out)
elif type(data) is str:
return '%d:' % len(data) + data + ','
elif type(dat... | [
"def",
"dump",
"(",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"is",
"long",
"or",
"type",
"(",
"data",
")",
"is",
"int",
":",
"out",
"=",
"str",
"(",
"data",
")",
"return",
"'%d:%s#'",
"%",
"(",
"len",
"(",
"out",
")",
",",
"out",
")"... | https://github.com/pgq/skytools-legacy/blob/8b7e6c118572a605d28b7a3403c96aeecfd0d272/python/skytools/tnetstrings.py#L4-L23 | ||||
triaquae/triaquae | bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9 | TriAquae/models/Ubuntu_13/paramiko/transport.py | python | Transport.auth_password | (self, username, password, event=None, fallback=True) | return None | Authenticate to the server using a password. The username and password
are sent over an encrypted link.
If an C{event} is passed in, this method will return immediately, and
the event will be triggered once authentication succeeds or fails. On
success, L{is_authenticated} will return ... | Authenticate to the server using a password. The username and password
are sent over an encrypted link. | [
"Authenticate",
"to",
"the",
"server",
"using",
"a",
"password",
".",
"The",
"username",
"and",
"password",
"are",
"sent",
"over",
"an",
"encrypted",
"link",
"."
] | def auth_password(self, username, password, event=None, fallback=True):
"""
Authenticate to the server using a password. The username and password
are sent over an encrypted link.
If an C{event} is passed in, this method will return immediately, and
the event will be triggered ... | [
"def",
"auth_password",
"(",
"self",
",",
"username",
",",
"password",
",",
"event",
"=",
"None",
",",
"fallback",
"=",
"True",
")",
":",
"if",
"(",
"not",
"self",
".",
"active",
")",
"or",
"(",
"not",
"self",
".",
"initial_kex_done",
")",
":",
"# we... | https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_13/paramiko/transport.py#L1122-L1203 | |
brython-dev/brython | 9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3 | www/src/Lib/email/utils.py | python | getaddresses | (fieldvalues) | return a.addresslist | Return a list of (REALNAME, EMAIL) for each fieldvalue. | Return a list of (REALNAME, EMAIL) for each fieldvalue. | [
"Return",
"a",
"list",
"of",
"(",
"REALNAME",
"EMAIL",
")",
"for",
"each",
"fieldvalue",
"."
] | def getaddresses(fieldvalues):
"""Return a list of (REALNAME, EMAIL) for each fieldvalue."""
all = COMMASPACE.join(str(v) for v in fieldvalues)
a = _AddressList(all)
return a.addresslist | [
"def",
"getaddresses",
"(",
"fieldvalues",
")",
":",
"all",
"=",
"COMMASPACE",
".",
"join",
"(",
"str",
"(",
"v",
")",
"for",
"v",
"in",
"fieldvalues",
")",
"a",
"=",
"_AddressList",
"(",
"all",
")",
"return",
"a",
".",
"addresslist"
] | https://github.com/brython-dev/brython/blob/9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3/www/src/Lib/email/utils.py#L110-L114 | |
windelbouwman/ppci | 915c069e0667042c085ec42c78e9e3c9a5295324 | ppci/lang/c/codegenerator.py | python | CCodeGenerator.data_layout | (self, typ: types.CType) | return size, alignment | Get size and alignment of the given type. | Get size and alignment of the given type. | [
"Get",
"size",
"and",
"alignment",
"of",
"the",
"given",
"type",
"."
] | def data_layout(self, typ: types.CType):
""" Get size and alignment of the given type. """
size = self.sizeof(typ)
alignment = self.context.alignment(typ)
return size, alignment | [
"def",
"data_layout",
"(",
"self",
",",
"typ",
":",
"types",
".",
"CType",
")",
":",
"size",
"=",
"self",
".",
"sizeof",
"(",
"typ",
")",
"alignment",
"=",
"self",
".",
"context",
".",
"alignment",
"(",
"typ",
")",
"return",
"size",
",",
"alignment"
... | https://github.com/windelbouwman/ppci/blob/915c069e0667042c085ec42c78e9e3c9a5295324/ppci/lang/c/codegenerator.py#L1635-L1639 | |
kevingo/system-design-primer-zh-tw | d664bbc3dbcde7e8d399a4a579f28ba7822209c4 | solutions/system_design/mint/mint_mapreduce.py | python | SpendingByCategory.extract_year_month | (self, timestamp) | Return the year and month portions of the timestamp. | Return the year and month portions of the timestamp. | [
"Return",
"the",
"year",
"and",
"month",
"portions",
"of",
"the",
"timestamp",
"."
] | def extract_year_month(self, timestamp):
"""Return the year and month portions of the timestamp."""
... | [
"def",
"extract_year_month",
"(",
"self",
",",
"timestamp",
")",
":",
"..."
] | https://github.com/kevingo/system-design-primer-zh-tw/blob/d664bbc3dbcde7e8d399a4a579f28ba7822209c4/solutions/system_design/mint/mint_mapreduce.py#L16-L18 | ||
pypa/setuptools | 9f37366aab9cd8f6baa23e6a77cfdb8daf97757e | pkg_resources/__init__.py | python | Distribution.has_version | (self) | return True | [] | def has_version(self):
try:
self.version
except ValueError:
issue_warning("Unbuilt egg for " + repr(self))
return False
return True | [
"def",
"has_version",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"version",
"except",
"ValueError",
":",
"issue_warning",
"(",
"\"Unbuilt egg for \"",
"+",
"repr",
"(",
"self",
")",
")",
"return",
"False",
"return",
"True"
] | https://github.com/pypa/setuptools/blob/9f37366aab9cd8f6baa23e6a77cfdb8daf97757e/pkg_resources/__init__.py#L2970-L2976 | |||
wxWidgets/Phoenix | b2199e299a6ca6d866aa6f3d0888499136ead9d6 | wx/lib/agw/ultimatelistctrl.py | python | UltimateListItem.__init__ | (self, item=None) | Default class constructor.
:param `item`: if not ``None``, another instance of :class:`UltimateListItem`. | Default class constructor. | [
"Default",
"class",
"constructor",
"."
] | def __init__(self, item=None):
"""
Default class constructor.
:param `item`: if not ``None``, another instance of :class:`UltimateListItem`.
"""
if not item:
self.Init()
self._attr = None
else:
self._mask = item._mask # I... | [
"def",
"__init__",
"(",
"self",
",",
"item",
"=",
"None",
")",
":",
"if",
"not",
"item",
":",
"self",
".",
"Init",
"(",
")",
"self",
".",
"_attr",
"=",
"None",
"else",
":",
"self",
".",
"_mask",
"=",
"item",
".",
"_mask",
"# Indicates what fields are... | https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/ultimatelistctrl.py#L1344-L1390 | ||
openstack/magnum | fa298eeab19b1d87070d72c7c4fb26cd75b0781e | magnum/api/controllers/v1/quota.py | python | QuotaController.__init__ | (self) | [] | def __init__(self):
super(QuotaController, self).__init__() | [
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
"QuotaController",
",",
"self",
")",
".",
"__init__",
"(",
")"
] | https://github.com/openstack/magnum/blob/fa298eeab19b1d87070d72c7c4fb26cd75b0781e/magnum/api/controllers/v1/quota.py#L94-L95 | ||||
HypothesisWorks/hypothesis | d1bfc4acc86899caa7a40f892322e1a69fbf36f4 | tooling/src/hypothesistooling/releasemanagement.py | python | commit_pending_release | (project) | Create a commit with the new release. | Create a commit with the new release. | [
"Create",
"a",
"commit",
"with",
"the",
"new",
"release",
"."
] | def commit_pending_release(project):
"""Create a commit with the new release."""
tools.git("rm", project.RELEASE_FILE)
tools.git("add", "-u", project.BASE_DIR)
tools.git(
"commit",
"-m",
f"Bump {project.PACKAGE_NAME} version to {project.current_version()} "
+ "and update... | [
"def",
"commit_pending_release",
"(",
"project",
")",
":",
"tools",
".",
"git",
"(",
"\"rm\"",
",",
"project",
".",
"RELEASE_FILE",
")",
"tools",
".",
"git",
"(",
"\"add\"",
",",
"\"-u\"",
",",
"project",
".",
"BASE_DIR",
")",
"tools",
".",
"git",
"(",
... | https://github.com/HypothesisWorks/hypothesis/blob/d1bfc4acc86899caa7a40f892322e1a69fbf36f4/tooling/src/hypothesistooling/releasemanagement.py#L169-L179 | ||
dimagi/commcare-hq | d67ff1d3b4c51fa050c19e60c3253a79d3452a39 | corehq/apps/app_manager/models.py | python | ApplicationBase.get_jar_path | (self) | return spec | [] | def get_jar_path(self):
spec = {
'nokia/s40': 'Nokia/S40',
'nokia/s60': 'Nokia/S60',
'generic': 'Generic/Default',
'winmo': 'Native/WinMo'
}[self.platform]
if self.platform in ('nokia/s40', 'nokia/s60'):
spec += {
('nat... | [
"def",
"get_jar_path",
"(",
"self",
")",
":",
"spec",
"=",
"{",
"'nokia/s40'",
":",
"'Nokia/S40'",
",",
"'nokia/s60'",
":",
"'Nokia/S60'",
",",
"'generic'",
":",
"'Generic/Default'",
",",
"'winmo'",
":",
"'Native/WinMo'",
"}",
"[",
"self",
".",
"platform",
"... | https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/app_manager/models.py#L4337-L4353 | |||
djc/couchdb-python | 459bb1ef24587eef2577ad414e1c070e8b0eaff5 | couchdb/client.py | python | Database.save | (self, doc, **options) | return id, rev | Create a new document or update an existing document.
If doc has no _id then the server will allocate a random ID and a new
document will be created. Otherwise the doc's _id will be used to
identify the document to create or update. Trying to update an existing
document with an incorrec... | Create a new document or update an existing document. | [
"Create",
"a",
"new",
"document",
"or",
"update",
"an",
"existing",
"document",
"."
] | def save(self, doc, **options):
"""Create a new document or update an existing document.
If doc has no _id then the server will allocate a random ID and a new
document will be created. Otherwise the doc's _id will be used to
identify the document to create or update. Trying to update an... | [
"def",
"save",
"(",
"self",
",",
"doc",
",",
"*",
"*",
"options",
")",
":",
"if",
"'_id'",
"in",
"doc",
":",
"func",
"=",
"_doc_resource",
"(",
"self",
".",
"resource",
",",
"doc",
"[",
"'_id'",
"]",
")",
".",
"put_json",
"else",
":",
"func",
"="... | https://github.com/djc/couchdb-python/blob/459bb1ef24587eef2577ad414e1c070e8b0eaff5/couchdb/client.py#L498-L534 | |
tspurway/hustle | e62bf1269b446ea6fae23bc5698f845a2f3247c7 | hustle/__init__.py | python | Table.base_tag | (cls, name, partition=None) | return rval | return the *DDFS* tag name for a given hustle table name
:type name: string
:param name: the name of the table
:type partition: string
:param partition: the value of the partition | return the *DDFS* tag name for a given hustle table name | [
"return",
"the",
"*",
"DDFS",
"*",
"tag",
"name",
"for",
"a",
"given",
"hustle",
"table",
"name"
] | def base_tag(cls, name, partition=None):
"""
return the *DDFS* tag name for a given hustle table name
:type name: string
:param name: the name of the table
:type partition: string
:param partition: the value of the partition
"""
rval = "hustle:" + name... | [
"def",
"base_tag",
"(",
"cls",
",",
"name",
",",
"partition",
"=",
"None",
")",
":",
"rval",
"=",
"\"hustle:\"",
"+",
"name",
"if",
"partition",
":",
"rval",
"+=",
"':'",
"+",
"str",
"(",
"partition",
")",
"return",
"rval"
] | https://github.com/tspurway/hustle/blob/e62bf1269b446ea6fae23bc5698f845a2f3247c7/hustle/__init__.py#L193-L206 | |
VITA-Group/AutoGAN | a5eeef0592ba92ec8987080c44bf025184da7b30 | utils/fid_score.py | python | calculate_activation_statistics_from_files | (
files, sess, batch_size=50, verbose=False
) | return mu, sigma | Calculation of the statistics used by the FID.
Params:
-- files : list of paths to image files. Images need to have same dimensions for all files.
-- sess : current session
-- batch_size : the images numpy array is split into batches with batch size
batch_size. A reason... | Calculation of the statistics used by the FID.
Params:
-- files : list of paths to image files. Images need to have same dimensions for all files.
-- sess : current session
-- batch_size : the images numpy array is split into batches with batch size
batch_size. A reason... | [
"Calculation",
"of",
"the",
"statistics",
"used",
"by",
"the",
"FID",
".",
"Params",
":",
"--",
"files",
":",
"list",
"of",
"paths",
"to",
"image",
"files",
".",
"Images",
"need",
"to",
"have",
"same",
"dimensions",
"for",
"all",
"files",
".",
"--",
"s... | def calculate_activation_statistics_from_files(
files, sess, batch_size=50, verbose=False
):
"""Calculation of the statistics used by the FID.
Params:
-- files : list of paths to image files. Images need to have same dimensions for all files.
-- sess : current session
-- batch_size ... | [
"def",
"calculate_activation_statistics_from_files",
"(",
"files",
",",
"sess",
",",
"batch_size",
"=",
"50",
",",
"verbose",
"=",
"False",
")",
":",
"act",
"=",
"get_activations_from_files",
"(",
"files",
",",
"sess",
",",
"batch_size",
",",
"verbose",
")",
"... | https://github.com/VITA-Group/AutoGAN/blob/a5eeef0592ba92ec8987080c44bf025184da7b30/utils/fid_score.py#L256-L276 | |
Azure/azure-devops-cli-extension | 11334cd55806bef0b99c3bee5a438eed71e44037 | azure-devops/azext_devops/devops_sdk/v5_0/feed/feed_client.py | python | FeedClient.get_global_permissions | (self) | return self._deserialize('[GlobalPermission]', self._unwrap_collection(response)) | GetGlobalPermissions.
[Preview API] Get all service-wide feed creation permissions.
:rtype: [GlobalPermission] | GetGlobalPermissions.
[Preview API] Get all service-wide feed creation permissions.
:rtype: [GlobalPermission] | [
"GetGlobalPermissions",
".",
"[",
"Preview",
"API",
"]",
"Get",
"all",
"service",
"-",
"wide",
"feed",
"creation",
"permissions",
".",
":",
"rtype",
":",
"[",
"GlobalPermission",
"]"
] | def get_global_permissions(self):
"""GetGlobalPermissions.
[Preview API] Get all service-wide feed creation permissions.
:rtype: [GlobalPermission]
"""
response = self._send(http_method='GET',
location_id='a74419ef-b477-43df-8758-3cd1cd5f56c6',
... | [
"def",
"get_global_permissions",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_send",
"(",
"http_method",
"=",
"'GET'",
",",
"location_id",
"=",
"'a74419ef-b477-43df-8758-3cd1cd5f56c6'",
",",
"version",
"=",
"'5.0-preview.1'",
")",
"return",
"self",
".",
... | https://github.com/Azure/azure-devops-cli-extension/blob/11334cd55806bef0b99c3bee5a438eed71e44037/azure-devops/azext_devops/devops_sdk/v5_0/feed/feed_client.py#L164-L172 | |
ZhixiuYe/HSCRF-pytorch | 86bb64890317b74517c5ad44b47c66635df327d8 | model/utils.py | python | calc_threshold_mean | (features) | return [lower_average, average, upper_average, max_len] | calculate the threshold for bucket by mean | calculate the threshold for bucket by mean | [
"calculate",
"the",
"threshold",
"for",
"bucket",
"by",
"mean"
] | def calc_threshold_mean(features):
"""
calculate the threshold for bucket by mean
"""
lines_len = list(map(lambda t: len(t) + 1, features))
average = int(sum(lines_len) / len(lines_len))
lower_line = list(filter(lambda t: t < average, lines_len))
upper_line = list(filter(lambda t: t >= avera... | [
"def",
"calc_threshold_mean",
"(",
"features",
")",
":",
"lines_len",
"=",
"list",
"(",
"map",
"(",
"lambda",
"t",
":",
"len",
"(",
"t",
")",
"+",
"1",
",",
"features",
")",
")",
"average",
"=",
"int",
"(",
"sum",
"(",
"lines_len",
")",
"/",
"len",... | https://github.com/ZhixiuYe/HSCRF-pytorch/blob/86bb64890317b74517c5ad44b47c66635df327d8/model/utils.py#L360-L371 | |
wucng/TensorExpand | 4ea58f64f5c5082b278229b799c9f679536510b7 | TensorExpand/Object detection/Mask RCNN/CharlesShang_FastMaskRCNN/libs/boxes/gprof2dot.py | python | GprofParser.parse | (self) | return profile | [] | def parse(self):
self.parse_cg()
self.fp.close()
profile = Profile()
profile[TIME] = 0.0
cycles = {}
for index in self.cycles:
cycles[index] = Cycle()
for entry in compat_itervalues(self.functions):
# populate the function
... | [
"def",
"parse",
"(",
"self",
")",
":",
"self",
".",
"parse_cg",
"(",
")",
"self",
".",
"fp",
".",
"close",
"(",
")",
"profile",
"=",
"Profile",
"(",
")",
"profile",
"[",
"TIME",
"]",
"=",
"0.0",
"cycles",
"=",
"{",
"}",
"for",
"index",
"in",
"s... | https://github.com/wucng/TensorExpand/blob/4ea58f64f5c5082b278229b799c9f679536510b7/TensorExpand/Object detection/Mask RCNN/CharlesShang_FastMaskRCNN/libs/boxes/gprof2dot.py#L1256-L1319 | |||
perone/Pyevolve | 589b6a9b92ed1fd9ef00987bf4bfe807c4a7b7e0 | pyevolve/Util.py | python | Graph.__iadd__ | (self, node) | return self | Add a node using the += operator | Add a node using the += operator | [
"Add",
"a",
"node",
"using",
"the",
"+",
"=",
"operator"
] | def __iadd__(self, node):
""" Add a node using the += operator """
self.addNode(node)
return self | [
"def",
"__iadd__",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"addNode",
"(",
"node",
")",
"return",
"self"
] | https://github.com/perone/Pyevolve/blob/589b6a9b92ed1fd9ef00987bf4bfe807c4a7b7e0/pyevolve/Util.py#L251-L254 | |
nanoporetech/medaka | 2b83074fe3b6a6ec971614bfc6804f543fe1e5f0 | medaka/datastore.py | python | ModelStoreTF.unpack | (self) | return self | Unpack model files from archive. | Unpack model files from archive. | [
"Unpack",
"model",
"files",
"from",
"archive",
"."
] | def unpack(self):
"""Unpack model files from archive."""
if self.tmpdir is None:
# tmpdir is removed by .cleanup()
self.tmpdir = tempfile.TemporaryDirectory()
self._exitstack = contextlib.ExitStack()
self._exitstack.enter_context(self.tmpdir)
w... | [
"def",
"unpack",
"(",
"self",
")",
":",
"if",
"self",
".",
"tmpdir",
"is",
"None",
":",
"# tmpdir is removed by .cleanup()",
"self",
".",
"tmpdir",
"=",
"tempfile",
".",
"TemporaryDirectory",
"(",
")",
"self",
".",
"_exitstack",
"=",
"contextlib",
".",
"Exit... | https://github.com/nanoporetech/medaka/blob/2b83074fe3b6a6ec971614bfc6804f543fe1e5f0/medaka/datastore.py#L111-L124 | |
oilshell/oil | 94388e7d44a9ad879b12615f6203b38596b5a2d3 | Python-2.7.13/Lib/plat-mac/ic.py | python | _code_default | (data, key) | return chr(len(data)) + data | [] | def _code_default(data, key):
return chr(len(data)) + data | [
"def",
"_code_default",
"(",
"data",
",",
"key",
")",
":",
"return",
"chr",
"(",
"len",
"(",
"data",
")",
")",
"+",
"data"
] | https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/plat-mac/ic.py#L84-L85 | |||
dustin/twitty-twister | 8524750ee73adb57bbe14ef0cfd8aa08e1e59fb3 | twittytwister/twitter.py | python | Twitter.update_profile_image | (self, filename, image) | return self.__postMultipart('/account/update_profile_image.xml',
files=(('image', filename, image),)) | Update the profile image of an authenticated user.
The image parameter must be raw data.
Returns no useful data. | Update the profile image of an authenticated user.
The image parameter must be raw data. | [
"Update",
"the",
"profile",
"image",
"of",
"an",
"authenticated",
"user",
".",
"The",
"image",
"parameter",
"must",
"be",
"raw",
"data",
"."
] | def update_profile_image(self, filename, image):
"""Update the profile image of an authenticated user.
The image parameter must be raw data.
Returns no useful data."""
return self.__postMultipart('/account/update_profile_image.xml',
files=(('image', ... | [
"def",
"update_profile_image",
"(",
"self",
",",
"filename",
",",
"image",
")",
":",
"return",
"self",
".",
"__postMultipart",
"(",
"'/account/update_profile_image.xml'",
",",
"files",
"=",
"(",
"(",
"'image'",
",",
"filename",
",",
"image",
")",
",",
")",
"... | https://github.com/dustin/twitty-twister/blob/8524750ee73adb57bbe14ef0cfd8aa08e1e59fb3/twittytwister/twitter.py#L527-L534 | |
demisto/content | 5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07 | Packs/ProofpointThreatResponse/Integrations/ProofpointThreatResponse/ProofpointThreatResponse.py | python | get_emails_context | (event) | return emails_context | Returns the context of the emails in the event
Args:
event (dict): The event to parse the emails from
Returns:
list. The parsed emails list from the event | Returns the context of the emails in the event | [
"Returns",
"the",
"context",
"of",
"the",
"emails",
"in",
"the",
"event"
] | def get_emails_context(event):
"""Returns the context of the emails in the event
Args:
event (dict): The event to parse the emails from
Returns:
list. The parsed emails list from the event
"""
emails_context = []
for email in event.get('emails', []):
emails_context.appe... | [
"def",
"get_emails_context",
"(",
"event",
")",
":",
"emails_context",
"=",
"[",
"]",
"for",
"email",
"in",
"event",
".",
"get",
"(",
"'emails'",
",",
"[",
"]",
")",
":",
"emails_context",
".",
"append",
"(",
"assign_params",
"(",
"*",
"*",
"{",
"'send... | https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/ProofpointThreatResponse/Integrations/ProofpointThreatResponse/ProofpointThreatResponse.py#L229-L256 | |
trakt/Plex-Trakt-Scrobbler | aeb0bfbe62fad4b06c164f1b95581da7f35dce0b | Trakttv.bundle/Contents/Libraries/Linux/armv7_hf/marvell-pj4/ucs4/cryptography/x509/base.py | python | CertificateBuilder.serial_number | (self, number) | return CertificateBuilder(
self._issuer_name, self._subject_name,
self._public_key, number, self._not_valid_before,
self._not_valid_after, self._extensions
) | Sets the certificate serial number. | Sets the certificate serial number. | [
"Sets",
"the",
"certificate",
"serial",
"number",
"."
] | def serial_number(self, number):
"""
Sets the certificate serial number.
"""
if not isinstance(number, six.integer_types):
raise TypeError('Serial number must be of integral type.')
if self._serial_number is not None:
raise ValueError('The serial number ma... | [
"def",
"serial_number",
"(",
"self",
",",
"number",
")",
":",
"if",
"not",
"isinstance",
"(",
"number",
",",
"six",
".",
"integer_types",
")",
":",
"raise",
"TypeError",
"(",
"'Serial number must be of integral type.'",
")",
"if",
"self",
".",
"_serial_number",
... | https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Linux/armv7_hf/marvell-pj4/ucs4/cryptography/x509/base.py#L434-L454 | |
staticafi/symbiotic | 792b3b8112cb837a58d878129e8bc7a919d1a2f7 | lib/symbioticpy/symbiotic/benchexec/tools/template.py | python | BaseTool.working_directory | (self, executable) | return os.curdir | OPTIONAL, this method is only necessary for situations
when the tool needs a separate working directory.
@param executable: the path to the executable of the tool (typically the result of executable())
@return a string pointing to a directory | OPTIONAL, this method is only necessary for situations
when the tool needs a separate working directory. | [
"OPTIONAL",
"this",
"method",
"is",
"only",
"necessary",
"for",
"situations",
"when",
"the",
"tool",
"needs",
"a",
"separate",
"working",
"directory",
"."
] | def working_directory(self, executable):
"""
OPTIONAL, this method is only necessary for situations
when the tool needs a separate working directory.
@param executable: the path to the executable of the tool (typically the result of executable())
@return a string pointing to a di... | [
"def",
"working_directory",
"(",
"self",
",",
"executable",
")",
":",
"return",
"os",
".",
"curdir"
] | https://github.com/staticafi/symbiotic/blob/792b3b8112cb837a58d878129e8bc7a919d1a2f7/lib/symbioticpy/symbiotic/benchexec/tools/template.py#L171-L178 | |
mrkipling/maraschino | c6be9286937783ae01df2d6d8cebfc8b2734a7d7 | lib/rtorrent/torrent.py | python | Torrent.stop | (self) | return(self.active) | Stop the torrent | Stop the torrent | [
"Stop",
"the",
"torrent"
] | def stop(self):
""""Stop the torrent"""
m = rtorrent.rpc.Multicall(self)
self.multicall_add(m, "d.try_stop")
self.multicall_add(m, "d.is_active")
self.active = m.call()[-1]
return(self.active) | [
"def",
"stop",
"(",
"self",
")",
":",
"m",
"=",
"rtorrent",
".",
"rpc",
".",
"Multicall",
"(",
"self",
")",
"self",
".",
"multicall_add",
"(",
"m",
",",
"\"d.try_stop\"",
")",
"self",
".",
"multicall_add",
"(",
"m",
",",
"\"d.is_active\"",
")",
"self",... | https://github.com/mrkipling/maraschino/blob/c6be9286937783ae01df2d6d8cebfc8b2734a7d7/lib/rtorrent/torrent.py#L195-L202 | |
edfungus/Crouton | ada98b3930192938a48909072b45cb84b945f875 | clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/_vendor/requests/utils.py | python | parse_header_links | (value) | return links | Return a dict of parsed link headers proxies.
i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg" | Return a dict of parsed link headers proxies. | [
"Return",
"a",
"dict",
"of",
"parsed",
"link",
"headers",
"proxies",
"."
] | def parse_header_links(value):
"""Return a dict of parsed link headers proxies.
i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
"""
links = []
replace_chars = " '\""
for val in re.split(", *<", value):
try:
... | [
"def",
"parse_header_links",
"(",
"value",
")",
":",
"links",
"=",
"[",
"]",
"replace_chars",
"=",
"\" '\\\"\"",
"for",
"val",
"in",
"re",
".",
"split",
"(",
"\", *<\"",
",",
"value",
")",
":",
"try",
":",
"url",
",",
"params",
"=",
"val",
".",
"spli... | https://github.com/edfungus/Crouton/blob/ada98b3930192938a48909072b45cb84b945f875/clients/esp8266_clients/venv/lib/python2.7/site-packages/pip/_vendor/requests/utils.py#L580-L611 | |
DataDog/integrations-core | 934674b29d94b70ccc008f76ea172d0cdae05e1e | couch/datadog_checks/couch/couch.py | python | CouchDb.get_server | (self) | return server | [] | def get_server(self):
server = self.instance.get('server')
if server is None:
raise ConfigurationError("A server must be specified")
return server | [
"def",
"get_server",
"(",
"self",
")",
":",
"server",
"=",
"self",
".",
"instance",
".",
"get",
"(",
"'server'",
")",
"if",
"server",
"is",
"None",
":",
"raise",
"ConfigurationError",
"(",
"\"A server must be specified\"",
")",
"return",
"server"
] | https://github.com/DataDog/integrations-core/blob/934674b29d94b70ccc008f76ea172d0cdae05e1e/couch/datadog_checks/couch/couch.py#L90-L94 | |||
packetloop/packetpig | 6e101090224df219123ff5f6ab4c37524637571f | lib/scripts/impacket/impacket/dot11.py | python | Dot11WEP.set_keyid | (self, value) | Set the \'WEP KEY ID\' field | Set the \'WEP KEY ID\' field | [
"Set",
"the",
"\\",
"WEP",
"KEY",
"ID",
"\\",
"field"
] | def set_keyid(self, value):
'Set the \'WEP KEY ID\' field'
# clear the bits
mask = (~0xC0) & 0xFF
masked = self.header.get_byte(3) & mask
# set the bits
nb = masked | ((value & 0x03) << 6)
self.header.set_byte(3, nb) | [
"def",
"set_keyid",
"(",
"self",
",",
"value",
")",
":",
"# clear the bits",
"mask",
"=",
"(",
"~",
"0xC0",
")",
"&",
"0xFF",
"masked",
"=",
"self",
".",
"header",
".",
"get_byte",
"(",
"3",
")",
"&",
"mask",
"# set the bits",
"nb",
"=",
"masked",
"|... | https://github.com/packetloop/packetpig/blob/6e101090224df219123ff5f6ab4c37524637571f/lib/scripts/impacket/impacket/dot11.py#L1057-L1064 | ||
benhoyt/pygit | aa8d8bb62ae273ae2f4f167e36f24f40a11634b9 | pygit.py | python | encode_pack_object | (obj) | return bytes(header) + zlib.compress(data) | Encode a single object for a pack file and return bytes (variable-
length header followed by compressed data bytes). | Encode a single object for a pack file and return bytes (variable-
length header followed by compressed data bytes). | [
"Encode",
"a",
"single",
"object",
"for",
"a",
"pack",
"file",
"and",
"return",
"bytes",
"(",
"variable",
"-",
"length",
"header",
"followed",
"by",
"compressed",
"data",
"bytes",
")",
"."
] | def encode_pack_object(obj):
"""Encode a single object for a pack file and return bytes (variable-
length header followed by compressed data bytes).
"""
obj_type, data = read_object(obj)
type_num = ObjectType[obj_type].value
size = len(data)
byte = (type_num << 4) | (size & 0x0f)
size >>... | [
"def",
"encode_pack_object",
"(",
"obj",
")",
":",
"obj_type",
",",
"data",
"=",
"read_object",
"(",
"obj",
")",
"type_num",
"=",
"ObjectType",
"[",
"obj_type",
"]",
".",
"value",
"size",
"=",
"len",
"(",
"data",
")",
"byte",
"=",
"(",
"type_num",
"<<"... | https://github.com/benhoyt/pygit/blob/aa8d8bb62ae273ae2f4f167e36f24f40a11634b9/pygit.py#L441-L456 | |
freewym/espresso | 6671c507350295269e38add57dbe601dcb8e6ecf | espresso/tools/specaug_interpolate.py | python | freq_mask | (spec, F=30, num_masks=1, pad_value=0.0) | return cloned | Frequency masking
Args:
spec (torch.Tensor): input tensor of shape `(dim, T)`
F (int): maximum width of each mask
num_masks (int): number of masks
pad_value (float): value for padding
Returns:
freq masked tensor (torch.Tensor): output tensor of shape `(dim, T)` | Frequency masking | [
"Frequency",
"masking"
] | def freq_mask(spec, F=30, num_masks=1, pad_value=0.0):
"""Frequency masking
Args:
spec (torch.Tensor): input tensor of shape `(dim, T)`
F (int): maximum width of each mask
num_masks (int): number of masks
pad_value (float): value for padding
Returns:
freq masked t... | [
"def",
"freq_mask",
"(",
"spec",
",",
"F",
"=",
"30",
",",
"num_masks",
"=",
"1",
",",
"pad_value",
"=",
"0.0",
")",
":",
"cloned",
"=",
"spec",
".",
"clone",
"(",
")",
"num_mel_channels",
"=",
"cloned",
".",
"size",
"(",
"0",
")",
"for",
"i",
"i... | https://github.com/freewym/espresso/blob/6671c507350295269e38add57dbe601dcb8e6ecf/espresso/tools/specaug_interpolate.py#L97-L119 | |
pyscf/pyscf | 0adfb464333f5ceee07b664f291d4084801bae64 | pyscf/pbc/dft/numint.py | python | KNumInt.nr_vxc | (self, cell, grids, xc_code, dms, spin=0, relativity=0, hermi=0,
kpts=None, kpts_band=None, max_memory=2000, verbose=None) | Evaluate RKS/UKS XC functional and potential matrix.
See :func:`nr_rks` and :func:`nr_uks` for more details. | Evaluate RKS/UKS XC functional and potential matrix.
See :func:`nr_rks` and :func:`nr_uks` for more details. | [
"Evaluate",
"RKS",
"/",
"UKS",
"XC",
"functional",
"and",
"potential",
"matrix",
".",
"See",
":",
"func",
":",
"nr_rks",
"and",
":",
"func",
":",
"nr_uks",
"for",
"more",
"details",
"."
] | def nr_vxc(self, cell, grids, xc_code, dms, spin=0, relativity=0, hermi=0,
kpts=None, kpts_band=None, max_memory=2000, verbose=None):
'''Evaluate RKS/UKS XC functional and potential matrix.
See :func:`nr_rks` and :func:`nr_uks` for more details.
'''
if spin == 0:
... | [
"def",
"nr_vxc",
"(",
"self",
",",
"cell",
",",
"grids",
",",
"xc_code",
",",
"dms",
",",
"spin",
"=",
"0",
",",
"relativity",
"=",
"0",
",",
"hermi",
"=",
"0",
",",
"kpts",
"=",
"None",
",",
"kpts_band",
"=",
"None",
",",
"max_memory",
"=",
"200... | https://github.com/pyscf/pyscf/blob/0adfb464333f5ceee07b664f291d4084801bae64/pyscf/pbc/dft/numint.py#L1110-L1120 | ||
BasioMeusPuga/Lector | 1b1d87739a8c14e0e22009435350b155fc3e3b77 | lector/parsers/txt.py | python | ParseTXT.generate_content | (self) | return toc, content, False | Generate content of the book. | Generate content of the book. | [
"Generate",
"content",
"of",
"the",
"book",
"."
] | def generate_content(self):
"""Generate content of the book."""
with open(self.filename, 'rt') as txt:
text = txt.read()
content = [textile.textile(text)]
toc = [(1, 'Text', 1)]
return toc, content, False | [
"def",
"generate_content",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"filename",
",",
"'rt'",
")",
"as",
"txt",
":",
"text",
"=",
"txt",
".",
"read",
"(",
")",
"content",
"=",
"[",
"textile",
".",
"textile",
"(",
"text",
")",
"]",
... | https://github.com/BasioMeusPuga/Lector/blob/1b1d87739a8c14e0e22009435350b155fc3e3b77/lector/parsers/txt.py#L47-L55 | |
dropbox/dropbox-sdk-python | 015437429be224732990041164a21a0501235db1 | dropbox/team_log.py | python | EventType.get_sign_in_as_session_end | (self) | return self._value | (logins) Ended admin sign-in-as session
Only call this if :meth:`is_sign_in_as_session_end` is true.
:rtype: SignInAsSessionEndType | (logins) Ended admin sign-in-as session | [
"(",
"logins",
")",
"Ended",
"admin",
"sign",
"-",
"in",
"-",
"as",
"session"
] | def get_sign_in_as_session_end(self):
"""
(logins) Ended admin sign-in-as session
Only call this if :meth:`is_sign_in_as_session_end` is true.
:rtype: SignInAsSessionEndType
"""
if not self.is_sign_in_as_session_end():
raise AttributeError("tag 'sign_in_as_s... | [
"def",
"get_sign_in_as_session_end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_sign_in_as_session_end",
"(",
")",
":",
"raise",
"AttributeError",
"(",
"\"tag 'sign_in_as_session_end' not set\"",
")",
"return",
"self",
".",
"_value"
] | https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/team_log.py#L33747-L33757 | |
eddyhkchiu/mahalanobis_3d_multi_object_tracking | 25c098a1e56744e65b9cbcfde94bff2b296a645b | get_nuscenes_stats.py | python | get_mean | (tracks) | return mean, std, var | Input:
tracks: {scene_token: {t: [TrackingBox]}} | Input:
tracks: {scene_token: {t: [TrackingBox]}} | [
"Input",
":",
"tracks",
":",
"{",
"scene_token",
":",
"{",
"t",
":",
"[",
"TrackingBox",
"]",
"}}"
] | def get_mean(tracks):
'''
Input:
tracks: {scene_token: {t: [TrackingBox]}}
'''
print('len(tracks.keys()): ', len(tracks.keys()))
# gt_trajectory_map to compute residual or velocity
# tracking_name: {scene_token -> {tracking_id: {t_idx -> det_data}}
# [h, w, l, x, y, z, yaw] #x_dot, y_dot, z_dot, yaw... | [
"def",
"get_mean",
"(",
"tracks",
")",
":",
"print",
"(",
"'len(tracks.keys()): '",
",",
"len",
"(",
"tracks",
".",
"keys",
"(",
")",
")",
")",
"# gt_trajectory_map to compute residual or velocity",
"# tracking_name: {scene_token -> {tracking_id: {t_idx -> det_data}}",
"# [... | https://github.com/eddyhkchiu/mahalanobis_3d_multi_object_tracking/blob/25c098a1e56744e65b9cbcfde94bff2b296a645b/get_nuscenes_stats.py#L35-L110 | |
F8LEFT/DecLLVM | d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c | python/idaapi.py | python | cinsn_t.__le__ | (self, *args) | return _idaapi.cinsn_t___le__(self, *args) | __le__(self, r) -> bool | __le__(self, r) -> bool | [
"__le__",
"(",
"self",
"r",
")",
"-",
">",
"bool"
] | def __le__(self, *args):
"""
__le__(self, r) -> bool
"""
return _idaapi.cinsn_t___le__(self, *args) | [
"def",
"__le__",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"_idaapi",
".",
"cinsn_t___le__",
"(",
"self",
",",
"*",
"args",
")"
] | https://github.com/F8LEFT/DecLLVM/blob/d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c/python/idaapi.py#L38292-L38296 | |
Walleclipse/ChineseAddress_OCR | ca7929c72cbac09c71501f06bf16c387f42f00cf | densenet/model.py | python | predict | (img) | return out | img_array = np.array(img.convert('1'))
boundary_array = np.concatenate((img_array[0, :], img_array[:, width - 1], img_array[31, :], img_array[:, 0]), axis=0)
if np.median(boundary_array) == 0: # 将黑底白字转换为白底黑字
img = ImageOps.invert(img) | img_array = np.array(img.convert('1'))
boundary_array = np.concatenate((img_array[0, :], img_array[:, width - 1], img_array[31, :], img_array[:, 0]), axis=0)
if np.median(boundary_array) == 0: # 将黑底白字转换为白底黑字
img = ImageOps.invert(img) | [
"img_array",
"=",
"np",
".",
"array",
"(",
"img",
".",
"convert",
"(",
"1",
"))",
"boundary_array",
"=",
"np",
".",
"concatenate",
"((",
"img_array",
"[",
"0",
":",
"]",
"img_array",
"[",
":",
"width",
"-",
"1",
"]",
"img_array",
"[",
"31",
":",
"]... | def predict(img):
width, height = img.size[0], img.size[1]
scale = height * 1.0 / 32
width = int(width / scale)
img = img.resize([width, 32], Image.ANTIALIAS)
'''
img_array = np.array(img.convert('1'))
boundary_array = np.concatenate((img_array[0, :], img_array[:, width - 1], img_ar... | [
"def",
"predict",
"(",
"img",
")",
":",
"width",
",",
"height",
"=",
"img",
".",
"size",
"[",
"0",
"]",
",",
"img",
".",
"size",
"[",
"1",
"]",
"scale",
"=",
"height",
"*",
"1.0",
"/",
"32",
"width",
"=",
"int",
"(",
"width",
"/",
"scale",
")... | https://github.com/Walleclipse/ChineseAddress_OCR/blob/ca7929c72cbac09c71501f06bf16c387f42f00cf/densenet/model.py#L47-L72 | |
jrzaurin/pytorch-widedeep | 8b4c3a8acbf06b385c821d7111b1139a16b4f480 | pytorch_widedeep/preprocessing/wide_preprocessor.py | python | WidePreprocessor.fit | (self, df: pd.DataFrame) | return self | r"""Fits the Preprocessor and creates required attributes | r"""Fits the Preprocessor and creates required attributes | [
"r",
"Fits",
"the",
"Preprocessor",
"and",
"creates",
"required",
"attributes"
] | def fit(self, df: pd.DataFrame) -> BasePreprocessor:
r"""Fits the Preprocessor and creates required attributes"""
df_wide = self._prepare_wide(df)
self.wide_crossed_cols = df_wide.columns.tolist()
glob_feature_list = self._make_global_feature_list(
df_wide[self.wide_crossed_c... | [
"def",
"fit",
"(",
"self",
",",
"df",
":",
"pd",
".",
"DataFrame",
")",
"->",
"BasePreprocessor",
":",
"df_wide",
"=",
"self",
".",
"_prepare_wide",
"(",
"df",
")",
"self",
".",
"wide_crossed_cols",
"=",
"df_wide",
".",
"columns",
".",
"tolist",
"(",
"... | https://github.com/jrzaurin/pytorch-widedeep/blob/8b4c3a8acbf06b385c821d7111b1139a16b4f480/pytorch_widedeep/preprocessing/wide_preprocessor.py#L69-L81 | |
scikit-learn-contrib/category_encoders | 55636b5ae11dc45075a0c248028f17f9df93bbb9 | category_encoders/utils.py | python | get_obj_cols | (df) | return obj_cols | Returns names of 'object' columns in the DataFrame. | Returns names of 'object' columns in the DataFrame. | [
"Returns",
"names",
"of",
"object",
"columns",
"in",
"the",
"DataFrame",
"."
] | def get_obj_cols(df):
"""
Returns names of 'object' columns in the DataFrame.
"""
obj_cols = []
for idx, dt in enumerate(df.dtypes):
if dt == 'object' or is_category(dt):
obj_cols.append(df.columns.values[idx])
return obj_cols | [
"def",
"get_obj_cols",
"(",
"df",
")",
":",
"obj_cols",
"=",
"[",
"]",
"for",
"idx",
",",
"dt",
"in",
"enumerate",
"(",
"df",
".",
"dtypes",
")",
":",
"if",
"dt",
"==",
"'object'",
"or",
"is_category",
"(",
"dt",
")",
":",
"obj_cols",
".",
"append"... | https://github.com/scikit-learn-contrib/category_encoders/blob/55636b5ae11dc45075a0c248028f17f9df93bbb9/category_encoders/utils.py#L27-L36 | |
hubblestack/hubble | 763142474edcecdec5fd25591dc29c3536e8f969 | hubblestack/audit/readfile.py | python | _check_pattern | (line, pattern, ignore_pattern) | return keep | Check a given line against both a pattern and an ignore_pattern and return
True or False based on whether that line should be used. | Check a given line against both a pattern and an ignore_pattern and return
True or False based on whether that line should be used. | [
"Check",
"a",
"given",
"line",
"against",
"both",
"a",
"pattern",
"and",
"an",
"ignore_pattern",
"and",
"return",
"True",
"or",
"False",
"based",
"on",
"whether",
"that",
"line",
"should",
"be",
"used",
"."
] | def _check_pattern(line, pattern, ignore_pattern):
"""
Check a given line against both a pattern and an ignore_pattern and return
True or False based on whether that line should be used.
"""
keep = False
if pattern is None:
keep = True
elif re.match(pattern, line):
keep = Tr... | [
"def",
"_check_pattern",
"(",
"line",
",",
"pattern",
",",
"ignore_pattern",
")",
":",
"keep",
"=",
"False",
"if",
"pattern",
"is",
"None",
":",
"keep",
"=",
"True",
"elif",
"re",
".",
"match",
"(",
"pattern",
",",
"line",
")",
":",
"keep",
"=",
"Tru... | https://github.com/hubblestack/hubble/blob/763142474edcecdec5fd25591dc29c3536e8f969/hubblestack/audit/readfile.py#L556-L571 | |
AI4Finance-Foundation/ElegantRL | 74103d9cc4ce9c573f83bc42d9129ff15b9ff018 | elegantrl/agents/net.py | python | ActorPPO.forward | (self, state) | return self.net(state).tanh() | The forward function.
:param state: [tensor] the input state.
:return: the output tensor. | The forward function.
:param state: [tensor] the input state.
:return: the output tensor. | [
"The",
"forward",
"function",
".",
":",
"param",
"state",
":",
"[",
"tensor",
"]",
"the",
"input",
"state",
".",
":",
"return",
":",
"the",
"output",
"tensor",
"."
] | def forward(self, state):
"""
The forward function.
:param state: [tensor] the input state.
:return: the output tensor.
"""
return self.net(state).tanh() | [
"def",
"forward",
"(",
"self",
",",
"state",
")",
":",
"return",
"self",
".",
"net",
"(",
"state",
")",
".",
"tanh",
"(",
")"
] | https://github.com/AI4Finance-Foundation/ElegantRL/blob/74103d9cc4ce9c573f83bc42d9129ff15b9ff018/elegantrl/agents/net.py#L318-L325 | |
CheckPointSW/Karta | b845928487b50a5b41acd532ae0399177a4356aa | src/thumbs_up/utils/code_regions.py | python | CodeRegions.insert | (self, region) | Insert the given region at it's suitable (sorted) place.
Args:
region (CodeRegion): new code region to be inserted | Insert the given region at it's suitable (sorted) place. | [
"Insert",
"the",
"given",
"region",
"at",
"it",
"s",
"suitable",
"(",
"sorted",
")",
"place",
"."
] | def insert(self, region):
"""Insert the given region at it's suitable (sorted) place.
Args:
region (CodeRegion): new code region to be inserted
"""
# Check if we are the first (the easy case)
if len(self._regions) == 0:
# Insert the element
se... | [
"def",
"insert",
"(",
"self",
",",
"region",
")",
":",
"# Check if we are the first (the easy case)",
"if",
"len",
"(",
"self",
".",
"_regions",
")",
"==",
"0",
":",
"# Insert the element",
"self",
".",
"_regions",
".",
"append",
"(",
"region",
")",
"return",
... | https://github.com/CheckPointSW/Karta/blob/b845928487b50a5b41acd532ae0399177a4356aa/src/thumbs_up/utils/code_regions.py#L78-L96 | ||
haiwen/seahub | e92fcd44e3e46260597d8faa9347cb8222b8b10d | seahub/utils/__init__.py | python | gen_file_share_link | (token) | return gen_shared_link(token, 'f') | Generate file share link. | Generate file share link. | [
"Generate",
"file",
"share",
"link",
"."
] | def gen_file_share_link(token):
"""Generate file share link.
"""
return gen_shared_link(token, 'f') | [
"def",
"gen_file_share_link",
"(",
"token",
")",
":",
"return",
"gen_shared_link",
"(",
"token",
",",
"'f'",
")"
] | https://github.com/haiwen/seahub/blob/e92fcd44e3e46260597d8faa9347cb8222b8b10d/seahub/utils/__init__.py#L961-L964 | |
inkandswitch/livebook | 93c8d467734787366ad084fc3566bf5cbe249c51 | public/pypyjs/modules/email/_parseaddr.py | python | AddrlistClass.getdomainliteral | (self) | return '[%s]' % self.getdelimited('[', ']\r', False) | Parse an RFC 2822 domain-literal. | Parse an RFC 2822 domain-literal. | [
"Parse",
"an",
"RFC",
"2822",
"domain",
"-",
"literal",
"."
] | def getdomainliteral(self):
"""Parse an RFC 2822 domain-literal."""
return '[%s]' % self.getdelimited('[', ']\r', False) | [
"def",
"getdomainliteral",
"(",
"self",
")",
":",
"return",
"'[%s]'",
"%",
"self",
".",
"getdelimited",
"(",
"'['",
",",
"']\\r'",
",",
"False",
")"
] | https://github.com/inkandswitch/livebook/blob/93c8d467734787366ad084fc3566bf5cbe249c51/public/pypyjs/modules/email/_parseaddr.py#L405-L407 | |
phage-nz/ph0neutria | 865aae37d8503d3f580f6762aa67f65958355ba7 | core/malware_utils.py | python | get_plugin_malware_hosts | () | return host_list | Produce a list of malware hosts.
Returns:
- host_list: (type: MalwareHost list) list of malware hosts. | Produce a list of malware hosts. | [
"Produce",
"a",
"list",
"of",
"malware",
"hosts",
"."
] | def get_plugin_malware_hosts():
"""Produce a list of malware hosts.
Returns:
- host_list: (type: MalwareHost list) list of malware hosts.
"""
host_list = []
LOGGING.info('Loading malware host plugins...')
for plugin in load_plugins():
try:
if 'malware-host' in plugin.T... | [
"def",
"get_plugin_malware_hosts",
"(",
")",
":",
"host_list",
"=",
"[",
"]",
"LOGGING",
".",
"info",
"(",
"'Loading malware host plugins...'",
")",
"for",
"plugin",
"in",
"load_plugins",
"(",
")",
":",
"try",
":",
"if",
"'malware-host'",
"in",
"plugin",
".",
... | https://github.com/phage-nz/ph0neutria/blob/865aae37d8503d3f580f6762aa67f65958355ba7/core/malware_utils.py#L51-L77 | |
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/Django-1.11.29/django/contrib/sites/models.py | python | SiteManager.get_current | (self, request=None) | Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database. | Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database. | [
"Returns",
"the",
"current",
"Site",
"based",
"on",
"the",
"SITE_ID",
"in",
"the",
"project",
"s",
"settings",
".",
"If",
"SITE_ID",
"isn",
"t",
"defined",
"it",
"returns",
"the",
"site",
"with",
"domain",
"matching",
"request",
".",
"get_host",
"()",
".",... | def get_current(self, request=None):
"""
Returns the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, it returns the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
... | [
"def",
"get_current",
"(",
"self",
",",
"request",
"=",
"None",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"getattr",
"(",
"settings",
",",
"'SITE_ID'",
",",
"''",
")",
":",
"site_id",
"=",
"settings",
".",
"SITE_ID",
"return",
... | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/Django-1.11.29/django/contrib/sites/models.py#L53-L72 | ||
STIXProject/python-stix | 5ab382b1a3c19364fb8c3e5219addab9e3b64ee9 | stix/exploit_target/weakness.py | python | Weakness.add_description | (self, description) | Adds a description to the ``descriptions`` collection.
This is the same as calling "foo.descriptions.add(bar)". | Adds a description to the ``descriptions`` collection. | [
"Adds",
"a",
"description",
"to",
"the",
"descriptions",
"collection",
"."
] | def add_description(self, description):
"""Adds a description to the ``descriptions`` collection.
This is the same as calling "foo.descriptions.add(bar)".
"""
self.descriptions.add(description) | [
"def",
"add_description",
"(",
"self",
",",
"description",
")",
":",
"self",
".",
"descriptions",
".",
"add",
"(",
"description",
")"
] | https://github.com/STIXProject/python-stix/blob/5ab382b1a3c19364fb8c3e5219addab9e3b64ee9/stix/exploit_target/weakness.py#L48-L53 | ||
sympy/sympy | d822fcba181155b85ff2b29fe525adbafb22b448 | sympy/physics/quantum/operatorordering.py | python | _normal_ordered_form_factor | (product, independent=False, recursive_limit=10,
_recursive_depth=0) | Helper function for normal_ordered_form_factor: Write multiplication
expression with bosonic or fermionic operators on normally ordered form,
using the bosonic and fermionic commutation relations. The resulting
operator expression is equivalent to the argument, but will in general be
a sum of operator p... | Helper function for normal_ordered_form_factor: Write multiplication
expression with bosonic or fermionic operators on normally ordered form,
using the bosonic and fermionic commutation relations. The resulting
operator expression is equivalent to the argument, but will in general be
a sum of operator p... | [
"Helper",
"function",
"for",
"normal_ordered_form_factor",
":",
"Write",
"multiplication",
"expression",
"with",
"bosonic",
"or",
"fermionic",
"operators",
"on",
"normally",
"ordered",
"form",
"using",
"the",
"bosonic",
"and",
"fermionic",
"commutation",
"relations",
... | def _normal_ordered_form_factor(product, independent=False, recursive_limit=10,
_recursive_depth=0):
"""
Helper function for normal_ordered_form_factor: Write multiplication
expression with bosonic or fermionic operators on normally ordered form,
using the bosonic and fer... | [
"def",
"_normal_ordered_form_factor",
"(",
"product",
",",
"independent",
"=",
"False",
",",
"recursive_limit",
"=",
"10",
",",
"_recursive_depth",
"=",
"0",
")",
":",
"factors",
"=",
"_expand_powers",
"(",
"product",
")",
"new_factors",
"=",
"[",
"]",
"n",
... | https://github.com/sympy/sympy/blob/d822fcba181155b85ff2b29fe525adbafb22b448/sympy/physics/quantum/operatorordering.py#L39-L145 | ||
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e | tensorflow_dl_models/research/object_detection/core/preprocessor.py | python | random_pad_image | (image,
boxes,
min_image_size=None,
max_image_size=None,
pad_color=None,
seed=None) | return new_image, new_boxes | Randomly pads the image.
This function randomly pads the image with zeros. The final size of the
padded image will be between min_image_size and max_image_size.
if min_image_size is smaller than the input image size, min_image_size will
be set to the input image size. The same for max_image_size. The input ima... | Randomly pads the image. | [
"Randomly",
"pads",
"the",
"image",
"."
] | def random_pad_image(image,
boxes,
min_image_size=None,
max_image_size=None,
pad_color=None,
seed=None):
"""Randomly pads the image.
This function randomly pads the image with zeros. The final size of the
pad... | [
"def",
"random_pad_image",
"(",
"image",
",",
"boxes",
",",
"min_image_size",
"=",
"None",
",",
"max_image_size",
"=",
"None",
",",
"pad_color",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"if",
"pad_color",
"is",
"None",
":",
"pad_color",
"=",
"tf"... | https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/tensorflow_dl_models/research/object_detection/core/preprocessor.py#L1082-L1188 | |
kensho-technologies/graphql-compiler | 4318443b7b2512a059f3616112bfc40bbf8eec06 | graphql_compiler/query_formatting/cypher_formatting.py | python | _safe_cypher_string | (argument_value) | return escaped_and_quoted | Sanitize and represent a string argument in Cypher. | Sanitize and represent a string argument in Cypher. | [
"Sanitize",
"and",
"represent",
"a",
"string",
"argument",
"in",
"Cypher",
"."
] | def _safe_cypher_string(argument_value):
"""Sanitize and represent a string argument in Cypher."""
if not isinstance(argument_value, six.string_types):
if isinstance(argument_value, bytes): # likely to only happen in py2
argument_value = argument_value.decode("utf-8")
else:
... | [
"def",
"_safe_cypher_string",
"(",
"argument_value",
")",
":",
"if",
"not",
"isinstance",
"(",
"argument_value",
",",
"six",
".",
"string_types",
")",
":",
"if",
"isinstance",
"(",
"argument_value",
",",
"bytes",
")",
":",
"# likely to only happen in py2",
"argume... | https://github.com/kensho-technologies/graphql-compiler/blob/4318443b7b2512a059f3616112bfc40bbf8eec06/graphql_compiler/query_formatting/cypher_formatting.py#L17-L32 | |
Blizzard/heroprotocol | 3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c | heroprotocol/versions/protocol37274.py | python | decode_replay_game_events | (contents) | Decodes and yields each game event from the contents byte string. | Decodes and yields each game event from the contents byte string. | [
"Decodes",
"and",
"yields",
"each",
"game",
"event",
"from",
"the",
"contents",
"byte",
"string",
"."
] | def decode_replay_game_events(contents):
"""Decodes and yields each game event from the contents byte string."""
decoder = BitPackedDecoder(contents, typeinfos)
for event in _decode_event_stream(decoder,
game_eventid_typeid,
game_ev... | [
"def",
"decode_replay_game_events",
"(",
"contents",
")",
":",
"decoder",
"=",
"BitPackedDecoder",
"(",
"contents",
",",
"typeinfos",
")",
"for",
"event",
"in",
"_decode_event_stream",
"(",
"decoder",
",",
"game_eventid_typeid",
",",
"game_event_types",
",",
"decode... | https://github.com/Blizzard/heroprotocol/blob/3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c/heroprotocol/versions/protocol37274.py#L415-L422 | ||
lyft/cartography | 921a790d686c679ab5d8936b07e167fd424ee8d6 | cartography/driftdetect/get_states.py | python | get_query_state | (session, query_directory, state_serializer, storage, filename) | return state | Gets the most recent state of a query.
:type session: neo4j session.
:param session: neo4j session to connect to.
:type query_directory: String.
:param query_directory: Path to query directory.
:type state_serializer: Schema
:param state_serializer: Schema to serialize and deserialize states.
... | Gets the most recent state of a query. | [
"Gets",
"the",
"most",
"recent",
"state",
"of",
"a",
"query",
"."
] | def get_query_state(session, query_directory, state_serializer, storage, filename):
"""
Gets the most recent state of a query.
:type session: neo4j session.
:param session: neo4j session to connect to.
:type query_directory: String.
:param query_directory: Path to query directory.
:type sta... | [
"def",
"get_query_state",
"(",
"session",
",",
"query_directory",
",",
"state_serializer",
",",
"storage",
",",
"filename",
")",
":",
"state_data",
"=",
"storage",
".",
"load",
"(",
"os",
".",
"path",
".",
"join",
"(",
"query_directory",
",",
"\"template.json\... | https://github.com/lyft/cartography/blob/921a790d686c679ab5d8936b07e167fd424ee8d6/cartography/driftdetect/get_states.py#L93-L115 | |
SintefManufacturing/python-urx | 2250bda067d79692fb7515e78005d36aad5a0545 | tools/fakerobot.py | python | Server.init | (self) | __init__ should not be overriden | __init__ should not be overriden | [
"__init__",
"should",
"not",
"be",
"overriden"
] | def init(self):
"""
__init__ should not be overriden
"""
self.handlers = [] | [
"def",
"init",
"(",
"self",
")",
":",
"self",
".",
"handlers",
"=",
"[",
"]"
] | https://github.com/SintefManufacturing/python-urx/blob/2250bda067d79692fb7515e78005d36aad5a0545/tools/fakerobot.py#L31-L35 | ||
jazzband/tablib | 94ffe67e50eb5bfd99d73a4f010e463478a98928 | src/tablib/core.py | python | Dataset.append_separator | (self, text='-') | Adds a :ref:`separator <separators>` to the :class:`Dataset`. | Adds a :ref:`separator <separators>` to the :class:`Dataset`. | [
"Adds",
"a",
":",
"ref",
":",
"separator",
"<separators",
">",
"to",
"the",
":",
"class",
":",
"Dataset",
"."
] | def append_separator(self, text='-'):
"""Adds a :ref:`separator <separators>` to the :class:`Dataset`."""
# change offsets if headers are or aren't defined
if not self.headers:
index = self.height if self.height else 0
else:
index = (self.height + 1) if self.heig... | [
"def",
"append_separator",
"(",
"self",
",",
"text",
"=",
"'-'",
")",
":",
"# change offsets if headers are or aren't defined",
"if",
"not",
"self",
".",
"headers",
":",
"index",
"=",
"self",
".",
"height",
"if",
"self",
".",
"height",
"else",
"0",
"else",
"... | https://github.com/jazzband/tablib/blob/94ffe67e50eb5bfd99d73a4f010e463478a98928/src/tablib/core.py#L578-L587 | ||
LagoLunatic/wwrando | 33164143eb9f51c3015be3e31402a79dfcebacfd | wwlib/jpc.py | python | BSP1.read_color_table | (self, color_data_offset, color_data_count) | return color_table | [] | def read_color_table(self, color_data_offset, color_data_count):
color_table = []
for i in range(color_data_count):
keyframe_time = read_u16(self.data, color_data_offset+i*6 + 0)
r = read_u8(self.data, color_data_offset+i*6 + 2)
g = read_u8(self.data, color_data_offset+i*6 + 3)
b = read_... | [
"def",
"read_color_table",
"(",
"self",
",",
"color_data_offset",
",",
"color_data_count",
")",
":",
"color_table",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"color_data_count",
")",
":",
"keyframe_time",
"=",
"read_u16",
"(",
"self",
".",
"data",
",",
... | https://github.com/LagoLunatic/wwrando/blob/33164143eb9f51c3015be3e31402a79dfcebacfd/wwlib/jpc.py#L309-L319 | |||
vlachoudis/bCNC | 67126b4894dabf6579baf47af8d0f9b7de35e6e3 | bCNC/lib/svg_elements.py | python | Shape.__iadd__ | (self, other) | return NotImplemented | [] | def __iadd__(self, other):
if isinstance(other, Shape):
return Path(self) + Path(other)
return NotImplemented | [
"def",
"__iadd__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Shape",
")",
":",
"return",
"Path",
"(",
"self",
")",
"+",
"Path",
"(",
"other",
")",
"return",
"NotImplemented"
] | https://github.com/vlachoudis/bCNC/blob/67126b4894dabf6579baf47af8d0f9b7de35e6e3/bCNC/lib/svg_elements.py#L3174-L3177 | |||
wal-e/wal-e | 6c43976e13c619ebdddd0d869301c42ed131e983 | wal_e/log_help.py | python | WalELogger._fmt_structured | (d) | return ' '.join([timeEntry, pidEntry] + rest) | Formats '{k1:v1, k2:v2}' => 'time=... pid=... k1=v1 k2=v2'
Output is lexically sorted, *except* the time and pid always
come first, to assist with human scanning of the data. | Formats '{k1:v1, k2:v2}' => 'time=... pid=... k1=v1 k2=v2' | [
"Formats",
"{",
"k1",
":",
"v1",
"k2",
":",
"v2",
"}",
"=",
">",
"time",
"=",
"...",
"pid",
"=",
"...",
"k1",
"=",
"v1",
"k2",
"=",
"v2"
] | def _fmt_structured(d):
"""Formats '{k1:v1, k2:v2}' => 'time=... pid=... k1=v1 k2=v2'
Output is lexically sorted, *except* the time and pid always
come first, to assist with human scanning of the data.
"""
timeEntry = datetime.datetime.utcnow().strftime(
"time=%Y-%m-... | [
"def",
"_fmt_structured",
"(",
"d",
")",
":",
"timeEntry",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"strftime",
"(",
"\"time=%Y-%m-%dT%H:%M:%S.%f-00\"",
")",
"pidEntry",
"=",
"\"pid=\"",
"+",
"str",
"(",
"os",
".",
"getpid",
"(",
")"... | https://github.com/wal-e/wal-e/blob/6c43976e13c619ebdddd0d869301c42ed131e983/wal_e/log_help.py#L145-L158 | |
rucio/rucio | 6d0d358e04f5431f0b9a98ae40f31af0ddff4833 | lib/rucio/core/did.py | python | __add_files_to_dataset | (scope, name, files, account, rse_id, ignore_duplicate=False, session=None) | Add files to dataset.
:param scope: The scope name.
:param name: The data identifier name.
:param files: The list of files.
:param account: The account owner.
:param rse_id: The RSE id for the replicas.
:param ignore_duplicate: If... | Add files to dataset. | [
"Add",
"files",
"to",
"dataset",
"."
] | def __add_files_to_dataset(scope, name, files, account, rse_id, ignore_duplicate=False, session=None):
"""
Add files to dataset.
:param scope: The scope name.
:param name: The data identifier name.
:param files: The list of files.
:param account: ... | [
"def",
"__add_files_to_dataset",
"(",
"scope",
",",
"name",
",",
"files",
",",
"account",
",",
"rse_id",
",",
"ignore_duplicate",
"=",
"False",
",",
"session",
"=",
"None",
")",
":",
"# Get metadata from dataset",
"try",
":",
"dataset_meta",
"=",
"validate_name"... | https://github.com/rucio/rucio/blob/6d0d358e04f5431f0b9a98ae40f31af0ddff4833/lib/rucio/core/did.py#L359-L446 | ||
Jenyay/outwiker | 50530cf7b3f71480bb075b2829bc0669773b835b | src/outwiker/gui/controls/ultimatelistctrl.py | python | UltimateListMainWindow.GetItemVisited | (self, item) | return item.GetVisited() | Returns whether an hypertext item was visited.
:param `item`: an instance of :class:`UltimateListItem`. | Returns whether an hypertext item was visited. | [
"Returns",
"whether",
"an",
"hypertext",
"item",
"was",
"visited",
"."
] | def GetItemVisited(self, item):
"""
Returns whether an hypertext item was visited.
:param `item`: an instance of :class:`UltimateListItem`.
"""
item = self.GetItem(item, item._col)
return item.GetVisited() | [
"def",
"GetItemVisited",
"(",
"self",
",",
"item",
")",
":",
"item",
"=",
"self",
".",
"GetItem",
"(",
"item",
",",
"item",
".",
"_col",
")",
"return",
"item",
".",
"GetVisited",
"(",
")"
] | https://github.com/Jenyay/outwiker/blob/50530cf7b3f71480bb075b2829bc0669773b835b/src/outwiker/gui/controls/ultimatelistctrl.py#L9230-L9238 | |
bitcoin-core/HWI | 6871946c2176f2f9777b6ac8f0614d96d99bfa0e | hwilib/_gui.py | python | BitBox02NoiseConfig.show_pairing | (self, code: str, device_response: Callable[[], bool]) | return dialog.result() == QDialog.Accepted | [] | def show_pairing(self, code: str, device_response: Callable[[], bool]) -> bool:
dialog = BitBox02PairingDialog(code, device_response)
dialog.show()
# render the window since the next operation is blocking
while True:
QCoreApplication.processEvents()
if dialog.pain... | [
"def",
"show_pairing",
"(",
"self",
",",
"code",
":",
"str",
",",
"device_response",
":",
"Callable",
"[",
"[",
"]",
",",
"bool",
"]",
")",
"->",
"bool",
":",
"dialog",
"=",
"BitBox02PairingDialog",
"(",
"code",
",",
"device_response",
")",
"dialog",
"."... | https://github.com/bitcoin-core/HWI/blob/6871946c2176f2f9777b6ac8f0614d96d99bfa0e/hwilib/_gui.py#L246-L259 | |||
ubuntu/microk8s | 9d61706b8cee7476e66093bb60ebea2c81bc3723 | scripts/wrappers/common/utils.py | python | xable | (action: str, addons: list, xabled_addons: list) | Enables or disables the given addons.
Collated into a single function since the logic is identical other than
the script names. | Enables or disables the given addons. | [
"Enables",
"or",
"disables",
"the",
"given",
"addons",
"."
] | def xable(action: str, addons: list, xabled_addons: list):
"""Enables or disables the given addons.
Collated into a single function since the logic is identical other than
the script names.
"""
actions = Path(__file__).absolute().parent / "../../../actions"
existing_addons = {sh.with_suffix("")... | [
"def",
"xable",
"(",
"action",
":",
"str",
",",
"addons",
":",
"list",
",",
"xabled_addons",
":",
"list",
")",
":",
"actions",
"=",
"Path",
"(",
"__file__",
")",
".",
"absolute",
"(",
")",
".",
"parent",
"/",
"\"../../../actions\"",
"existing_addons",
"=... | https://github.com/ubuntu/microk8s/blob/9d61706b8cee7476e66093bb60ebea2c81bc3723/scripts/wrappers/common/utils.py#L243-L300 | ||
plone/guillotina | 57ad54988f797a93630e424fd4b6a75fa26410af | guillotina/utils/execute.py | python | in_queue | (func: Callable[..., Coroutine[Any, Any, Any]], *args, **kwargs) | return ExecuteContext(util.add, partial(func, *args, **kwargs)) | Execute view-type object(context, request) in the async queue.
:param view: view to be queued
:rtype: ExecuteContext | Execute view-type object(context, request) in the async queue. | [
"Execute",
"view",
"-",
"type",
"object",
"(",
"context",
"request",
")",
"in",
"the",
"async",
"queue",
"."
] | def in_queue(func: Callable[..., Coroutine[Any, Any, Any]], *args, **kwargs) -> ExecuteContext:
"""
Execute view-type object(context, request) in the async queue.
:param view: view to be queued
:rtype: ExecuteContext
"""
util = get_utility(IQueueUtility)
return ExecuteContext(util.add, par... | [
"def",
"in_queue",
"(",
"func",
":",
"Callable",
"[",
"...",
",",
"Coroutine",
"[",
"Any",
",",
"Any",
",",
"Any",
"]",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"ExecuteContext",
":",
"util",
"=",
"get_utility",
"(",
"IQueueUtility"... | https://github.com/plone/guillotina/blob/57ad54988f797a93630e424fd4b6a75fa26410af/guillotina/utils/execute.py#L59-L68 | |
KhronosGroup/NNEF-Tools | c913758ca687dab8cb7b49e8f1556819a2d0ca25 | nnef_tools/optimization/nnef_optimizer.py | python | Optimizer._merge_linear_mul | (linear, mul) | [] | def _merge_linear_mul(linear, mul):
variable = mul.inputs[1] if mul.inputs[0] == linear.output else mul.inputs[0]
if variable.data is None or not Optimizer._is_channelwise_shape(variable.shape):
return False
if len(variable.shape) == 0:
scale = np.expand_dims(variable.da... | [
"def",
"_merge_linear_mul",
"(",
"linear",
",",
"mul",
")",
":",
"variable",
"=",
"mul",
".",
"inputs",
"[",
"1",
"]",
"if",
"mul",
".",
"inputs",
"[",
"0",
"]",
"==",
"linear",
".",
"output",
"else",
"mul",
".",
"inputs",
"[",
"0",
"]",
"if",
"v... | https://github.com/KhronosGroup/NNEF-Tools/blob/c913758ca687dab8cb7b49e8f1556819a2d0ca25/nnef_tools/optimization/nnef_optimizer.py#L373-L405 | ||||
DamnWidget/anaconda | a9998fb362320f907d5ccbc6fcf5b62baca677c0 | anaconda_lib/linting/sublime.py | python | Linter.is_that_code | (self, point) | return self.view.match_selector(point, matcher) | Determines if the given region is valid Python code | Determines if the given region is valid Python code | [
"Determines",
"if",
"the",
"given",
"region",
"is",
"valid",
"Python",
"code"
] | def is_that_code(self, point):
"""Determines if the given region is valid Python code
"""
matcher = 'source.python - string - comment'
return self.view.match_selector(point, matcher) | [
"def",
"is_that_code",
"(",
"self",
",",
"point",
")",
":",
"matcher",
"=",
"'source.python - string - comment'",
"return",
"self",
".",
"view",
".",
"match_selector",
"(",
"point",
",",
"matcher",
")"
] | https://github.com/DamnWidget/anaconda/blob/a9998fb362320f907d5ccbc6fcf5b62baca677c0/anaconda_lib/linting/sublime.py#L113-L118 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.