partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Vim.command | Execute command on *Vim*.
.. warning:: Do not use ``redir`` command if ``capture`` is ``True``.
It's already enabled for internal use.
If ``capture`` argument is set ``False``,
the command execution becomes slightly faster.
Example:
>>> import headlessvim
>>> w... | headlessvim/__init__.py | def command(self, command, capture=True):
"""
Execute command on *Vim*.
.. warning:: Do not use ``redir`` command if ``capture`` is ``True``.
It's already enabled for internal use.
If ``capture`` argument is set ``False``,
the command execution becomes slightly faster.
... | def command(self, command, capture=True):
"""
Execute command on *Vim*.
.. warning:: Do not use ``redir`` command if ``capture`` is ``True``.
It's already enabled for internal use.
If ``capture`` argument is set ``False``,
the command execution becomes slightly faster.
... | [
"Execute",
"command",
"on",
"*",
"Vim",
"*",
".",
"..",
"warning",
"::",
"Do",
"not",
"use",
"redir",
"command",
"if",
"capture",
"is",
"True",
".",
"It",
"s",
"already",
"enabled",
"for",
"internal",
"use",
"."
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L207-L241 | [
"def",
"command",
"(",
"self",
",",
"command",
",",
"capture",
"=",
"True",
")",
":",
"if",
"capture",
":",
"self",
".",
"command",
"(",
"'redir! >> {0}'",
".",
"format",
"(",
"self",
".",
"_tempfile",
".",
"name",
")",
",",
"False",
")",
"self",
"."... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.set_mode | Set *Vim* mode to ``mode``.
Supported modes:
* ``normal``
* ``insert``
* ``command``
* ``visual``
* ``visual-block``
This method behave as setter-only property.
Example:
>>> import headlessvim
>>> with headlessvim.open() as vim:
... | headlessvim/__init__.py | def set_mode(self, mode):
"""
Set *Vim* mode to ``mode``.
Supported modes:
* ``normal``
* ``insert``
* ``command``
* ``visual``
* ``visual-block``
This method behave as setter-only property.
Example:
>>> import headlessvim
... | def set_mode(self, mode):
"""
Set *Vim* mode to ``mode``.
Supported modes:
* ``normal``
* ``insert``
* ``command``
* ``visual``
* ``visual-block``
This method behave as setter-only property.
Example:
>>> import headlessvim
... | [
"Set",
"*",
"Vim",
"*",
"mode",
"to",
"mode",
".",
"Supported",
"modes",
":"
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L268-L306 | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
")",
":",
"keys",
"=",
"'\\033\\033'",
"if",
"mode",
"==",
"'normal'",
":",
"pass",
"elif",
"mode",
"==",
"'insert'",
":",
"keys",
"+=",
"'i'",
"elif",
"mode",
"==",
"'command'",
":",
"keys",
"+=",
"':'",
... | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.screen_size | :param size: (lines, columns) tuple of a screen connected to *Vim*.
:type size: (int, int) | headlessvim/__init__.py | def screen_size(self, size):
"""
:param size: (lines, columns) tuple of a screen connected to *Vim*.
:type size: (int, int)
"""
if self.screen_size != size:
self._screen.resize(*self._swap(size)) | def screen_size(self, size):
"""
:param size: (lines, columns) tuple of a screen connected to *Vim*.
:type size: (int, int)
"""
if self.screen_size != size:
self._screen.resize(*self._swap(size)) | [
":",
"param",
"size",
":",
"(",
"lines",
"columns",
")",
"tuple",
"of",
"a",
"screen",
"connected",
"to",
"*",
"Vim",
"*",
".",
":",
"type",
"size",
":",
"(",
"int",
"int",
")"
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L341-L347 | [
"def",
"screen_size",
"(",
"self",
",",
"size",
")",
":",
"if",
"self",
".",
"screen_size",
"!=",
"size",
":",
"self",
".",
"_screen",
".",
"resize",
"(",
"*",
"self",
".",
"_swap",
"(",
"size",
")",
")"
] | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | Vim.runtimepath | :return: runtime path of *Vim*
:rtype: runtimepath.RuntimePath | headlessvim/__init__.py | def runtimepath(self):
"""
:return: runtime path of *Vim*
:rtype: runtimepath.RuntimePath
"""
if self._runtimepath is None:
self._runtimepath = runtimepath.RuntimePath(self)
return self._runtimepath | def runtimepath(self):
"""
:return: runtime path of *Vim*
:rtype: runtimepath.RuntimePath
"""
if self._runtimepath is None:
self._runtimepath = runtimepath.RuntimePath(self)
return self._runtimepath | [
":",
"return",
":",
"runtime",
"path",
"of",
"*",
"Vim",
"*",
":",
"rtype",
":",
"runtimepath",
".",
"RuntimePath"
] | manicmaniac/headlessvim | python | https://github.com/manicmaniac/headlessvim/blob/3e4657f95d981ddf21fd285b7e1b9da2154f9cb9/headlessvim/__init__.py#L365-L372 | [
"def",
"runtimepath",
"(",
"self",
")",
":",
"if",
"self",
".",
"_runtimepath",
"is",
"None",
":",
"self",
".",
"_runtimepath",
"=",
"runtimepath",
".",
"RuntimePath",
"(",
"self",
")",
"return",
"self",
".",
"_runtimepath"
] | 3e4657f95d981ddf21fd285b7e1b9da2154f9cb9 |
valid | make_seekable | If the file-object is not seekable, return ArchiveTemp of the fileobject,
otherwise return the file-object itself | destream/helpers.py | def make_seekable(fileobj):
"""
If the file-object is not seekable, return ArchiveTemp of the fileobject,
otherwise return the file-object itself
"""
if sys.version_info < (3, 0) and isinstance(fileobj, file):
filename = fileobj.name
fileobj = io.FileIO(fileobj.fileno(), closefd=Fal... | def make_seekable(fileobj):
"""
If the file-object is not seekable, return ArchiveTemp of the fileobject,
otherwise return the file-object itself
"""
if sys.version_info < (3, 0) and isinstance(fileobj, file):
filename = fileobj.name
fileobj = io.FileIO(fileobj.fileno(), closefd=Fal... | [
"If",
"the",
"file",
"-",
"object",
"is",
"not",
"seekable",
"return",
"ArchiveTemp",
"of",
"the",
"fileobject",
"otherwise",
"return",
"the",
"file",
"-",
"object",
"itself"
] | cecton/destream | python | https://github.com/cecton/destream/blob/a9e12b4ac7d41bcd9af54a820c235d77a68a9b8c/destream/helpers.py#L57-L70 | [
"def",
"make_seekable",
"(",
"fileobj",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
"and",
"isinstance",
"(",
"fileobj",
",",
"file",
")",
":",
"filename",
"=",
"fileobj",
".",
"name",
"fileobj",
"=",
"io",
".",
"FileIO"... | a9e12b4ac7d41bcd9af54a820c235d77a68a9b8c |
valid | Tracy.init_app | Setup before_request, after_request handlers for tracing. | flask_tracy/base.py | def init_app(self, app):
"""Setup before_request, after_request handlers for tracing.
"""
app.config.setdefault("TRACY_REQUIRE_CLIENT", False)
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['restpoints'] = self
app.before_request(self._... | def init_app(self, app):
"""Setup before_request, after_request handlers for tracing.
"""
app.config.setdefault("TRACY_REQUIRE_CLIENT", False)
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['restpoints'] = self
app.before_request(self._... | [
"Setup",
"before_request",
"after_request",
"handlers",
"for",
"tracing",
"."
] | juztin/flask-tracy | python | https://github.com/juztin/flask-tracy/blob/8a43094f0fced3c216f7b65ad6c5c7a22c14ea25/flask_tracy/base.py#L48-L57 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"\"TRACY_REQUIRE_CLIENT\"",
",",
"False",
")",
"if",
"not",
"hasattr",
"(",
"app",
",",
"'extensions'",
")",
":",
"app",
".",
"extensions",
"=",
"{",
"}... | 8a43094f0fced3c216f7b65ad6c5c7a22c14ea25 |
valid | Tracy._before | Records the starting time of this reqeust. | flask_tracy/base.py | def _before(self):
"""Records the starting time of this reqeust.
"""
# Don't trace excluded routes.
if request.path in self.excluded_routes:
request._tracy_exclude = True
return
request._tracy_start_time = monotonic()
client = request.headers.get(... | def _before(self):
"""Records the starting time of this reqeust.
"""
# Don't trace excluded routes.
if request.path in self.excluded_routes:
request._tracy_exclude = True
return
request._tracy_start_time = monotonic()
client = request.headers.get(... | [
"Records",
"the",
"starting",
"time",
"of",
"this",
"reqeust",
"."
] | juztin/flask-tracy | python | https://github.com/juztin/flask-tracy/blob/8a43094f0fced3c216f7b65ad6c5c7a22c14ea25/flask_tracy/base.py#L59-L74 | [
"def",
"_before",
"(",
"self",
")",
":",
"# Don't trace excluded routes.",
"if",
"request",
".",
"path",
"in",
"self",
".",
"excluded_routes",
":",
"request",
".",
"_tracy_exclude",
"=",
"True",
"return",
"request",
".",
"_tracy_start_time",
"=",
"monotonic",
"(... | 8a43094f0fced3c216f7b65ad6c5c7a22c14ea25 |
valid | Tracy._after | Calculates the request duration, and adds a transaction
ID to the header. | flask_tracy/base.py | def _after(self, response):
"""Calculates the request duration, and adds a transaction
ID to the header.
"""
# Ignore excluded routes.
if getattr(request, '_tracy_exclude', False):
return response
duration = None
if getattr(request, '_tracy_start_time... | def _after(self, response):
"""Calculates the request duration, and adds a transaction
ID to the header.
"""
# Ignore excluded routes.
if getattr(request, '_tracy_exclude', False):
return response
duration = None
if getattr(request, '_tracy_start_time... | [
"Calculates",
"the",
"request",
"duration",
"and",
"adds",
"a",
"transaction",
"ID",
"to",
"the",
"header",
"."
] | juztin/flask-tracy | python | https://github.com/juztin/flask-tracy/blob/8a43094f0fced3c216f7b65ad6c5c7a22c14ea25/flask_tracy/base.py#L76-L107 | [
"def",
"_after",
"(",
"self",
",",
"response",
")",
":",
"# Ignore excluded routes.",
"if",
"getattr",
"(",
"request",
",",
"'_tracy_exclude'",
",",
"False",
")",
":",
"return",
"response",
"duration",
"=",
"None",
"if",
"getattr",
"(",
"request",
",",
"'_tr... | 8a43094f0fced3c216f7b65ad6c5c7a22c14ea25 |
valid | Http.close | Close the http/https connect. | arguspy/http_requests.py | def close(self):
"""Close the http/https connect."""
try:
self.response.close()
self.logger.debug("close connect succeed.")
except Exception as e:
self.unknown("close connect error: %s" % e) | def close(self):
"""Close the http/https connect."""
try:
self.response.close()
self.logger.debug("close connect succeed.")
except Exception as e:
self.unknown("close connect error: %s" % e) | [
"Close",
"the",
"http",
"/",
"https",
"connect",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/http_requests.py#L61-L67 | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"response",
".",
"close",
"(",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"close connect succeed.\"",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"unknown",
"(",
"\"clos... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | FileSystemOverlay._stat | IMPORTANT: expects `path`'s parent to already be deref()'erenced. | fso/filesystemoverlay.py | def _stat(self, path):
'''IMPORTANT: expects `path`'s parent to already be deref()'erenced.'''
if path not in self.entries:
return OverlayStat(*self.originals['os:stat'](path)[:10], st_overlay=0)
st = self.entries[path].stat
if stat.S_ISLNK(st.st_mode):
return self._stat(self.deref(path))
... | def _stat(self, path):
'''IMPORTANT: expects `path`'s parent to already be deref()'erenced.'''
if path not in self.entries:
return OverlayStat(*self.originals['os:stat'](path)[:10], st_overlay=0)
st = self.entries[path].stat
if stat.S_ISLNK(st.st_mode):
return self._stat(self.deref(path))
... | [
"IMPORTANT",
":",
"expects",
"path",
"s",
"parent",
"to",
"already",
"be",
"deref",
"()",
"erenced",
"."
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L321-L328 | [
"def",
"_stat",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"entries",
":",
"return",
"OverlayStat",
"(",
"*",
"self",
".",
"originals",
"[",
"'os:stat'",
"]",
"(",
"path",
")",
"[",
":",
"10",
"]",
",",
"st_overlay"... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay._lstat | IMPORTANT: expects `path`'s parent to already be deref()'erenced. | fso/filesystemoverlay.py | def _lstat(self, path):
'''IMPORTANT: expects `path`'s parent to already be deref()'erenced.'''
if path not in self.entries:
return OverlayStat(*self.originals['os:lstat'](path)[:10], st_overlay=0)
return self.entries[path].stat | def _lstat(self, path):
'''IMPORTANT: expects `path`'s parent to already be deref()'erenced.'''
if path not in self.entries:
return OverlayStat(*self.originals['os:lstat'](path)[:10], st_overlay=0)
return self.entries[path].stat | [
"IMPORTANT",
":",
"expects",
"path",
"s",
"parent",
"to",
"already",
"be",
"deref",
"()",
"erenced",
"."
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L331-L335 | [
"def",
"_lstat",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"not",
"in",
"self",
".",
"entries",
":",
"return",
"OverlayStat",
"(",
"*",
"self",
".",
"originals",
"[",
"'os:lstat'",
"]",
"(",
"path",
")",
"[",
":",
"10",
"]",
",",
"st_overla... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay._exists | IMPORTANT: expects `path` to already be deref()'erenced. | fso/filesystemoverlay.py | def _exists(self, path):
'''IMPORTANT: expects `path` to already be deref()'erenced.'''
try:
return bool(self._stat(path))
except os.error:
return False | def _exists(self, path):
'''IMPORTANT: expects `path` to already be deref()'erenced.'''
try:
return bool(self._stat(path))
except os.error:
return False | [
"IMPORTANT",
":",
"expects",
"path",
"to",
"already",
"be",
"deref",
"()",
"erenced",
"."
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L366-L371 | [
"def",
"_exists",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"bool",
"(",
"self",
".",
"_stat",
"(",
"path",
")",
")",
"except",
"os",
".",
"error",
":",
"return",
"False"
] | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay._lexists | IMPORTANT: expects `path` to already be deref()'erenced. | fso/filesystemoverlay.py | def _lexists(self, path):
'''IMPORTANT: expects `path` to already be deref()'erenced.'''
try:
return bool(self._lstat(path))
except os.error:
return False | def _lexists(self, path):
'''IMPORTANT: expects `path` to already be deref()'erenced.'''
try:
return bool(self._lstat(path))
except os.error:
return False | [
"IMPORTANT",
":",
"expects",
"path",
"to",
"already",
"be",
"deref",
"()",
"erenced",
"."
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L374-L379 | [
"def",
"_lexists",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"bool",
"(",
"self",
".",
"_lstat",
"(",
"path",
")",
")",
"except",
"os",
".",
"error",
":",
"return",
"False"
] | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_exists | overlays os.path.exists() | fso/filesystemoverlay.py | def fso_exists(self, path):
'overlays os.path.exists()'
try:
return self._exists(self.deref(path))
except os.error:
return False | def fso_exists(self, path):
'overlays os.path.exists()'
try:
return self._exists(self.deref(path))
except os.error:
return False | [
"overlays",
"os",
".",
"path",
".",
"exists",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L382-L387 | [
"def",
"fso_exists",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"self",
".",
"_exists",
"(",
"self",
".",
"deref",
"(",
"path",
")",
")",
"except",
"os",
".",
"error",
":",
"return",
"False"
] | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_lexists | overlays os.path.lexists() | fso/filesystemoverlay.py | def fso_lexists(self, path):
'overlays os.path.lexists()'
try:
return self._lexists(self.deref(path, to_parent=True))
except os.error:
return False | def fso_lexists(self, path):
'overlays os.path.lexists()'
try:
return self._lexists(self.deref(path, to_parent=True))
except os.error:
return False | [
"overlays",
"os",
".",
"path",
".",
"lexists",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L390-L395 | [
"def",
"fso_lexists",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"self",
".",
"_lexists",
"(",
"self",
".",
"deref",
"(",
"path",
",",
"to_parent",
"=",
"True",
")",
")",
"except",
"os",
".",
"error",
":",
"return",
"False"
] | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_listdir | overlays os.listdir() | fso/filesystemoverlay.py | def fso_listdir(self, path):
'overlays os.listdir()'
path = self.deref(path)
if not stat.S_ISDIR(self._stat(path).st_mode):
raise OSError(20, 'Not a directory', path)
try:
ret = self.originals['os:listdir'](path)
except Exception:
# assuming that `path` was created within this FSO.... | def fso_listdir(self, path):
'overlays os.listdir()'
path = self.deref(path)
if not stat.S_ISDIR(self._stat(path).st_mode):
raise OSError(20, 'Not a directory', path)
try:
ret = self.originals['os:listdir'](path)
except Exception:
# assuming that `path` was created within this FSO.... | [
"overlays",
"os",
".",
"listdir",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L412-L434 | [
"def",
"fso_listdir",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"deref",
"(",
"path",
")",
"if",
"not",
"stat",
".",
"S_ISDIR",
"(",
"self",
".",
"_stat",
"(",
"path",
")",
".",
"st_mode",
")",
":",
"raise",
"OSError",
"(",
"2... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_mkdir | overlays os.mkdir() | fso/filesystemoverlay.py | def fso_mkdir(self, path, mode=None):
'overlays os.mkdir()'
path = self.deref(path, to_parent=True)
if self._lexists(path):
raise OSError(17, 'File exists', path)
self._addentry(OverlayEntry(self, path, stat.S_IFDIR)) | def fso_mkdir(self, path, mode=None):
'overlays os.mkdir()'
path = self.deref(path, to_parent=True)
if self._lexists(path):
raise OSError(17, 'File exists', path)
self._addentry(OverlayEntry(self, path, stat.S_IFDIR)) | [
"overlays",
"os",
".",
"mkdir",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L437-L442 | [
"def",
"fso_mkdir",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
")",
":",
"path",
"=",
"self",
".",
"deref",
"(",
"path",
",",
"to_parent",
"=",
"True",
")",
"if",
"self",
".",
"_lexists",
"(",
"path",
")",
":",
"raise",
"OSError",
"(",
"... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_makedirs | overlays os.makedirs() | fso/filesystemoverlay.py | def fso_makedirs(self, path, mode=None):
'overlays os.makedirs()'
path = self.abs(path)
cur = '/'
segments = path.split('/')
for idx, seg in enumerate(segments):
cur = os.path.join(cur, seg)
try:
st = self.fso_stat(cur)
except OSError:
st = None
if st is None:... | def fso_makedirs(self, path, mode=None):
'overlays os.makedirs()'
path = self.abs(path)
cur = '/'
segments = path.split('/')
for idx, seg in enumerate(segments):
cur = os.path.join(cur, seg)
try:
st = self.fso_stat(cur)
except OSError:
st = None
if st is None:... | [
"overlays",
"os",
".",
"makedirs",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L445-L462 | [
"def",
"fso_makedirs",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"None",
")",
":",
"path",
"=",
"self",
".",
"abs",
"(",
"path",
")",
"cur",
"=",
"'/'",
"segments",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"for",
"idx",
",",
"seg",
"in",
"... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_rmdir | overlays os.rmdir() | fso/filesystemoverlay.py | def fso_rmdir(self, path):
'overlays os.rmdir()'
st = self.fso_lstat(path)
if not stat.S_ISDIR(st.st_mode):
raise OSError(20, 'Not a directory', path)
if len(self.fso_listdir(path)) > 0:
raise OSError(39, 'Directory not empty', path)
self._addentry(OverlayEntry(self, path, None)) | def fso_rmdir(self, path):
'overlays os.rmdir()'
st = self.fso_lstat(path)
if not stat.S_ISDIR(st.st_mode):
raise OSError(20, 'Not a directory', path)
if len(self.fso_listdir(path)) > 0:
raise OSError(39, 'Directory not empty', path)
self._addentry(OverlayEntry(self, path, None)) | [
"overlays",
"os",
".",
"rmdir",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L465-L472 | [
"def",
"fso_rmdir",
"(",
"self",
",",
"path",
")",
":",
"st",
"=",
"self",
".",
"fso_lstat",
"(",
"path",
")",
"if",
"not",
"stat",
".",
"S_ISDIR",
"(",
"st",
".",
"st_mode",
")",
":",
"raise",
"OSError",
"(",
"20",
",",
"'Not a directory'",
",",
"... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_readlink | overlays os.readlink() | fso/filesystemoverlay.py | def fso_readlink(self, path):
'overlays os.readlink()'
path = self.deref(path, to_parent=True)
st = self.fso_lstat(path)
if not stat.S_ISLNK(st.st_mode):
raise OSError(22, 'Invalid argument', path)
if st.st_overlay:
return self.entries[path].content
return self.originals['os:readlink... | def fso_readlink(self, path):
'overlays os.readlink()'
path = self.deref(path, to_parent=True)
st = self.fso_lstat(path)
if not stat.S_ISLNK(st.st_mode):
raise OSError(22, 'Invalid argument', path)
if st.st_overlay:
return self.entries[path].content
return self.originals['os:readlink... | [
"overlays",
"os",
".",
"readlink",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L475-L483 | [
"def",
"fso_readlink",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"deref",
"(",
"path",
",",
"to_parent",
"=",
"True",
")",
"st",
"=",
"self",
".",
"fso_lstat",
"(",
"path",
")",
"if",
"not",
"stat",
".",
"S_ISLNK",
"(",
"st",
... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_symlink | overlays os.symlink() | fso/filesystemoverlay.py | def fso_symlink(self, source, link_name):
'overlays os.symlink()'
path = self.deref(link_name, to_parent=True)
if self._exists(path):
raise OSError(17, 'File exists')
self._addentry(OverlayEntry(self, path, stat.S_IFLNK, source)) | def fso_symlink(self, source, link_name):
'overlays os.symlink()'
path = self.deref(link_name, to_parent=True)
if self._exists(path):
raise OSError(17, 'File exists')
self._addentry(OverlayEntry(self, path, stat.S_IFLNK, source)) | [
"overlays",
"os",
".",
"symlink",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L486-L491 | [
"def",
"fso_symlink",
"(",
"self",
",",
"source",
",",
"link_name",
")",
":",
"path",
"=",
"self",
".",
"deref",
"(",
"link_name",
",",
"to_parent",
"=",
"True",
")",
"if",
"self",
".",
"_exists",
"(",
"path",
")",
":",
"raise",
"OSError",
"(",
"17",... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_unlink | overlays os.unlink() | fso/filesystemoverlay.py | def fso_unlink(self, path):
'overlays os.unlink()'
path = self.deref(path, to_parent=True)
if not self._lexists(path):
raise OSError(2, 'No such file or directory', path)
self._addentry(OverlayEntry(self, path, None)) | def fso_unlink(self, path):
'overlays os.unlink()'
path = self.deref(path, to_parent=True)
if not self._lexists(path):
raise OSError(2, 'No such file or directory', path)
self._addentry(OverlayEntry(self, path, None)) | [
"overlays",
"os",
".",
"unlink",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L494-L499 | [
"def",
"fso_unlink",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"deref",
"(",
"path",
",",
"to_parent",
"=",
"True",
")",
"if",
"not",
"self",
".",
"_lexists",
"(",
"path",
")",
":",
"raise",
"OSError",
"(",
"2",
",",
"'No such f... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_islink | overlays os.path.islink() | fso/filesystemoverlay.py | def fso_islink(self, path):
'overlays os.path.islink()'
try:
return stat.S_ISLNK(self.fso_lstat(path).st_mode)
except OSError:
return False | def fso_islink(self, path):
'overlays os.path.islink()'
try:
return stat.S_ISLNK(self.fso_lstat(path).st_mode)
except OSError:
return False | [
"overlays",
"os",
".",
"path",
".",
"islink",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L507-L512 | [
"def",
"fso_islink",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"return",
"stat",
".",
"S_ISLNK",
"(",
"self",
".",
"fso_lstat",
"(",
"path",
")",
".",
"st_mode",
")",
"except",
"OSError",
":",
"return",
"False"
] | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | FileSystemOverlay.fso_rmtree | overlays shutil.rmtree() | fso/filesystemoverlay.py | def fso_rmtree(self, path, ignore_errors=False, onerror=None):
'overlays shutil.rmtree()'
if ignore_errors:
def onerror(*args):
pass
elif onerror is None:
def onerror(*args):
raise
try:
if self.fso_islink(path):
# symlinks to directories are forbidden, see shuti... | def fso_rmtree(self, path, ignore_errors=False, onerror=None):
'overlays shutil.rmtree()'
if ignore_errors:
def onerror(*args):
pass
elif onerror is None:
def onerror(*args):
raise
try:
if self.fso_islink(path):
# symlinks to directories are forbidden, see shuti... | [
"overlays",
"shutil",
".",
"rmtree",
"()"
] | metagriffin/fso | python | https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L515-L552 | [
"def",
"fso_rmtree",
"(",
"self",
",",
"path",
",",
"ignore_errors",
"=",
"False",
",",
"onerror",
"=",
"None",
")",
":",
"if",
"ignore_errors",
":",
"def",
"onerror",
"(",
"*",
"args",
")",
":",
"pass",
"elif",
"onerror",
"is",
"None",
":",
"def",
"... | c37701fbfdfde359a2044eb9420abe569a7b35e4 |
valid | MWAPIWrapper | MWAPIWrapper 控制API请求异常的装饰器
根据requests库定义的异常来控制请求返回的意外情况 | moebot/__init__.py | def MWAPIWrapper(func):
"""
MWAPIWrapper 控制API请求异常的装饰器
根据requests库定义的异常来控制请求返回的意外情况
"""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
try:
result = func(*args, **kwargs)
return result
except ConnectionError:
err_title = '连接错... | def MWAPIWrapper(func):
"""
MWAPIWrapper 控制API请求异常的装饰器
根据requests库定义的异常来控制请求返回的意外情况
"""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
try:
result = func(*args, **kwargs)
return result
except ConnectionError:
err_title = '连接错... | [
"MWAPIWrapper",
"控制API请求异常的装饰器",
"根据requests库定义的异常来控制请求返回的意外情况"
] | grzhan/moebot | python | https://github.com/grzhan/moebot/blob/2591626b568bf9988940144984d4b2e954def966/moebot/__init__.py#L48-L91 | [
"def",
"MWAPIWrapper",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"try",
":",
"result",
"=",
"func",
"(",
"*",
"args",
",",
... | 2591626b568bf9988940144984d4b2e954def966 |
valid | FormatBlock.expand_words | Insert spaces between words until it is wide enough for `width`. | fmtblock/formatters.py | def expand_words(self, line, width=60):
""" Insert spaces between words until it is wide enough for `width`.
"""
if not line.strip():
return line
# Word index, which word to insert on (cycles between 1->len(words))
wordi = 1
while len(strip_codes(line)) < widt... | def expand_words(self, line, width=60):
""" Insert spaces between words until it is wide enough for `width`.
"""
if not line.strip():
return line
# Word index, which word to insert on (cycles between 1->len(words))
wordi = 1
while len(strip_codes(line)) < widt... | [
"Insert",
"spaces",
"between",
"words",
"until",
"it",
"is",
"wide",
"enough",
"for",
"width",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L24-L47 | [
"def",
"expand_words",
"(",
"self",
",",
"line",
",",
"width",
"=",
"60",
")",
":",
"if",
"not",
"line",
".",
"strip",
"(",
")",
":",
"return",
"line",
"# Word index, which word to insert on (cycles between 1->len(words))",
"wordi",
"=",
"1",
"while",
"len",
"... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.find_word_end | This is a helper method for self.expand_words().
Finds the index of word endings (default is first word).
The last word doesn't count.
If there are no words, or there are no spaces in the word, it
returns -1.
This method ignores escape codes.
Exam... | fmtblock/formatters.py | def find_word_end(text, count=1):
""" This is a helper method for self.expand_words().
Finds the index of word endings (default is first word).
The last word doesn't count.
If there are no words, or there are no spaces in the word, it
returns -1.
This... | def find_word_end(text, count=1):
""" This is a helper method for self.expand_words().
Finds the index of word endings (default is first word).
The last word doesn't count.
If there are no words, or there are no spaces in the word, it
returns -1.
This... | [
"This",
"is",
"a",
"helper",
"method",
"for",
"self",
".",
"expand_words",
"()",
".",
"Finds",
"the",
"index",
"of",
"word",
"endings",
"(",
"default",
"is",
"first",
"word",
")",
".",
"The",
"last",
"word",
"doesn",
"t",
"count",
".",
"If",
"there",
... | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L50-L117 | [
"def",
"find_word_end",
"(",
"text",
",",
"count",
"=",
"1",
")",
":",
"if",
"not",
"text",
":",
"return",
"-",
"1",
"elif",
"' '",
"not",
"in",
"text",
":",
"return",
"0",
"elif",
"not",
"text",
".",
"strip",
"(",
")",
":",
"return",
"-",
"1",
... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.format | Format a long string into a block of newline seperated text.
Arguments:
See iter_format_block(). | fmtblock/formatters.py | def format(
self, text=None,
width=60, chars=False, fill=False, newlines=False,
prepend=None, append=None, strip_first=False, strip_last=False,
lstrip=False):
""" Format a long string into a block of newline seperated text.
Arguments:
S... | def format(
self, text=None,
width=60, chars=False, fill=False, newlines=False,
prepend=None, append=None, strip_first=False, strip_last=False,
lstrip=False):
""" Format a long string into a block of newline seperated text.
Arguments:
S... | [
"Format",
"a",
"long",
"string",
"into",
"a",
"block",
"of",
"newline",
"seperated",
"text",
".",
"Arguments",
":",
"See",
"iter_format_block",
"()",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L119-L142 | [
"def",
"format",
"(",
"self",
",",
"text",
"=",
"None",
",",
"width",
"=",
"60",
",",
"chars",
"=",
"False",
",",
"fill",
"=",
"False",
",",
"newlines",
"=",
"False",
",",
"prepend",
"=",
"None",
",",
"append",
"=",
"None",
",",
"strip_first",
"=",... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.iter_add_text | Prepend or append text to lines. Yields each line. | fmtblock/formatters.py | def iter_add_text(self, lines, prepend=None, append=None):
""" Prepend or append text to lines. Yields each line. """
if (prepend is None) and (append is None):
yield from lines
else:
# Build up a format string, with optional {prepend}/{append}
fmtpcs = ['{pre... | def iter_add_text(self, lines, prepend=None, append=None):
""" Prepend or append text to lines. Yields each line. """
if (prepend is None) and (append is None):
yield from lines
else:
# Build up a format string, with optional {prepend}/{append}
fmtpcs = ['{pre... | [
"Prepend",
"or",
"append",
"text",
"to",
"lines",
".",
"Yields",
"each",
"line",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L144-L158 | [
"def",
"iter_add_text",
"(",
"self",
",",
"lines",
",",
"prepend",
"=",
"None",
",",
"append",
"=",
"None",
")",
":",
"if",
"(",
"prepend",
"is",
"None",
")",
"and",
"(",
"append",
"is",
"None",
")",
":",
"yield",
"from",
"lines",
"else",
":",
"# B... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.iter_block | Iterator that turns a long string into lines no greater than
'width' in length.
It can wrap on spaces or characters. It only does basic blocks.
For prepending see `iter_format_block()`.
Arguments:
text : String to format.
width : Ma... | fmtblock/formatters.py | def iter_block(
self, text=None,
width=60, chars=False, newlines=False, lstrip=False):
""" Iterator that turns a long string into lines no greater than
'width' in length.
It can wrap on spaces or characters. It only does basic blocks.
For prepending se... | def iter_block(
self, text=None,
width=60, chars=False, newlines=False, lstrip=False):
""" Iterator that turns a long string into lines no greater than
'width' in length.
It can wrap on spaces or characters. It only does basic blocks.
For prepending se... | [
"Iterator",
"that",
"turns",
"a",
"long",
"string",
"into",
"lines",
"no",
"greater",
"than",
"width",
"in",
"length",
".",
"It",
"can",
"wrap",
"on",
"spaces",
"or",
"characters",
".",
"It",
"only",
"does",
"basic",
"blocks",
".",
"For",
"prepending",
"... | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L160-L207 | [
"def",
"iter_block",
"(",
"self",
",",
"text",
"=",
"None",
",",
"width",
"=",
"60",
",",
"chars",
"=",
"False",
",",
"newlines",
"=",
"False",
",",
"lstrip",
"=",
"False",
")",
":",
"text",
"=",
"(",
"self",
".",
"text",
"if",
"text",
"is",
"Non... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.iter_char_block | Format block by splitting on individual characters. | fmtblock/formatters.py | def iter_char_block(self, text=None, width=60, fmtfunc=str):
""" Format block by splitting on individual characters. """
if width < 1:
width = 1
text = (self.text if text is None else text) or ''
text = ' '.join(text.split('\n'))
escapecodes = get_codes(text)
... | def iter_char_block(self, text=None, width=60, fmtfunc=str):
""" Format block by splitting on individual characters. """
if width < 1:
width = 1
text = (self.text if text is None else text) or ''
text = ' '.join(text.split('\n'))
escapecodes = get_codes(text)
... | [
"Format",
"block",
"by",
"splitting",
"on",
"individual",
"characters",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L209-L236 | [
"def",
"iter_char_block",
"(",
"self",
",",
"text",
"=",
"None",
",",
"width",
"=",
"60",
",",
"fmtfunc",
"=",
"str",
")",
":",
"if",
"width",
"<",
"1",
":",
"width",
"=",
"1",
"text",
"=",
"(",
"self",
".",
"text",
"if",
"text",
"is",
"None",
... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.iter_format_block | Iterate over lines in a formatted block of text.
This iterator allows you to prepend to each line.
For basic blocks see iter_block().
Arguments:
text : String to format.
width : Maximum width for each line. The prepend string
... | fmtblock/formatters.py | def iter_format_block(
self, text=None,
width=60, chars=False, fill=False, newlines=False,
append=None, prepend=None, strip_first=False, strip_last=False,
lstrip=False):
""" Iterate over lines in a formatted block of text.
This iterator allows you to p... | def iter_format_block(
self, text=None,
width=60, chars=False, fill=False, newlines=False,
append=None, prepend=None, strip_first=False, strip_last=False,
lstrip=False):
""" Iterate over lines in a formatted block of text.
This iterator allows you to p... | [
"Iterate",
"over",
"lines",
"in",
"a",
"formatted",
"block",
"of",
"text",
".",
"This",
"iterator",
"allows",
"you",
"to",
"prepend",
"to",
"each",
"line",
".",
"For",
"basic",
"blocks",
"see",
"iter_block",
"()",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L238-L337 | [
"def",
"iter_format_block",
"(",
"self",
",",
"text",
"=",
"None",
",",
"width",
"=",
"60",
",",
"chars",
"=",
"False",
",",
"fill",
"=",
"False",
",",
"newlines",
"=",
"False",
",",
"append",
"=",
"None",
",",
"prepend",
"=",
"None",
",",
"strip_fir... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.iter_space_block | Format block by wrapping on spaces. | fmtblock/formatters.py | def iter_space_block(self, text=None, width=60, fmtfunc=str):
""" Format block by wrapping on spaces. """
if width < 1:
width = 1
curline = ''
text = (self.text if text is None else text) or ''
for word in text.split():
possibleline = ' '.join((curline, wo... | def iter_space_block(self, text=None, width=60, fmtfunc=str):
""" Format block by wrapping on spaces. """
if width < 1:
width = 1
curline = ''
text = (self.text if text is None else text) or ''
for word in text.split():
possibleline = ' '.join((curline, wo... | [
"Format",
"block",
"by",
"wrapping",
"on",
"spaces",
"."
] | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L339-L359 | [
"def",
"iter_space_block",
"(",
"self",
",",
"text",
"=",
"None",
",",
"width",
"=",
"60",
",",
"fmtfunc",
"=",
"str",
")",
":",
"if",
"width",
"<",
"1",
":",
"width",
"=",
"1",
"curline",
"=",
"''",
"text",
"=",
"(",
"self",
".",
"text",
"if",
... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | FormatBlock.squeeze_words | Remove spaces in between words until it is small enough for
`width`.
This will always leave at least one space between words,
so it may not be able to get below `width` characters. | fmtblock/formatters.py | def squeeze_words(line, width=60):
""" Remove spaces in between words until it is small enough for
`width`.
This will always leave at least one space between words,
so it may not be able to get below `width` characters.
"""
# Start removing spaces to "squeeze"... | def squeeze_words(line, width=60):
""" Remove spaces in between words until it is small enough for
`width`.
This will always leave at least one space between words,
so it may not be able to get below `width` characters.
"""
# Start removing spaces to "squeeze"... | [
"Remove",
"spaces",
"in",
"between",
"words",
"until",
"it",
"is",
"small",
"enough",
"for",
"width",
".",
"This",
"will",
"always",
"leave",
"at",
"least",
"one",
"space",
"between",
"words",
"so",
"it",
"may",
"not",
"be",
"able",
"to",
"get",
"below",... | welbornprod/fmtblock | python | https://github.com/welbornprod/fmtblock/blob/92a5529235d557170ed21e058e3c5995197facbe/fmtblock/formatters.py#L362-L373 | [
"def",
"squeeze_words",
"(",
"line",
",",
"width",
"=",
"60",
")",
":",
"# Start removing spaces to \"squeeze\" the text, leaving at least one.",
"while",
"(",
"' '",
"in",
"line",
")",
"and",
"(",
"len",
"(",
"line",
")",
">",
"width",
")",
":",
"# Remove two ... | 92a5529235d557170ed21e058e3c5995197facbe |
valid | CachedHTTPBL.check_ip | Check IP trough the httpBL API
:param ip: ipv4 ip address
:return: httpBL results or None if any error is occurred | cached_httpbl/api.py | def check_ip(self, ip):
"""
Check IP trough the httpBL API
:param ip: ipv4 ip address
:return: httpBL results or None if any error is occurred
"""
self._last_result = None
if is_valid_ipv4(ip):
key = None
if self._use_cache:
... | def check_ip(self, ip):
"""
Check IP trough the httpBL API
:param ip: ipv4 ip address
:return: httpBL results or None if any error is occurred
"""
self._last_result = None
if is_valid_ipv4(ip):
key = None
if self._use_cache:
... | [
"Check",
"IP",
"trough",
"the",
"httpBL",
"API"
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/api.py#L88-L127 | [
"def",
"check_ip",
"(",
"self",
",",
"ip",
")",
":",
"self",
".",
"_last_result",
"=",
"None",
"if",
"is_valid_ipv4",
"(",
"ip",
")",
":",
"key",
"=",
"None",
"if",
"self",
".",
"_use_cache",
":",
"key",
"=",
"self",
".",
"_make_cache_key",
"(",
"ip"... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | CachedHTTPBL.is_threat | Check if IP is a threat
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:param harmless_age: harmless age for check if httpBL age is older (optional)
:param threat_score: threat score for check if httpBL threat is lower (optional)
:param threat_... | cached_httpbl/api.py | def is_threat(self, result=None, harmless_age=None, threat_score=None, threat_type=None):
"""
Check if IP is a threat
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:param harmless_age: harmless age for check if httpBL age is older (optional)
... | def is_threat(self, result=None, harmless_age=None, threat_score=None, threat_type=None):
"""
Check if IP is a threat
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:param harmless_age: harmless age for check if httpBL age is older (optional)
... | [
"Check",
"if",
"IP",
"is",
"a",
"threat"
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/api.py#L129-L153 | [
"def",
"is_threat",
"(",
"self",
",",
"result",
"=",
"None",
",",
"harmless_age",
"=",
"None",
",",
"threat_score",
"=",
"None",
",",
"threat_type",
"=",
"None",
")",
":",
"harmless_age",
"=",
"harmless_age",
"if",
"harmless_age",
"is",
"not",
"None",
"els... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | CachedHTTPBL.is_suspicious | Check if IP is suspicious
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:return: True or False | cached_httpbl/api.py | def is_suspicious(self, result=None):
"""
Check if IP is suspicious
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:return: True or False
"""
result = result if result is not None else self._last_result
suspicious = Fal... | def is_suspicious(self, result=None):
"""
Check if IP is suspicious
:param result: httpBL results; if None, then results from last check_ip() used (optional)
:return: True or False
"""
result = result if result is not None else self._last_result
suspicious = Fal... | [
"Check",
"if",
"IP",
"is",
"suspicious"
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/api.py#L155-L167 | [
"def",
"is_suspicious",
"(",
"self",
",",
"result",
"=",
"None",
")",
":",
"result",
"=",
"result",
"if",
"result",
"is",
"not",
"None",
"else",
"self",
".",
"_last_result",
"suspicious",
"=",
"False",
"if",
"result",
"is",
"not",
"None",
":",
"suspiciou... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | CachedHTTPBL.invalidate_ip | Invalidate httpBL cache for IP address
:param ip: ipv4 IP address | cached_httpbl/api.py | def invalidate_ip(self, ip):
"""
Invalidate httpBL cache for IP address
:param ip: ipv4 IP address
"""
if self._use_cache:
key = self._make_cache_key(ip)
self._cache.delete(key, version=self._cache_version) | def invalidate_ip(self, ip):
"""
Invalidate httpBL cache for IP address
:param ip: ipv4 IP address
"""
if self._use_cache:
key = self._make_cache_key(ip)
self._cache.delete(key, version=self._cache_version) | [
"Invalidate",
"httpBL",
"cache",
"for",
"IP",
"address"
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/api.py#L169-L178 | [
"def",
"invalidate_ip",
"(",
"self",
",",
"ip",
")",
":",
"if",
"self",
".",
"_use_cache",
":",
"key",
"=",
"self",
".",
"_make_cache_key",
"(",
"ip",
")",
"self",
".",
"_cache",
".",
"delete",
"(",
"key",
",",
"version",
"=",
"self",
".",
"_cache_ve... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | CachedHTTPBL.invalidate_cache | Invalidate httpBL cache | cached_httpbl/api.py | def invalidate_cache(self):
"""
Invalidate httpBL cache
"""
if self._use_cache:
self._cache_version += 1
self._cache.increment('cached_httpbl_{0}_version'.format(self._api_key)) | def invalidate_cache(self):
"""
Invalidate httpBL cache
"""
if self._use_cache:
self._cache_version += 1
self._cache.increment('cached_httpbl_{0}_version'.format(self._api_key)) | [
"Invalidate",
"httpBL",
"cache"
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/api.py#L180-L187 | [
"def",
"invalidate_cache",
"(",
"self",
")",
":",
"if",
"self",
".",
"_use_cache",
":",
"self",
".",
"_cache_version",
"+=",
"1",
"self",
".",
"_cache",
".",
"increment",
"(",
"'cached_httpbl_{0}_version'",
".",
"format",
"(",
"self",
".",
"_api_key",
")",
... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | Consumer.run | Runs the consumer. | librato_bg/consumer.py | def run(self):
"""Runs the consumer."""
self.log.debug('consumer is running...')
self.running = True
while self.running:
self.upload()
self.log.debug('consumer exited.') | def run(self):
"""Runs the consumer."""
self.log.debug('consumer is running...')
self.running = True
while self.running:
self.upload()
self.log.debug('consumer exited.') | [
"Runs",
"the",
"consumer",
"."
] | nyaruka/python-librato-bg | python | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L23-L31 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'consumer is running...'",
")",
"self",
".",
"running",
"=",
"True",
"while",
"self",
".",
"running",
":",
"self",
".",
"upload",
"(",
")",
"self",
".",
"log",
".",
"debug",... | e541092838694de31d256becea8391a9cfe086c7 |
valid | Consumer.upload | Upload the next batch of items, return whether successful. | librato_bg/consumer.py | def upload(self):
"""Upload the next batch of items, return whether successful."""
success = False
batch = self.next()
if len(batch) == 0:
return False
try:
self.request(batch)
success = True
except Exception as e:
self.log... | def upload(self):
"""Upload the next batch of items, return whether successful."""
success = False
batch = self.next()
if len(batch) == 0:
return False
try:
self.request(batch)
success = True
except Exception as e:
self.log... | [
"Upload",
"the",
"next",
"batch",
"of",
"items",
"return",
"whether",
"successful",
"."
] | nyaruka/python-librato-bg | python | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L37-L57 | [
"def",
"upload",
"(",
"self",
")",
":",
"success",
"=",
"False",
"batch",
"=",
"self",
".",
"next",
"(",
")",
"if",
"len",
"(",
"batch",
")",
"==",
"0",
":",
"return",
"False",
"try",
":",
"self",
".",
"request",
"(",
"batch",
")",
"success",
"="... | e541092838694de31d256becea8391a9cfe086c7 |
valid | Consumer.next | Return the next batch of items to upload. | librato_bg/consumer.py | def next(self):
"""Return the next batch of items to upload."""
queue = self.queue
items = []
item = self.next_item()
if item is None:
return items
items.append(item)
while len(items) < self.upload_size and not queue.empty():
item = self.n... | def next(self):
"""Return the next batch of items to upload."""
queue = self.queue
items = []
item = self.next_item()
if item is None:
return items
items.append(item)
while len(items) < self.upload_size and not queue.empty():
item = self.n... | [
"Return",
"the",
"next",
"batch",
"of",
"items",
"to",
"upload",
"."
] | nyaruka/python-librato-bg | python | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L59-L73 | [
"def",
"next",
"(",
"self",
")",
":",
"queue",
"=",
"self",
".",
"queue",
"items",
"=",
"[",
"]",
"item",
"=",
"self",
".",
"next_item",
"(",
")",
"if",
"item",
"is",
"None",
":",
"return",
"items",
"items",
".",
"append",
"(",
"item",
")",
"whil... | e541092838694de31d256becea8391a9cfe086c7 |
valid | Consumer.next_item | Get a single item from the queue. | librato_bg/consumer.py | def next_item(self):
"""Get a single item from the queue."""
queue = self.queue
try:
item = queue.get(block=True, timeout=5)
return item
except Exception:
return None | def next_item(self):
"""Get a single item from the queue."""
queue = self.queue
try:
item = queue.get(block=True, timeout=5)
return item
except Exception:
return None | [
"Get",
"a",
"single",
"item",
"from",
"the",
"queue",
"."
] | nyaruka/python-librato-bg | python | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L75-L82 | [
"def",
"next_item",
"(",
"self",
")",
":",
"queue",
"=",
"self",
".",
"queue",
"try",
":",
"item",
"=",
"queue",
".",
"get",
"(",
"block",
"=",
"True",
",",
"timeout",
"=",
"5",
")",
"return",
"item",
"except",
"Exception",
":",
"return",
"None"
] | e541092838694de31d256becea8391a9cfe086c7 |
valid | Consumer.request | Attempt to upload the batch and retry before raising an error | librato_bg/consumer.py | def request(self, batch, attempt=0):
"""Attempt to upload the batch and retry before raising an error """
try:
q = self.api.new_queue()
for msg in batch:
q.add(msg['event'], msg['value'], source=msg['source'])
q.submit()
except:
if ... | def request(self, batch, attempt=0):
"""Attempt to upload the batch and retry before raising an error """
try:
q = self.api.new_queue()
for msg in batch:
q.add(msg['event'], msg['value'], source=msg['source'])
q.submit()
except:
if ... | [
"Attempt",
"to",
"upload",
"the",
"batch",
"and",
"retry",
"before",
"raising",
"an",
"error"
] | nyaruka/python-librato-bg | python | https://github.com/nyaruka/python-librato-bg/blob/e541092838694de31d256becea8391a9cfe086c7/librato_bg/consumer.py#L84-L94 | [
"def",
"request",
"(",
"self",
",",
"batch",
",",
"attempt",
"=",
"0",
")",
":",
"try",
":",
"q",
"=",
"self",
".",
"api",
".",
"new_queue",
"(",
")",
"for",
"msg",
"in",
"batch",
":",
"q",
".",
"add",
"(",
"msg",
"[",
"'event'",
"]",
",",
"m... | e541092838694de31d256becea8391a9cfe086c7 |
valid | _camelcase_to_underscore | Translate camelCase into underscore format.
>>> _camelcase_to_underscore('minutesBetweenSummaries')
'minutes_between_summaries' | trelloapi/make_endpoints.py | def _camelcase_to_underscore(url):
"""
Translate camelCase into underscore format.
>>> _camelcase_to_underscore('minutesBetweenSummaries')
'minutes_between_summaries'
"""
def upper2underscore(text):
for char in text:
if char.islower():
yield char
... | def _camelcase_to_underscore(url):
"""
Translate camelCase into underscore format.
>>> _camelcase_to_underscore('minutesBetweenSummaries')
'minutes_between_summaries'
"""
def upper2underscore(text):
for char in text:
if char.islower():
yield char
... | [
"Translate",
"camelCase",
"into",
"underscore",
"format",
"."
] | nilp0inter/trelloapi | python | https://github.com/nilp0inter/trelloapi/blob/88f4135832548ea71598d50a73943890e1cf9e20/trelloapi/make_endpoints.py#L52-L68 | [
"def",
"_camelcase_to_underscore",
"(",
"url",
")",
":",
"def",
"upper2underscore",
"(",
"text",
")",
":",
"for",
"char",
"in",
"text",
":",
"if",
"char",
".",
"islower",
"(",
")",
":",
"yield",
"char",
"else",
":",
"yield",
"'_'",
"if",
"char",
".",
... | 88f4135832548ea71598d50a73943890e1cf9e20 |
valid | create_tree | Creates the Trello endpoint tree.
>>> r = {'1': { \
'actions': {'METHODS': {'GET'}}, \
'boards': { \
'members': {'METHODS': {'DELETE'}}}} \
}
>>> r == create_tree([ \
'GET /1/actions/[idAction]', \
'DELETE /1/b... | trelloapi/make_endpoints.py | def create_tree(endpoints):
"""
Creates the Trello endpoint tree.
>>> r = {'1': { \
'actions': {'METHODS': {'GET'}}, \
'boards': { \
'members': {'METHODS': {'DELETE'}}}} \
}
>>> r == create_tree([ \
'GET /1/actions/[idA... | def create_tree(endpoints):
"""
Creates the Trello endpoint tree.
>>> r = {'1': { \
'actions': {'METHODS': {'GET'}}, \
'boards': { \
'members': {'METHODS': {'DELETE'}}}} \
}
>>> r == create_tree([ \
'GET /1/actions/[idA... | [
"Creates",
"the",
"Trello",
"endpoint",
"tree",
"."
] | nilp0inter/trelloapi | python | https://github.com/nilp0inter/trelloapi/blob/88f4135832548ea71598d50a73943890e1cf9e20/trelloapi/make_endpoints.py#L71-L110 | [
"def",
"create_tree",
"(",
"endpoints",
")",
":",
"tree",
"=",
"{",
"}",
"for",
"method",
",",
"url",
",",
"doc",
"in",
"endpoints",
":",
"path",
"=",
"[",
"p",
"for",
"p",
"in",
"url",
".",
"strip",
"(",
"'/'",
")",
".",
"split",
"(",
"'/'",
"... | 88f4135832548ea71598d50a73943890e1cf9e20 |
valid | main | Prints the complete YAML. | trelloapi/make_endpoints.py | def main():
"""
Prints the complete YAML.
"""
ep = requests.get(TRELLO_API_DOC).content
root = html.fromstring(ep)
links = root.xpath('//a[contains(@class, "reference internal")]/@href')
pages = [requests.get(TRELLO_API_DOC + u)
for u in links if u.endswith('index.html')]
... | def main():
"""
Prints the complete YAML.
"""
ep = requests.get(TRELLO_API_DOC).content
root = html.fromstring(ep)
links = root.xpath('//a[contains(@class, "reference internal")]/@href')
pages = [requests.get(TRELLO_API_DOC + u)
for u in links if u.endswith('index.html')]
... | [
"Prints",
"the",
"complete",
"YAML",
"."
] | nilp0inter/trelloapi | python | https://github.com/nilp0inter/trelloapi/blob/88f4135832548ea71598d50a73943890e1cf9e20/trelloapi/make_endpoints.py#L113-L140 | [
"def",
"main",
"(",
")",
":",
"ep",
"=",
"requests",
".",
"get",
"(",
"TRELLO_API_DOC",
")",
".",
"content",
"root",
"=",
"html",
".",
"fromstring",
"(",
"ep",
")",
"links",
"=",
"root",
".",
"xpath",
"(",
"'//a[contains(@class, \"reference internal\")]/@hre... | 88f4135832548ea71598d50a73943890e1cf9e20 |
valid | _parser_exit | Override the default exit in the parser.
:param parser:
:param _: exit code. Unused because we don't exit
:param message: Optional message | dirlistproc/DirectoryListProcessor.py | def _parser_exit(parser: argparse.ArgumentParser, proc: "DirectoryListProcessor", _=0,
message: Optional[str]=None) -> None:
"""
Override the default exit in the parser.
:param parser:
:param _: exit code. Unused because we don't exit
:param message: Optional message
"""
if... | def _parser_exit(parser: argparse.ArgumentParser, proc: "DirectoryListProcessor", _=0,
message: Optional[str]=None) -> None:
"""
Override the default exit in the parser.
:param parser:
:param _: exit code. Unused because we don't exit
:param message: Optional message
"""
if... | [
"Override",
"the",
"default",
"exit",
"in",
"the",
"parser",
".",
":",
"param",
"parser",
":",
":",
"param",
"_",
":",
"exit",
"code",
".",
"Unused",
"because",
"we",
"don",
"t",
"exit",
":",
"param",
"message",
":",
"Optional",
"message"
] | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L37-L47 | [
"def",
"_parser_exit",
"(",
"parser",
":",
"argparse",
".",
"ArgumentParser",
",",
"proc",
":",
"\"DirectoryListProcessor\"",
",",
"_",
"=",
"0",
",",
"message",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"message",
":",... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | DirectoryListProcessor.decode_file_args | Preprocess any arguments that begin with the fromfile prefix char(s).
This replaces the one in Argparse because it
a) doesn't process "-x y" correctly and
b) ignores bad files
:param argv: raw options list
:return: options list with file references replaced | dirlistproc/DirectoryListProcessor.py | def decode_file_args(self, argv: List[str]) -> List[str]:
"""
Preprocess any arguments that begin with the fromfile prefix char(s).
This replaces the one in Argparse because it
a) doesn't process "-x y" correctly and
b) ignores bad files
:param argv: raw options l... | def decode_file_args(self, argv: List[str]) -> List[str]:
"""
Preprocess any arguments that begin with the fromfile prefix char(s).
This replaces the one in Argparse because it
a) doesn't process "-x y" correctly and
b) ignores bad files
:param argv: raw options l... | [
"Preprocess",
"any",
"arguments",
"that",
"begin",
"with",
"the",
"fromfile",
"prefix",
"char",
"(",
"s",
")",
".",
"This",
"replaces",
"the",
"one",
"in",
"Argparse",
"because",
"it",
"a",
")",
"doesn",
"t",
"process",
"-",
"x",
"y",
"correctly",
"and",... | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L98-L112 | [
"def",
"decode_file_args",
"(",
"self",
",",
"argv",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"for",
"arg",
"in",
"[",
"arg",
"for",
"arg",
"in",
"argv",
"if",
"arg",
"[",
"0",
"]",
"in",
"self",
".",
"fromfile_prefi... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | DirectoryListProcessor._proc_error | Report an error
:param ifn: Input file name
:param e: Exception to report | dirlistproc/DirectoryListProcessor.py | def _proc_error(ifn: str, e: Exception) -> None:
""" Report an error
:param ifn: Input file name
:param e: Exception to report
"""
type_, value_, traceback_ = sys.exc_info()
traceback.print_tb(traceback_, file=sys.stderr)
print(file=sys.stderr)
print("****... | def _proc_error(ifn: str, e: Exception) -> None:
""" Report an error
:param ifn: Input file name
:param e: Exception to report
"""
type_, value_, traceback_ = sys.exc_info()
traceback.print_tb(traceback_, file=sys.stderr)
print(file=sys.stderr)
print("****... | [
"Report",
"an",
"error",
":",
"param",
"ifn",
":",
"Input",
"file",
"name",
":",
"param",
"e",
":",
"Exception",
"to",
"report"
] | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L115-L124 | [
"def",
"_proc_error",
"(",
"ifn",
":",
"str",
",",
"e",
":",
"Exception",
")",
"->",
"None",
":",
"type_",
",",
"value_",
",",
"traceback_",
"=",
"sys",
".",
"exc_info",
"(",
")",
"traceback",
".",
"print_tb",
"(",
"traceback_",
",",
"file",
"=",
"sy... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | DirectoryListProcessor._call_proc | Call the actual processor and intercept anything that goes wrong
:param proc: Process to call
:param ifn: Input file name to process. If absent, typical use is stdin
:param ofn: Output file name. If absent, typical use is stdout
:return: true means process was successful | dirlistproc/DirectoryListProcessor.py | def _call_proc(self,
proc: Callable[[Optional[str], Optional[str], argparse.Namespace], bool],
ifn: Optional[str],
ofn: Optional[str]) -> bool:
""" Call the actual processor and intercept anything that goes wrong
:param proc: Process to call
... | def _call_proc(self,
proc: Callable[[Optional[str], Optional[str], argparse.Namespace], bool],
ifn: Optional[str],
ofn: Optional[str]) -> bool:
""" Call the actual processor and intercept anything that goes wrong
:param proc: Process to call
... | [
"Call",
"the",
"actual",
"processor",
"and",
"intercept",
"anything",
"that",
"goes",
"wrong",
":",
"param",
"proc",
":",
"Process",
"to",
"call",
":",
"param",
"ifn",
":",
"Input",
"file",
"name",
"to",
"process",
".",
"If",
"absent",
"typical",
"use",
... | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L126-L141 | [
"def",
"_call_proc",
"(",
"self",
",",
"proc",
":",
"Callable",
"[",
"[",
"Optional",
"[",
"str",
"]",
",",
"Optional",
"[",
"str",
"]",
",",
"argparse",
".",
"Namespace",
"]",
",",
"bool",
"]",
",",
"ifn",
":",
"Optional",
"[",
"str",
"]",
",",
... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | DirectoryListProcessor.run | Run the directory list processor calling a function per file.
:param proc: Process to invoke. Args: input_file_name, output_file_name, argparse options. Return pass or fail.
No return also means pass
:param file_filter: Additional filter for testing file names, types, etc.
:... | dirlistproc/DirectoryListProcessor.py | def run(self,
proc: Callable[[Optional[str], Optional[str], argparse.Namespace], Optional[bool]],
file_filter: Optional[Callable[[str], bool]]=None,
file_filter_2: Optional[Callable[[Optional[str], str, argparse.Namespace], bool]]=None) \
-> Tuple[int, int]:
""" R... | def run(self,
proc: Callable[[Optional[str], Optional[str], argparse.Namespace], Optional[bool]],
file_filter: Optional[Callable[[str], bool]]=None,
file_filter_2: Optional[Callable[[Optional[str], str, argparse.Namespace], bool]]=None) \
-> Tuple[int, int]:
""" R... | [
"Run",
"the",
"directory",
"list",
"processor",
"calling",
"a",
"function",
"per",
"file",
".",
":",
"param",
"proc",
":",
"Process",
"to",
"invoke",
".",
"Args",
":",
"input_file_name",
"output_file_name",
"argparse",
"options",
".",
"Return",
"pass",
"or",
... | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L154-L200 | [
"def",
"run",
"(",
"self",
",",
"proc",
":",
"Callable",
"[",
"[",
"Optional",
"[",
"str",
"]",
",",
"Optional",
"[",
"str",
"]",
",",
"argparse",
".",
"Namespace",
"]",
",",
"Optional",
"[",
"bool",
"]",
"]",
",",
"file_filter",
":",
"Optional",
"... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | DirectoryListProcessor._outfile_name | Construct the output file name from the input file. If a single output file was named and there isn't a
directory, return the output file.
:param dirpath: Directory path to infile
:param infile: Name of input file
:param outfile_idx: Index into output file list (for multiple input/outpu... | dirlistproc/DirectoryListProcessor.py | def _outfile_name(self, dirpath: str, infile: str, outfile_idx: int=0) -> Optional[str]:
""" Construct the output file name from the input file. If a single output file was named and there isn't a
directory, return the output file.
:param dirpath: Directory path to infile
:param infile:... | def _outfile_name(self, dirpath: str, infile: str, outfile_idx: int=0) -> Optional[str]:
""" Construct the output file name from the input file. If a single output file was named and there isn't a
directory, return the output file.
:param dirpath: Directory path to infile
:param infile:... | [
"Construct",
"the",
"output",
"file",
"name",
"from",
"the",
"input",
"file",
".",
"If",
"a",
"single",
"output",
"file",
"was",
"named",
"and",
"there",
"isn",
"t",
"a",
"directory",
"return",
"the",
"output",
"file",
".",
":",
"param",
"dirpath",
":",
... | hsolbrig/dirlistproc | python | https://github.com/hsolbrig/dirlistproc/blob/3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad/dirlistproc/DirectoryListProcessor.py#L202-L231 | [
"def",
"_outfile_name",
"(",
"self",
",",
"dirpath",
":",
"str",
",",
"infile",
":",
"str",
",",
"outfile_idx",
":",
"int",
"=",
"0",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"opts",
".",
"outfile",
"and",
"not",
"self... | 3d5dedeb2bc653b409a476d91c8a4e30eb6a08ad |
valid | Ftp.quit | Close and exit the connection. | arguspy/ftp_ftplib.py | def quit(self):
"""Close and exit the connection."""
try:
self.ftp.quit()
self.logger.debug("quit connect succeed.")
except ftplib.Error as e:
self.unknown("quit connect error: %s" % e) | def quit(self):
"""Close and exit the connection."""
try:
self.ftp.quit()
self.logger.debug("quit connect succeed.")
except ftplib.Error as e:
self.unknown("quit connect error: %s" % e) | [
"Close",
"and",
"exit",
"the",
"connection",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/ftp_ftplib.py#L45-L51 | [
"def",
"quit",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"ftp",
".",
"quit",
"(",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"quit connect succeed.\"",
")",
"except",
"ftplib",
".",
"Error",
"as",
"e",
":",
"self",
".",
"unknown",
"(",
... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | Wmi.query | Connect by wmi and run wql. | arguspy/wmi_subprocess.py | def query(self, wql):
"""Connect by wmi and run wql."""
try:
self.__wql = ['wmic', '-U',
self.args.domain + '\\' + self.args.user + '%' + self.args.password,
'//' + self.args.host,
'--namespace', self.args.namespac... | def query(self, wql):
"""Connect by wmi and run wql."""
try:
self.__wql = ['wmic', '-U',
self.args.domain + '\\' + self.args.user + '%' + self.args.password,
'//' + self.args.host,
'--namespace', self.args.namespac... | [
"Connect",
"by",
"wmi",
"and",
"run",
"wql",
"."
] | crazy-canux/arguspy | python | https://github.com/crazy-canux/arguspy/blob/e9486b5df61978a990d56bf43de35f3a4cdefcc3/arguspy/wmi_subprocess.py#L30-L49 | [
"def",
"query",
"(",
"self",
",",
"wql",
")",
":",
"try",
":",
"self",
".",
"__wql",
"=",
"[",
"'wmic'",
",",
"'-U'",
",",
"self",
".",
"args",
".",
"domain",
"+",
"'\\\\'",
"+",
"self",
".",
"args",
".",
"user",
"+",
"'%'",
"+",
"self",
".",
... | e9486b5df61978a990d56bf43de35f3a4cdefcc3 |
valid | CacheEntry.set_value | Changes the cached value and updates creation time.
Args:
value: the new cached value.
timeout: time to live for the object in milliseconds
Returns: None | pip_services_commons/cache/CacheEntry.py | def set_value(self, value, timeout):
"""
Changes the cached value and updates creation time.
Args:
value: the new cached value.
timeout: time to live for the object in milliseconds
Returns: None
"""
self.value = value
s... | def set_value(self, value, timeout):
"""
Changes the cached value and updates creation time.
Args:
value: the new cached value.
timeout: time to live for the object in milliseconds
Returns: None
"""
self.value = value
s... | [
"Changes",
"the",
"cached",
"value",
"and",
"updates",
"creation",
"time",
".",
"Args",
":",
"value",
":",
"the",
"new",
"cached",
"value",
".",
"timeout",
":",
"time",
"to",
"live",
"for",
"the",
"object",
"in",
"milliseconds",
"Returns",
":",
"None"
] | pip-services/pip-services-commons-python | python | https://github.com/pip-services/pip-services-commons-python/blob/2205b18c45c60372966c62c1f23ac4fbc31e11b3/pip_services_commons/cache/CacheEntry.py#L36-L47 | [
"def",
"set_value",
"(",
"self",
",",
"value",
",",
"timeout",
")",
":",
"self",
".",
"value",
"=",
"value",
"self",
".",
"expiration",
"=",
"time",
".",
"clock",
"(",
")",
"*",
"1000",
"+",
"timeout"
] | 2205b18c45c60372966c62c1f23ac4fbc31e11b3 |
valid | DataReporter.log | Wrapper for the other log methods, decide which one based on the
URL parameter. | libardurep/datareporter.py | def log(self, url=None, credentials=None, do_verify_certificate=True):
"""
Wrapper for the other log methods, decide which one based on the
URL parameter.
"""
if url is None:
url = self.url
if re.match("file://", url):
self.log_file(url)
el... | def log(self, url=None, credentials=None, do_verify_certificate=True):
"""
Wrapper for the other log methods, decide which one based on the
URL parameter.
"""
if url is None:
url = self.url
if re.match("file://", url):
self.log_file(url)
el... | [
"Wrapper",
"for",
"the",
"other",
"log",
"methods",
"decide",
"which",
"one",
"based",
"on",
"the",
"URL",
"parameter",
"."
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datareporter.py#L34-L46 | [
"def",
"log",
"(",
"self",
",",
"url",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"do_verify_certificate",
"=",
"True",
")",
":",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"self",
".",
"url",
"if",
"re",
".",
"match",
"(",
"\"file://\"",
... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataReporter.log_file | Write to a local log file | libardurep/datareporter.py | def log_file(self, url=None):
"""
Write to a local log file
"""
if url is None:
url = self.url
f = re.sub("file://", "", url)
try:
with open(f, "a") as of:
of.write(str(self.store.get_json_tuples(True)))
except IOError as e:... | def log_file(self, url=None):
"""
Write to a local log file
"""
if url is None:
url = self.url
f = re.sub("file://", "", url)
try:
with open(f, "a") as of:
of.write(str(self.store.get_json_tuples(True)))
except IOError as e:... | [
"Write",
"to",
"a",
"local",
"log",
"file"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datareporter.py#L54-L66 | [
"def",
"log_file",
"(",
"self",
",",
"url",
"=",
"None",
")",
":",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"self",
".",
"url",
"f",
"=",
"re",
".",
"sub",
"(",
"\"file://\"",
",",
"\"\"",
",",
"url",
")",
"try",
":",
"with",
"open",
"(",
... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataReporter.log_post | Write to a remote host via HTTP POST | libardurep/datareporter.py | def log_post(self, url=None, credentials=None, do_verify_certificate=True):
"""
Write to a remote host via HTTP POST
"""
if url is None:
url = self.url
if credentials is None:
credentials = self.credentials
if do_verify_certificate is None:
... | def log_post(self, url=None, credentials=None, do_verify_certificate=True):
"""
Write to a remote host via HTTP POST
"""
if url is None:
url = self.url
if credentials is None:
credentials = self.credentials
if do_verify_certificate is None:
... | [
"Write",
"to",
"a",
"remote",
"host",
"via",
"HTTP",
"POST"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datareporter.py#L68-L87 | [
"def",
"log_post",
"(",
"self",
",",
"url",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"do_verify_certificate",
"=",
"True",
")",
":",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"self",
".",
"url",
"if",
"credentials",
"is",
"None",
":",
"cr... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | DataReporter.register_credentials | Helper method to store username and password | libardurep/datareporter.py | def register_credentials(self, credentials=None, user=None, user_file=None, password=None, password_file=None):
"""
Helper method to store username and password
"""
# lets store all kind of credential data into this dict
if credentials is not None:
self.credentials = ... | def register_credentials(self, credentials=None, user=None, user_file=None, password=None, password_file=None):
"""
Helper method to store username and password
"""
# lets store all kind of credential data into this dict
if credentials is not None:
self.credentials = ... | [
"Helper",
"method",
"to",
"store",
"username",
"and",
"password"
] | zwischenloesung/ardu-report-lib | python | https://github.com/zwischenloesung/ardu-report-lib/blob/51bd4a07e036065aafcb1273b151bea3fdfa50fa/libardurep/datareporter.py#L95-L143 | [
"def",
"register_credentials",
"(",
"self",
",",
"credentials",
"=",
"None",
",",
"user",
"=",
"None",
",",
"user_file",
"=",
"None",
",",
"password",
"=",
"None",
",",
"password_file",
"=",
"None",
")",
":",
"# lets store all kind of credential data into this dic... | 51bd4a07e036065aafcb1273b151bea3fdfa50fa |
valid | generator_to_list | Wrap a generator function so that it returns a list when called.
For example:
# Define a generator
>>> def mygen(n):
... i = 0
... while i < n:
... yield i
... i += 1
# This is how it might work
>>> generator = myg... | relax/utils.py | def generator_to_list(function):
"""
Wrap a generator function so that it returns a list when called.
For example:
# Define a generator
>>> def mygen(n):
... i = 0
... while i < n:
... yield i
... i += 1
# This is ... | def generator_to_list(function):
"""
Wrap a generator function so that it returns a list when called.
For example:
# Define a generator
>>> def mygen(n):
... i = 0
... while i < n:
... yield i
... i += 1
# This is ... | [
"Wrap",
"a",
"generator",
"function",
"so",
"that",
"it",
"returns",
"a",
"list",
"when",
"called",
".",
"For",
"example",
":",
"#",
"Define",
"a",
"generator",
">>>",
"def",
"mygen",
"(",
"n",
")",
":",
"...",
"i",
"=",
"0",
"...",
"while",
"i",
"... | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/utils.py#L7-L35 | [
"def",
"generator_to_list",
"(",
"function",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"list",
"(",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
"wrapper",
".",
"__name__",
"=",
"... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | logrotate | Return the next available filename for a particular filename prefix.
For example:
>>> import os
# Make three (empty) files in a directory
>>> fp0 = open('file.0', 'w')
>>> fp1 = open('file.1', 'w')
>>> fp2 = open('file.2', 'w')
>>> fp0.close(), fp1.close(), ... | relax/utils.py | def logrotate(filename):
"""
Return the next available filename for a particular filename prefix.
For example:
>>> import os
# Make three (empty) files in a directory
>>> fp0 = open('file.0', 'w')
>>> fp1 = open('file.1', 'w')
>>> fp2 = open('file.2', '... | def logrotate(filename):
"""
Return the next available filename for a particular filename prefix.
For example:
>>> import os
# Make three (empty) files in a directory
>>> fp0 = open('file.0', 'w')
>>> fp1 = open('file.1', 'w')
>>> fp2 = open('file.2', '... | [
"Return",
"the",
"next",
"available",
"filename",
"for",
"a",
"particular",
"filename",
"prefix",
".",
"For",
"example",
":",
">>>",
"import",
"os",
"#",
"Make",
"three",
"(",
"empty",
")",
"files",
"in",
"a",
"directory",
">>>",
"fp0",
"=",
"open",
"(",... | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/utils.py#L38-L74 | [
"def",
"logrotate",
"(",
"filename",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'(.*)'",
"+",
"re",
".",
"escape",
"(",
"os",
".",
"path",
".",
"extsep",
")",
"+",
"r'(\\d+)'",
",",
"filename",
")",
"if",
"os",
".",
"path",
".",
"exists",
... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | set_connection | Set connection parameters. Call set_connection with no arguments to clear. | dpostools/legacy.py | def set_connection(host=None, database=None, user=None, password=None):
"""Set connection parameters. Call set_connection with no arguments to clear."""
c.CONNECTION['HOST'] = host
c.CONNECTION['DATABASE'] = database
c.CONNECTION['USER'] = user
c.CONNECTION['PASSWORD'] = password | def set_connection(host=None, database=None, user=None, password=None):
"""Set connection parameters. Call set_connection with no arguments to clear."""
c.CONNECTION['HOST'] = host
c.CONNECTION['DATABASE'] = database
c.CONNECTION['USER'] = user
c.CONNECTION['PASSWORD'] = password | [
"Set",
"connection",
"parameters",
".",
"Call",
"set_connection",
"with",
"no",
"arguments",
"to",
"clear",
"."
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L49-L54 | [
"def",
"set_connection",
"(",
"host",
"=",
"None",
",",
"database",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"c",
".",
"CONNECTION",
"[",
"'HOST'",
"]",
"=",
"host",
"c",
".",
"CONNECTION",
"[",
"'DATABASE'",
"]"... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | set_delegate | Set delegate parameters. Call set_delegate with no arguments to clear. | dpostools/legacy.py | def set_delegate(address=None, pubkey=None, secret=None):
"""Set delegate parameters. Call set_delegate with no arguments to clear."""
c.DELEGATE['ADDRESS'] = address
c.DELEGATE['PUBKEY'] = pubkey
c.DELEGATE['PASSPHRASE'] = secret | def set_delegate(address=None, pubkey=None, secret=None):
"""Set delegate parameters. Call set_delegate with no arguments to clear."""
c.DELEGATE['ADDRESS'] = address
c.DELEGATE['PUBKEY'] = pubkey
c.DELEGATE['PASSPHRASE'] = secret | [
"Set",
"delegate",
"parameters",
".",
"Call",
"set_delegate",
"with",
"no",
"arguments",
"to",
"clear",
"."
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L57-L61 | [
"def",
"set_delegate",
"(",
"address",
"=",
"None",
",",
"pubkey",
"=",
"None",
",",
"secret",
"=",
"None",
")",
":",
"c",
".",
"DELEGATE",
"[",
"'ADDRESS'",
"]",
"=",
"address",
"c",
".",
"DELEGATE",
"[",
"'PUBKEY'",
"]",
"=",
"pubkey",
"c",
".",
... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | get_transactionlist | returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipientId senderId rawasset type fee blockId | dpostools/legacy.py | def get_transactionlist(delegate_pubkey):
"""returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipien... | def get_transactionlist(delegate_pubkey):
"""returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipien... | [
"returns",
"a",
"list",
"of",
"named",
"tuples",
"of",
"all",
"transactions",
"relevant",
"to",
"a",
"specific",
"delegates",
"voters",
".",
"Flow",
":",
"finds",
"all",
"voters",
"and",
"unvoters",
"SELECTs",
"all",
"transactions",
"of",
"those",
"voters",
... | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L989-L1032 | [
"def",
"get_transactionlist",
"(",
"delegate_pubkey",
")",
":",
"res",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT transactions.\"id\", transactions.\"amount\",\n blocks.\"timestamp\", transactions.\"recipientId\",\n tr... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | get_events | returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipientId senderId rawasset type fee blockId | dpostools/legacy.py | def get_events(delegate_pubkey):
"""returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipientId sende... | def get_events(delegate_pubkey):
"""returns a list of named tuples of all transactions relevant to a specific delegates voters.
Flow: finds all voters and unvoters, SELECTs all transactions of those voters, names all transactions according to
the scheme: 'transaction', 'id amount timestamp recipientId sende... | [
"returns",
"a",
"list",
"of",
"named",
"tuples",
"of",
"all",
"transactions",
"relevant",
"to",
"a",
"specific",
"delegates",
"voters",
".",
"Flow",
":",
"finds",
"all",
"voters",
"and",
"unvoters",
"SELECTs",
"all",
"transactions",
"of",
"those",
"voters",
... | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L1035-L1100 | [
"def",
"get_events",
"(",
"delegate_pubkey",
")",
":",
"res",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT *\n FROM(\n SELECT transactions.\"id\",\n transactions.\"amount\",\n transactions.\"fee\",\n ... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Address.payout | returns all received transactions between the address and registered delegate accounts
ORDER by timestamp ASC. | dpostools/legacy.py | def payout(address):
"""returns all received transactions between the address and registered delegate accounts
ORDER by timestamp ASC."""
qry = DbCursor().execute_and_fetchall("""
SELECT DISTINCT transactions."id", transactions."amount",
transactions."times... | def payout(address):
"""returns all received transactions between the address and registered delegate accounts
ORDER by timestamp ASC."""
qry = DbCursor().execute_and_fetchall("""
SELECT DISTINCT transactions."id", transactions."amount",
transactions."times... | [
"returns",
"all",
"received",
"transactions",
"between",
"the",
"address",
"and",
"registered",
"delegate",
"accounts",
"ORDER",
"by",
"timestamp",
"ASC",
"."
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L177-L212 | [
"def",
"payout",
"(",
"address",
")",
":",
"qry",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT DISTINCT transactions.\"id\", transactions.\"amount\",\n transactions.\"timestamp\", transactions.\"recipientId\",\n ... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Address.votes | Returns a list of namedtuples all votes made by an address, {(+/-)pubkeydelegate:timestamp}, timestamp DESC | dpostools/legacy.py | def votes(address):
"""Returns a list of namedtuples all votes made by an address, {(+/-)pubkeydelegate:timestamp}, timestamp DESC"""
qry = DbCursor().execute_and_fetchall("""
SELECT votes."votes", transactions."timestamp"
FROM votes, transactions
WHERE transactions."id"... | def votes(address):
"""Returns a list of namedtuples all votes made by an address, {(+/-)pubkeydelegate:timestamp}, timestamp DESC"""
qry = DbCursor().execute_and_fetchall("""
SELECT votes."votes", transactions."timestamp"
FROM votes, transactions
WHERE transactions."id"... | [
"Returns",
"a",
"list",
"of",
"namedtuples",
"all",
"votes",
"made",
"by",
"an",
"address",
"{",
"(",
"+",
"/",
"-",
")",
"pubkeydelegate",
":",
"timestamp",
"}",
"timestamp",
"DESC"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L251-L279 | [
"def",
"votes",
"(",
"address",
")",
":",
"qry",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT votes.\"votes\", transactions.\"timestamp\"\n FROM votes, transactions\n WHERE transactions.\"id\" = votes.\"transactionId\"\n ... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Address.balance | Takes a single address and returns the current balance. | dpostools/legacy.py | def balance(address):
"""
Takes a single address and returns the current balance.
"""
txhistory = Address.transactions(address)
balance = 0
for i in txhistory:
if i.recipientId == address:
balance += i.amount
if i.senderId == addres... | def balance(address):
"""
Takes a single address and returns the current balance.
"""
txhistory = Address.transactions(address)
balance = 0
for i in txhistory:
if i.recipientId == address:
balance += i.amount
if i.senderId == addres... | [
"Takes",
"a",
"single",
"address",
"and",
"returns",
"the",
"current",
"balance",
"."
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L282-L305 | [
"def",
"balance",
"(",
"address",
")",
":",
"txhistory",
"=",
"Address",
".",
"transactions",
"(",
"address",
")",
"balance",
"=",
"0",
"for",
"i",
"in",
"txhistory",
":",
"if",
"i",
".",
"recipientId",
"==",
"address",
":",
"balance",
"+=",
"i",
".",
... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Address.balance_over_time | returns a list of named tuples, x.timestamp, x.amount including block rewards | dpostools/legacy.py | def balance_over_time(address):
"""returns a list of named tuples, x.timestamp, x.amount including block rewards"""
forged_blocks = None
txhistory = Address.transactions(address)
delegates = Delegate.delegates()
for i in delegates:
if address == i.address:
... | def balance_over_time(address):
"""returns a list of named tuples, x.timestamp, x.amount including block rewards"""
forged_blocks = None
txhistory = Address.transactions(address)
delegates = Delegate.delegates()
for i in delegates:
if address == i.address:
... | [
"returns",
"a",
"list",
"of",
"named",
"tuples",
"x",
".",
"timestamp",
"x",
".",
"amount",
"including",
"block",
"rewards"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L308-L348 | [
"def",
"balance_over_time",
"(",
"address",
")",
":",
"forged_blocks",
"=",
"None",
"txhistory",
"=",
"Address",
".",
"transactions",
"(",
"address",
")",
"delegates",
"=",
"Delegate",
".",
"delegates",
"(",
")",
"for",
"i",
"in",
"delegates",
":",
"if",
"... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.delegates | returns a list of named tuples of all delegates.
{username: {'pubkey':pubkey, 'timestamp':timestamp, 'address':address}} | dpostools/legacy.py | def delegates():
"""returns a list of named tuples of all delegates.
{username: {'pubkey':pubkey, 'timestamp':timestamp, 'address':address}}"""
qry = DbCursor().execute_and_fetchall("""
SELECT delegates."username", delegates."transactionId", transactions."timestamp", transactions."se... | def delegates():
"""returns a list of named tuples of all delegates.
{username: {'pubkey':pubkey, 'timestamp':timestamp, 'address':address}}"""
qry = DbCursor().execute_and_fetchall("""
SELECT delegates."username", delegates."transactionId", transactions."timestamp", transactions."se... | [
"returns",
"a",
"list",
"of",
"named",
"tuples",
"of",
"all",
"delegates",
".",
"{",
"username",
":",
"{",
"pubkey",
":",
"pubkey",
"timestamp",
":",
"timestamp",
"address",
":",
"address",
"}}"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L354-L377 | [
"def",
"delegates",
"(",
")",
":",
"qry",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT delegates.\"username\", delegates.\"transactionId\", transactions.\"timestamp\", transactions.\"senderId\", \n transactions.\"senderPublicKey\" \n ... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.lastpayout | Assumes that all send transactions from a delegate are payouts.
Use blacklist to remove rewardwallet and other transactions if the
address is not a voter. blacklist can contain both addresses and transactionIds | dpostools/legacy.py | def lastpayout(delegate_address, blacklist=None):
'''
Assumes that all send transactions from a delegate are payouts.
Use blacklist to remove rewardwallet and other transactions if the
address is not a voter. blacklist can contain both addresses and transactionIds'''
if blacklist... | def lastpayout(delegate_address, blacklist=None):
'''
Assumes that all send transactions from a delegate are payouts.
Use blacklist to remove rewardwallet and other transactions if the
address is not a voter. blacklist can contain both addresses and transactionIds'''
if blacklist... | [
"Assumes",
"that",
"all",
"send",
"transactions",
"from",
"a",
"delegate",
"are",
"payouts",
".",
"Use",
"blacklist",
"to",
"remove",
"rewardwallet",
"and",
"other",
"transactions",
"if",
"the",
"address",
"is",
"not",
"a",
"voter",
".",
"blacklist",
"can",
... | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L380-L417 | [
"def",
"lastpayout",
"(",
"delegate_address",
",",
"blacklist",
"=",
"None",
")",
":",
"if",
"blacklist",
"and",
"len",
"(",
"blacklist",
")",
">",
"1",
":",
"command_blacklist",
"=",
"'NOT IN '",
"+",
"str",
"(",
"tuple",
"(",
"blacklist",
")",
")",
"el... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.votes | returns every address that has voted for a delegate.
Current voters can be obtained using voters. ORDER BY timestamp ASC | dpostools/legacy.py | def votes(delegate_pubkey):
"""returns every address that has voted for a delegate.
Current voters can be obtained using voters. ORDER BY timestamp ASC"""
qry = DbCursor().execute_and_fetchall("""
SELECT transactions."recipientId", transactions."timestamp"
FROM ... | def votes(delegate_pubkey):
"""returns every address that has voted for a delegate.
Current voters can be obtained using voters. ORDER BY timestamp ASC"""
qry = DbCursor().execute_and_fetchall("""
SELECT transactions."recipientId", transactions."timestamp"
FROM ... | [
"returns",
"every",
"address",
"that",
"has",
"voted",
"for",
"a",
"delegate",
".",
"Current",
"voters",
"can",
"be",
"obtained",
"using",
"voters",
".",
"ORDER",
"BY",
"timestamp",
"ASC"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L420-L441 | [
"def",
"votes",
"(",
"delegate_pubkey",
")",
":",
"qry",
"=",
"DbCursor",
"(",
")",
".",
"execute_and_fetchall",
"(",
"\"\"\"\n SELECT transactions.\"recipientId\", transactions.\"timestamp\"\n FROM transactions, votes\n WHERE transactions.... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.blocks | returns a list of named tuples of all blocks forged by a delegate.
if delegate_pubkey is not specified, set_delegate needs to be called in advance.
max_timestamp can be configured to retrieve blocks up to a certain timestamp. | dpostools/legacy.py | def blocks(delegate_pubkey=None, max_timestamp=None):
"""returns a list of named tuples of all blocks forged by a delegate.
if delegate_pubkey is not specified, set_delegate needs to be called in advance.
max_timestamp can be configured to retrieve blocks up to a certain timestamp."""
i... | def blocks(delegate_pubkey=None, max_timestamp=None):
"""returns a list of named tuples of all blocks forged by a delegate.
if delegate_pubkey is not specified, set_delegate needs to be called in advance.
max_timestamp can be configured to retrieve blocks up to a certain timestamp."""
i... | [
"returns",
"a",
"list",
"of",
"named",
"tuples",
"of",
"all",
"blocks",
"forged",
"by",
"a",
"delegate",
".",
"if",
"delegate_pubkey",
"is",
"not",
"specified",
"set_delegate",
"needs",
"to",
"be",
"called",
"in",
"advance",
".",
"max_timestamp",
"can",
"be"... | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L480-L512 | [
"def",
"blocks",
"(",
"delegate_pubkey",
"=",
"None",
",",
"max_timestamp",
"=",
"None",
")",
":",
"if",
"not",
"delegate_pubkey",
":",
"delegate_pubkey",
"=",
"c",
".",
"DELEGATE",
"[",
"'PUBKEY'",
"]",
"if",
"max_timestamp",
":",
"max_timestamp_sql",
"=",
... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.share | Calculate the true blockweight payout share for a given delegate,
assuming no exceptions were made for a voter. last_payout is a map of addresses and timestamps:
{address: timestamp}. If no argument are given, it will start the calculation at the first forged block
by the delegate, generate a la... | dpostools/legacy.py | def share(passphrase=None, last_payout=None, start_block=0, del_pubkey=None, del_address=None):
"""Calculate the true blockweight payout share for a given delegate,
assuming no exceptions were made for a voter. last_payout is a map of addresses and timestamps:
{address: timestamp}. If no argumen... | def share(passphrase=None, last_payout=None, start_block=0, del_pubkey=None, del_address=None):
"""Calculate the true blockweight payout share for a given delegate,
assuming no exceptions were made for a voter. last_payout is a map of addresses and timestamps:
{address: timestamp}. If no argumen... | [
"Calculate",
"the",
"true",
"blockweight",
"payout",
"share",
"for",
"a",
"given",
"delegate",
"assuming",
"no",
"exceptions",
"were",
"made",
"for",
"a",
"voter",
".",
"last_payout",
"is",
"a",
"map",
"of",
"addresses",
"and",
"timestamps",
":",
"{",
"addre... | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L515-L701 | [
"def",
"share",
"(",
"passphrase",
"=",
"None",
",",
"last_payout",
"=",
"None",
",",
"start_block",
"=",
"0",
",",
"del_pubkey",
"=",
"None",
",",
"del_address",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"'starting share calculation using settings: {... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.dep_trueshare | Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_block: block from which we start adding to the share (we calculate balances from block 0 anyways)
:param str del_pubkey: delegate public key as is presented ... | dpostools/legacy.py | def dep_trueshare(start_block=0, del_pubkey=None, del_address=None, blacklist=None, share_fees=False, max_weight=float('inf'), raiseError=True):
'''
Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_... | def dep_trueshare(start_block=0, del_pubkey=None, del_address=None, blacklist=None, share_fees=False, max_weight=float('inf'), raiseError=True):
'''
Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_... | [
"Legacy",
"TBW",
"script",
"(",
"still",
"pretty",
"performant",
"but",
"has",
"some",
"quirky",
"behavior",
"when",
"forging",
"delegates",
"are",
"amongst",
"your",
"voters",
")"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L705-L852 | [
"def",
"dep_trueshare",
"(",
"start_block",
"=",
"0",
",",
"del_pubkey",
"=",
"None",
",",
"del_address",
"=",
"None",
",",
"blacklist",
"=",
"None",
",",
"share_fees",
"=",
"False",
",",
"max_weight",
"=",
"float",
"(",
"'inf'",
")",
",",
"raiseError",
... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | Delegate.trueshare | Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_block: block from which we start adding to the share (we calculate balances from block 0 anyways)
:param str del_pubkey: delegate public key as is presented ... | dpostools/legacy.py | def trueshare(start_block=0, del_pubkey=None, del_address=None, blacklist=None, share_fees=False,
max_weight=float('inf')):
'''
Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_blo... | def trueshare(start_block=0, del_pubkey=None, del_address=None, blacklist=None, share_fees=False,
max_weight=float('inf')):
'''
Legacy TBW script (still pretty performant, but has some quirky behavior when forging delegates are amongst
your voters)
:param int start_blo... | [
"Legacy",
"TBW",
"script",
"(",
"still",
"pretty",
"performant",
"but",
"has",
"some",
"quirky",
"behavior",
"when",
"forging",
"delegates",
"are",
"amongst",
"your",
"voters",
")"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/legacy.py#L855-L986 | [
"def",
"trueshare",
"(",
"start_block",
"=",
"0",
",",
"del_pubkey",
"=",
"None",
",",
"del_address",
"=",
"None",
",",
"blacklist",
"=",
"None",
",",
"share_fees",
"=",
"False",
",",
"max_weight",
"=",
"float",
"(",
"'inf'",
")",
")",
":",
"delegate_pub... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | IPSourceFactory.add_source | Adds a source to the factory provided it's type and constructor arguments
:param source_class: The class used to instantiate the source
:type source_class: type
:param constructor_args: Arguments to be passed into the constructor
:type constructor_args: Iterable | src/echoip/sources.py | def add_source(self, source_class, *constructor_args):
"""
Adds a source to the factory provided it's type and constructor arguments
:param source_class: The class used to instantiate the source
:type source_class: type
:param constructor_args: Arguments to be passed into the con... | def add_source(self, source_class, *constructor_args):
"""
Adds a source to the factory provided it's type and constructor arguments
:param source_class: The class used to instantiate the source
:type source_class: type
:param constructor_args: Arguments to be passed into the con... | [
"Adds",
"a",
"source",
"to",
"the",
"factory",
"provided",
"it",
"s",
"type",
"and",
"constructor",
"arguments",
":",
"param",
"source_class",
":",
"The",
"class",
"used",
"to",
"instantiate",
"the",
"source",
":",
"type",
"source_class",
":",
"type",
":",
... | eflee/pyechoip | python | https://github.com/eflee/pyechoip/blob/226e5eab21dbfdfb59b9af312a56a8ddc3675419/src/echoip/sources.py#L158-L169 | [
"def",
"add_source",
"(",
"self",
",",
"source_class",
",",
"*",
"constructor_args",
")",
":",
"if",
"not",
"IIPSource",
".",
"implementedBy",
"(",
"source_class",
")",
":",
"raise",
"TypeError",
"(",
"\"source_class {} must implement IIPSource\"",
".",
"format",
... | 226e5eab21dbfdfb59b9af312a56a8ddc3675419 |
valid | IPSourceFactory.get_sources | Generates instantiated sources from the factory
:param limit: the max number of sources to yield
:type limit: int
:param types_list: filter by types so the constructor can be used to accomidate many types
:type types_list: class or list of classes
:return: Yields types added by a... | src/echoip/sources.py | def get_sources(self, limit=sys.maxsize, types_list=None):
"""
Generates instantiated sources from the factory
:param limit: the max number of sources to yield
:type limit: int
:param types_list: filter by types so the constructor can be used to accomidate many types
:typ... | def get_sources(self, limit=sys.maxsize, types_list=None):
"""
Generates instantiated sources from the factory
:param limit: the max number of sources to yield
:type limit: int
:param types_list: filter by types so the constructor can be used to accomidate many types
:typ... | [
"Generates",
"instantiated",
"sources",
"from",
"the",
"factory",
":",
"param",
"limit",
":",
"the",
"max",
"number",
"of",
"sources",
"to",
"yield",
":",
"type",
"limit",
":",
"int",
":",
"param",
"types_list",
":",
"filter",
"by",
"types",
"so",
"the",
... | eflee/pyechoip | python | https://github.com/eflee/pyechoip/blob/226e5eab21dbfdfb59b9af312a56a8ddc3675419/src/echoip/sources.py#L171-L193 | [
"def",
"get_sources",
"(",
"self",
",",
"limit",
"=",
"sys",
".",
"maxsize",
",",
"types_list",
"=",
"None",
")",
":",
"if",
"types_list",
"and",
"not",
"isinstance",
"(",
"types_list",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"types_list",
"=",
... | 226e5eab21dbfdfb59b9af312a56a8ddc3675419 |
valid | value_to_bool | Massages the 'true' and 'false' strings to bool equivalents.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:rtype: bool
:return: True or False, depending on the value. | evarify/filters/python_basics.py | def value_to_bool(config_val, evar):
"""
Massages the 'true' and 'false' strings to bool equivalents.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:rtype: bool
:return: True or False, depending on the value.
... | def value_to_bool(config_val, evar):
"""
Massages the 'true' and 'false' strings to bool equivalents.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:rtype: bool
:return: True or False, depending on the value.
... | [
"Massages",
"the",
"true",
"and",
"false",
"strings",
"to",
"bool",
"equivalents",
"."
] | gtaylor/evarify | python | https://github.com/gtaylor/evarify/blob/37cec29373c820eda96939633e2067d55598915b/evarify/filters/python_basics.py#L64-L79 | [
"def",
"value_to_bool",
"(",
"config_val",
",",
"evar",
")",
":",
"if",
"not",
"config_val",
":",
"return",
"False",
"if",
"config_val",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"==",
"'true'",
":",
"return",
"True",
"else",
":",
"return",
"Fals... | 37cec29373c820eda96939633e2067d55598915b |
valid | validate_is_not_none | If the value is ``None``, fail validation.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value is None. | evarify/filters/python_basics.py | def validate_is_not_none(config_val, evar):
"""
If the value is ``None``, fail validation.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value is None.
"""
if config_val is ... | def validate_is_not_none(config_val, evar):
"""
If the value is ``None``, fail validation.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value is None.
"""
if config_val is ... | [
"If",
"the",
"value",
"is",
"None",
"fail",
"validation",
"."
] | gtaylor/evarify | python | https://github.com/gtaylor/evarify/blob/37cec29373c820eda96939633e2067d55598915b/evarify/filters/python_basics.py#L83-L96 | [
"def",
"validate_is_not_none",
"(",
"config_val",
",",
"evar",
")",
":",
"if",
"config_val",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Value for environment variable '{evar_name}' can't \"",
"\"be empty.\"",
".",
"format",
"(",
"evar_name",
"=",
"evar",
".",
... | 37cec29373c820eda96939633e2067d55598915b |
valid | validate_is_boolean_true | Make sure the value evaluates to boolean True.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value evaluates to boolean False. | evarify/filters/python_basics.py | def validate_is_boolean_true(config_val, evar):
"""
Make sure the value evaluates to boolean True.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value evaluates to boolean False.
... | def validate_is_boolean_true(config_val, evar):
"""
Make sure the value evaluates to boolean True.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:raises: ValueError if the config value evaluates to boolean False.
... | [
"Make",
"sure",
"the",
"value",
"evaluates",
"to",
"boolean",
"True",
"."
] | gtaylor/evarify | python | https://github.com/gtaylor/evarify/blob/37cec29373c820eda96939633e2067d55598915b/evarify/filters/python_basics.py#L100-L113 | [
"def",
"validate_is_boolean_true",
"(",
"config_val",
",",
"evar",
")",
":",
"if",
"config_val",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Value for environment variable '{evar_name}' can't \"",
"\"be empty.\"",
".",
"format",
"(",
"evar_name",
"=",
"evar",
".... | 37cec29373c820eda96939633e2067d55598915b |
valid | value_to_python_log_level | Convert an evar value into a Python logging level constant.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:return: A validated string.
:raises: ValueError if the log level is invalid. | evarify/filters/python_basics.py | def value_to_python_log_level(config_val, evar):
"""
Convert an evar value into a Python logging level constant.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:return: A validated string.
:raises: ValueError if ... | def value_to_python_log_level(config_val, evar):
"""
Convert an evar value into a Python logging level constant.
:param str config_val: The env var value.
:param EnvironmentVariable evar: The EVar object we are validating
a value for.
:return: A validated string.
:raises: ValueError if ... | [
"Convert",
"an",
"evar",
"value",
"into",
"a",
"Python",
"logging",
"level",
"constant",
"."
] | gtaylor/evarify | python | https://github.com/gtaylor/evarify/blob/37cec29373c820eda96939633e2067d55598915b/evarify/filters/python_basics.py#L117-L131 | [
"def",
"value_to_python_log_level",
"(",
"config_val",
",",
"evar",
")",
":",
"if",
"not",
"config_val",
":",
"config_val",
"=",
"evar",
".",
"default_val",
"config_val",
"=",
"config_val",
".",
"upper",
"(",
")",
"# noinspection PyProtectedMember",
"return",
"log... | 37cec29373c820eda96939633e2067d55598915b |
valid | register_range_type | Register a new range type as a PostgreSQL range.
>>> register_range_type("int4range", intrange, conn)
The above will make sure intrange is regarded as an int4range for queries
and that int4ranges will be cast into intrange when fetching rows.
pgrange should be the full name including schema for t... | psycospans/__init__.py | def register_range_type(pgrange, pyrange, conn):
"""
Register a new range type as a PostgreSQL range.
>>> register_range_type("int4range", intrange, conn)
The above will make sure intrange is regarded as an int4range for queries
and that int4ranges will be cast into intrange when fetching rows... | def register_range_type(pgrange, pyrange, conn):
"""
Register a new range type as a PostgreSQL range.
>>> register_range_type("int4range", intrange, conn)
The above will make sure intrange is regarded as an int4range for queries
and that int4ranges will be cast into intrange when fetching rows... | [
"Register",
"a",
"new",
"range",
"type",
"as",
"a",
"PostgreSQL",
"range",
"."
] | runfalk/psycospans | python | https://github.com/runfalk/psycospans/blob/77a2d33cb280e7ff78252e173d702dd800f03133/psycospans/__init__.py#L36-L55 | [
"def",
"register_range_type",
"(",
"pgrange",
",",
"pyrange",
",",
"conn",
")",
":",
"register_adapter",
"(",
"pyrange",
",",
"partial",
"(",
"adapt_range",
",",
"pgrange",
")",
")",
"register_range_caster",
"(",
"pgrange",
",",
"pyrange",
",",
"*",
"query_ran... | 77a2d33cb280e7ff78252e173d702dd800f03133 |
valid | get_api_error | Acquires the correct error for a given response.
:param requests.Response response: HTTP error response
:returns: the appropriate error for a given response
:rtype: APIError | cbexchange/error.py | def get_api_error(response):
"""Acquires the correct error for a given response.
:param requests.Response response: HTTP error response
:returns: the appropriate error for a given response
:rtype: APIError
"""
error_class = _status_code_to_class.get(response.status_code, APIError)
return error_class(res... | def get_api_error(response):
"""Acquires the correct error for a given response.
:param requests.Response response: HTTP error response
:returns: the appropriate error for a given response
:rtype: APIError
"""
error_class = _status_code_to_class.get(response.status_code, APIError)
return error_class(res... | [
"Acquires",
"the",
"correct",
"error",
"for",
"a",
"given",
"response",
"."
] | agsimeonov/cbexchange | python | https://github.com/agsimeonov/cbexchange/blob/e3762f77583f89cf7b4f501ab3c7675fc7d30ab3/cbexchange/error.py#L42-L51 | [
"def",
"get_api_error",
"(",
"response",
")",
":",
"error_class",
"=",
"_status_code_to_class",
".",
"get",
"(",
"response",
".",
"status_code",
",",
"APIError",
")",
"return",
"error_class",
"(",
"response",
")"
] | e3762f77583f89cf7b4f501ab3c7675fc7d30ab3 |
valid | get_param_values | Converts the request parameters to Python.
:param request: <pyramid.request.Request> || <dict>
:return: <dict> | pyramid_orb/utils.py | def get_param_values(request, model=None):
"""
Converts the request parameters to Python.
:param request: <pyramid.request.Request> || <dict>
:return: <dict>
"""
if type(request) == dict:
return request
params = get_payload(request)
# support in-place editing formatted reques... | def get_param_values(request, model=None):
"""
Converts the request parameters to Python.
:param request: <pyramid.request.Request> || <dict>
:return: <dict>
"""
if type(request) == dict:
return request
params = get_payload(request)
# support in-place editing formatted reques... | [
"Converts",
"the",
"request",
"parameters",
"to",
"Python",
"."
] | orb-framework/pyramid_orb | python | https://github.com/orb-framework/pyramid_orb/blob/e5c716fc75626e1cd966f7bd87b470a8b71126bf/pyramid_orb/utils.py#L10-L33 | [
"def",
"get_param_values",
"(",
"request",
",",
"model",
"=",
"None",
")",
":",
"if",
"type",
"(",
"request",
")",
"==",
"dict",
":",
"return",
"request",
"params",
"=",
"get_payload",
"(",
"request",
")",
"# support in-place editing formatted request",
"try",
... | e5c716fc75626e1cd966f7bd87b470a8b71126bf |
valid | get_context | Extracts ORB context information from the request.
:param request: <pyramid.request.Request>
:param model: <orb.Model> || None
:return: {<str> key: <variant> value} values, <orb.Context> | pyramid_orb/utils.py | def get_context(request, model=None):
"""
Extracts ORB context information from the request.
:param request: <pyramid.request.Request>
:param model: <orb.Model> || None
:return: {<str> key: <variant> value} values, <orb.Context>
"""
# convert request parameters to python
param_values =... | def get_context(request, model=None):
"""
Extracts ORB context information from the request.
:param request: <pyramid.request.Request>
:param model: <orb.Model> || None
:return: {<str> key: <variant> value} values, <orb.Context>
"""
# convert request parameters to python
param_values =... | [
"Extracts",
"ORB",
"context",
"information",
"from",
"the",
"request",
"."
] | orb-framework/pyramid_orb | python | https://github.com/orb-framework/pyramid_orb/blob/e5c716fc75626e1cd966f7bd87b470a8b71126bf/pyramid_orb/utils.py#L36-L113 | [
"def",
"get_context",
"(",
"request",
",",
"model",
"=",
"None",
")",
":",
"# convert request parameters to python",
"param_values",
"=",
"get_param_values",
"(",
"request",
",",
"model",
"=",
"model",
")",
"# extract the full orb context if provided",
"context",
"=",
... | e5c716fc75626e1cd966f7bd87b470a8b71126bf |
valid | OrderBook._real_time_thread | Handles real-time updates to the order book. | cbexchange/orderbook.py | def _real_time_thread(self):
"""Handles real-time updates to the order book."""
while self.ws_client.connected():
if self.die:
break
if self.pause:
sleep(5)
continue
message = self.ws_client.receive()
if message is None:
break
message_type ... | def _real_time_thread(self):
"""Handles real-time updates to the order book."""
while self.ws_client.connected():
if self.die:
break
if self.pause:
sleep(5)
continue
message = self.ws_client.receive()
if message is None:
break
message_type ... | [
"Handles",
"real",
"-",
"time",
"updates",
"to",
"the",
"order",
"book",
"."
] | agsimeonov/cbexchange | python | https://github.com/agsimeonov/cbexchange/blob/e3762f77583f89cf7b4f501ab3c7675fc7d30ab3/cbexchange/orderbook.py#L120-L153 | [
"def",
"_real_time_thread",
"(",
"self",
")",
":",
"while",
"self",
".",
"ws_client",
".",
"connected",
"(",
")",
":",
"if",
"self",
".",
"die",
":",
"break",
"if",
"self",
".",
"pause",
":",
"sleep",
"(",
"5",
")",
"continue",
"message",
"=",
"self"... | e3762f77583f89cf7b4f501ab3c7675fc7d30ab3 |
valid | WSClient._keep_alive_thread | Used exclusively as a thread which keeps the WebSocket alive. | cbexchange/websock.py | def _keep_alive_thread(self):
"""Used exclusively as a thread which keeps the WebSocket alive."""
while True:
with self._lock:
if self.connected():
self._ws.ping()
else:
self.disconnect()
self._thread = None
return
sleep(30) | def _keep_alive_thread(self):
"""Used exclusively as a thread which keeps the WebSocket alive."""
while True:
with self._lock:
if self.connected():
self._ws.ping()
else:
self.disconnect()
self._thread = None
return
sleep(30) | [
"Used",
"exclusively",
"as",
"a",
"thread",
"which",
"keeps",
"the",
"WebSocket",
"alive",
"."
] | agsimeonov/cbexchange | python | https://github.com/agsimeonov/cbexchange/blob/e3762f77583f89cf7b4f501ab3c7675fc7d30ab3/cbexchange/websock.py#L104-L114 | [
"def",
"_keep_alive_thread",
"(",
"self",
")",
":",
"while",
"True",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"connected",
"(",
")",
":",
"self",
".",
"_ws",
".",
"ping",
"(",
")",
"else",
":",
"self",
".",
"disconnect",
"(",
")",... | e3762f77583f89cf7b4f501ab3c7675fc7d30ab3 |
valid | WSClient.connect | Connects and subscribes to the WebSocket Feed. | cbexchange/websock.py | def connect(self):
"""Connects and subscribes to the WebSocket Feed."""
if not self.connected():
self._ws = create_connection(self.WS_URI)
message = {
'type':self.WS_TYPE,
'product_id':self.WS_PRODUCT_ID
}
self._ws.send(dumps(message))
# There will be only one keep... | def connect(self):
"""Connects and subscribes to the WebSocket Feed."""
if not self.connected():
self._ws = create_connection(self.WS_URI)
message = {
'type':self.WS_TYPE,
'product_id':self.WS_PRODUCT_ID
}
self._ws.send(dumps(message))
# There will be only one keep... | [
"Connects",
"and",
"subscribes",
"to",
"the",
"WebSocket",
"Feed",
"."
] | agsimeonov/cbexchange | python | https://github.com/agsimeonov/cbexchange/blob/e3762f77583f89cf7b4f501ab3c7675fc7d30ab3/cbexchange/websock.py#L116-L130 | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"connected",
"(",
")",
":",
"self",
".",
"_ws",
"=",
"create_connection",
"(",
"self",
".",
"WS_URI",
")",
"message",
"=",
"{",
"'type'",
":",
"self",
".",
"WS_TYPE",
",",
"'product_i... | e3762f77583f89cf7b4f501ab3c7675fc7d30ab3 |
valid | cached_httpbl_exempt | Marks a view function as being exempt from the cached httpbl view protection. | cached_httpbl/decorators.py | def cached_httpbl_exempt(view_func):
"""
Marks a view function as being exempt from the cached httpbl view protection.
"""
# We could just do view_func.cached_httpbl_exempt = True, but decorators
# are nicer if they don't have side-effects, so we return a new
# function.
def wrapped_view(*ar... | def cached_httpbl_exempt(view_func):
"""
Marks a view function as being exempt from the cached httpbl view protection.
"""
# We could just do view_func.cached_httpbl_exempt = True, but decorators
# are nicer if they don't have side-effects, so we return a new
# function.
def wrapped_view(*ar... | [
"Marks",
"a",
"view",
"function",
"as",
"being",
"exempt",
"from",
"the",
"cached",
"httpbl",
"view",
"protection",
"."
] | dlancer/django-cached-httpbl | python | https://github.com/dlancer/django-cached-httpbl/blob/b32106f4283f9605122255f2c9bfbd3bff465fa5/cached_httpbl/decorators.py#L16-L26 | [
"def",
"cached_httpbl_exempt",
"(",
"view_func",
")",
":",
"# We could just do view_func.cached_httpbl_exempt = True, but decorators",
"# are nicer if they don't have side-effects, so we return a new",
"# function.",
"def",
"wrapped_view",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",... | b32106f4283f9605122255f2c9bfbd3bff465fa5 |
valid | CounterPool.get_conn | Hook point for overriding how the CounterPool gets its connection to
AWS. | albertson/base.py | def get_conn(self, aws_access_key=None, aws_secret_key=None):
'''
Hook point for overriding how the CounterPool gets its connection to
AWS.
'''
return boto.connect_dynamodb(
aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key,
) | def get_conn(self, aws_access_key=None, aws_secret_key=None):
'''
Hook point for overriding how the CounterPool gets its connection to
AWS.
'''
return boto.connect_dynamodb(
aws_access_key_id=aws_access_key,
aws_secret_access_key=aws_secret_key,
) | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CounterPool",
"gets",
"its",
"connection",
"to",
"AWS",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L55-L63 | [
"def",
"get_conn",
"(",
"self",
",",
"aws_access_key",
"=",
"None",
",",
"aws_secret_key",
"=",
"None",
")",
":",
"return",
"boto",
".",
"connect_dynamodb",
"(",
"aws_access_key_id",
"=",
"aws_access_key",
",",
"aws_secret_access_key",
"=",
"aws_secret_key",
",",
... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.get_schema | Hook point for overriding how the CounterPool determines the schema
to be used when creating a missing table. | albertson/base.py | def get_schema(self):
'''
Hook point for overriding how the CounterPool determines the schema
to be used when creating a missing table.
'''
if not self.schema:
raise NotImplementedError(
'You must provide a schema value or override the get_schema metho... | def get_schema(self):
'''
Hook point for overriding how the CounterPool determines the schema
to be used when creating a missing table.
'''
if not self.schema:
raise NotImplementedError(
'You must provide a schema value or override the get_schema metho... | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CounterPool",
"determines",
"the",
"schema",
"to",
"be",
"used",
"when",
"creating",
"a",
"missing",
"table",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L76-L86 | [
"def",
"get_schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"schema",
":",
"raise",
"NotImplementedError",
"(",
"'You must provide a schema value or override the get_schema method'",
")",
"return",
"self",
".",
"conn",
".",
"create_schema",
"(",
"*",
"*",
... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.create_table | Hook point for overriding how the CounterPool creates a new table
in DynamooDB | albertson/base.py | def create_table(self):
'''
Hook point for overriding how the CounterPool creates a new table
in DynamooDB
'''
table = self.conn.create_table(
name=self.get_table_name(),
schema=self.get_schema(),
read_units=self.get_read_units(),
w... | def create_table(self):
'''
Hook point for overriding how the CounterPool creates a new table
in DynamooDB
'''
table = self.conn.create_table(
name=self.get_table_name(),
schema=self.get_schema(),
read_units=self.get_read_units(),
w... | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CounterPool",
"creates",
"a",
"new",
"table",
"in",
"DynamooDB"
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L102-L117 | [
"def",
"create_table",
"(",
"self",
")",
":",
"table",
"=",
"self",
".",
"conn",
".",
"create_table",
"(",
"name",
"=",
"self",
".",
"get_table_name",
"(",
")",
",",
"schema",
"=",
"self",
".",
"get_schema",
"(",
")",
",",
"read_units",
"=",
"self",
... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.get_table | Hook point for overriding how the CounterPool transforms table_name
into a boto DynamoDB Table object. | albertson/base.py | def get_table(self):
'''
Hook point for overriding how the CounterPool transforms table_name
into a boto DynamoDB Table object.
'''
if hasattr(self, '_table'):
table = self._table
else:
try:
table = self.conn.get_table(self.get_tabl... | def get_table(self):
'''
Hook point for overriding how the CounterPool transforms table_name
into a boto DynamoDB Table object.
'''
if hasattr(self, '_table'):
table = self._table
else:
try:
table = self.conn.get_table(self.get_tabl... | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CounterPool",
"transforms",
"table_name",
"into",
"a",
"boto",
"DynamoDB",
"Table",
"object",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L119-L137 | [
"def",
"get_table",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_table'",
")",
":",
"table",
"=",
"self",
".",
"_table",
"else",
":",
"try",
":",
"table",
"=",
"self",
".",
"conn",
".",
"get_table",
"(",
"self",
".",
"get_table_name",... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.create_item | Hook point for overriding how the CouterPool creates a DynamoDB item
for a given counter when an existing item can't be found. | albertson/base.py | def create_item(self, hash_key, start=0, extra_attrs=None):
'''
Hook point for overriding how the CouterPool creates a DynamoDB item
for a given counter when an existing item can't be found.
'''
table = self.get_table()
now = datetime.utcnow().replace(microsecond=0).isofo... | def create_item(self, hash_key, start=0, extra_attrs=None):
'''
Hook point for overriding how the CouterPool creates a DynamoDB item
for a given counter when an existing item can't be found.
'''
table = self.get_table()
now = datetime.utcnow().replace(microsecond=0).isofo... | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CouterPool",
"creates",
"a",
"DynamoDB",
"item",
"for",
"a",
"given",
"counter",
"when",
"an",
"existing",
"item",
"can",
"t",
"be",
"found",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L139-L160 | [
"def",
"create_item",
"(",
"self",
",",
"hash_key",
",",
"start",
"=",
"0",
",",
"extra_attrs",
"=",
"None",
")",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
")",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"microsecon... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.get_item | Hook point for overriding how the CouterPool fetches a DynamoDB item
for a given counter. | albertson/base.py | def get_item(self, hash_key, start=0, extra_attrs=None):
'''
Hook point for overriding how the CouterPool fetches a DynamoDB item
for a given counter.
'''
table = self.get_table()
try:
item = table.get_item(hash_key=hash_key)
except DynamoDBKeyNotFoun... | def get_item(self, hash_key, start=0, extra_attrs=None):
'''
Hook point for overriding how the CouterPool fetches a DynamoDB item
for a given counter.
'''
table = self.get_table()
try:
item = table.get_item(hash_key=hash_key)
except DynamoDBKeyNotFoun... | [
"Hook",
"point",
"for",
"overriding",
"how",
"the",
"CouterPool",
"fetches",
"a",
"DynamoDB",
"item",
"for",
"a",
"given",
"counter",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L162-L181 | [
"def",
"get_item",
"(",
"self",
",",
"hash_key",
",",
"start",
"=",
"0",
",",
"extra_attrs",
"=",
"None",
")",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
")",
"try",
":",
"item",
"=",
"table",
".",
"get_item",
"(",
"hash_key",
"=",
"hash_key",... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | CounterPool.get_counter | Gets the DynamoDB item behind a counter and ties it to a Counter
instace. | albertson/base.py | def get_counter(self, name, start=0):
'''
Gets the DynamoDB item behind a counter and ties it to a Counter
instace.
'''
item = self.get_item(hash_key=name, start=start)
counter = Counter(dynamo_item=item, pool=self)
return counter | def get_counter(self, name, start=0):
'''
Gets the DynamoDB item behind a counter and ties it to a Counter
instace.
'''
item = self.get_item(hash_key=name, start=start)
counter = Counter(dynamo_item=item, pool=self)
return counter | [
"Gets",
"the",
"DynamoDB",
"item",
"behind",
"a",
"counter",
"and",
"ties",
"it",
"to",
"a",
"Counter",
"instace",
"."
] | FocusLab/Albertson | python | https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L183-L191 | [
"def",
"get_counter",
"(",
"self",
",",
"name",
",",
"start",
"=",
"0",
")",
":",
"item",
"=",
"self",
".",
"get_item",
"(",
"hash_key",
"=",
"name",
",",
"start",
"=",
"start",
")",
"counter",
"=",
"Counter",
"(",
"dynamo_item",
"=",
"item",
",",
... | a42f9873559df9188c40c34fdffb079d78eaa3fe |
valid | Descriptor.exact_match | Matches this descriptor to another descriptor exactly.
Args:
descriptor: another descriptor to match this one.
Returns: True if descriptors match or False otherwise. | pip_services_commons/refer/Descriptor.py | def exact_match(self, descriptor):
"""
Matches this descriptor to another descriptor exactly.
Args:
descriptor: another descriptor to match this one.
Returns: True if descriptors match or False otherwise.
"""
return self._exact_match_field... | def exact_match(self, descriptor):
"""
Matches this descriptor to another descriptor exactly.
Args:
descriptor: another descriptor to match this one.
Returns: True if descriptors match or False otherwise.
"""
return self._exact_match_field... | [
"Matches",
"this",
"descriptor",
"to",
"another",
"descriptor",
"exactly",
".",
"Args",
":",
"descriptor",
":",
"another",
"descriptor",
"to",
"match",
"this",
"one",
".",
"Returns",
":",
"True",
"if",
"descriptors",
"match",
"or",
"False",
"otherwise",
"."
] | pip-services/pip-services-commons-python | python | https://github.com/pip-services/pip-services-commons-python/blob/2205b18c45c60372966c62c1f23ac4fbc31e11b3/pip_services_commons/refer/Descriptor.py#L117-L130 | [
"def",
"exact_match",
"(",
"self",
",",
"descriptor",
")",
":",
"return",
"self",
".",
"_exact_match_field",
"(",
"self",
".",
"_group",
",",
"descriptor",
".",
"get_group",
"(",
")",
")",
"and",
"self",
".",
"_exact_atch_field",
"(",
"self",
".",
"_type",... | 2205b18c45c60372966c62c1f23ac4fbc31e11b3 |
valid | many_to_one | Use an event to build a many-to-one relationship on a class.
This makes use of the :meth:`.References._reference_table` method
to generate a full foreign key relationship to the remote table. | baka_model/model/meta/orm.py | def many_to_one(clsname, **kw):
"""Use an event to build a many-to-one relationship on a class.
This makes use of the :meth:`.References._reference_table` method
to generate a full foreign key relationship to the remote table.
"""
@declared_attr
def m2o(cls):
cls._references((cls.__nam... | def many_to_one(clsname, **kw):
"""Use an event to build a many-to-one relationship on a class.
This makes use of the :meth:`.References._reference_table` method
to generate a full foreign key relationship to the remote table.
"""
@declared_attr
def m2o(cls):
cls._references((cls.__nam... | [
"Use",
"an",
"event",
"to",
"build",
"a",
"many",
"-",
"to",
"-",
"one",
"relationship",
"on",
"a",
"class",
"."
] | suryakencana007/baka_model | python | https://github.com/suryakencana007/baka_model/blob/915c2da9920e973302f5764ae63799acd5ecf0b7/baka_model/model/meta/orm.py#L23-L34 | [
"def",
"many_to_one",
"(",
"clsname",
",",
"*",
"*",
"kw",
")",
":",
"@",
"declared_attr",
"def",
"m2o",
"(",
"cls",
")",
":",
"cls",
".",
"_references",
"(",
"(",
"cls",
".",
"__name__",
",",
"clsname",
")",
")",
"return",
"relationship",
"(",
"clsn... | 915c2da9920e973302f5764ae63799acd5ecf0b7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.