repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
PyFilesystem/pyfilesystem2 | fs/ftpfs.py | FTPFS.ftp_url | def ftp_url(self):
# type: () -> Text
"""Get the FTP url this filesystem will open."""
url = (
"ftp://{}".format(self.host)
if self.port == 21
else "ftp://{}:{}".format(self.host, self.port)
)
return url | python | def ftp_url(self):
# type: () -> Text
"""Get the FTP url this filesystem will open."""
url = (
"ftp://{}".format(self.host)
if self.port == 21
else "ftp://{}:{}".format(self.host, self.port)
)
return url | [
"def",
"ftp_url",
"(",
"self",
")",
":",
"url",
"=",
"(",
"\"ftp://{}\"",
".",
"format",
"(",
"self",
".",
"host",
")",
"if",
"self",
".",
"port",
"==",
"21",
"else",
"\"ftp://{}:{}\"",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"po... | Get the FTP url this filesystem will open. | [
"Get",
"the",
"FTP",
"url",
"this",
"filesystem",
"will",
"open",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/ftpfs.py#L440-L448 | train |
PyFilesystem/pyfilesystem2 | fs/ftpfs.py | FTPFS._parse_ftp_time | def _parse_ftp_time(cls, time_text):
# type: (Text) -> Optional[int]
"""Parse a time from an ftp directory listing.
"""
try:
tm_year = int(time_text[0:4])
tm_month = int(time_text[4:6])
tm_day = int(time_text[6:8])
tm_hour = int(time_text[8... | python | def _parse_ftp_time(cls, time_text):
# type: (Text) -> Optional[int]
"""Parse a time from an ftp directory listing.
"""
try:
tm_year = int(time_text[0:4])
tm_month = int(time_text[4:6])
tm_day = int(time_text[6:8])
tm_hour = int(time_text[8... | [
"def",
"_parse_ftp_time",
"(",
"cls",
",",
"time_text",
")",
":",
"try",
":",
"tm_year",
"=",
"int",
"(",
"time_text",
"[",
"0",
":",
"4",
"]",
")",
"tm_month",
"=",
"int",
"(",
"time_text",
"[",
"4",
":",
"6",
"]",
")",
"tm_day",
"=",
"int",
"("... | Parse a time from an ftp directory listing. | [
"Parse",
"a",
"time",
"from",
"an",
"ftp",
"directory",
"listing",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/ftpfs.py#L506-L522 | train |
PyFilesystem/pyfilesystem2 | fs/compress.py | write_zip | def write_zip(
src_fs, # type: FS
file, # type: Union[Text, BinaryIO]
compression=zipfile.ZIP_DEFLATED, # type: int
encoding="utf-8", # type: Text
walker=None, # type: Optional[Walker]
):
# type: (...) -> None
"""Write the contents of a filesystem to a zip file.
Arguments:
... | python | def write_zip(
src_fs, # type: FS
file, # type: Union[Text, BinaryIO]
compression=zipfile.ZIP_DEFLATED, # type: int
encoding="utf-8", # type: Text
walker=None, # type: Optional[Walker]
):
# type: (...) -> None
"""Write the contents of a filesystem to a zip file.
Arguments:
... | [
"def",
"write_zip",
"(",
"src_fs",
",",
"file",
",",
"compression",
"=",
"zipfile",
".",
"ZIP_DEFLATED",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"walker",
"=",
"None",
",",
")",
":",
"_zip",
"=",
"zipfile",
".",
"ZipFile",
"(",
"file",
",",
"mode",
"="... | Write the contents of a filesystem to a zip file.
Arguments:
src_fs (~fs.base.FS): The source filesystem to compress.
file (str or io.IOBase): Destination file, may be a file name
or an open file object.
compression (int): Compression to use (one of the constants
def... | [
"Write",
"the",
"contents",
"of",
"a",
"filesystem",
"to",
"a",
"zip",
"file",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/compress.py#L32-L105 | train |
PyFilesystem/pyfilesystem2 | fs/compress.py | write_tar | def write_tar(
src_fs, # type: FS
file, # type: Union[Text, BinaryIO]
compression=None, # type: Optional[Text]
encoding="utf-8", # type: Text
walker=None, # type: Optional[Walker]
):
# type: (...) -> None
"""Write the contents of a filesystem to a tar file.
Arguments:
file ... | python | def write_tar(
src_fs, # type: FS
file, # type: Union[Text, BinaryIO]
compression=None, # type: Optional[Text]
encoding="utf-8", # type: Text
walker=None, # type: Optional[Walker]
):
# type: (...) -> None
"""Write the contents of a filesystem to a tar file.
Arguments:
file ... | [
"def",
"write_tar",
"(",
"src_fs",
",",
"file",
",",
"compression",
"=",
"None",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"walker",
"=",
"None",
",",
")",
":",
"type_map",
"=",
"{",
"ResourceType",
".",
"block_special_file",
":",
"tarfile",
".",
"BLKTYPE",
... | Write the contents of a filesystem to a tar file.
Arguments:
file (str or io.IOBase): Destination file, may be a file
name or an open file object.
compression (str, optional): Compression to use, or `None`
for a plain Tar archive without compression.
encoding(str): T... | [
"Write",
"the",
"contents",
"of",
"a",
"filesystem",
"to",
"a",
"tar",
"file",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/compress.py#L108-L187 | train |
PyFilesystem/pyfilesystem2 | fs/glob.py | Globber.count_lines | def count_lines(self):
# type: () -> LineCounts
"""Count the lines in the matched files.
Returns:
`~LineCounts`: A named tuple containing line counts.
Example:
>>> import fs
>>> fs.open_fs('~/projects').glob('**/*.py').count_lines()
LineC... | python | def count_lines(self):
# type: () -> LineCounts
"""Count the lines in the matched files.
Returns:
`~LineCounts`: A named tuple containing line counts.
Example:
>>> import fs
>>> fs.open_fs('~/projects').glob('**/*.py').count_lines()
LineC... | [
"def",
"count_lines",
"(",
"self",
")",
":",
"lines",
"=",
"0",
"non_blank",
"=",
"0",
"for",
"path",
",",
"info",
"in",
"self",
".",
"_make_iter",
"(",
")",
":",
"if",
"info",
".",
"is_file",
":",
"for",
"line",
"in",
"self",
".",
"fs",
".",
"op... | Count the lines in the matched files.
Returns:
`~LineCounts`: A named tuple containing line counts.
Example:
>>> import fs
>>> fs.open_fs('~/projects').glob('**/*.py').count_lines()
LineCounts(lines=5767102, non_blank=4915110) | [
"Count",
"the",
"lines",
"in",
"the",
"matched",
"files",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/glob.py#L190-L212 | train |
PyFilesystem/pyfilesystem2 | fs/glob.py | Globber.remove | def remove(self):
# type: () -> int
"""Removed all matched paths.
Returns:
int: Number of file and directories removed.
Example:
>>> import fs
>>> fs.open_fs('~/projects/my_project').glob('**/*.pyc').remove()
29
"""
remov... | python | def remove(self):
# type: () -> int
"""Removed all matched paths.
Returns:
int: Number of file and directories removed.
Example:
>>> import fs
>>> fs.open_fs('~/projects/my_project').glob('**/*.pyc').remove()
29
"""
remov... | [
"def",
"remove",
"(",
"self",
")",
":",
"removes",
"=",
"0",
"for",
"path",
",",
"info",
"in",
"self",
".",
"_make_iter",
"(",
"search",
"=",
"\"depth\"",
")",
":",
"if",
"info",
".",
"is_dir",
":",
"self",
".",
"fs",
".",
"removetree",
"(",
"path"... | Removed all matched paths.
Returns:
int: Number of file and directories removed.
Example:
>>> import fs
>>> fs.open_fs('~/projects/my_project').glob('**/*.pyc').remove()
29 | [
"Removed",
"all",
"matched",
"paths",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/glob.py#L214-L234 | train |
PyFilesystem/pyfilesystem2 | fs/move.py | move_file | def move_file(
src_fs, # type: Union[Text, FS]
src_path, # type: Text
dst_fs, # type: Union[Text, FS]
dst_path, # type: Text
):
# type: (...) -> None
"""Move a file from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (instance or URL).
src_pa... | python | def move_file(
src_fs, # type: Union[Text, FS]
src_path, # type: Text
dst_fs, # type: Union[Text, FS]
dst_path, # type: Text
):
# type: (...) -> None
"""Move a file from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (instance or URL).
src_pa... | [
"def",
"move_file",
"(",
"src_fs",
",",
"src_path",
",",
"dst_fs",
",",
"dst_path",
",",
")",
":",
"with",
"manage_fs",
"(",
"src_fs",
")",
"as",
"_src_fs",
":",
"with",
"manage_fs",
"(",
"dst_fs",
",",
"create",
"=",
"True",
")",
"as",
"_dst_fs",
":",... | Move a file from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (instance or URL).
src_path (str): Path to a file on ``src_fs``.
dst_fs (FS or str); Destination filesystem (instance or URL).
dst_path (str): Path to a file on ``dst_fs``. | [
"Move",
"a",
"file",
"from",
"one",
"filesystem",
"to",
"another",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/move.py#L32-L57 | train |
PyFilesystem/pyfilesystem2 | fs/move.py | move_dir | def move_dir(
src_fs, # type: Union[Text, FS]
src_path, # type: Text
dst_fs, # type: Union[Text, FS]
dst_path, # type: Text
workers=0, # type: int
):
# type: (...) -> None
"""Move a directory from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (... | python | def move_dir(
src_fs, # type: Union[Text, FS]
src_path, # type: Text
dst_fs, # type: Union[Text, FS]
dst_path, # type: Text
workers=0, # type: int
):
# type: (...) -> None
"""Move a directory from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (... | [
"def",
"move_dir",
"(",
"src_fs",
",",
"src_path",
",",
"dst_fs",
",",
"dst_path",
",",
"workers",
"=",
"0",
",",
")",
":",
"def",
"src",
"(",
")",
":",
"return",
"manage_fs",
"(",
"src_fs",
",",
"writeable",
"=",
"False",
")",
"def",
"dst",
"(",
"... | Move a directory from one filesystem to another.
Arguments:
src_fs (FS or str): Source filesystem (instance or URL).
src_path (str): Path to a directory on ``src_fs``
dst_fs (FS or str): Destination filesystem (instance or URL).
dst_path (str): Path to a directory on ``dst_fs``.
... | [
"Move",
"a",
"directory",
"from",
"one",
"filesystem",
"to",
"another",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/move.py#L60-L90 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | recursepath | def recursepath(path, reverse=False):
# type: (Text, bool) -> List[Text]
"""Get intermediate paths from the root to the given path.
Arguments:
path (str): A PyFilesystem path
reverse (bool): Reverses the order of the paths
(default `False`).
Returns:
list: A list of... | python | def recursepath(path, reverse=False):
# type: (Text, bool) -> List[Text]
"""Get intermediate paths from the root to the given path.
Arguments:
path (str): A PyFilesystem path
reverse (bool): Reverses the order of the paths
(default `False`).
Returns:
list: A list of... | [
"def",
"recursepath",
"(",
"path",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"path",
"in",
"\"/\"",
":",
"return",
"[",
"\"/\"",
"]",
"path",
"=",
"abspath",
"(",
"normpath",
"(",
"path",
")",
")",
"+",
"\"/\"",
"paths",
"=",
"[",
"\"/\"",
"]",... | Get intermediate paths from the root to the given path.
Arguments:
path (str): A PyFilesystem path
reverse (bool): Reverses the order of the paths
(default `False`).
Returns:
list: A list of paths.
Example:
>>> recursepath('a/b/c')
['/', '/a', '/a/b', '... | [
"Get",
"intermediate",
"paths",
"from",
"the",
"root",
"to",
"the",
"given",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L114-L149 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | join | def join(*paths):
# type: (*Text) -> Text
"""Join any number of paths together.
Arguments:
*paths (str): Paths to join, given as positional arguments.
Returns:
str: The joined path.
Example:
>>> join('foo', 'bar', 'baz')
'foo/bar/baz'
>>> join('foo/bar', '.... | python | def join(*paths):
# type: (*Text) -> Text
"""Join any number of paths together.
Arguments:
*paths (str): Paths to join, given as positional arguments.
Returns:
str: The joined path.
Example:
>>> join('foo', 'bar', 'baz')
'foo/bar/baz'
>>> join('foo/bar', '.... | [
"def",
"join",
"(",
"*",
"paths",
")",
":",
"absolute",
"=",
"False",
"relpaths",
"=",
"[",
"]",
"for",
"p",
"in",
"paths",
":",
"if",
"p",
":",
"if",
"p",
"[",
"0",
"]",
"==",
"\"/\"",
":",
"del",
"relpaths",
"[",
":",
"]",
"absolute",
"=",
... | Join any number of paths together.
Arguments:
*paths (str): Paths to join, given as positional arguments.
Returns:
str: The joined path.
Example:
>>> join('foo', 'bar', 'baz')
'foo/bar/baz'
>>> join('foo/bar', '../baz')
'foo/baz'
>>> join('foo/bar',... | [
"Join",
"any",
"number",
"of",
"paths",
"together",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L208-L239 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | combine | def combine(path1, path2):
# type: (Text, Text) -> Text
"""Join two paths together.
This is faster than :func:`~fs.path.join`, but only works when the
second path is relative, and there are no back references in either
path.
Arguments:
path1 (str): A PyFilesytem path.
path2 (st... | python | def combine(path1, path2):
# type: (Text, Text) -> Text
"""Join two paths together.
This is faster than :func:`~fs.path.join`, but only works when the
second path is relative, and there are no back references in either
path.
Arguments:
path1 (str): A PyFilesytem path.
path2 (st... | [
"def",
"combine",
"(",
"path1",
",",
"path2",
")",
":",
"if",
"not",
"path1",
":",
"return",
"path2",
".",
"lstrip",
"(",
")",
"return",
"\"{}/{}\"",
".",
"format",
"(",
"path1",
".",
"rstrip",
"(",
"\"/\"",
")",
",",
"path2",
".",
"lstrip",
"(",
"... | Join two paths together.
This is faster than :func:`~fs.path.join`, but only works when the
second path is relative, and there are no back references in either
path.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
str: The joint path.
... | [
"Join",
"two",
"paths",
"together",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L242-L264 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | parts | def parts(path):
# type: (Text) -> List[Text]
"""Split a path in to its component parts.
Arguments:
path (str): Path to split in to parts.
Returns:
list: List of components
Example:
>>> parts('/foo/bar/baz')
['/', 'foo', 'bar', 'baz']
"""
_path = normpath(... | python | def parts(path):
# type: (Text) -> List[Text]
"""Split a path in to its component parts.
Arguments:
path (str): Path to split in to parts.
Returns:
list: List of components
Example:
>>> parts('/foo/bar/baz')
['/', 'foo', 'bar', 'baz']
"""
_path = normpath(... | [
"def",
"parts",
"(",
"path",
")",
":",
"_path",
"=",
"normpath",
"(",
"path",
")",
"components",
"=",
"_path",
".",
"strip",
"(",
"\"/\"",
")",
"_parts",
"=",
"[",
"\"/\"",
"if",
"_path",
".",
"startswith",
"(",
"\"/\"",
")",
"else",
"\"./\"",
"]",
... | Split a path in to its component parts.
Arguments:
path (str): Path to split in to parts.
Returns:
list: List of components
Example:
>>> parts('/foo/bar/baz')
['/', 'foo', 'bar', 'baz'] | [
"Split",
"a",
"path",
"in",
"to",
"its",
"component",
"parts",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L267-L288 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | splitext | def splitext(path):
# type: (Text) -> Tuple[Text, Text]
"""Split the extension from the path.
Arguments:
path (str): A path to split.
Returns:
(str, str): A tuple containing the path and the extension.
Example:
>>> splitext('baz.txt')
('baz', '.txt')
>>> sp... | python | def splitext(path):
# type: (Text) -> Tuple[Text, Text]
"""Split the extension from the path.
Arguments:
path (str): A path to split.
Returns:
(str, str): A tuple containing the path and the extension.
Example:
>>> splitext('baz.txt')
('baz', '.txt')
>>> sp... | [
"def",
"splitext",
"(",
"path",
")",
":",
"parent_path",
",",
"pathname",
"=",
"split",
"(",
"path",
")",
"if",
"pathname",
".",
"startswith",
"(",
"\".\"",
")",
"and",
"pathname",
".",
"count",
"(",
"\".\"",
")",
"==",
"1",
":",
"return",
"path",
",... | Split the extension from the path.
Arguments:
path (str): A path to split.
Returns:
(str, str): A tuple containing the path and the extension.
Example:
>>> splitext('baz.txt')
('baz', '.txt')
>>> splitext('foo/bar/baz.txt')
('foo/bar/baz', '.txt')
>... | [
"Split",
"the",
"extension",
"from",
"the",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L319-L345 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | isbase | def isbase(path1, path2):
# type: (Text, Text) -> bool
"""Check if ``path1`` is a base of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path2`` starts with ``path1``
Example:
>>> isbase('foo/bar',... | python | def isbase(path1, path2):
# type: (Text, Text) -> bool
"""Check if ``path1`` is a base of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path2`` starts with ``path1``
Example:
>>> isbase('foo/bar',... | [
"def",
"isbase",
"(",
"path1",
",",
"path2",
")",
":",
"_path1",
"=",
"forcedir",
"(",
"abspath",
"(",
"path1",
")",
")",
"_path2",
"=",
"forcedir",
"(",
"abspath",
"(",
"path2",
")",
")",
"return",
"_path2",
".",
"startswith",
"(",
"_path1",
")"
] | Check if ``path1`` is a base of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path2`` starts with ``path1``
Example:
>>> isbase('foo/bar', 'foo/bar/baz/egg.txt')
True | [
"Check",
"if",
"path1",
"is",
"a",
"base",
"of",
"path2",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L441-L459 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | isparent | def isparent(path1, path2):
# type: (Text, Text) -> bool
"""Check if ``path1`` is a parent directory of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path1`` is a parent directory of ``path2``
Example:
... | python | def isparent(path1, path2):
# type: (Text, Text) -> bool
"""Check if ``path1`` is a parent directory of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path1`` is a parent directory of ``path2``
Example:
... | [
"def",
"isparent",
"(",
"path1",
",",
"path2",
")",
":",
"bits1",
"=",
"path1",
".",
"split",
"(",
"\"/\"",
")",
"bits2",
"=",
"path2",
".",
"split",
"(",
"\"/\"",
")",
"while",
"bits1",
"and",
"bits1",
"[",
"-",
"1",
"]",
"==",
"\"\"",
":",
"bit... | Check if ``path1`` is a parent directory of ``path2``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
bool: `True` if ``path1`` is a parent directory of ``path2``
Example:
>>> isparent("foo/bar", "foo/bar/spam.txt")
True
... | [
"Check",
"if",
"path1",
"is",
"a",
"parent",
"directory",
"of",
"path2",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L462-L493 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | frombase | def frombase(path1, path2):
# type: (Text, Text) -> Text
"""Get the final path of ``path2`` that isn't in ``path1``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
str: the final part of ``path2``.
Example:
>>> frombase('foo/b... | python | def frombase(path1, path2):
# type: (Text, Text) -> Text
"""Get the final path of ``path2`` that isn't in ``path1``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
str: the final part of ``path2``.
Example:
>>> frombase('foo/b... | [
"def",
"frombase",
"(",
"path1",
",",
"path2",
")",
":",
"if",
"not",
"isparent",
"(",
"path1",
",",
"path2",
")",
":",
"raise",
"ValueError",
"(",
"\"path1 must be a prefix of path2\"",
")",
"return",
"path2",
"[",
"len",
"(",
"path1",
")",
":",
"]"
] | Get the final path of ``path2`` that isn't in ``path1``.
Arguments:
path1 (str): A PyFilesytem path.
path2 (str): A PyFilesytem path.
Returns:
str: the final part of ``path2``.
Example:
>>> frombase('foo/bar/', 'foo/bar/baz/egg')
'baz/egg' | [
"Get",
"the",
"final",
"path",
"of",
"path2",
"that",
"isn",
"t",
"in",
"path1",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L520-L538 | train |
PyFilesystem/pyfilesystem2 | fs/path.py | relativefrom | def relativefrom(base, path):
# type: (Text, Text) -> Text
"""Return a path relative from a given base path.
Insert backrefs as appropriate to reach the path from the base.
Arguments:
base (str): Path to a directory.
path (str): Path to make relative.
Returns:
str: the pat... | python | def relativefrom(base, path):
# type: (Text, Text) -> Text
"""Return a path relative from a given base path.
Insert backrefs as appropriate to reach the path from the base.
Arguments:
base (str): Path to a directory.
path (str): Path to make relative.
Returns:
str: the pat... | [
"def",
"relativefrom",
"(",
"base",
",",
"path",
")",
":",
"base_parts",
"=",
"list",
"(",
"iteratepath",
"(",
"base",
")",
")",
"path_parts",
"=",
"list",
"(",
"iteratepath",
"(",
"path",
")",
")",
"common",
"=",
"0",
"for",
"component_a",
",",
"compo... | Return a path relative from a given base path.
Insert backrefs as appropriate to reach the path from the base.
Arguments:
base (str): Path to a directory.
path (str): Path to make relative.
Returns:
str: the path to ``base`` from ``path``.
>>> relativefrom("foo/bar", "baz/ind... | [
"Return",
"a",
"path",
"relative",
"from",
"a",
"given",
"base",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/path.py#L541-L567 | train |
PyFilesystem/pyfilesystem2 | fs/error_tools.py | unwrap_errors | def unwrap_errors(path_replace):
# type: (Union[Text, Mapping[Text, Text]]) -> Iterator[None]
"""Get a context to map OS errors to their `fs.errors` counterpart.
The context will re-write the paths in resource exceptions to be
in the same context as the wrapped filesystem.
The only parameter may b... | python | def unwrap_errors(path_replace):
# type: (Union[Text, Mapping[Text, Text]]) -> Iterator[None]
"""Get a context to map OS errors to their `fs.errors` counterpart.
The context will re-write the paths in resource exceptions to be
in the same context as the wrapped filesystem.
The only parameter may b... | [
"def",
"unwrap_errors",
"(",
"path_replace",
")",
":",
"try",
":",
"yield",
"except",
"errors",
".",
"ResourceError",
"as",
"e",
":",
"if",
"hasattr",
"(",
"e",
",",
"\"path\"",
")",
":",
"if",
"isinstance",
"(",
"path_replace",
",",
"Mapping",
")",
":",... | Get a context to map OS errors to their `fs.errors` counterpart.
The context will re-write the paths in resource exceptions to be
in the same context as the wrapped filesystem.
The only parameter may be the path from the parent, if only one path
is to be unwrapped. Or it may be a dictionary that maps ... | [
"Get",
"a",
"context",
"to",
"map",
"OS",
"errors",
"to",
"their",
"fs",
".",
"errors",
"counterpart",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/error_tools.py#L99-L119 | train |
PyFilesystem/pyfilesystem2 | fs/wildcard.py | match | def match(pattern, name):
# type: (Text, Text) -> bool
"""Test whether a name matches a wildcard pattern.
Arguments:
pattern (str): A wildcard pattern, e.g. ``"*.py"``.
name (str): A filename.
Returns:
bool: `True` if the filename matches the pattern.
"""
try:
... | python | def match(pattern, name):
# type: (Text, Text) -> bool
"""Test whether a name matches a wildcard pattern.
Arguments:
pattern (str): A wildcard pattern, e.g. ``"*.py"``.
name (str): A filename.
Returns:
bool: `True` if the filename matches the pattern.
"""
try:
... | [
"def",
"match",
"(",
"pattern",
",",
"name",
")",
":",
"try",
":",
"re_pat",
"=",
"_PATTERN_CACHE",
"[",
"(",
"pattern",
",",
"True",
")",
"]",
"except",
"KeyError",
":",
"res",
"=",
"\"(?ms)\"",
"+",
"_translate",
"(",
"pattern",
")",
"+",
"r'\\Z'",
... | Test whether a name matches a wildcard pattern.
Arguments:
pattern (str): A wildcard pattern, e.g. ``"*.py"``.
name (str): A filename.
Returns:
bool: `True` if the filename matches the pattern. | [
"Test",
"whether",
"a",
"name",
"matches",
"a",
"wildcard",
"pattern",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/wildcard.py#L21-L38 | train |
PyFilesystem/pyfilesystem2 | fs/wildcard.py | match_any | def match_any(patterns, name):
# type: (Iterable[Text], Text) -> bool
"""Test if a name matches any of a list of patterns.
Will return `True` if ``patterns`` is an empty list.
Arguments:
patterns (list): A list of wildcard pattern, e.g ``["*.py",
"*.pyc"]``
name (str): A fi... | python | def match_any(patterns, name):
# type: (Iterable[Text], Text) -> bool
"""Test if a name matches any of a list of patterns.
Will return `True` if ``patterns`` is an empty list.
Arguments:
patterns (list): A list of wildcard pattern, e.g ``["*.py",
"*.pyc"]``
name (str): A fi... | [
"def",
"match_any",
"(",
"patterns",
",",
"name",
")",
":",
"if",
"not",
"patterns",
":",
"return",
"True",
"return",
"any",
"(",
"match",
"(",
"pattern",
",",
"name",
")",
"for",
"pattern",
"in",
"patterns",
")"
] | Test if a name matches any of a list of patterns.
Will return `True` if ``patterns`` is an empty list.
Arguments:
patterns (list): A list of wildcard pattern, e.g ``["*.py",
"*.pyc"]``
name (str): A filename.
Returns:
bool: `True` if the name matches at least one of th... | [
"Test",
"if",
"a",
"name",
"matches",
"any",
"of",
"a",
"list",
"of",
"patterns",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/wildcard.py#L61-L78 | train |
PyFilesystem/pyfilesystem2 | fs/wildcard.py | get_matcher | def get_matcher(patterns, case_sensitive):
# type: (Iterable[Text], bool) -> Callable[[Text], bool]
"""Get a callable that matches names against the given patterns.
Arguments:
patterns (list): A list of wildcard pattern. e.g. ``["*.py",
"*.pyc"]``
case_sensitive (bool): If ``Tru... | python | def get_matcher(patterns, case_sensitive):
# type: (Iterable[Text], bool) -> Callable[[Text], bool]
"""Get a callable that matches names against the given patterns.
Arguments:
patterns (list): A list of wildcard pattern. e.g. ``["*.py",
"*.pyc"]``
case_sensitive (bool): If ``Tru... | [
"def",
"get_matcher",
"(",
"patterns",
",",
"case_sensitive",
")",
":",
"if",
"not",
"patterns",
":",
"return",
"lambda",
"name",
":",
"True",
"if",
"case_sensitive",
":",
"return",
"partial",
"(",
"match_any",
",",
"patterns",
")",
"else",
":",
"return",
... | Get a callable that matches names against the given patterns.
Arguments:
patterns (list): A list of wildcard pattern. e.g. ``["*.py",
"*.pyc"]``
case_sensitive (bool): If ``True``, then the callable will be case
sensitive, otherwise it will be case insensitive.
Returns:... | [
"Get",
"a",
"callable",
"that",
"matches",
"names",
"against",
"the",
"given",
"patterns",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/wildcard.py#L101-L129 | train |
PyFilesystem/pyfilesystem2 | fs/wildcard.py | _translate | def _translate(pattern, case_sensitive=True):
# type: (Text, bool) -> Text
"""Translate a wildcard pattern to a regular expression.
There is no way to quote meta-characters.
Arguments:
pattern (str): A wildcard pattern.
case_sensitive (bool): Set to `False` to use a case
in... | python | def _translate(pattern, case_sensitive=True):
# type: (Text, bool) -> Text
"""Translate a wildcard pattern to a regular expression.
There is no way to quote meta-characters.
Arguments:
pattern (str): A wildcard pattern.
case_sensitive (bool): Set to `False` to use a case
in... | [
"def",
"_translate",
"(",
"pattern",
",",
"case_sensitive",
"=",
"True",
")",
":",
"if",
"not",
"case_sensitive",
":",
"pattern",
"=",
"pattern",
".",
"lower",
"(",
")",
"i",
",",
"n",
"=",
"0",
",",
"len",
"(",
"pattern",
")",
"res",
"=",
"\"\"",
... | Translate a wildcard pattern to a regular expression.
There is no way to quote meta-characters.
Arguments:
pattern (str): A wildcard pattern.
case_sensitive (bool): Set to `False` to use a case
insensitive regex (default `True`).
Returns:
str: A regex equivalent to the... | [
"Translate",
"a",
"wildcard",
"pattern",
"to",
"a",
"regular",
"expression",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/wildcard.py#L132-L178 | train |
PyFilesystem/pyfilesystem2 | fs/mountfs.py | MountFS._delegate | def _delegate(self, path):
# type: (Text) -> Tuple[FS, Text]
"""Get the delegate FS for a given path.
Arguments:
path (str): A path.
Returns:
(FS, str): a tuple of ``(<fs>, <path>)`` for a mounted filesystem,
or ``(None, None)`` if no filesystem is m... | python | def _delegate(self, path):
# type: (Text) -> Tuple[FS, Text]
"""Get the delegate FS for a given path.
Arguments:
path (str): A path.
Returns:
(FS, str): a tuple of ``(<fs>, <path>)`` for a mounted filesystem,
or ``(None, None)`` if no filesystem is m... | [
"def",
"_delegate",
"(",
"self",
",",
"path",
")",
":",
"_path",
"=",
"forcedir",
"(",
"abspath",
"(",
"normpath",
"(",
"path",
")",
")",
")",
"is_mounted",
"=",
"_path",
".",
"startswith",
"for",
"mount_path",
",",
"fs",
"in",
"self",
".",
"mounts",
... | Get the delegate FS for a given path.
Arguments:
path (str): A path.
Returns:
(FS, str): a tuple of ``(<fs>, <path>)`` for a mounted filesystem,
or ``(None, None)`` if no filesystem is mounted on the
given ``path``. | [
"Get",
"the",
"delegate",
"FS",
"for",
"a",
"given",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/mountfs.py#L80-L100 | train |
PyFilesystem/pyfilesystem2 | fs/mountfs.py | MountFS.mount | def mount(self, path, fs):
# type: (Text, Union[FS, Text]) -> None
"""Mounts a host FS object on a given path.
Arguments:
path (str): A path within the MountFS.
fs (FS or str): A filesystem (instance or URL) to mount.
"""
if isinstance(fs, text_type):
... | python | def mount(self, path, fs):
# type: (Text, Union[FS, Text]) -> None
"""Mounts a host FS object on a given path.
Arguments:
path (str): A path within the MountFS.
fs (FS or str): A filesystem (instance or URL) to mount.
"""
if isinstance(fs, text_type):
... | [
"def",
"mount",
"(",
"self",
",",
"path",
",",
"fs",
")",
":",
"if",
"isinstance",
"(",
"fs",
",",
"text_type",
")",
":",
"from",
".",
"opener",
"import",
"open_fs",
"fs",
"=",
"open_fs",
"(",
"fs",
")",
"if",
"not",
"isinstance",
"(",
"fs",
",",
... | Mounts a host FS object on a given path.
Arguments:
path (str): A path within the MountFS.
fs (FS or str): A filesystem (instance or URL) to mount. | [
"Mounts",
"a",
"host",
"FS",
"object",
"on",
"a",
"given",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/mountfs.py#L102-L128 | train |
PyFilesystem/pyfilesystem2 | fs/_bulk.py | Copier.start | def start(self):
"""Start the workers."""
if self.num_workers:
self.queue = Queue(maxsize=self.num_workers)
self.workers = [_Worker(self) for _ in range(self.num_workers)]
for worker in self.workers:
worker.start()
self.running = True | python | def start(self):
"""Start the workers."""
if self.num_workers:
self.queue = Queue(maxsize=self.num_workers)
self.workers = [_Worker(self) for _ in range(self.num_workers)]
for worker in self.workers:
worker.start()
self.running = True | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"num_workers",
":",
"self",
".",
"queue",
"=",
"Queue",
"(",
"maxsize",
"=",
"self",
".",
"num_workers",
")",
"self",
".",
"workers",
"=",
"[",
"_Worker",
"(",
"self",
")",
"for",
"_",
"in",... | Start the workers. | [
"Start",
"the",
"workers",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/_bulk.py#L87-L94 | train |
PyFilesystem/pyfilesystem2 | fs/_bulk.py | Copier.copy | def copy(self, src_fs, src_path, dst_fs, dst_path):
# type: (FS, Text, FS, Text) -> None
"""Copy a file from one fs to another."""
if self.queue is None:
# This should be the most performant for a single-thread
copy_file_internal(src_fs, src_path, dst_fs, dst_path)
... | python | def copy(self, src_fs, src_path, dst_fs, dst_path):
# type: (FS, Text, FS, Text) -> None
"""Copy a file from one fs to another."""
if self.queue is None:
# This should be the most performant for a single-thread
copy_file_internal(src_fs, src_path, dst_fs, dst_path)
... | [
"def",
"copy",
"(",
"self",
",",
"src_fs",
",",
"src_path",
",",
"dst_fs",
",",
"dst_path",
")",
":",
"if",
"self",
".",
"queue",
"is",
"None",
":",
"copy_file_internal",
"(",
"src_fs",
",",
"src_path",
",",
"dst_fs",
",",
"dst_path",
")",
"else",
":",... | Copy a file from one fs to another. | [
"Copy",
"a",
"file",
"from",
"one",
"fs",
"to",
"another",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/_bulk.py#L126-L140 | train |
PyFilesystem/pyfilesystem2 | fs/multifs.py | MultiFS.add_fs | def add_fs(self, name, fs, write=False, priority=0):
# type: (Text, FS, bool, int) -> None
"""Add a filesystem to the MultiFS.
Arguments:
name (str): A unique name to refer to the filesystem being
added.
fs (FS or str): The filesystem (instance or URL) to... | python | def add_fs(self, name, fs, write=False, priority=0):
# type: (Text, FS, bool, int) -> None
"""Add a filesystem to the MultiFS.
Arguments:
name (str): A unique name to refer to the filesystem being
added.
fs (FS or str): The filesystem (instance or URL) to... | [
"def",
"add_fs",
"(",
"self",
",",
"name",
",",
"fs",
",",
"write",
"=",
"False",
",",
"priority",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"fs",
",",
"text_type",
")",
":",
"fs",
"=",
"open_fs",
"(",
"fs",
")",
"if",
"not",
"isinstance",
"("... | Add a filesystem to the MultiFS.
Arguments:
name (str): A unique name to refer to the filesystem being
added.
fs (FS or str): The filesystem (instance or URL) to add.
write (bool): If this value is True, then the ``fs`` will
be used as the wri... | [
"Add",
"a",
"filesystem",
"to",
"the",
"MultiFS",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/multifs.py#L79-L110 | train |
PyFilesystem/pyfilesystem2 | fs/multifs.py | MultiFS._delegate | def _delegate(self, path):
# type: (Text) -> Optional[FS]
"""Get a filesystem which has a given path.
"""
for _name, fs in self.iterate_fs():
if fs.exists(path):
return fs
return None | python | def _delegate(self, path):
# type: (Text) -> Optional[FS]
"""Get a filesystem which has a given path.
"""
for _name, fs in self.iterate_fs():
if fs.exists(path):
return fs
return None | [
"def",
"_delegate",
"(",
"self",
",",
"path",
")",
":",
"for",
"_name",
",",
"fs",
"in",
"self",
".",
"iterate_fs",
"(",
")",
":",
"if",
"fs",
".",
"exists",
"(",
"path",
")",
":",
"return",
"fs",
"return",
"None"
] | Get a filesystem which has a given path. | [
"Get",
"a",
"filesystem",
"which",
"has",
"a",
"given",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/multifs.py#L147-L154 | train |
PyFilesystem/pyfilesystem2 | fs/multifs.py | MultiFS._delegate_required | def _delegate_required(self, path):
# type: (Text) -> FS
"""Check that there is a filesystem with the given ``path``.
"""
fs = self._delegate(path)
if fs is None:
raise errors.ResourceNotFound(path)
return fs | python | def _delegate_required(self, path):
# type: (Text) -> FS
"""Check that there is a filesystem with the given ``path``.
"""
fs = self._delegate(path)
if fs is None:
raise errors.ResourceNotFound(path)
return fs | [
"def",
"_delegate_required",
"(",
"self",
",",
"path",
")",
":",
"fs",
"=",
"self",
".",
"_delegate",
"(",
"path",
")",
"if",
"fs",
"is",
"None",
":",
"raise",
"errors",
".",
"ResourceNotFound",
"(",
"path",
")",
"return",
"fs"
] | Check that there is a filesystem with the given ``path``. | [
"Check",
"that",
"there",
"is",
"a",
"filesystem",
"with",
"the",
"given",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/multifs.py#L156-L163 | train |
PyFilesystem/pyfilesystem2 | fs/multifs.py | MultiFS._writable_required | def _writable_required(self, path):
# type: (Text) -> FS
"""Check that ``path`` is writeable.
"""
if self.write_fs is None:
raise errors.ResourceReadOnly(path)
return self.write_fs | python | def _writable_required(self, path):
# type: (Text) -> FS
"""Check that ``path`` is writeable.
"""
if self.write_fs is None:
raise errors.ResourceReadOnly(path)
return self.write_fs | [
"def",
"_writable_required",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"write_fs",
"is",
"None",
":",
"raise",
"errors",
".",
"ResourceReadOnly",
"(",
"path",
")",
"return",
"self",
".",
"write_fs"
] | Check that ``path`` is writeable. | [
"Check",
"that",
"path",
"is",
"writeable",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/multifs.py#L165-L171 | train |
PyFilesystem/pyfilesystem2 | fs/iotools.py | make_stream | def make_stream(
name, # type: Text
bin_file, # type: RawIOBase
mode="r", # type: Text
buffering=-1, # type: int
encoding=None, # type: Optional[Text]
errors=None, # type: Optional[Text]
newline="", # type: Optional[Text]
line_buffering=False, # type: bool
**kwargs # type: A... | python | def make_stream(
name, # type: Text
bin_file, # type: RawIOBase
mode="r", # type: Text
buffering=-1, # type: int
encoding=None, # type: Optional[Text]
errors=None, # type: Optional[Text]
newline="", # type: Optional[Text]
line_buffering=False, # type: bool
**kwargs # type: A... | [
"def",
"make_stream",
"(",
"name",
",",
"bin_file",
",",
"mode",
"=",
"\"r\"",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"\"\"",
",",
"line_buffering",
"=",
"False",
",",
"**",
"kw... | Take a Python 2.x binary file and return an IO Stream. | [
"Take",
"a",
"Python",
"2",
".",
"x",
"binary",
"file",
"and",
"return",
"an",
"IO",
"Stream",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/iotools.py#L153-L204 | train |
PyFilesystem/pyfilesystem2 | fs/iotools.py | line_iterator | def line_iterator(readable_file, size=None):
# type: (IO[bytes], Optional[int]) -> Iterator[bytes]
"""Iterate over the lines of a file.
Implementation reads each char individually, which is not very
efficient.
Yields:
str: a single line in the file.
"""
read = readable_file.read
... | python | def line_iterator(readable_file, size=None):
# type: (IO[bytes], Optional[int]) -> Iterator[bytes]
"""Iterate over the lines of a file.
Implementation reads each char individually, which is not very
efficient.
Yields:
str: a single line in the file.
"""
read = readable_file.read
... | [
"def",
"line_iterator",
"(",
"readable_file",
",",
"size",
"=",
"None",
")",
":",
"read",
"=",
"readable_file",
".",
"read",
"line",
"=",
"[",
"]",
"byte",
"=",
"b\"1\"",
"if",
"size",
"is",
"None",
"or",
"size",
"<",
"0",
":",
"while",
"byte",
":",
... | Iterate over the lines of a file.
Implementation reads each char individually, which is not very
efficient.
Yields:
str: a single line in the file. | [
"Iterate",
"over",
"the",
"lines",
"of",
"a",
"file",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/iotools.py#L207-L236 | train |
PyFilesystem/pyfilesystem2 | fs/mode.py | validate_openbin_mode | def validate_openbin_mode(mode, _valid_chars=frozenset("rwxab+")):
# type: (Text, Union[Set[Text], FrozenSet[Text]]) -> None
"""Check ``mode`` parameter of `~fs.base.FS.openbin` is valid.
Arguments:
mode (str): Mode parameter.
Raises:
`ValueError` if mode is not valid.
"""
if ... | python | def validate_openbin_mode(mode, _valid_chars=frozenset("rwxab+")):
# type: (Text, Union[Set[Text], FrozenSet[Text]]) -> None
"""Check ``mode`` parameter of `~fs.base.FS.openbin` is valid.
Arguments:
mode (str): Mode parameter.
Raises:
`ValueError` if mode is not valid.
"""
if ... | [
"def",
"validate_openbin_mode",
"(",
"mode",
",",
"_valid_chars",
"=",
"frozenset",
"(",
"\"rwxab+\"",
")",
")",
":",
"if",
"\"t\"",
"in",
"mode",
":",
"raise",
"ValueError",
"(",
"\"text mode not valid in openbin\"",
")",
"if",
"not",
"mode",
":",
"raise",
"V... | Check ``mode`` parameter of `~fs.base.FS.openbin` is valid.
Arguments:
mode (str): Mode parameter.
Raises:
`ValueError` if mode is not valid. | [
"Check",
"mode",
"parameter",
"of",
"~fs",
".",
"base",
".",
"FS",
".",
"openbin",
"is",
"valid",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/mode.py#L229-L247 | train |
PyFilesystem/pyfilesystem2 | fs/mirror.py | _compare | def _compare(info1, info2):
# type: (Info, Info) -> bool
"""Compare two `Info` objects to see if they should be copied.
Returns:
bool: `True` if the `Info` are different in size or mtime.
"""
# Check filesize has changed
if info1.size != info2.size:
return True
# Check modi... | python | def _compare(info1, info2):
# type: (Info, Info) -> bool
"""Compare two `Info` objects to see if they should be copied.
Returns:
bool: `True` if the `Info` are different in size or mtime.
"""
# Check filesize has changed
if info1.size != info2.size:
return True
# Check modi... | [
"def",
"_compare",
"(",
"info1",
",",
"info2",
")",
":",
"if",
"info1",
".",
"size",
"!=",
"info2",
".",
"size",
":",
"return",
"True",
"date1",
"=",
"info1",
".",
"modified",
"date2",
"=",
"info2",
".",
"modified",
"return",
"date1",
"is",
"None",
"... | Compare two `Info` objects to see if they should be copied.
Returns:
bool: `True` if the `Info` are different in size or mtime. | [
"Compare",
"two",
"Info",
"objects",
"to",
"see",
"if",
"they",
"should",
"be",
"copied",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/mirror.py#L38-L52 | train |
PyFilesystem/pyfilesystem2 | fs/opener/parse.py | parse_fs_url | def parse_fs_url(fs_url):
# type: (Text) -> ParseResult
"""Parse a Filesystem URL and return a `ParseResult`.
Arguments:
fs_url (str): A filesystem URL.
Returns:
~fs.opener.parse.ParseResult: a parse result instance.
Raises:
~fs.errors.ParseError: if the FS URL is not vali... | python | def parse_fs_url(fs_url):
# type: (Text) -> ParseResult
"""Parse a Filesystem URL and return a `ParseResult`.
Arguments:
fs_url (str): A filesystem URL.
Returns:
~fs.opener.parse.ParseResult: a parse result instance.
Raises:
~fs.errors.ParseError: if the FS URL is not vali... | [
"def",
"parse_fs_url",
"(",
"fs_url",
")",
":",
"match",
"=",
"_RE_FS_URL",
".",
"match",
"(",
"fs_url",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"ParseError",
"(",
"\"{!r} is not a fs2 url\"",
".",
"format",
"(",
"fs_url",
")",
")",
"fs_name",
",",... | Parse a Filesystem URL and return a `ParseResult`.
Arguments:
fs_url (str): A filesystem URL.
Returns:
~fs.opener.parse.ParseResult: a parse result instance.
Raises:
~fs.errors.ParseError: if the FS URL is not valid. | [
"Parse",
"a",
"Filesystem",
"URL",
"and",
"return",
"a",
"ParseResult",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/opener/parse.py#L62-L97 | train |
PyFilesystem/pyfilesystem2 | fs/zipfs.py | _ZipExtFile.seek | def seek(self, offset, whence=Seek.set):
# type: (int, SupportsInt) -> int
"""Change stream position.
Change the stream position to the given byte offset. The
offset is interpreted relative to the position indicated by
``whence``.
Arguments:
offset (int): th... | python | def seek(self, offset, whence=Seek.set):
# type: (int, SupportsInt) -> int
"""Change stream position.
Change the stream position to the given byte offset. The
offset is interpreted relative to the position indicated by
``whence``.
Arguments:
offset (int): th... | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"Seek",
".",
"set",
")",
":",
"_whence",
"=",
"int",
"(",
"whence",
")",
"if",
"_whence",
"==",
"Seek",
".",
"current",
":",
"offset",
"+=",
"self",
".",
"_pos",
"if",
"_whence",
"==",
... | Change stream position.
Change the stream position to the given byte offset. The
offset is interpreted relative to the position indicated by
``whence``.
Arguments:
offset (int): the offset to the new position, in bytes.
whence (int): the position reference. Poss... | [
"Change",
"stream",
"position",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/zipfs.py#L65-L116 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | Walker._iter_walk | def _iter_walk(
self,
fs, # type: FS
path, # type: Text
namespaces=None, # type: Optional[Collection[Text]]
):
# type: (...) -> Iterator[Tuple[Text, Optional[Info]]]
"""Get the walk generator."""
if self.search == "breadth":
return self._walk_br... | python | def _iter_walk(
self,
fs, # type: FS
path, # type: Text
namespaces=None, # type: Optional[Collection[Text]]
):
# type: (...) -> Iterator[Tuple[Text, Optional[Info]]]
"""Get the walk generator."""
if self.search == "breadth":
return self._walk_br... | [
"def",
"_iter_walk",
"(",
"self",
",",
"fs",
",",
"path",
",",
"namespaces",
"=",
"None",
",",
")",
":",
"if",
"self",
".",
"search",
"==",
"\"breadth\"",
":",
"return",
"self",
".",
"_walk_breadth",
"(",
"fs",
",",
"path",
",",
"namespaces",
"=",
"n... | Get the walk generator. | [
"Get",
"the",
"walk",
"generator",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L188-L199 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | Walker._check_open_dir | def _check_open_dir(self, fs, path, info):
# type: (FS, Text, Info) -> bool
"""Check if a directory should be considered in the walk.
"""
if self.exclude_dirs is not None and fs.match(self.exclude_dirs, info.name):
return False
if self.filter_dirs is not None and not ... | python | def _check_open_dir(self, fs, path, info):
# type: (FS, Text, Info) -> bool
"""Check if a directory should be considered in the walk.
"""
if self.exclude_dirs is not None and fs.match(self.exclude_dirs, info.name):
return False
if self.filter_dirs is not None and not ... | [
"def",
"_check_open_dir",
"(",
"self",
",",
"fs",
",",
"path",
",",
"info",
")",
":",
"if",
"self",
".",
"exclude_dirs",
"is",
"not",
"None",
"and",
"fs",
".",
"match",
"(",
"self",
".",
"exclude_dirs",
",",
"info",
".",
"name",
")",
":",
"return",
... | Check if a directory should be considered in the walk. | [
"Check",
"if",
"a",
"directory",
"should",
"be",
"considered",
"in",
"the",
"walk",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L201-L209 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | Walker._check_scan_dir | def _check_scan_dir(self, fs, path, info, depth):
# type: (FS, Text, Info, int) -> bool
"""Check if a directory contents should be scanned."""
if self.max_depth is not None and depth >= self.max_depth:
return False
return self.check_scan_dir(fs, path, info) | python | def _check_scan_dir(self, fs, path, info, depth):
# type: (FS, Text, Info, int) -> bool
"""Check if a directory contents should be scanned."""
if self.max_depth is not None and depth >= self.max_depth:
return False
return self.check_scan_dir(fs, path, info) | [
"def",
"_check_scan_dir",
"(",
"self",
",",
"fs",
",",
"path",
",",
"info",
",",
"depth",
")",
":",
"if",
"self",
".",
"max_depth",
"is",
"not",
"None",
"and",
"depth",
">=",
"self",
".",
"max_depth",
":",
"return",
"False",
"return",
"self",
".",
"c... | Check if a directory contents should be scanned. | [
"Check",
"if",
"a",
"directory",
"contents",
"should",
"be",
"scanned",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L228-L233 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | Walker.check_file | def check_file(self, fs, info):
# type: (FS, Info) -> bool
"""Check if a filename should be included.
Override to exclude files from the walk.
Arguments:
fs (FS): A filesystem instance.
info (Info): A resource info object.
Returns:
bool: `Tr... | python | def check_file(self, fs, info):
# type: (FS, Info) -> bool
"""Check if a filename should be included.
Override to exclude files from the walk.
Arguments:
fs (FS): A filesystem instance.
info (Info): A resource info object.
Returns:
bool: `Tr... | [
"def",
"check_file",
"(",
"self",
",",
"fs",
",",
"info",
")",
":",
"if",
"self",
".",
"exclude",
"is",
"not",
"None",
"and",
"fs",
".",
"match",
"(",
"self",
".",
"exclude",
",",
"info",
".",
"name",
")",
":",
"return",
"False",
"return",
"fs",
... | Check if a filename should be included.
Override to exclude files from the walk.
Arguments:
fs (FS): A filesystem instance.
info (Info): A resource info object.
Returns:
bool: `True` if the file should be included. | [
"Check",
"if",
"a",
"filename",
"should",
"be",
"included",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L254-L271 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | Walker._scan | def _scan(
self,
fs, # type: FS
dir_path, # type: Text
namespaces=None, # type: Optional[Collection[Text]]
):
# type: (...) -> Iterator[Info]
"""Get an iterator of `Info` objects for a directory path.
Arguments:
fs (FS): A filesystem instance.
... | python | def _scan(
self,
fs, # type: FS
dir_path, # type: Text
namespaces=None, # type: Optional[Collection[Text]]
):
# type: (...) -> Iterator[Info]
"""Get an iterator of `Info` objects for a directory path.
Arguments:
fs (FS): A filesystem instance.
... | [
"def",
"_scan",
"(",
"self",
",",
"fs",
",",
"dir_path",
",",
"namespaces",
"=",
"None",
",",
")",
":",
"try",
":",
"for",
"info",
"in",
"fs",
".",
"scandir",
"(",
"dir_path",
",",
"namespaces",
"=",
"namespaces",
")",
":",
"yield",
"info",
"except",... | Get an iterator of `Info` objects for a directory path.
Arguments:
fs (FS): A filesystem instance.
dir_path (str): A path to a directory on the filesystem.
namespaces (list): A list of additional namespaces to
include in the `Info` objects.
Returns:
... | [
"Get",
"an",
"iterator",
"of",
"Info",
"objects",
"for",
"a",
"directory",
"path",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L273-L298 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | BoundWalker._make_walker | def _make_walker(self, *args, **kwargs):
# type: (*Any, **Any) -> Walker
"""Create a walker instance.
"""
walker = self.walker_class(*args, **kwargs)
return walker | python | def _make_walker(self, *args, **kwargs):
# type: (*Any, **Any) -> Walker
"""Create a walker instance.
"""
walker = self.walker_class(*args, **kwargs)
return walker | [
"def",
"_make_walker",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"walker",
"=",
"self",
".",
"walker_class",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"return",
"walker"
] | Create a walker instance. | [
"Create",
"a",
"walker",
"instance",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L529-L534 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | BoundWalker.dirs | def dirs(self, path="/", **kwargs):
# type: (Text, **Any) -> Iterator[Text]
"""Walk a filesystem, yielding absolute paths to directories.
Arguments:
path (str): A path to a directory.
Keyword Arguments:
ignore_errors (bool): If `True`, any errors reading a
... | python | def dirs(self, path="/", **kwargs):
# type: (Text, **Any) -> Iterator[Text]
"""Walk a filesystem, yielding absolute paths to directories.
Arguments:
path (str): A path to a directory.
Keyword Arguments:
ignore_errors (bool): If `True`, any errors reading a
... | [
"def",
"dirs",
"(",
"self",
",",
"path",
"=",
"\"/\"",
",",
"**",
"kwargs",
")",
":",
"walker",
"=",
"self",
".",
"_make_walker",
"(",
"**",
"kwargs",
")",
"return",
"walker",
".",
"dirs",
"(",
"self",
".",
"fs",
",",
"path",
"=",
"path",
")"
] | Walk a filesystem, yielding absolute paths to directories.
Arguments:
path (str): A path to a directory.
Keyword Arguments:
ignore_errors (bool): If `True`, any errors reading a
directory will be ignored, otherwise exceptions will be
raised.
... | [
"Walk",
"a",
"filesystem",
"yielding",
"absolute",
"paths",
"to",
"directories",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L641-L674 | train |
PyFilesystem/pyfilesystem2 | fs/walk.py | BoundWalker.info | def info(
self,
path="/", # type: Text
namespaces=None, # type: Optional[Collection[Text]]
**kwargs # type: Any
):
# type: (...) -> Iterator[Tuple[Text, Info]]
"""Walk a filesystem, yielding path and `Info` of resources.
Arguments:
path (str): ... | python | def info(
self,
path="/", # type: Text
namespaces=None, # type: Optional[Collection[Text]]
**kwargs # type: Any
):
# type: (...) -> Iterator[Tuple[Text, Info]]
"""Walk a filesystem, yielding path and `Info` of resources.
Arguments:
path (str): ... | [
"def",
"info",
"(",
"self",
",",
"path",
"=",
"\"/\"",
",",
"namespaces",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"walker",
"=",
"self",
".",
"_make_walker",
"(",
"**",
"kwargs",
")",
"return",
"walker",
".",
"info",
"(",
"self",
".",
"fs",
","... | Walk a filesystem, yielding path and `Info` of resources.
Arguments:
path (str): A path to a directory.
namespaces (list, optional): A list of namespaces to include
in the resource information, e.g. ``['basic', 'access']``
(defaults to ``['basic']``).
... | [
"Walk",
"a",
"filesystem",
"yielding",
"path",
"and",
"Info",
"of",
"resources",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/walk.py#L676-L724 | train |
PyFilesystem/pyfilesystem2 | fs/tools.py | remove_empty | def remove_empty(fs, path):
# type: (FS, Text) -> None
"""Remove all empty parents.
Arguments:
fs (FS): A filesystem instance.
path (str): Path to a directory on the filesystem.
"""
path = abspath(normpath(path))
try:
while path not in ("", "/"):
fs.removedi... | python | def remove_empty(fs, path):
# type: (FS, Text) -> None
"""Remove all empty parents.
Arguments:
fs (FS): A filesystem instance.
path (str): Path to a directory on the filesystem.
"""
path = abspath(normpath(path))
try:
while path not in ("", "/"):
fs.removedi... | [
"def",
"remove_empty",
"(",
"fs",
",",
"path",
")",
":",
"path",
"=",
"abspath",
"(",
"normpath",
"(",
"path",
")",
")",
"try",
":",
"while",
"path",
"not",
"in",
"(",
"\"\"",
",",
"\"/\"",
")",
":",
"fs",
".",
"removedir",
"(",
"path",
")",
"pat... | Remove all empty parents.
Arguments:
fs (FS): A filesystem instance.
path (str): Path to a directory on the filesystem. | [
"Remove",
"all",
"empty",
"parents",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/tools.py#L23-L38 | train |
PyFilesystem/pyfilesystem2 | fs/tools.py | copy_file_data | def copy_file_data(src_file, dst_file, chunk_size=None):
# type: (IO, IO, Optional[int]) -> None
"""Copy data from one file object to another.
Arguments:
src_file (io.IOBase): File open for reading.
dst_file (io.IOBase): File open for writing.
chunk_size (int): Number of bytes to co... | python | def copy_file_data(src_file, dst_file, chunk_size=None):
# type: (IO, IO, Optional[int]) -> None
"""Copy data from one file object to another.
Arguments:
src_file (io.IOBase): File open for reading.
dst_file (io.IOBase): File open for writing.
chunk_size (int): Number of bytes to co... | [
"def",
"copy_file_data",
"(",
"src_file",
",",
"dst_file",
",",
"chunk_size",
"=",
"None",
")",
":",
"_chunk_size",
"=",
"1024",
"*",
"1024",
"if",
"chunk_size",
"is",
"None",
"else",
"chunk_size",
"read",
"=",
"src_file",
".",
"read",
"write",
"=",
"dst_f... | Copy data from one file object to another.
Arguments:
src_file (io.IOBase): File open for reading.
dst_file (io.IOBase): File open for writing.
chunk_size (int): Number of bytes to copy at
a time (or `None` to use sensible default). | [
"Copy",
"data",
"from",
"one",
"file",
"object",
"to",
"another",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/tools.py#L41-L57 | train |
PyFilesystem/pyfilesystem2 | fs/tools.py | get_intermediate_dirs | def get_intermediate_dirs(fs, dir_path):
# type: (FS, Text) -> List[Text]
"""Get a list of non-existing intermediate directories.
Arguments:
fs (FS): A filesystem instance.
dir_path (str): A path to a new directory on the filesystem.
Returns:
list: A list of non-existing paths.... | python | def get_intermediate_dirs(fs, dir_path):
# type: (FS, Text) -> List[Text]
"""Get a list of non-existing intermediate directories.
Arguments:
fs (FS): A filesystem instance.
dir_path (str): A path to a new directory on the filesystem.
Returns:
list: A list of non-existing paths.... | [
"def",
"get_intermediate_dirs",
"(",
"fs",
",",
"dir_path",
")",
":",
"intermediates",
"=",
"[",
"]",
"with",
"fs",
".",
"lock",
"(",
")",
":",
"for",
"path",
"in",
"recursepath",
"(",
"abspath",
"(",
"dir_path",
")",
",",
"reverse",
"=",
"True",
")",
... | Get a list of non-existing intermediate directories.
Arguments:
fs (FS): A filesystem instance.
dir_path (str): A path to a new directory on the filesystem.
Returns:
list: A list of non-existing paths.
Raises:
~fs.errors.DirectoryExpected: If a path component
r... | [
"Get",
"a",
"list",
"of",
"non",
"-",
"existing",
"intermediate",
"directories",
"."
] | 047f3593f297d1442194cda3da7a7335bcc9c14a | https://github.com/PyFilesystem/pyfilesystem2/blob/047f3593f297d1442194cda3da7a7335bcc9c14a/fs/tools.py#L60-L87 | train |
soynatan/django-easy-audit | easyaudit/admin_helpers.py | prettify_json | def prettify_json(json_string):
"""Given a JSON string, it returns it as a
safe formatted HTML"""
try:
data = json.loads(json_string)
html = '<pre>' + json.dumps(data, sort_keys=True, indent=4) + '</pre>'
except:
html = json_string
return mark_safe(html) | python | def prettify_json(json_string):
"""Given a JSON string, it returns it as a
safe formatted HTML"""
try:
data = json.loads(json_string)
html = '<pre>' + json.dumps(data, sort_keys=True, indent=4) + '</pre>'
except:
html = json_string
return mark_safe(html) | [
"def",
"prettify_json",
"(",
"json_string",
")",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"json_string",
")",
"html",
"=",
"'<pre>'",
"+",
"json",
".",
"dumps",
"(",
"data",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
")",... | Given a JSON string, it returns it as a
safe formatted HTML | [
"Given",
"a",
"JSON",
"string",
"it",
"returns",
"it",
"as",
"a",
"safe",
"formatted",
"HTML"
] | 03e05bc94beb29fc3e4ff86e313a6fef4b766b4b | https://github.com/soynatan/django-easy-audit/blob/03e05bc94beb29fc3e4ff86e313a6fef4b766b4b/easyaudit/admin_helpers.py#L21-L29 | train |
soynatan/django-easy-audit | easyaudit/admin_helpers.py | EasyAuditModelAdmin.purge_objects | def purge_objects(self, request):
"""
Removes all objects in this table.
This action first displays a confirmation page;
next, it deletes all objects and redirects back to the change list.
"""
def truncate_table(model):
if settings.TRUNCATE_TABLE_SQL_STATEMEN... | python | def purge_objects(self, request):
"""
Removes all objects in this table.
This action first displays a confirmation page;
next, it deletes all objects and redirects back to the change list.
"""
def truncate_table(model):
if settings.TRUNCATE_TABLE_SQL_STATEMEN... | [
"def",
"purge_objects",
"(",
"self",
",",
"request",
")",
":",
"def",
"truncate_table",
"(",
"model",
")",
":",
"if",
"settings",
".",
"TRUNCATE_TABLE_SQL_STATEMENT",
":",
"from",
"django",
".",
"db",
"import",
"connection",
"sql",
"=",
"settings",
".",
"TRU... | Removes all objects in this table.
This action first displays a confirmation page;
next, it deletes all objects and redirects back to the change list. | [
"Removes",
"all",
"objects",
"in",
"this",
"table",
".",
"This",
"action",
"first",
"displays",
"a",
"confirmation",
"page",
";",
"next",
"it",
"deletes",
"all",
"objects",
"and",
"redirects",
"back",
"to",
"the",
"change",
"list",
"."
] | 03e05bc94beb29fc3e4ff86e313a6fef4b766b4b | https://github.com/soynatan/django-easy-audit/blob/03e05bc94beb29fc3e4ff86e313a6fef4b766b4b/easyaudit/admin_helpers.py#L66-L116 | train |
soynatan/django-easy-audit | easyaudit/settings.py | get_model_list | def get_model_list(class_list):
"""
Receives a list of strings with app_name.model_name format
and turns them into classes. If an item is already a class
it ignores it.
"""
for idx, item in enumerate(class_list):
if isinstance(item, six.string_types):
model_class = apps.get_m... | python | def get_model_list(class_list):
"""
Receives a list of strings with app_name.model_name format
and turns them into classes. If an item is already a class
it ignores it.
"""
for idx, item in enumerate(class_list):
if isinstance(item, six.string_types):
model_class = apps.get_m... | [
"def",
"get_model_list",
"(",
"class_list",
")",
":",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"class_list",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"six",
".",
"string_types",
")",
":",
"model_class",
"=",
"apps",
".",
"get_model",
"("... | Receives a list of strings with app_name.model_name format
and turns them into classes. If an item is already a class
it ignores it. | [
"Receives",
"a",
"list",
"of",
"strings",
"with",
"app_name",
".",
"model_name",
"format",
"and",
"turns",
"them",
"into",
"classes",
".",
"If",
"an",
"item",
"is",
"already",
"a",
"class",
"it",
"ignores",
"it",
"."
] | 03e05bc94beb29fc3e4ff86e313a6fef4b766b4b | https://github.com/soynatan/django-easy-audit/blob/03e05bc94beb29fc3e4ff86e313a6fef4b766b4b/easyaudit/settings.py#L15-L24 | train |
soynatan/django-easy-audit | easyaudit/signals/model_signals.py | should_audit | def should_audit(instance):
"""Returns True or False to indicate whether the instance
should be audited or not, depending on the project settings."""
# do not audit any model listed in UNREGISTERED_CLASSES
for unregistered_class in UNREGISTERED_CLASSES:
if isinstance(instance, unregistered_clas... | python | def should_audit(instance):
"""Returns True or False to indicate whether the instance
should be audited or not, depending on the project settings."""
# do not audit any model listed in UNREGISTERED_CLASSES
for unregistered_class in UNREGISTERED_CLASSES:
if isinstance(instance, unregistered_clas... | [
"def",
"should_audit",
"(",
"instance",
")",
":",
"for",
"unregistered_class",
"in",
"UNREGISTERED_CLASSES",
":",
"if",
"isinstance",
"(",
"instance",
",",
"unregistered_class",
")",
":",
"return",
"False",
"if",
"len",
"(",
"REGISTERED_CLASSES",
")",
">",
"0",
... | Returns True or False to indicate whether the instance
should be audited or not, depending on the project settings. | [
"Returns",
"True",
"or",
"False",
"to",
"indicate",
"whether",
"the",
"instance",
"should",
"be",
"audited",
"or",
"not",
"depending",
"on",
"the",
"project",
"settings",
"."
] | 03e05bc94beb29fc3e4ff86e313a6fef4b766b4b | https://github.com/soynatan/django-easy-audit/blob/03e05bc94beb29fc3e4ff86e313a6fef4b766b4b/easyaudit/signals/model_signals.py#L23-L41 | train |
soynatan/django-easy-audit | easyaudit/signals/model_signals.py | _m2m_rev_field_name | def _m2m_rev_field_name(model1, model2):
"""Gets the name of the reverse m2m accessor from `model1` to `model2`
For example, if User has a ManyToManyField connected to Group,
`_m2m_rev_field_name(Group, User)` retrieves the name of the field on
Group that lists a group's Users. (By default, this field ... | python | def _m2m_rev_field_name(model1, model2):
"""Gets the name of the reverse m2m accessor from `model1` to `model2`
For example, if User has a ManyToManyField connected to Group,
`_m2m_rev_field_name(Group, User)` retrieves the name of the field on
Group that lists a group's Users. (By default, this field ... | [
"def",
"_m2m_rev_field_name",
"(",
"model1",
",",
"model2",
")",
":",
"m2m_field_names",
"=",
"[",
"rel",
".",
"get_accessor_name",
"(",
")",
"for",
"rel",
"in",
"model1",
".",
"_meta",
".",
"get_fields",
"(",
")",
"if",
"rel",
".",
"many_to_many",
"and",
... | Gets the name of the reverse m2m accessor from `model1` to `model2`
For example, if User has a ManyToManyField connected to Group,
`_m2m_rev_field_name(Group, User)` retrieves the name of the field on
Group that lists a group's Users. (By default, this field is called
`user_set`, but the name can be ov... | [
"Gets",
"the",
"name",
"of",
"the",
"reverse",
"m2m",
"accessor",
"from",
"model1",
"to",
"model2"
] | 03e05bc94beb29fc3e4ff86e313a6fef4b766b4b | https://github.com/soynatan/django-easy-audit/blob/03e05bc94beb29fc3e4ff86e313a6fef4b766b4b/easyaudit/signals/model_signals.py#L174-L188 | train |
wookayin/gpustat | gpustat/core.py | GPUStatCollection.new_query | def new_query():
"""Query the information of all the GPUs on local machine"""
N.nvmlInit()
def _decode(b):
if isinstance(b, bytes):
return b.decode() # for python3, to unicode
return b
def get_gpu_info(handle):
"""Get one GPU info... | python | def new_query():
"""Query the information of all the GPUs on local machine"""
N.nvmlInit()
def _decode(b):
if isinstance(b, bytes):
return b.decode() # for python3, to unicode
return b
def get_gpu_info(handle):
"""Get one GPU info... | [
"def",
"new_query",
"(",
")",
":",
"N",
".",
"nvmlInit",
"(",
")",
"def",
"_decode",
"(",
"b",
")",
":",
"if",
"isinstance",
"(",
"b",
",",
"bytes",
")",
":",
"return",
"b",
".",
"decode",
"(",
")",
"return",
"b",
"def",
"get_gpu_info",
"(",
"han... | Query the information of all the GPUs on local machine | [
"Query",
"the",
"information",
"of",
"all",
"the",
"GPUs",
"on",
"local",
"machine"
] | 28299cdcf55dd627fdd9800cf344988b43188ee8 | https://github.com/wookayin/gpustat/blob/28299cdcf55dd627fdd9800cf344988b43188ee8/gpustat/core.py#L262-L385 | train |
wookayin/gpustat | gpustat/__main__.py | print_gpustat | def print_gpustat(json=False, debug=False, **kwargs):
'''
Display the GPU query results into standard output.
'''
try:
gpu_stats = GPUStatCollection.new_query()
except Exception as e:
sys.stderr.write('Error on querying NVIDIA devices.'
' Use --debug flag for... | python | def print_gpustat(json=False, debug=False, **kwargs):
'''
Display the GPU query results into standard output.
'''
try:
gpu_stats = GPUStatCollection.new_query()
except Exception as e:
sys.stderr.write('Error on querying NVIDIA devices.'
' Use --debug flag for... | [
"def",
"print_gpustat",
"(",
"json",
"=",
"False",
",",
"debug",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"gpu_stats",
"=",
"GPUStatCollection",
".",
"new_query",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"sys",
".",
"stderr",
".... | Display the GPU query results into standard output. | [
"Display",
"the",
"GPU",
"query",
"results",
"into",
"standard",
"output",
"."
] | 28299cdcf55dd627fdd9800cf344988b43188ee8 | https://github.com/wookayin/gpustat/blob/28299cdcf55dd627fdd9800cf344988b43188ee8/gpustat/__main__.py#L14-L37 | train |
westonplatter/fast_arrow | fast_arrow/resources/option.py | Option.fetch_list | def fetch_list(cls, client, ids):
"""
fetch instruments by ids
"""
results = []
request_url = "https://api.robinhood.com/options/instruments/"
for _ids in chunked_list(ids, 50):
params = {"ids": ",".join(_ids)}
data = client.get(request_url, para... | python | def fetch_list(cls, client, ids):
"""
fetch instruments by ids
"""
results = []
request_url = "https://api.robinhood.com/options/instruments/"
for _ids in chunked_list(ids, 50):
params = {"ids": ",".join(_ids)}
data = client.get(request_url, para... | [
"def",
"fetch_list",
"(",
"cls",
",",
"client",
",",
"ids",
")",
":",
"results",
"=",
"[",
"]",
"request_url",
"=",
"\"https://api.robinhood.com/options/instruments/\"",
"for",
"_ids",
"in",
"chunked_list",
"(",
"ids",
",",
"50",
")",
":",
"params",
"=",
"{"... | fetch instruments by ids | [
"fetch",
"instruments",
"by",
"ids"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option.py#L44-L62 | train |
westonplatter/fast_arrow | fast_arrow/resources/option.py | Option.in_chain | def in_chain(cls, client, chain_id, expiration_dates=[]):
"""
fetch all option instruments in an options chain
- expiration_dates = optionally scope
"""
request_url = "https://api.robinhood.com/options/instruments/"
params = {
"chain_id": chain_id,
... | python | def in_chain(cls, client, chain_id, expiration_dates=[]):
"""
fetch all option instruments in an options chain
- expiration_dates = optionally scope
"""
request_url = "https://api.robinhood.com/options/instruments/"
params = {
"chain_id": chain_id,
... | [
"def",
"in_chain",
"(",
"cls",
",",
"client",
",",
"chain_id",
",",
"expiration_dates",
"=",
"[",
"]",
")",
":",
"request_url",
"=",
"\"https://api.robinhood.com/options/instruments/\"",
"params",
"=",
"{",
"\"chain_id\"",
":",
"chain_id",
",",
"\"expiration_dates\"... | fetch all option instruments in an options chain
- expiration_dates = optionally scope | [
"fetch",
"all",
"option",
"instruments",
"in",
"an",
"options",
"chain",
"-",
"expiration_dates",
"=",
"optionally",
"scope"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option.py#L65-L83 | train |
westonplatter/fast_arrow | fast_arrow/option_strategies/iron_condor.py | IronCondor.generate_by_deltas | def generate_by_deltas(cls, options,
width, put_inner_lte_delta, call_inner_lte_delta):
"""
totally just playing around ideas for the API.
this IC sells
- credit put spread
- credit call spread
the approach
- set width for the wing spr... | python | def generate_by_deltas(cls, options,
width, put_inner_lte_delta, call_inner_lte_delta):
"""
totally just playing around ideas for the API.
this IC sells
- credit put spread
- credit call spread
the approach
- set width for the wing spr... | [
"def",
"generate_by_deltas",
"(",
"cls",
",",
"options",
",",
"width",
",",
"put_inner_lte_delta",
",",
"call_inner_lte_delta",
")",
":",
"raise",
"Exception",
"(",
"\"Not Implemented starting at the 0.3.0 release\"",
")",
"put_options_unsorted",
"=",
"list",
"(",
"filt... | totally just playing around ideas for the API.
this IC sells
- credit put spread
- credit call spread
the approach
- set width for the wing spread (eg, 1, ie, 1 unit width spread)
- set delta for inner leg of the put credit spread (eg, -0.2)
- set delta for inne... | [
"totally",
"just",
"playing",
"around",
"ideas",
"for",
"the",
"API",
"."
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/option_strategies/iron_condor.py#L41-L127 | train |
westonplatter/fast_arrow | fast_arrow/resources/option_chain.py | OptionChain.fetch | def fetch(cls, client, _id, symbol):
"""
fetch option chain for instrument
"""
url = "https://api.robinhood.com/options/chains/"
params = {
"equity_instrument_ids": _id,
"state": "active",
"tradability": "tradable"
}
data = clie... | python | def fetch(cls, client, _id, symbol):
"""
fetch option chain for instrument
"""
url = "https://api.robinhood.com/options/chains/"
params = {
"equity_instrument_ids": _id,
"state": "active",
"tradability": "tradable"
}
data = clie... | [
"def",
"fetch",
"(",
"cls",
",",
"client",
",",
"_id",
",",
"symbol",
")",
":",
"url",
"=",
"\"https://api.robinhood.com/options/chains/\"",
"params",
"=",
"{",
"\"equity_instrument_ids\"",
":",
"_id",
",",
"\"state\"",
":",
"\"active\"",
",",
"\"tradability\"",
... | fetch option chain for instrument | [
"fetch",
"option",
"chain",
"for",
"instrument"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option_chain.py#L4-L19 | train |
westonplatter/fast_arrow | fast_arrow/client.py | Client.authenticate | def authenticate(self):
'''
Authenticate using data in `options`
'''
if "username" in self.options and "password" in self.options:
self.login_oauth2(
self.options["username"],
self.options["password"],
self.options.get('mfa_code... | python | def authenticate(self):
'''
Authenticate using data in `options`
'''
if "username" in self.options and "password" in self.options:
self.login_oauth2(
self.options["username"],
self.options["password"],
self.options.get('mfa_code... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"if",
"\"username\"",
"in",
"self",
".",
"options",
"and",
"\"password\"",
"in",
"self",
".",
"options",
":",
"self",
".",
"login_oauth2",
"(",
"self",
".",
"options",
"[",
"\"username\"",
"]",
",",
"self",
"... | Authenticate using data in `options` | [
"Authenticate",
"using",
"data",
"in",
"options"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/client.py#L27-L43 | train |
westonplatter/fast_arrow | fast_arrow/client.py | Client.get | def get(self, url=None, params=None, retry=True):
'''
Execute HTTP GET
'''
headers = self._gen_headers(self.access_token, url)
attempts = 1
while attempts <= HTTP_ATTEMPTS_MAX:
try:
res = requests.get(url,
hea... | python | def get(self, url=None, params=None, retry=True):
'''
Execute HTTP GET
'''
headers = self._gen_headers(self.access_token, url)
attempts = 1
while attempts <= HTTP_ATTEMPTS_MAX:
try:
res = requests.get(url,
hea... | [
"def",
"get",
"(",
"self",
",",
"url",
"=",
"None",
",",
"params",
"=",
"None",
",",
"retry",
"=",
"True",
")",
":",
"headers",
"=",
"self",
".",
"_gen_headers",
"(",
"self",
".",
"access_token",
",",
"url",
")",
"attempts",
"=",
"1",
"while",
"att... | Execute HTTP GET | [
"Execute",
"HTTP",
"GET"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/client.py#L45-L65 | train |
westonplatter/fast_arrow | fast_arrow/client.py | Client._gen_headers | def _gen_headers(self, bearer, url):
'''
Generate headders, adding in Oauth2 bearer token if present
'''
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": ("en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, " +
... | python | def _gen_headers(self, bearer, url):
'''
Generate headders, adding in Oauth2 bearer token if present
'''
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": ("en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, " +
... | [
"def",
"_gen_headers",
"(",
"self",
",",
"bearer",
",",
"url",
")",
":",
"headers",
"=",
"{",
"\"Accept\"",
":",
"\"*/*\"",
",",
"\"Accept-Encoding\"",
":",
"\"gzip, deflate\"",
",",
"\"Accept-Language\"",
":",
"(",
"\"en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, \"",
"+",... | Generate headders, adding in Oauth2 bearer token if present | [
"Generate",
"headders",
"adding",
"in",
"Oauth2",
"bearer",
"token",
"if",
"present"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/client.py#L89-L107 | train |
westonplatter/fast_arrow | fast_arrow/client.py | Client.logout_oauth2 | def logout_oauth2(self):
'''
Logout for given Oauth2 bearer token
'''
url = "https://api.robinhood.com/oauth2/revoke_token/"
data = {
"client_id": CLIENT_ID,
"token": self.refresh_token,
}
res = self.post(url, payload=data)
if res i... | python | def logout_oauth2(self):
'''
Logout for given Oauth2 bearer token
'''
url = "https://api.robinhood.com/oauth2/revoke_token/"
data = {
"client_id": CLIENT_ID,
"token": self.refresh_token,
}
res = self.post(url, payload=data)
if res i... | [
"def",
"logout_oauth2",
"(",
"self",
")",
":",
"url",
"=",
"\"https://api.robinhood.com/oauth2/revoke_token/\"",
"data",
"=",
"{",
"\"client_id\"",
":",
"CLIENT_ID",
",",
"\"token\"",
":",
"self",
".",
"refresh_token",
",",
"}",
"res",
"=",
"self",
".",
"post",
... | Logout for given Oauth2 bearer token | [
"Logout",
"for",
"given",
"Oauth2",
"bearer",
"token"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/client.py#L178-L198 | train |
westonplatter/fast_arrow | fast_arrow/resources/stock.py | Stock.fetch | def fetch(cls, client, symbol):
"""
fetch data for stock
"""
assert(type(symbol) is str)
url = ("https://api.robinhood.com/instruments/?symbol={0}".
format(symbol))
data = client.get(url)
return data["results"][0] | python | def fetch(cls, client, symbol):
"""
fetch data for stock
"""
assert(type(symbol) is str)
url = ("https://api.robinhood.com/instruments/?symbol={0}".
format(symbol))
data = client.get(url)
return data["results"][0] | [
"def",
"fetch",
"(",
"cls",
",",
"client",
",",
"symbol",
")",
":",
"assert",
"(",
"type",
"(",
"symbol",
")",
"is",
"str",
")",
"url",
"=",
"(",
"\"https://api.robinhood.com/instruments/?symbol={0}\"",
".",
"format",
"(",
"symbol",
")",
")",
"data",
"=",
... | fetch data for stock | [
"fetch",
"data",
"for",
"stock"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/stock.py#L7-L16 | train |
westonplatter/fast_arrow | fast_arrow/option_strategies/vertical.py | Vertical.gen_df | def gen_df(cls, options, width, spread_type="call", spread_kind="buy"):
"""
Generate Pandas Dataframe of Vertical
:param options: python dict of options.
:param width: offset for spread. Must be integer.
:param spread_type: call or put. defaults to "call".
:param spread_... | python | def gen_df(cls, options, width, spread_type="call", spread_kind="buy"):
"""
Generate Pandas Dataframe of Vertical
:param options: python dict of options.
:param width: offset for spread. Must be integer.
:param spread_type: call or put. defaults to "call".
:param spread_... | [
"def",
"gen_df",
"(",
"cls",
",",
"options",
",",
"width",
",",
"spread_type",
"=",
"\"call\"",
",",
"spread_kind",
"=",
"\"buy\"",
")",
":",
"assert",
"type",
"(",
"width",
")",
"is",
"int",
"assert",
"spread_type",
"in",
"[",
"\"call\"",
",",
"\"put\""... | Generate Pandas Dataframe of Vertical
:param options: python dict of options.
:param width: offset for spread. Must be integer.
:param spread_type: call or put. defaults to "call".
:param spread_kind: buy or sell. defaults to "buy". | [
"Generate",
"Pandas",
"Dataframe",
"of",
"Vertical"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/option_strategies/vertical.py#L7-L57 | train |
westonplatter/fast_arrow | fast_arrow/resources/stock_marketdata.py | StockMarketdata.quote_by_instruments | def quote_by_instruments(cls, client, ids):
"""
create instrument urls, fetch, return results
"""
base_url = "https://api.robinhood.com/instruments"
id_urls = ["{}/{}/".format(base_url, _id) for _id in ids]
return cls.quotes_by_instrument_urls(client, id_urls) | python | def quote_by_instruments(cls, client, ids):
"""
create instrument urls, fetch, return results
"""
base_url = "https://api.robinhood.com/instruments"
id_urls = ["{}/{}/".format(base_url, _id) for _id in ids]
return cls.quotes_by_instrument_urls(client, id_urls) | [
"def",
"quote_by_instruments",
"(",
"cls",
",",
"client",
",",
"ids",
")",
":",
"base_url",
"=",
"\"https://api.robinhood.com/instruments\"",
"id_urls",
"=",
"[",
"\"{}/{}/\"",
".",
"format",
"(",
"base_url",
",",
"_id",
")",
"for",
"_id",
"in",
"ids",
"]",
... | create instrument urls, fetch, return results | [
"create",
"instrument",
"urls",
"fetch",
"return",
"results"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/stock_marketdata.py#L13-L19 | train |
westonplatter/fast_arrow | fast_arrow/resources/stock_marketdata.py | StockMarketdata.quotes_by_instrument_urls | def quotes_by_instrument_urls(cls, client, urls):
"""
fetch and return results
"""
instruments = ",".join(urls)
params = {"instruments": instruments}
url = "https://api.robinhood.com/marketdata/quotes/"
data = client.get(url, params=params)
results = data[... | python | def quotes_by_instrument_urls(cls, client, urls):
"""
fetch and return results
"""
instruments = ",".join(urls)
params = {"instruments": instruments}
url = "https://api.robinhood.com/marketdata/quotes/"
data = client.get(url, params=params)
results = data[... | [
"def",
"quotes_by_instrument_urls",
"(",
"cls",
",",
"client",
",",
"urls",
")",
":",
"instruments",
"=",
"\",\"",
".",
"join",
"(",
"urls",
")",
"params",
"=",
"{",
"\"instruments\"",
":",
"instruments",
"}",
"url",
"=",
"\"https://api.robinhood.com/marketdata/... | fetch and return results | [
"fetch",
"and",
"return",
"results"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/stock_marketdata.py#L22-L34 | train |
westonplatter/fast_arrow | fast_arrow/resources/option_position.py | OptionPosition.all | def all(cls, client, **kwargs):
"""
fetch all option positions
"""
max_date = kwargs['max_date'] if 'max_date' in kwargs else None
max_fetches = \
kwargs['max_fetches'] if 'max_fetches' in kwargs else None
url = 'https://api.robinhood.com/options/positions/'
... | python | def all(cls, client, **kwargs):
"""
fetch all option positions
"""
max_date = kwargs['max_date'] if 'max_date' in kwargs else None
max_fetches = \
kwargs['max_fetches'] if 'max_fetches' in kwargs else None
url = 'https://api.robinhood.com/options/positions/'
... | [
"def",
"all",
"(",
"cls",
",",
"client",
",",
"**",
"kwargs",
")",
":",
"max_date",
"=",
"kwargs",
"[",
"'max_date'",
"]",
"if",
"'max_date'",
"in",
"kwargs",
"else",
"None",
"max_fetches",
"=",
"kwargs",
"[",
"'max_fetches'",
"]",
"if",
"'max_fetches'",
... | fetch all option positions | [
"fetch",
"all",
"option",
"positions"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option_position.py#L10-L37 | train |
westonplatter/fast_arrow | fast_arrow/resources/option_position.py | OptionPosition.mergein_marketdata_list | def mergein_marketdata_list(cls, client, option_positions):
"""
Fetch and merge in Marketdata for each option position
"""
ids = cls._extract_ids(option_positions)
mds = OptionMarketdata.quotes_by_instrument_ids(client, ids)
results = []
for op in option_position... | python | def mergein_marketdata_list(cls, client, option_positions):
"""
Fetch and merge in Marketdata for each option position
"""
ids = cls._extract_ids(option_positions)
mds = OptionMarketdata.quotes_by_instrument_ids(client, ids)
results = []
for op in option_position... | [
"def",
"mergein_marketdata_list",
"(",
"cls",
",",
"client",
",",
"option_positions",
")",
":",
"ids",
"=",
"cls",
".",
"_extract_ids",
"(",
"option_positions",
")",
"mds",
"=",
"OptionMarketdata",
".",
"quotes_by_instrument_ids",
"(",
"client",
",",
"ids",
")",... | Fetch and merge in Marketdata for each option position | [
"Fetch",
"and",
"merge",
"in",
"Marketdata",
"for",
"each",
"option",
"position"
] | 514cbca4994f52a97222058167830a302e313d04 | https://github.com/westonplatter/fast_arrow/blob/514cbca4994f52a97222058167830a302e313d04/fast_arrow/resources/option_position.py#L47-L61 | train |
etingof/snmpsim | snmpsim/record/snmprec.py | SnmprecRecord.evaluateRawString | def evaluateRawString(self, escaped):
"""Evaluates raw Python string like `ast.literal_eval` does"""
unescaped = []
hexdigit = None
escape = False
for char in escaped:
number = ord(char)
if hexdigit is not None:
if hexdigit:
... | python | def evaluateRawString(self, escaped):
"""Evaluates raw Python string like `ast.literal_eval` does"""
unescaped = []
hexdigit = None
escape = False
for char in escaped:
number = ord(char)
if hexdigit is not None:
if hexdigit:
... | [
"def",
"evaluateRawString",
"(",
"self",
",",
"escaped",
")",
":",
"unescaped",
"=",
"[",
"]",
"hexdigit",
"=",
"None",
"escape",
"=",
"False",
"for",
"char",
"in",
"escaped",
":",
"number",
"=",
"ord",
"(",
"char",
")",
"if",
"hexdigit",
"is",
"not",
... | Evaluates raw Python string like `ast.literal_eval` does | [
"Evaluates",
"raw",
"Python",
"string",
"like",
"ast",
".",
"literal_eval",
"does"
] | c6a2c2c6db39620dcdd4f60c79cd545962a1493a | https://github.com/etingof/snmpsim/blob/c6a2c2c6db39620dcdd4f60c79cd545962a1493a/snmpsim/record/snmprec.py#L42-L80 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.subnode_parse | def subnode_parse(self, node, pieces=None, indent=0, ignore=[], restrict=None):
"""Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. If pieces is given, use this as target for
the parse results instead of self.pieces. Indent all lines by the amount
... | python | def subnode_parse(self, node, pieces=None, indent=0, ignore=[], restrict=None):
"""Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. If pieces is given, use this as target for
the parse results instead of self.pieces. Indent all lines by the amount
... | [
"def",
"subnode_parse",
"(",
"self",
",",
"node",
",",
"pieces",
"=",
"None",
",",
"indent",
"=",
"0",
",",
"ignore",
"=",
"[",
"]",
",",
"restrict",
"=",
"None",
")",
":",
"if",
"pieces",
"is",
"not",
"None",
":",
"old_pieces",
",",
"self",
".",
... | Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. If pieces is given, use this as target for
the parse results instead of self.pieces. Indent all lines by the amount
given in `indent`. Note that the initial content in `pieces` is not
indented. The f... | [
"Parse",
"the",
"subnodes",
"of",
"a",
"given",
"node",
".",
"Subnodes",
"with",
"tags",
"in",
"the",
"ignore",
"list",
"are",
"ignored",
".",
"If",
"pieces",
"is",
"given",
"use",
"this",
"as",
"target",
"for",
"the",
"parse",
"results",
"instead",
"of"... | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L224-L254 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.surround_parse | def surround_parse(self, node, pre_char, post_char):
"""Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. Prepend `pre_char` and append `post_char` to
the output in self.pieces."""
self.add_text(pre_char)
self.subnode_parse(node)
sel... | python | def surround_parse(self, node, pre_char, post_char):
"""Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. Prepend `pre_char` and append `post_char` to
the output in self.pieces."""
self.add_text(pre_char)
self.subnode_parse(node)
sel... | [
"def",
"surround_parse",
"(",
"self",
",",
"node",
",",
"pre_char",
",",
"post_char",
")",
":",
"self",
".",
"add_text",
"(",
"pre_char",
")",
"self",
".",
"subnode_parse",
"(",
"node",
")",
"self",
".",
"add_text",
"(",
"post_char",
")"
] | Parse the subnodes of a given node. Subnodes with tags in the
`ignore` list are ignored. Prepend `pre_char` and append `post_char` to
the output in self.pieces. | [
"Parse",
"the",
"subnodes",
"of",
"a",
"given",
"node",
".",
"Subnodes",
"with",
"tags",
"in",
"the",
"ignore",
"list",
"are",
"ignored",
".",
"Prepend",
"pre_char",
"and",
"append",
"post_char",
"to",
"the",
"output",
"in",
"self",
".",
"pieces",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L256-L262 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.get_specific_subnodes | def get_specific_subnodes(self, node, name, recursive=0):
"""Given a node and a name, return a list of child `ELEMENT_NODEs`, that
have a `tagName` matching the `name`. Search recursively for `recursive`
levels.
"""
children = [x for x in node.childNodes if x.nodeType == x.ELEMEN... | python | def get_specific_subnodes(self, node, name, recursive=0):
"""Given a node and a name, return a list of child `ELEMENT_NODEs`, that
have a `tagName` matching the `name`. Search recursively for `recursive`
levels.
"""
children = [x for x in node.childNodes if x.nodeType == x.ELEMEN... | [
"def",
"get_specific_subnodes",
"(",
"self",
",",
"node",
",",
"name",
",",
"recursive",
"=",
"0",
")",
":",
"children",
"=",
"[",
"x",
"for",
"x",
"in",
"node",
".",
"childNodes",
"if",
"x",
".",
"nodeType",
"==",
"x",
".",
"ELEMENT_NODE",
"]",
"ret... | Given a node and a name, return a list of child `ELEMENT_NODEs`, that
have a `tagName` matching the `name`. Search recursively for `recursive`
levels. | [
"Given",
"a",
"node",
"and",
"a",
"name",
"return",
"a",
"list",
"of",
"child",
"ELEMENT_NODEs",
"that",
"have",
"a",
"tagName",
"matching",
"the",
"name",
".",
"Search",
"recursively",
"for",
"recursive",
"levels",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L265-L275 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.get_specific_nodes | def get_specific_nodes(self, node, names):
"""Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name.
"""
nodes = [(x.tagName, x) for x in node.childNodes
... | python | def get_specific_nodes(self, node, names):
"""Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name.
"""
nodes = [(x.tagName, x) for x in node.childNodes
... | [
"def",
"get_specific_nodes",
"(",
"self",
",",
"node",
",",
"names",
")",
":",
"nodes",
"=",
"[",
"(",
"x",
".",
"tagName",
",",
"x",
")",
"for",
"x",
"in",
"node",
".",
"childNodes",
"if",
"x",
".",
"nodeType",
"==",
"x",
".",
"ELEMENT_NODE",
"and... | Given a node and a sequence of strings in `names`, return a
dictionary containing the names as keys and child
`ELEMENT_NODEs`, that have a `tagName` equal to the name. | [
"Given",
"a",
"node",
"and",
"a",
"sequence",
"of",
"strings",
"in",
"names",
"return",
"a",
"dictionary",
"containing",
"the",
"names",
"as",
"keys",
"and",
"child",
"ELEMENT_NODEs",
"that",
"have",
"a",
"tagName",
"equal",
"to",
"the",
"name",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L277-L286 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.add_text | def add_text(self, value):
"""Adds text corresponding to `value` into `self.pieces`."""
if isinstance(value, (list, tuple)):
self.pieces.extend(value)
else:
self.pieces.append(value) | python | def add_text(self, value):
"""Adds text corresponding to `value` into `self.pieces`."""
if isinstance(value, (list, tuple)):
self.pieces.extend(value)
else:
self.pieces.append(value) | [
"def",
"add_text",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"self",
".",
"pieces",
".",
"extend",
"(",
"value",
")",
"else",
":",
"self",
".",
"pieces",
".",
"append",
"... | Adds text corresponding to `value` into `self.pieces`. | [
"Adds",
"text",
"corresponding",
"to",
"value",
"into",
"self",
".",
"pieces",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L288-L293 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.start_new_paragraph | def start_new_paragraph(self):
"""Make sure to create an empty line. This is overridden, if the previous
text ends with the special marker ''. In that case, nothing is done.
"""
if self.pieces[-1:] == ['']: # respect special marker
return
elif self.pieces == []: # fir... | python | def start_new_paragraph(self):
"""Make sure to create an empty line. This is overridden, if the previous
text ends with the special marker ''. In that case, nothing is done.
"""
if self.pieces[-1:] == ['']: # respect special marker
return
elif self.pieces == []: # fir... | [
"def",
"start_new_paragraph",
"(",
"self",
")",
":",
"if",
"self",
".",
"pieces",
"[",
"-",
"1",
":",
"]",
"==",
"[",
"''",
"]",
":",
"return",
"elif",
"self",
".",
"pieces",
"==",
"[",
"]",
":",
"self",
".",
"pieces",
"=",
"[",
"'\\n'",
"]",
"... | Make sure to create an empty line. This is overridden, if the previous
text ends with the special marker ''. In that case, nothing is done. | [
"Make",
"sure",
"to",
"create",
"an",
"empty",
"line",
".",
"This",
"is",
"overridden",
"if",
"the",
"previous",
"text",
"ends",
"with",
"the",
"special",
"marker",
".",
"In",
"that",
"case",
"nothing",
"is",
"done",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L295-L306 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.add_line_with_subsequent_indent | def add_line_with_subsequent_indent(self, line, indent=4):
"""Add line of text and wrap such that subsequent lines are indented
by `indent` spaces.
"""
if isinstance(line, (list, tuple)):
line = ''.join(line)
line = line.strip()
width = self.textwidth-self.ind... | python | def add_line_with_subsequent_indent(self, line, indent=4):
"""Add line of text and wrap such that subsequent lines are indented
by `indent` spaces.
"""
if isinstance(line, (list, tuple)):
line = ''.join(line)
line = line.strip()
width = self.textwidth-self.ind... | [
"def",
"add_line_with_subsequent_indent",
"(",
"self",
",",
"line",
",",
"indent",
"=",
"4",
")",
":",
"if",
"isinstance",
"(",
"line",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"line",
"=",
"''",
".",
"join",
"(",
"line",
")",
"line",
"=",
"l... | Add line of text and wrap such that subsequent lines are indented
by `indent` spaces. | [
"Add",
"line",
"of",
"text",
"and",
"wrap",
"such",
"that",
"subsequent",
"lines",
"are",
"indented",
"by",
"indent",
"spaces",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L308-L320 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.extract_text | def extract_text(self, node):
"""Return the string representation of the node or list of nodes by parsing the
subnodes, but returning the result as a string instead of adding it to `self.pieces`.
Note that this allows extracting text even if the node is in the ignore list.
"""
if... | python | def extract_text(self, node):
"""Return the string representation of the node or list of nodes by parsing the
subnodes, but returning the result as a string instead of adding it to `self.pieces`.
Note that this allows extracting text even if the node is in the ignore list.
"""
if... | [
"def",
"extract_text",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"node",
"=",
"[",
"node",
"]",
"pieces",
",",
"self",
".",
"pieces",
"=",
"self",
".",
"pieces",
","... | Return the string representation of the node or list of nodes by parsing the
subnodes, but returning the result as a string instead of adding it to `self.pieces`.
Note that this allows extracting text even if the node is in the ignore list. | [
"Return",
"the",
"string",
"representation",
"of",
"the",
"node",
"or",
"list",
"of",
"nodes",
"by",
"parsing",
"the",
"subnodes",
"but",
"returning",
"the",
"result",
"as",
"a",
"string",
"instead",
"of",
"adding",
"it",
"to",
"self",
".",
"pieces",
".",
... | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L322-L335 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.get_function_signature | def get_function_signature(self, node):
"""Returns the function signature string for memberdef nodes."""
name = self.extract_text(self.get_specific_subnodes(node, 'name'))
if self.with_type_info:
argsstring = self.extract_text(self.get_specific_subnodes(node, 'argsstring'))
e... | python | def get_function_signature(self, node):
"""Returns the function signature string for memberdef nodes."""
name = self.extract_text(self.get_specific_subnodes(node, 'name'))
if self.with_type_info:
argsstring = self.extract_text(self.get_specific_subnodes(node, 'argsstring'))
e... | [
"def",
"get_function_signature",
"(",
"self",
",",
"node",
")",
":",
"name",
"=",
"self",
".",
"extract_text",
"(",
"self",
".",
"get_specific_subnodes",
"(",
"node",
",",
"'name'",
")",
")",
"if",
"self",
".",
"with_type_info",
":",
"argsstring",
"=",
"se... | Returns the function signature string for memberdef nodes. | [
"Returns",
"the",
"function",
"signature",
"string",
"for",
"memberdef",
"nodes",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L337-L359 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.handle_typical_memberdefs_no_overload | def handle_typical_memberdefs_no_overload(self, signature, memberdef_nodes):
"""Produce standard documentation for memberdef_nodes."""
for n in memberdef_nodes:
self.add_text(['\n', '%feature("docstring") ', signature, ' "', '\n'])
if self.with_function_signature:
... | python | def handle_typical_memberdefs_no_overload(self, signature, memberdef_nodes):
"""Produce standard documentation for memberdef_nodes."""
for n in memberdef_nodes:
self.add_text(['\n', '%feature("docstring") ', signature, ' "', '\n'])
if self.with_function_signature:
... | [
"def",
"handle_typical_memberdefs_no_overload",
"(",
"self",
",",
"signature",
",",
"memberdef_nodes",
")",
":",
"for",
"n",
"in",
"memberdef_nodes",
":",
"self",
".",
"add_text",
"(",
"[",
"'\\n'",
",",
"'%feature(\"docstring\") '",
",",
"signature",
",",
"' \"'"... | Produce standard documentation for memberdef_nodes. | [
"Produce",
"standard",
"documentation",
"for",
"memberdef_nodes",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L431-L438 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.handle_typical_memberdefs | def handle_typical_memberdefs(self, signature, memberdef_nodes):
"""Produces docstring entries containing an "Overloaded function"
section with the documentation for each overload, if the function is
overloaded and self.with_overloaded_functions is set. Else, produce
normal documentation... | python | def handle_typical_memberdefs(self, signature, memberdef_nodes):
"""Produces docstring entries containing an "Overloaded function"
section with the documentation for each overload, if the function is
overloaded and self.with_overloaded_functions is set. Else, produce
normal documentation... | [
"def",
"handle_typical_memberdefs",
"(",
"self",
",",
"signature",
",",
"memberdef_nodes",
")",
":",
"if",
"len",
"(",
"memberdef_nodes",
")",
"==",
"1",
"or",
"not",
"self",
".",
"with_overloaded_functions",
":",
"self",
".",
"handle_typical_memberdefs_no_overload"... | Produces docstring entries containing an "Overloaded function"
section with the documentation for each overload, if the function is
overloaded and self.with_overloaded_functions is set. Else, produce
normal documentation. | [
"Produces",
"docstring",
"entries",
"containing",
"an",
"Overloaded",
"function",
"section",
"with",
"the",
"documentation",
"for",
"each",
"overload",
"if",
"the",
"function",
"is",
"overloaded",
"and",
"self",
".",
"with_overloaded_functions",
"is",
"set",
".",
... | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L440-L461 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.do_memberdef | def do_memberdef(self, node):
"""Handle cases outside of class, struct, file or namespace. These are
now dealt with by `handle_overloaded_memberfunction`.
Do these even exist???
"""
prot = node.attributes['prot'].value
id = node.attributes['id'].value
kind = node.... | python | def do_memberdef(self, node):
"""Handle cases outside of class, struct, file or namespace. These are
now dealt with by `handle_overloaded_memberfunction`.
Do these even exist???
"""
prot = node.attributes['prot'].value
id = node.attributes['id'].value
kind = node.... | [
"def",
"do_memberdef",
"(",
"self",
",",
"node",
")",
":",
"prot",
"=",
"node",
".",
"attributes",
"[",
"'prot'",
"]",
".",
"value",
"id",
"=",
"node",
".",
"attributes",
"[",
"'id'",
"]",
".",
"value",
"kind",
"=",
"node",
".",
"attributes",
"[",
... | Handle cases outside of class, struct, file or namespace. These are
now dealt with by `handle_overloaded_memberfunction`.
Do these even exist??? | [
"Handle",
"cases",
"outside",
"of",
"class",
"struct",
"file",
"or",
"namespace",
".",
"These",
"are",
"now",
"dealt",
"with",
"by",
"handle_overloaded_memberfunction",
".",
"Do",
"these",
"even",
"exist???"
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L699-L730 | train |
basler/pypylon | scripts/builddoxy2swig/doxy2swig/doxy2swig.py | Doxy2SWIG.do_header | def do_header(self, node):
"""For a user defined section def a header field is present
which should not be printed as such, so we comment it in the
output."""
data = self.extract_text(node)
self.add_text('\n/*\n %s \n*/\n' % data)
# If our immediate sibling is a 'descript... | python | def do_header(self, node):
"""For a user defined section def a header field is present
which should not be printed as such, so we comment it in the
output."""
data = self.extract_text(node)
self.add_text('\n/*\n %s \n*/\n' % data)
# If our immediate sibling is a 'descript... | [
"def",
"do_header",
"(",
"self",
",",
"node",
")",
":",
"data",
"=",
"self",
".",
"extract_text",
"(",
"node",
")",
"self",
".",
"add_text",
"(",
"'\\n/*\\n %s \\n*/\\n'",
"%",
"data",
")",
"parent",
"=",
"node",
".",
"parentNode",
"idx",
"=",
"parent",
... | For a user defined section def a header field is present
which should not be printed as such, so we comment it in the
output. | [
"For",
"a",
"user",
"defined",
"section",
"def",
"a",
"header",
"field",
"is",
"present",
"which",
"should",
"not",
"be",
"printed",
"as",
"such",
"so",
"we",
"comment",
"it",
"in",
"the",
"output",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/builddoxy2swig/doxy2swig/doxy2swig.py#L738-L755 | train |
basler/pypylon | scripts/generatedoc/generatedoc.py | visiblename | def visiblename(name, all=None, obj=None):
"""Decide whether to show documentation on a variable."""
# Certain special names are redundant or internal.
# XXX Remove __initializing__?
if name in {'__author__', '__builtins__', '__cached__', '__credits__',
'__date__', '__doc__', '__fil... | python | def visiblename(name, all=None, obj=None):
"""Decide whether to show documentation on a variable."""
# Certain special names are redundant or internal.
# XXX Remove __initializing__?
if name in {'__author__', '__builtins__', '__cached__', '__credits__',
'__date__', '__doc__', '__fil... | [
"def",
"visiblename",
"(",
"name",
",",
"all",
"=",
"None",
",",
"obj",
"=",
"None",
")",
":",
"if",
"name",
"in",
"{",
"'__author__'",
",",
"'__builtins__'",
",",
"'__cached__'",
",",
"'__credits__'",
",",
"'__date__'",
",",
"'__doc__'",
",",
"'__file__'"... | Decide whether to show documentation on a variable. | [
"Decide",
"whether",
"to",
"show",
"documentation",
"on",
"a",
"variable",
"."
] | d3510fa419b1c2b17f3f0b80a5fbb720c7b84008 | https://github.com/basler/pypylon/blob/d3510fa419b1c2b17f3f0b80a5fbb720c7b84008/scripts/generatedoc/generatedoc.py#L1-L43 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | _download_file | def _download_file(uri, bulk_api):
"""Download the bulk API result file for a single batch"""
resp = requests.get(uri, headers=bulk_api.headers(), stream=True)
with tempfile.TemporaryFile("w+b") as f:
for chunk in resp.iter_content(chunk_size=None):
f.write(chunk)
f.seek(0)
... | python | def _download_file(uri, bulk_api):
"""Download the bulk API result file for a single batch"""
resp = requests.get(uri, headers=bulk_api.headers(), stream=True)
with tempfile.TemporaryFile("w+b") as f:
for chunk in resp.iter_content(chunk_size=None):
f.write(chunk)
f.seek(0)
... | [
"def",
"_download_file",
"(",
"uri",
",",
"bulk_api",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"uri",
",",
"headers",
"=",
"bulk_api",
".",
"headers",
"(",
")",
",",
"stream",
"=",
"True",
")",
"with",
"tempfile",
".",
"TemporaryFile",
"(",
... | Download the bulk API result file for a single batch | [
"Download",
"the",
"bulk",
"API",
"result",
"file",
"for",
"a",
"single",
"batch"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L801-L808 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._load_mapping | def _load_mapping(self, mapping):
"""Load data for a single step."""
mapping["oid_as_pk"] = bool(mapping.get("fields", {}).get("Id"))
job_id, local_ids_for_batch = self._create_job(mapping)
result = self._wait_for_job(job_id)
# We store inserted ids even if some batches failed
... | python | def _load_mapping(self, mapping):
"""Load data for a single step."""
mapping["oid_as_pk"] = bool(mapping.get("fields", {}).get("Id"))
job_id, local_ids_for_batch = self._create_job(mapping)
result = self._wait_for_job(job_id)
# We store inserted ids even if some batches failed
... | [
"def",
"_load_mapping",
"(",
"self",
",",
"mapping",
")",
":",
"mapping",
"[",
"\"oid_as_pk\"",
"]",
"=",
"bool",
"(",
"mapping",
".",
"get",
"(",
"\"fields\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"Id\"",
")",
")",
"job_id",
",",
"local_ids_for_batc... | Load data for a single step. | [
"Load",
"data",
"for",
"a",
"single",
"step",
"."
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L268-L275 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._create_job | def _create_job(self, mapping):
"""Initiate a bulk insert and upload batches to run in parallel."""
job_id = self.bulk.create_insert_job(mapping["sf_object"], contentType="CSV")
self.logger.info(" Created bulk job {}".format(job_id))
# Upload batches
local_ids_for_batch = {}
... | python | def _create_job(self, mapping):
"""Initiate a bulk insert and upload batches to run in parallel."""
job_id = self.bulk.create_insert_job(mapping["sf_object"], contentType="CSV")
self.logger.info(" Created bulk job {}".format(job_id))
# Upload batches
local_ids_for_batch = {}
... | [
"def",
"_create_job",
"(",
"self",
",",
"mapping",
")",
":",
"job_id",
"=",
"self",
".",
"bulk",
".",
"create_insert_job",
"(",
"mapping",
"[",
"\"sf_object\"",
"]",
",",
"contentType",
"=",
"\"CSV\"",
")",
"self",
".",
"logger",
".",
"info",
"(",
"\" C... | Initiate a bulk insert and upload batches to run in parallel. | [
"Initiate",
"a",
"bulk",
"insert",
"and",
"upload",
"batches",
"to",
"run",
"in",
"parallel",
"."
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L277-L290 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._get_batches | def _get_batches(self, mapping, batch_size=10000):
"""Get data from the local db"""
action = mapping.get("action", "insert")
fields = mapping.get("fields", {}).copy()
static = mapping.get("static", {})
lookups = mapping.get("lookups", {})
record_type = mapping.get("record... | python | def _get_batches(self, mapping, batch_size=10000):
"""Get data from the local db"""
action = mapping.get("action", "insert")
fields = mapping.get("fields", {}).copy()
static = mapping.get("static", {})
lookups = mapping.get("lookups", {})
record_type = mapping.get("record... | [
"def",
"_get_batches",
"(",
"self",
",",
"mapping",
",",
"batch_size",
"=",
"10000",
")",
":",
"action",
"=",
"mapping",
".",
"get",
"(",
"\"action\"",
",",
"\"insert\"",
")",
"fields",
"=",
"mapping",
".",
"get",
"(",
"\"fields\"",
",",
"{",
"}",
")",... | Get data from the local db | [
"Get",
"data",
"from",
"the",
"local",
"db"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L292-L364 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._query_db | def _query_db(self, mapping):
"""Build a query to retrieve data from the local db.
Includes columns from the mapping
as well as joining to the id tables to get real SF ids
for lookups.
"""
model = self.models[mapping.get("table")]
# Use primary key instead of th... | python | def _query_db(self, mapping):
"""Build a query to retrieve data from the local db.
Includes columns from the mapping
as well as joining to the id tables to get real SF ids
for lookups.
"""
model = self.models[mapping.get("table")]
# Use primary key instead of th... | [
"def",
"_query_db",
"(",
"self",
",",
"mapping",
")",
":",
"model",
"=",
"self",
".",
"models",
"[",
"mapping",
".",
"get",
"(",
"\"table\"",
")",
"]",
"fields",
"=",
"mapping",
".",
"get",
"(",
"\"fields\"",
",",
"{",
"}",
")",
".",
"copy",
"(",
... | Build a query to retrieve data from the local db.
Includes columns from the mapping
as well as joining to the id tables to get real SF ids
for lookups. | [
"Build",
"a",
"query",
"to",
"retrieve",
"data",
"from",
"the",
"local",
"db",
"."
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L366-L413 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._store_inserted_ids | def _store_inserted_ids(self, mapping, job_id, local_ids_for_batch):
"""Get the job results and store inserted SF Ids in a new table"""
id_table_name = self._reset_id_table(mapping)
conn = self.session.connection()
for batch_id, local_ids in local_ids_for_batch.items():
try:
... | python | def _store_inserted_ids(self, mapping, job_id, local_ids_for_batch):
"""Get the job results and store inserted SF Ids in a new table"""
id_table_name = self._reset_id_table(mapping)
conn = self.session.connection()
for batch_id, local_ids in local_ids_for_batch.items():
try:
... | [
"def",
"_store_inserted_ids",
"(",
"self",
",",
"mapping",
",",
"job_id",
",",
"local_ids_for_batch",
")",
":",
"id_table_name",
"=",
"self",
".",
"_reset_id_table",
"(",
"mapping",
")",
"conn",
"=",
"self",
".",
"session",
".",
"connection",
"(",
")",
"for"... | Get the job results and store inserted SF Ids in a new table | [
"Get",
"the",
"job",
"results",
"and",
"store",
"inserted",
"SF",
"Ids",
"in",
"a",
"new",
"table"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L421-L449 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | LoadData._reset_id_table | def _reset_id_table(self, mapping):
"""Create an empty table to hold the inserted SF Ids"""
if not hasattr(self, "_initialized_id_tables"):
self._initialized_id_tables = set()
id_table_name = "{}_sf_ids".format(mapping["table"])
if id_table_name not in self._initialized_id_ta... | python | def _reset_id_table(self, mapping):
"""Create an empty table to hold the inserted SF Ids"""
if not hasattr(self, "_initialized_id_tables"):
self._initialized_id_tables = set()
id_table_name = "{}_sf_ids".format(mapping["table"])
if id_table_name not in self._initialized_id_ta... | [
"def",
"_reset_id_table",
"(",
"self",
",",
"mapping",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_initialized_id_tables\"",
")",
":",
"self",
".",
"_initialized_id_tables",
"=",
"set",
"(",
")",
"id_table_name",
"=",
"\"{}_sf_ids\"",
".",
"format"... | Create an empty table to hold the inserted SF Ids | [
"Create",
"an",
"empty",
"table",
"to",
"hold",
"the",
"inserted",
"SF",
"Ids"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L451-L469 | train |
SFDO-Tooling/CumulusCI | cumulusci/tasks/bulkdata.py | QueryData._get_mapping_for_table | def _get_mapping_for_table(self, table):
""" Returns the first mapping for a table name """
for mapping in self.mappings.values():
if mapping["table"] == table:
return mapping | python | def _get_mapping_for_table(self, table):
""" Returns the first mapping for a table name """
for mapping in self.mappings.values():
if mapping["table"] == table:
return mapping | [
"def",
"_get_mapping_for_table",
"(",
"self",
",",
"table",
")",
":",
"for",
"mapping",
"in",
"self",
".",
"mappings",
".",
"values",
"(",
")",
":",
"if",
"mapping",
"[",
"\"table\"",
"]",
"==",
"table",
":",
"return",
"mapping"
] | Returns the first mapping for a table name | [
"Returns",
"the",
"first",
"mapping",
"for",
"a",
"table",
"name"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/tasks/bulkdata.py#L690-L694 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/config/BaseProjectConfig.py | BaseProjectConfig._load_config | def _load_config(self):
""" Loads the configuration from YAML, if no override config was passed in initially. """
if (
self.config
): # any config being pre-set at init will short circuit out, but not a plain {}
return
# Verify that we're in a project
r... | python | def _load_config(self):
""" Loads the configuration from YAML, if no override config was passed in initially. """
if (
self.config
): # any config being pre-set at init will short circuit out, but not a plain {}
return
# Verify that we're in a project
r... | [
"def",
"_load_config",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"config",
")",
":",
"return",
"repo_root",
"=",
"self",
".",
"repo_root",
"if",
"not",
"repo_root",
":",
"raise",
"NotInProject",
"(",
"\"No git repository was found in the current path. You mus... | Loads the configuration from YAML, if no override config was passed in initially. | [
"Loads",
"the",
"configuration",
"from",
"YAML",
"if",
"no",
"override",
"config",
"was",
"passed",
"in",
"initially",
"."
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/config/BaseProjectConfig.py#L58-L111 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/config/BaseProjectConfig.py | BaseProjectConfig.init_sentry | def init_sentry(self,):
""" Initializes sentry.io error logging for this session """
if not self.use_sentry:
return
sentry_config = self.keychain.get_service("sentry")
tags = {
"repo": self.repo_name,
"branch": self.repo_branch,
"commit":... | python | def init_sentry(self,):
""" Initializes sentry.io error logging for this session """
if not self.use_sentry:
return
sentry_config = self.keychain.get_service("sentry")
tags = {
"repo": self.repo_name,
"branch": self.repo_branch,
"commit":... | [
"def",
"init_sentry",
"(",
"self",
",",
")",
":",
"if",
"not",
"self",
".",
"use_sentry",
":",
"return",
"sentry_config",
"=",
"self",
".",
"keychain",
".",
"get_service",
"(",
"\"sentry\"",
")",
"tags",
"=",
"{",
"\"repo\"",
":",
"self",
".",
"repo_name... | Initializes sentry.io error logging for this session | [
"Initializes",
"sentry",
".",
"io",
"error",
"logging",
"for",
"this",
"session"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/config/BaseProjectConfig.py#L361-L383 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/config/BaseProjectConfig.py | BaseProjectConfig.get_previous_version | def get_previous_version(self):
"""Query GitHub releases to find the previous production release"""
gh = self.get_github_api()
repo = gh.repository(self.repo_owner, self.repo_name)
most_recent = None
for release in repo.releases():
# Return the second release that mat... | python | def get_previous_version(self):
"""Query GitHub releases to find the previous production release"""
gh = self.get_github_api()
repo = gh.repository(self.repo_owner, self.repo_name)
most_recent = None
for release in repo.releases():
# Return the second release that mat... | [
"def",
"get_previous_version",
"(",
"self",
")",
":",
"gh",
"=",
"self",
".",
"get_github_api",
"(",
")",
"repo",
"=",
"gh",
".",
"repository",
"(",
"self",
".",
"repo_owner",
",",
"self",
".",
"repo_name",
")",
"most_recent",
"=",
"None",
"for",
"releas... | Query GitHub releases to find the previous production release | [
"Query",
"GitHub",
"releases",
"to",
"find",
"the",
"previous",
"production",
"release"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/config/BaseProjectConfig.py#L418-L429 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/config/BaseProjectConfig.py | BaseProjectConfig.get_static_dependencies | def get_static_dependencies(self, dependencies=None, include_beta=None):
"""Resolves the project -> dependencies section of cumulusci.yml
to convert dynamic github dependencies into static dependencies
by inspecting the referenced repositories
Keyword arguments:
:param d... | python | def get_static_dependencies(self, dependencies=None, include_beta=None):
"""Resolves the project -> dependencies section of cumulusci.yml
to convert dynamic github dependencies into static dependencies
by inspecting the referenced repositories
Keyword arguments:
:param d... | [
"def",
"get_static_dependencies",
"(",
"self",
",",
"dependencies",
"=",
"None",
",",
"include_beta",
"=",
"None",
")",
":",
"if",
"not",
"dependencies",
":",
"dependencies",
"=",
"self",
".",
"project__dependencies",
"if",
"not",
"dependencies",
":",
"return",
... | Resolves the project -> dependencies section of cumulusci.yml
to convert dynamic github dependencies into static dependencies
by inspecting the referenced repositories
Keyword arguments:
:param dependencies: a list of dependencies to resolve
:param include_beta: when tru... | [
"Resolves",
"the",
"project",
"-",
">",
"dependencies",
"section",
"of",
"cumulusci",
".",
"yml",
"to",
"convert",
"dynamic",
"github",
"dependencies",
"into",
"static",
"dependencies",
"by",
"inspecting",
"the",
"referenced",
"repositories"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/config/BaseProjectConfig.py#L496-L521 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/tasks.py | BaseTask._init_logger | def _init_logger(self):
""" Initializes self.logger """
if self.flow:
self.logger = self.flow.logger.getChild(self.__class__.__name__)
else:
self.logger = logging.getLogger(__name__) | python | def _init_logger(self):
""" Initializes self.logger """
if self.flow:
self.logger = self.flow.logger.getChild(self.__class__.__name__)
else:
self.logger = logging.getLogger(__name__) | [
"def",
"_init_logger",
"(",
"self",
")",
":",
"if",
"self",
".",
"flow",
":",
"self",
".",
"logger",
"=",
"self",
".",
"flow",
".",
"logger",
".",
"getChild",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"else",
":",
"self",
".",
"logger",
... | Initializes self.logger | [
"Initializes",
"self",
".",
"logger"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L79-L84 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/tasks.py | BaseTask._init_options | def _init_options(self, kwargs):
""" Initializes self.options """
self.options = self.task_config.options
if self.options is None:
self.options = {}
if kwargs:
self.options.update(kwargs)
# Handle dynamic lookup of project_config values via $project_confi... | python | def _init_options(self, kwargs):
""" Initializes self.options """
self.options = self.task_config.options
if self.options is None:
self.options = {}
if kwargs:
self.options.update(kwargs)
# Handle dynamic lookup of project_config values via $project_confi... | [
"def",
"_init_options",
"(",
"self",
",",
"kwargs",
")",
":",
"self",
".",
"options",
"=",
"self",
".",
"task_config",
".",
"options",
"if",
"self",
".",
"options",
"is",
"None",
":",
"self",
".",
"options",
"=",
"{",
"}",
"if",
"kwargs",
":",
"self"... | Initializes self.options | [
"Initializes",
"self",
".",
"options"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L86-L101 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/tasks.py | BaseTask._log_begin | def _log_begin(self):
""" Log the beginning of the task execution """
self.logger.info("Beginning task: %s", self.__class__.__name__)
if self.salesforce_task and not self.flow:
self.logger.info("%15s %s", "As user:", self.org_config.username)
self.logger.info("%15s %s", "... | python | def _log_begin(self):
""" Log the beginning of the task execution """
self.logger.info("Beginning task: %s", self.__class__.__name__)
if self.salesforce_task and not self.flow:
self.logger.info("%15s %s", "As user:", self.org_config.username)
self.logger.info("%15s %s", "... | [
"def",
"_log_begin",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Beginning task: %s\"",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"if",
"self",
".",
"salesforce_task",
"and",
"not",
"self",
".",
"flow",
":",
"self",
".",... | Log the beginning of the task execution | [
"Log",
"the",
"beginning",
"of",
"the",
"task",
"execution"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L166-L172 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/tasks.py | BaseTask._poll | def _poll(self):
""" poll for a result in a loop """
while True:
self.poll_count += 1
self._poll_action()
if self.poll_complete:
break
time.sleep(self.poll_interval_s)
self._poll_update_interval() | python | def _poll(self):
""" poll for a result in a loop """
while True:
self.poll_count += 1
self._poll_action()
if self.poll_complete:
break
time.sleep(self.poll_interval_s)
self._poll_update_interval() | [
"def",
"_poll",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"poll_count",
"+=",
"1",
"self",
".",
"_poll_action",
"(",
")",
"if",
"self",
".",
"poll_complete",
":",
"break",
"time",
".",
"sleep",
"(",
"self",
".",
"poll_interval_s",
")",
... | poll for a result in a loop | [
"poll",
"for",
"a",
"result",
"in",
"a",
"loop"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L204-L212 | train |
SFDO-Tooling/CumulusCI | cumulusci/core/tasks.py | BaseTask._poll_update_interval | def _poll_update_interval(self):
""" update the polling interval to be used next iteration """
# Increase by 1 second every 3 polls
if old_div(self.poll_count, 3) > self.poll_interval_level:
self.poll_interval_level += 1
self.poll_interval_s += 1
self.logger.i... | python | def _poll_update_interval(self):
""" update the polling interval to be used next iteration """
# Increase by 1 second every 3 polls
if old_div(self.poll_count, 3) > self.poll_interval_level:
self.poll_interval_level += 1
self.poll_interval_s += 1
self.logger.i... | [
"def",
"_poll_update_interval",
"(",
"self",
")",
":",
"if",
"old_div",
"(",
"self",
".",
"poll_count",
",",
"3",
")",
">",
"self",
".",
"poll_interval_level",
":",
"self",
".",
"poll_interval_level",
"+=",
"1",
"self",
".",
"poll_interval_s",
"+=",
"1",
"... | update the polling interval to be used next iteration | [
"update",
"the",
"polling",
"interval",
"to",
"be",
"used",
"next",
"iteration"
] | e19047921ca771a297e045f22f0bb201651bb6f7 | https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/core/tasks.py#L221-L229 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.