partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | _DoCopyFile | :param unicode source_filename:
The source filename.
Schemas: local, ftp, http
:param unicode target_filename:
Target filename.
Schemas: local, ftp
:param copy_symlink:
@see _CopyFileLocal
:raises FileNotFoundError:
If source_filename does not exist | zerotk/easyfs/_easyfs.py | def _DoCopyFile(source_filename, target_filename, copy_symlink=True):
'''
:param unicode source_filename:
The source filename.
Schemas: local, ftp, http
:param unicode target_filename:
Target filename.
Schemas: local, ftp
:param copy_symlink:
@see _CopyFileLoca... | def _DoCopyFile(source_filename, target_filename, copy_symlink=True):
'''
:param unicode source_filename:
The source filename.
Schemas: local, ftp, http
:param unicode target_filename:
Target filename.
Schemas: local, ftp
:param copy_symlink:
@see _CopyFileLoca... | [
":",
"param",
"unicode",
"source_filename",
":",
"The",
"source",
"filename",
".",
"Schemas",
":",
"local",
"ftp",
"http"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L302-L349 | [
"def",
"_DoCopyFile",
"(",
"source_filename",
",",
"target_filename",
",",
"copy_symlink",
"=",
"True",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"source_url",
"=",
"urlparse",
"(",
"source_filename",
")",
"targe... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _CopyFileLocal | Copy a file locally to a directory.
:param unicode source_filename:
The filename to copy from.
:param unicode target_filename:
The filename to copy to.
:param bool copy_symlink:
If True and source_filename is a symlink, target_filename will also be created as
a symlink.
... | zerotk/easyfs/_easyfs.py | def _CopyFileLocal(source_filename, target_filename, copy_symlink=True):
'''
Copy a file locally to a directory.
:param unicode source_filename:
The filename to copy from.
:param unicode target_filename:
The filename to copy to.
:param bool copy_symlink:
If True and source... | def _CopyFileLocal(source_filename, target_filename, copy_symlink=True):
'''
Copy a file locally to a directory.
:param unicode source_filename:
The filename to copy from.
:param unicode target_filename:
The filename to copy to.
:param bool copy_symlink:
If True and source... | [
"Copy",
"a",
"file",
"locally",
"to",
"a",
"directory",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L352-L396 | [
"def",
"_CopyFileLocal",
"(",
"source_filename",
",",
"target_filename",
",",
"copy_symlink",
"=",
"True",
")",
":",
"import",
"shutil",
"try",
":",
"# >>> Create the target_filename directory if necessary",
"dir_name",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CopyFiles | Copy files from the given source to the target.
:param unicode source_dir:
A filename, URL or a file mask.
Ex.
x:\coilib50
x:\coilib50\*
http://server/directory/file
ftp://server/directory/file
:param unicode target_dir:
A directory or a... | zerotk/easyfs/_easyfs.py | def CopyFiles(source_dir, target_dir, create_target_dir=False, md5_check=False):
'''
Copy files from the given source to the target.
:param unicode source_dir:
A filename, URL or a file mask.
Ex.
x:\coilib50
x:\coilib50\*
http://server/directory/file
... | def CopyFiles(source_dir, target_dir, create_target_dir=False, md5_check=False):
'''
Copy files from the given source to the target.
:param unicode source_dir:
A filename, URL or a file mask.
Ex.
x:\coilib50
x:\coilib50\*
http://server/directory/file
... | [
"Copy",
"files",
"from",
"the",
"given",
"source",
"to",
"the",
"target",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L403-L473 | [
"def",
"CopyFiles",
"(",
"source_dir",
",",
"target_dir",
",",
"create_target_dir",
"=",
"False",
",",
"md5_check",
"=",
"False",
")",
":",
"import",
"fnmatch",
"# Check if we were given a directory or a directory with mask",
"if",
"IsDir",
"(",
"source_dir",
")",
":"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CopyFilesX | Copies files into directories, according to a file mapping
:param list(tuple(unicode,unicode)) file_mapping:
A list of mappings between the directory in the target and the source.
For syntax, @see: ExtendedPathMask
:rtype: list(tuple(unicode,unicode))
:returns:
List of files copied... | zerotk/easyfs/_easyfs.py | def CopyFilesX(file_mapping):
'''
Copies files into directories, according to a file mapping
:param list(tuple(unicode,unicode)) file_mapping:
A list of mappings between the directory in the target and the source.
For syntax, @see: ExtendedPathMask
:rtype: list(tuple(unicode,unicode))
... | def CopyFilesX(file_mapping):
'''
Copies files into directories, according to a file mapping
:param list(tuple(unicode,unicode)) file_mapping:
A list of mappings between the directory in the target and the source.
For syntax, @see: ExtendedPathMask
:rtype: list(tuple(unicode,unicode))
... | [
"Copies",
"files",
"into",
"directories",
"according",
"to",
"a",
"file",
"mapping"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L480-L524 | [
"def",
"CopyFilesX",
"(",
"file_mapping",
")",
":",
"# List files that match the mapping",
"files",
"=",
"[",
"]",
"for",
"i_target_path",
",",
"i_source_path_mask",
"in",
"file_mapping",
":",
"tree_recurse",
",",
"flat_recurse",
",",
"dirname",
",",
"in_filters",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | IsFile | :param unicode path:
Path to a file (local or ftp)
:raises NotImplementedProtocol:
If checking for a non-local, non-ftp file
:rtype: bool
:returns:
True if the file exists
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information | zerotk/easyfs/_easyfs.py | def IsFile(path):
'''
:param unicode path:
Path to a file (local or ftp)
:raises NotImplementedProtocol:
If checking for a non-local, non-ftp file
:rtype: bool
:returns:
True if the file exists
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues in... | def IsFile(path):
'''
:param unicode path:
Path to a file (local or ftp)
:raises NotImplementedProtocol:
If checking for a non-local, non-ftp file
:rtype: bool
:returns:
True if the file exists
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues in... | [
":",
"param",
"unicode",
"path",
":",
"Path",
"to",
"a",
"file",
"(",
"local",
"or",
"ftp",
")"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L531-L558 | [
"def",
"IsFile",
"(",
"path",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"url",
"=",
"urlparse",
"(",
"path",
")",
"if",
"_UrlIsLocal",
"(",
"url",
")",
":",
"if",
"IsLink",
"(",
"path",
")",
":",
"ret... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | GetDriveType | Determine the type of drive, which can be one of the following values:
DRIVE_UNKNOWN = 0
The drive type cannot be determined.
DRIVE_NO_ROOT_DIR = 1
The root path is invalid; for example, there is no volume mounted at the specified path.
DRIVE_REMOVABLE = 2
T... | zerotk/easyfs/_easyfs.py | def GetDriveType(path):
'''
Determine the type of drive, which can be one of the following values:
DRIVE_UNKNOWN = 0
The drive type cannot be determined.
DRIVE_NO_ROOT_DIR = 1
The root path is invalid; for example, there is no volume mounted at the specified path.
... | def GetDriveType(path):
'''
Determine the type of drive, which can be one of the following values:
DRIVE_UNKNOWN = 0
The drive type cannot be determined.
DRIVE_NO_ROOT_DIR = 1
The root path is invalid; for example, there is no volume mounted at the specified path.
... | [
"Determine",
"the",
"type",
"of",
"drive",
"which",
"can",
"be",
"one",
"of",
"the",
"following",
"values",
":",
"DRIVE_UNKNOWN",
"=",
"0",
"The",
"drive",
"type",
"cannot",
"be",
"determined",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L561-L606 | [
"def",
"GetDriveType",
"(",
"path",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"import",
"ctypes",
"kdll",
"=",
"ctypes",
".",
"windll",
".",
"LoadLibrary",
"(",
"\"kernel32.dll\"",
")",
"return",
"kdll",
".",
"GetDriveType",
"(",
"path"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | IsDir | :param unicode directory:
A path
:rtype: bool
:returns:
Returns whether the given path points to an existent directory.
:raises NotImplementedProtocol:
If the path protocol is not local or ftp
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information | zerotk/easyfs/_easyfs.py | def IsDir(directory):
'''
:param unicode directory:
A path
:rtype: bool
:returns:
Returns whether the given path points to an existent directory.
:raises NotImplementedProtocol:
If the path protocol is not local or ftp
.. seealso:: FTP LIMITATIONS at this module's doc ... | def IsDir(directory):
'''
:param unicode directory:
A path
:rtype: bool
:returns:
Returns whether the given path points to an existent directory.
:raises NotImplementedProtocol:
If the path protocol is not local or ftp
.. seealso:: FTP LIMITATIONS at this module's doc ... | [
":",
"param",
"unicode",
"directory",
":",
"A",
"path"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L614-L638 | [
"def",
"IsDir",
"(",
"directory",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"directory_url",
"=",
"urlparse",
"(",
"directory",
")",
"if",
"_UrlIsLocal",
"(",
"directory_url",
")",
":",
"return",
"os",
".",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | Exists | :rtype: bool
:returns:
True if the path already exists (either a file or a directory)
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information | zerotk/easyfs/_easyfs.py | def Exists(path):
'''
:rtype: bool
:returns:
True if the path already exists (either a file or a directory)
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information
'''
from six.moves.urllib.parse import urlparse
path_url = urlparse(path)
# Handle lo... | def Exists(path):
'''
:rtype: bool
:returns:
True if the path already exists (either a file or a directory)
.. seealso:: FTP LIMITATIONS at this module's doc for performance issues information
'''
from six.moves.urllib.parse import urlparse
path_url = urlparse(path)
# Handle lo... | [
":",
"rtype",
":",
"bool",
":",
"returns",
":",
"True",
"if",
"the",
"path",
"already",
"exists",
"(",
"either",
"a",
"file",
"or",
"a",
"directory",
")"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L645-L659 | [
"def",
"Exists",
"(",
"path",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"path_url",
"=",
"urlparse",
"(",
"path",
")",
"# Handle local",
"if",
"_UrlIsLocal",
"(",
"path_url",
")",
":",
"return",
"IsFile",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CopyDirectory | Recursively copy a directory tree.
:param unicode source_dir:
Where files will come from
:param unicode target_dir:
Where files will go to
:param bool override:
If True and target_dir already exists, it will be deleted before copying.
:raises NotImplementedForRemotePathError:... | zerotk/easyfs/_easyfs.py | def CopyDirectory(source_dir, target_dir, override=False):
'''
Recursively copy a directory tree.
:param unicode source_dir:
Where files will come from
:param unicode target_dir:
Where files will go to
:param bool override:
If True and target_dir already exists, it will be... | def CopyDirectory(source_dir, target_dir, override=False):
'''
Recursively copy a directory tree.
:param unicode source_dir:
Where files will come from
:param unicode target_dir:
Where files will go to
:param bool override:
If True and target_dir already exists, it will be... | [
"Recursively",
"copy",
"a",
"directory",
"tree",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L666-L689 | [
"def",
"CopyDirectory",
"(",
"source_dir",
",",
"target_dir",
",",
"override",
"=",
"False",
")",
":",
"_AssertIsLocal",
"(",
"source_dir",
")",
"_AssertIsLocal",
"(",
"target_dir",
")",
"if",
"override",
"and",
"IsDir",
"(",
"target_dir",
")",
":",
"DeleteDir... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | DeleteFile | Deletes the given local filename.
.. note:: If file doesn't exist this method has no effect.
:param unicode target_filename:
A local filename
:raises NotImplementedForRemotePathError:
If trying to delete a non-local path
:raises FileOnlyActionError:
Raised when filename refer... | zerotk/easyfs/_easyfs.py | def DeleteFile(target_filename):
'''
Deletes the given local filename.
.. note:: If file doesn't exist this method has no effect.
:param unicode target_filename:
A local filename
:raises NotImplementedForRemotePathError:
If trying to delete a non-local path
:raises FileOnlyAc... | def DeleteFile(target_filename):
'''
Deletes the given local filename.
.. note:: If file doesn't exist this method has no effect.
:param unicode target_filename:
A local filename
:raises NotImplementedForRemotePathError:
If trying to delete a non-local path
:raises FileOnlyAc... | [
"Deletes",
"the",
"given",
"local",
"filename",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L696-L722 | [
"def",
"DeleteFile",
"(",
"target_filename",
")",
":",
"_AssertIsLocal",
"(",
"target_filename",
")",
"try",
":",
"if",
"IsLink",
"(",
"target_filename",
")",
":",
"DeleteLink",
"(",
"target_filename",
")",
"elif",
"IsFile",
"(",
"target_filename",
")",
":",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | AppendToFile | Appends content to a local file.
:param unicode filename:
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
Replaces the EOL by the appropriate EOL depending on the eol_style value.
Considers that all content is using only "\n" as EOL.
:param unic... | zerotk/easyfs/_easyfs.py | def AppendToFile(filename, contents, eol_style=EOL_STYLE_NATIVE, encoding=None, binary=False):
'''
Appends content to a local file.
:param unicode filename:
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
Replaces the EOL by the appropriate EOL depen... | def AppendToFile(filename, contents, eol_style=EOL_STYLE_NATIVE, encoding=None, binary=False):
'''
Appends content to a local file.
:param unicode filename:
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
Replaces the EOL by the appropriate EOL depen... | [
"Appends",
"content",
"to",
"a",
"local",
"file",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L729-L773 | [
"def",
"AppendToFile",
"(",
"filename",
",",
"contents",
",",
"eol_style",
"=",
"EOL_STYLE_NATIVE",
",",
"encoding",
"=",
"None",
",",
"binary",
"=",
"False",
")",
":",
"_AssertIsLocal",
"(",
"filename",
")",
"assert",
"isinstance",
"(",
"contents",
",",
"si... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | MoveFile | Moves a file.
:param unicode source_filename:
:param unicode target_filename:
:raises NotImplementedForRemotePathError:
If trying to operate with non-local files. | zerotk/easyfs/_easyfs.py | def MoveFile(source_filename, target_filename):
'''
Moves a file.
:param unicode source_filename:
:param unicode target_filename:
:raises NotImplementedForRemotePathError:
If trying to operate with non-local files.
'''
_AssertIsLocal(source_filename)
_AssertIsLocal(target_file... | def MoveFile(source_filename, target_filename):
'''
Moves a file.
:param unicode source_filename:
:param unicode target_filename:
:raises NotImplementedForRemotePathError:
If trying to operate with non-local files.
'''
_AssertIsLocal(source_filename)
_AssertIsLocal(target_file... | [
"Moves",
"a",
"file",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L780-L795 | [
"def",
"MoveFile",
"(",
"source_filename",
",",
"target_filename",
")",
":",
"_AssertIsLocal",
"(",
"source_filename",
")",
"_AssertIsLocal",
"(",
"target_filename",
")",
"import",
"shutil",
"shutil",
".",
"move",
"(",
"source_filename",
",",
"target_filename",
")"
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | MoveDirectory | Moves a directory.
:param unicode source_dir:
:param unicode target_dir:
:raises NotImplementedError:
If trying to move anything other than:
Local dir -> local dir
FTP dir -> FTP dir (same host) | zerotk/easyfs/_easyfs.py | def MoveDirectory(source_dir, target_dir):
'''
Moves a directory.
:param unicode source_dir:
:param unicode target_dir:
:raises NotImplementedError:
If trying to move anything other than:
Local dir -> local dir
FTP dir -> FTP dir (same host)
'''
if not IsDi... | def MoveDirectory(source_dir, target_dir):
'''
Moves a directory.
:param unicode source_dir:
:param unicode target_dir:
:raises NotImplementedError:
If trying to move anything other than:
Local dir -> local dir
FTP dir -> FTP dir (same host)
'''
if not IsDi... | [
"Moves",
"a",
"directory",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L802-L837 | [
"def",
"MoveDirectory",
"(",
"source_dir",
",",
"target_dir",
")",
":",
"if",
"not",
"IsDir",
"(",
"source_dir",
")",
":",
"from",
".",
"_exceptions",
"import",
"DirectoryNotFoundError",
"raise",
"DirectoryNotFoundError",
"(",
"source_dir",
")",
"if",
"Exists",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | GetFileContents | Reads a file and returns its contents. Works for both local and remote files.
:param unicode filename:
:param bool binary:
If True returns the file as is, ignore any EOL conversion.
:param unicode encoding:
File's encoding. If not None, contents obtained from file will be decoded using th... | zerotk/easyfs/_easyfs.py | def GetFileContents(filename, binary=False, encoding=None, newline=None):
'''
Reads a file and returns its contents. Works for both local and remote files.
:param unicode filename:
:param bool binary:
If True returns the file as is, ignore any EOL conversion.
:param unicode encoding:
... | def GetFileContents(filename, binary=False, encoding=None, newline=None):
'''
Reads a file and returns its contents. Works for both local and remote files.
:param unicode filename:
:param bool binary:
If True returns the file as is, ignore any EOL conversion.
:param unicode encoding:
... | [
"Reads",
"a",
"file",
"and",
"returns",
"its",
"contents",
".",
"Works",
"for",
"both",
"local",
"and",
"remote",
"files",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L843-L872 | [
"def",
"GetFileContents",
"(",
"filename",
",",
"binary",
"=",
"False",
",",
"encoding",
"=",
"None",
",",
"newline",
"=",
"None",
")",
":",
"source_file",
"=",
"OpenFile",
"(",
"filename",
",",
"binary",
"=",
"binary",
",",
"encoding",
"=",
"encoding",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | GetFileLines | Reads a file and returns its contents as a list of lines. Works for both local and remote files.
:param unicode filename:
:param None|''|'\n'|'\r'|'\r\n' newline:
Controls universal newlines.
See 'io.open' newline parameter documentation for more details.
:param unicode encoding:
... | zerotk/easyfs/_easyfs.py | def GetFileLines(filename, newline=None, encoding=None):
'''
Reads a file and returns its contents as a list of lines. Works for both local and remote files.
:param unicode filename:
:param None|''|'\n'|'\r'|'\r\n' newline:
Controls universal newlines.
See 'io.open' newline parameter d... | def GetFileLines(filename, newline=None, encoding=None):
'''
Reads a file and returns its contents as a list of lines. Works for both local and remote files.
:param unicode filename:
:param None|''|'\n'|'\r'|'\r\n' newline:
Controls universal newlines.
See 'io.open' newline parameter d... | [
"Reads",
"a",
"file",
"and",
"returns",
"its",
"contents",
"as",
"a",
"list",
"of",
"lines",
".",
"Works",
"for",
"both",
"local",
"and",
"remote",
"files",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L878-L902 | [
"def",
"GetFileLines",
"(",
"filename",
",",
"newline",
"=",
"None",
",",
"encoding",
"=",
"None",
")",
":",
"return",
"GetFileContents",
"(",
"filename",
",",
"binary",
"=",
"False",
",",
"encoding",
"=",
"encoding",
",",
"newline",
"=",
"newline",
",",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | OpenFile | Open a file and returns it.
Consider the possibility of a remote file (HTTP, HTTPS, FTP)
:param unicode filename:
Local or remote filename.
:param bool binary:
If True returns the file as is, ignore any EOL conversion.
If set ignores univeral_newlines parameter.
:param None|''... | zerotk/easyfs/_easyfs.py | def OpenFile(filename, binary=False, newline=None, encoding=None):
'''
Open a file and returns it.
Consider the possibility of a remote file (HTTP, HTTPS, FTP)
:param unicode filename:
Local or remote filename.
:param bool binary:
If True returns the file as is, ignore any EOL conv... | def OpenFile(filename, binary=False, newline=None, encoding=None):
'''
Open a file and returns it.
Consider the possibility of a remote file (HTTP, HTTPS, FTP)
:param unicode filename:
Local or remote filename.
:param bool binary:
If True returns the file as is, ignore any EOL conv... | [
"Open",
"a",
"file",
"and",
"returns",
"it",
".",
"Consider",
"the",
"possibility",
"of",
"a",
"remote",
"file",
"(",
"HTTP",
"HTTPS",
"FTP",
")"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L905-L947 | [
"def",
"OpenFile",
"(",
"filename",
",",
"binary",
"=",
"False",
",",
"newline",
"=",
"None",
",",
"encoding",
"=",
"None",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"filename_url",
"=",
"urlparse",
"(",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ListFiles | Lists the files in the given directory
:type directory: unicode | unicode
:param directory:
A directory or URL
:rtype: list(unicode) | list(unicode)
:returns:
List of filenames/directories found in the given directory.
Returns None if the given directory does not exists.
... | zerotk/easyfs/_easyfs.py | def ListFiles(directory):
'''
Lists the files in the given directory
:type directory: unicode | unicode
:param directory:
A directory or URL
:rtype: list(unicode) | list(unicode)
:returns:
List of filenames/directories found in the given directory.
Returns None if the g... | def ListFiles(directory):
'''
Lists the files in the given directory
:type directory: unicode | unicode
:param directory:
A directory or URL
:rtype: list(unicode) | list(unicode)
:returns:
List of filenames/directories found in the given directory.
Returns None if the g... | [
"Lists",
"the",
"files",
"in",
"the",
"given",
"directory"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L954-L989 | [
"def",
"ListFiles",
"(",
"directory",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"directory_url",
"=",
"urlparse",
"(",
"directory",
")",
"# Handle local",
"if",
"_UrlIsLocal",
"(",
"directory_url",
")",
":",
"i... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CreateFile | Create a file with the given contents.
:param unicode filename:
Filename and path to be created.
:param unicode contents:
The file contents as a string.
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
Replaces the EOL by the appropriate EOL depending on the eol_style... | zerotk/easyfs/_easyfs.py | def CreateFile(filename, contents, eol_style=EOL_STYLE_NATIVE, create_dir=True, encoding=None, binary=False):
'''
Create a file with the given contents.
:param unicode filename:
Filename and path to be created.
:param unicode contents:
The file contents as a string.
:type eol_styl... | def CreateFile(filename, contents, eol_style=EOL_STYLE_NATIVE, create_dir=True, encoding=None, binary=False):
'''
Create a file with the given contents.
:param unicode filename:
Filename and path to be created.
:param unicode contents:
The file contents as a string.
:type eol_styl... | [
"Create",
"a",
"file",
"with",
"the",
"given",
"contents",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1034-L1113 | [
"def",
"CreateFile",
"(",
"filename",
",",
"contents",
",",
"eol_style",
"=",
"EOL_STYLE_NATIVE",
",",
"create_dir",
"=",
"True",
",",
"encoding",
"=",
"None",
",",
"binary",
"=",
"False",
")",
":",
"# Lots of checks when writing binary files",
"if",
"binary",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ReplaceInFile | Replaces all occurrences of "old" by "new" in the given file.
:param unicode filename:
The name of the file.
:param unicode old:
The string to search for.
:param unicode new:
Replacement string.
:return unicode:
The new contents of the file. | zerotk/easyfs/_easyfs.py | def ReplaceInFile(filename, old, new, encoding=None):
'''
Replaces all occurrences of "old" by "new" in the given file.
:param unicode filename:
The name of the file.
:param unicode old:
The string to search for.
:param unicode new:
Replacement string.
:return unicode... | def ReplaceInFile(filename, old, new, encoding=None):
'''
Replaces all occurrences of "old" by "new" in the given file.
:param unicode filename:
The name of the file.
:param unicode old:
The string to search for.
:param unicode new:
Replacement string.
:return unicode... | [
"Replaces",
"all",
"occurrences",
"of",
"old",
"by",
"new",
"in",
"the",
"given",
"file",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1117-L1136 | [
"def",
"ReplaceInFile",
"(",
"filename",
",",
"old",
",",
"new",
",",
"encoding",
"=",
"None",
")",
":",
"contents",
"=",
"GetFileContents",
"(",
"filename",
",",
"encoding",
"=",
"encoding",
")",
"contents",
"=",
"contents",
".",
"replace",
"(",
"old",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CreateDirectory | Create directory including any missing intermediate directory.
:param unicode directory:
:return unicode|urlparse.ParseResult:
Returns the created directory or url (see urlparse).
:raises NotImplementedProtocol:
If protocol is not local or FTP.
.. seealso:: FTP LIMITATIONS at this mo... | zerotk/easyfs/_easyfs.py | def CreateDirectory(directory):
'''
Create directory including any missing intermediate directory.
:param unicode directory:
:return unicode|urlparse.ParseResult:
Returns the created directory or url (see urlparse).
:raises NotImplementedProtocol:
If protocol is not local or FTP.
... | def CreateDirectory(directory):
'''
Create directory including any missing intermediate directory.
:param unicode directory:
:return unicode|urlparse.ParseResult:
Returns the created directory or url (see urlparse).
:raises NotImplementedProtocol:
If protocol is not local or FTP.
... | [
"Create",
"directory",
"including",
"any",
"missing",
"intermediate",
"directory",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1143-L1172 | [
"def",
"CreateDirectory",
"(",
"directory",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"directory_url",
"=",
"urlparse",
"(",
"directory",
")",
"# Handle local",
"if",
"_UrlIsLocal",
"(",
"directory_url",
")",
":"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | DeleteDirectory | Deletes a directory.
:param unicode directory:
:param bool skip_on_error:
If True, ignore any errors when trying to delete directory (for example, directory not
found)
:raises NotImplementedForRemotePathError:
If trying to delete a remote directory. | zerotk/easyfs/_easyfs.py | def DeleteDirectory(directory, skip_on_error=False):
'''
Deletes a directory.
:param unicode directory:
:param bool skip_on_error:
If True, ignore any errors when trying to delete directory (for example, directory not
found)
:raises NotImplementedForRemotePathError:
If try... | def DeleteDirectory(directory, skip_on_error=False):
'''
Deletes a directory.
:param unicode directory:
:param bool skip_on_error:
If True, ignore any errors when trying to delete directory (for example, directory not
found)
:raises NotImplementedForRemotePathError:
If try... | [
"Deletes",
"a",
"directory",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1329-L1372 | [
"def",
"DeleteDirectory",
"(",
"directory",
",",
"skip_on_error",
"=",
"False",
")",
":",
"_AssertIsLocal",
"(",
"directory",
")",
"import",
"shutil",
"def",
"OnError",
"(",
"fn",
",",
"path",
",",
"excinfo",
")",
":",
"'''\n Remove the read-only flag and t... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | GetMTime | :param unicode path:
Path to file or directory
:rtype: float
:returns:
Modification time for path.
If this is a directory, the highest mtime from files inside it will be returned.
@note:
In some Linux distros (such as CentOs, or anything with ext3), mtime will not return a... | zerotk/easyfs/_easyfs.py | def GetMTime(path):
'''
:param unicode path:
Path to file or directory
:rtype: float
:returns:
Modification time for path.
If this is a directory, the highest mtime from files inside it will be returned.
@note:
In some Linux distros (such as CentOs, or anything wit... | def GetMTime(path):
'''
:param unicode path:
Path to file or directory
:rtype: float
:returns:
Modification time for path.
If this is a directory, the highest mtime from files inside it will be returned.
@note:
In some Linux distros (such as CentOs, or anything wit... | [
":",
"param",
"unicode",
"path",
":",
"Path",
"to",
"file",
"or",
"directory"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1379-L1404 | [
"def",
"GetMTime",
"(",
"path",
")",
":",
"_AssertIsLocal",
"(",
"path",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"files",
"=",
"FindFiles",
"(",
"path",
")",
"if",
"len",
"(",
"files",
")",
">",
"0",
":",
"return",
"max... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ListMappedNetworkDrives | On Windows, returns a list of mapped network drives
:return: tuple(string, string, bool)
For each mapped netword drive, return 3 values tuple:
- the local drive
- the remote path-
- True if the mapping is enabled (warning: not reliable) | zerotk/easyfs/_easyfs.py | def ListMappedNetworkDrives():
'''
On Windows, returns a list of mapped network drives
:return: tuple(string, string, bool)
For each mapped netword drive, return 3 values tuple:
- the local drive
- the remote path-
- True if the mapping is enabled (warning: not r... | def ListMappedNetworkDrives():
'''
On Windows, returns a list of mapped network drives
:return: tuple(string, string, bool)
For each mapped netword drive, return 3 values tuple:
- the local drive
- the remote path-
- True if the mapping is enabled (warning: not r... | [
"On",
"Windows",
"returns",
"a",
"list",
"of",
"mapped",
"network",
"drives"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1411-L1429 | [
"def",
"ListMappedNetworkDrives",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"raise",
"NotImplementedError",
"drives_list",
"=",
"[",
"]",
"netuse",
"=",
"_CallWindowsNetCommand",
"(",
"[",
"'use'",
"]",
")",
"for",
"line",
"in",
"net... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CreateLink | Create a symbolic link at `link_path` pointing to `target_path`.
:param unicode target_path:
Link target
:param unicode link_path:
Fullpath to link name
:param bool override:
If True and `link_path` already exists as a link, that link is overridden. | zerotk/easyfs/_easyfs.py | def CreateLink(target_path, link_path, override=True):
'''
Create a symbolic link at `link_path` pointing to `target_path`.
:param unicode target_path:
Link target
:param unicode link_path:
Fullpath to link name
:param bool override:
If True and `link_path` already exists ... | def CreateLink(target_path, link_path, override=True):
'''
Create a symbolic link at `link_path` pointing to `target_path`.
:param unicode target_path:
Link target
:param unicode link_path:
Fullpath to link name
:param bool override:
If True and `link_path` already exists ... | [
"Create",
"a",
"symbolic",
"link",
"at",
"link_path",
"pointing",
"to",
"target_path",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1451-L1491 | [
"def",
"CreateLink",
"(",
"target_path",
",",
"link_path",
",",
"override",
"=",
"True",
")",
":",
"_AssertIsLocal",
"(",
"target_path",
")",
"_AssertIsLocal",
"(",
"link_path",
")",
"if",
"override",
"and",
"IsLink",
"(",
"link_path",
")",
":",
"DeleteLink",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | IsLink | :param unicode path:
Path being tested
:returns bool:
True if `path` is a link | zerotk/easyfs/_easyfs.py | def IsLink(path):
'''
:param unicode path:
Path being tested
:returns bool:
True if `path` is a link
'''
_AssertIsLocal(path)
if sys.platform != 'win32':
return os.path.islink(path)
import jaraco.windows.filesystem
return jaraco.windows.filesystem.islink(path) | def IsLink(path):
'''
:param unicode path:
Path being tested
:returns bool:
True if `path` is a link
'''
_AssertIsLocal(path)
if sys.platform != 'win32':
return os.path.islink(path)
import jaraco.windows.filesystem
return jaraco.windows.filesystem.islink(path) | [
":",
"param",
"unicode",
"path",
":",
"Path",
"being",
"tested"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1498-L1512 | [
"def",
"IsLink",
"(",
"path",
")",
":",
"_AssertIsLocal",
"(",
"path",
")",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"return",
"os",
".",
"path",
".",
"islink",
"(",
"path",
")",
"import",
"jaraco",
".",
"windows",
".",
"filesystem",
"return... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ReadLink | Read the target of the symbolic link at `path`.
:param unicode path:
Path to a symbolic link
:returns unicode:
Target of a symbolic link | zerotk/easyfs/_easyfs.py | def ReadLink(path):
'''
Read the target of the symbolic link at `path`.
:param unicode path:
Path to a symbolic link
:returns unicode:
Target of a symbolic link
'''
_AssertIsLocal(path)
if sys.platform != 'win32':
return os.readlink(path) # @UndefinedVariable
... | def ReadLink(path):
'''
Read the target of the symbolic link at `path`.
:param unicode path:
Path to a symbolic link
:returns unicode:
Target of a symbolic link
'''
_AssertIsLocal(path)
if sys.platform != 'win32':
return os.readlink(path) # @UndefinedVariable
... | [
"Read",
"the",
"target",
"of",
"the",
"symbolic",
"link",
"at",
"path",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1519-L1542 | [
"def",
"ReadLink",
"(",
"path",
")",
":",
"_AssertIsLocal",
"(",
"path",
")",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"return",
"os",
".",
"readlink",
"(",
"path",
")",
"# @UndefinedVariable",
"if",
"not",
"IsLink",
"(",
"path",
")",
":",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _AssertIsLocal | Checks if a given path is local, raise an exception if not.
This is used in filesystem functions that do not support remote operations yet.
:param unicode path:
:raises NotImplementedForRemotePathError:
If the given path is not local | zerotk/easyfs/_easyfs.py | def _AssertIsLocal(path):
'''
Checks if a given path is local, raise an exception if not.
This is used in filesystem functions that do not support remote operations yet.
:param unicode path:
:raises NotImplementedForRemotePathError:
If the given path is not local
'''
from six.move... | def _AssertIsLocal(path):
'''
Checks if a given path is local, raise an exception if not.
This is used in filesystem functions that do not support remote operations yet.
:param unicode path:
:raises NotImplementedForRemotePathError:
If the given path is not local
'''
from six.move... | [
"Checks",
"if",
"a",
"given",
"path",
"is",
"local",
"raise",
"an",
"exception",
"if",
"not",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1564-L1578 | [
"def",
"_AssertIsLocal",
"(",
"path",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"if",
"not",
"_UrlIsLocal",
"(",
"urlparse",
"(",
"path",
")",
")",
":",
"from",
".",
"_exceptions",
"import",
"NotImplementedFo... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _HandleContentsEol | Replaces eol on each line by the given eol_style.
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style: | zerotk/easyfs/_easyfs.py | def _HandleContentsEol(contents, eol_style):
'''
Replaces eol on each line by the given eol_style.
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
'''
if eol_style == EOL_STYLE_NONE:
return contents
if eol_style == EOL_STYLE_UNIX:
retu... | def _HandleContentsEol(contents, eol_style):
'''
Replaces eol on each line by the given eol_style.
:param unicode contents:
:type eol_style: EOL_STYLE_XXX constant
:param eol_style:
'''
if eol_style == EOL_STYLE_NONE:
return contents
if eol_style == EOL_STYLE_UNIX:
retu... | [
"Replaces",
"eol",
"on",
"each",
"line",
"by",
"the",
"given",
"eol_style",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1581-L1601 | [
"def",
"_HandleContentsEol",
"(",
"contents",
",",
"eol_style",
")",
":",
"if",
"eol_style",
"==",
"EOL_STYLE_NONE",
":",
"return",
"contents",
"if",
"eol_style",
"==",
"EOL_STYLE_UNIX",
":",
"return",
"contents",
".",
"replace",
"(",
"'\\r\\n'",
",",
"eol_style... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | _CallWindowsNetCommand | Call Windows NET command, used to acquire/configure network services settings.
:param parameters: list of command line parameters
:return: command output | zerotk/easyfs/_easyfs.py | def _CallWindowsNetCommand(parameters):
'''
Call Windows NET command, used to acquire/configure network services settings.
:param parameters: list of command line parameters
:return: command output
'''
import subprocess
popen = subprocess.Popen(["net"] + parameters, stdout=subprocess.PIPE,... | def _CallWindowsNetCommand(parameters):
'''
Call Windows NET command, used to acquire/configure network services settings.
:param parameters: list of command line parameters
:return: command output
'''
import subprocess
popen = subprocess.Popen(["net"] + parameters, stdout=subprocess.PIPE,... | [
"Call",
"Windows",
"NET",
"command",
"used",
"to",
"acquire",
"/",
"configure",
"network",
"services",
"settings",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1604-L1617 | [
"def",
"_CallWindowsNetCommand",
"(",
"parameters",
")",
":",
"import",
"subprocess",
"popen",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"net\"",
"]",
"+",
"parameters",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | CheckForUpdate | Checks if the given target filename should be re-generated because the source has changed.
:param source: the source filename.
:param target: the target filename.
:return bool:
True if the target is out-dated, False otherwise. | zerotk/easyfs/_easyfs.py | def CheckForUpdate(source, target):
'''
Checks if the given target filename should be re-generated because the source has changed.
:param source: the source filename.
:param target: the target filename.
:return bool:
True if the target is out-dated, False otherwise.
'''
return \
... | def CheckForUpdate(source, target):
'''
Checks if the given target filename should be re-generated because the source has changed.
:param source: the source filename.
:param target: the target filename.
:return bool:
True if the target is out-dated, False otherwise.
'''
return \
... | [
"Checks",
"if",
"the",
"given",
"target",
"filename",
"should",
"be",
"re",
"-",
"generated",
"because",
"the",
"source",
"has",
"changed",
".",
":",
"param",
"source",
":",
"the",
"source",
"filename",
".",
":",
"param",
"target",
":",
"the",
"target",
... | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1689-L1699 | [
"def",
"CheckForUpdate",
"(",
"source",
",",
"target",
")",
":",
"return",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"target",
")",
"or",
"os",
".",
"path",
".",
"getmtime",
"(",
"source",
")",
">",
"os",
".",
"path",
".",
"getmtime",
"(",
"tar... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | MatchMasks | Verifies if a filename match with given patterns.
:param str filename: The filename to match.
:param list(str) masks: The patterns to search in the filename.
:return bool:
True if the filename has matched with one pattern, False otherwise. | zerotk/easyfs/_easyfs.py | def MatchMasks(filename, masks):
'''
Verifies if a filename match with given patterns.
:param str filename: The filename to match.
:param list(str) masks: The patterns to search in the filename.
:return bool:
True if the filename has matched with one pattern, False otherwise.
'''
im... | def MatchMasks(filename, masks):
'''
Verifies if a filename match with given patterns.
:param str filename: The filename to match.
:param list(str) masks: The patterns to search in the filename.
:return bool:
True if the filename has matched with one pattern, False otherwise.
'''
im... | [
"Verifies",
"if",
"a",
"filename",
"match",
"with",
"given",
"patterns",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1706-L1723 | [
"def",
"MatchMasks",
"(",
"filename",
",",
"masks",
")",
":",
"import",
"fnmatch",
"if",
"not",
"isinstance",
"(",
"masks",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"masks",
"=",
"[",
"masks",
"]",
"for",
"i_mask",
"in",
"masks",
":",
"if",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | FindFiles | Searches for files in a given directory that match with the given patterns.
:param str dir_: the directory root, to search the files.
:param list(str) in_filters: a list with patterns to match (default = all). E.g.: ['*.py']
:param list(str) out_filters: a list with patterns to ignore (default = none). E.g... | zerotk/easyfs/_easyfs.py | def FindFiles(dir_, in_filters=None, out_filters=None, recursive=True, include_root_dir=True, standard_paths=False):
'''
Searches for files in a given directory that match with the given patterns.
:param str dir_: the directory root, to search the files.
:param list(str) in_filters: a list with pattern... | def FindFiles(dir_, in_filters=None, out_filters=None, recursive=True, include_root_dir=True, standard_paths=False):
'''
Searches for files in a given directory that match with the given patterns.
:param str dir_: the directory root, to search the files.
:param list(str) in_filters: a list with pattern... | [
"Searches",
"for",
"files",
"in",
"a",
"given",
"directory",
"that",
"match",
"with",
"the",
"given",
"patterns",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1730-L1775 | [
"def",
"FindFiles",
"(",
"dir_",
",",
"in_filters",
"=",
"None",
",",
"out_filters",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"include_root_dir",
"=",
"True",
",",
"standard_paths",
"=",
"False",
")",
":",
"# all files",
"if",
"in_filters",
"is",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ExpandUser | os.path.expanduser wrapper, necessary because it cannot handle unicode strings properly.
This is not necessary in Python 3.
:param path:
.. seealso:: os.path.expanduser | zerotk/easyfs/_easyfs.py | def ExpandUser(path):
'''
os.path.expanduser wrapper, necessary because it cannot handle unicode strings properly.
This is not necessary in Python 3.
:param path:
.. seealso:: os.path.expanduser
'''
if six.PY2:
encoding = sys.getfilesystemencoding()
path = path.encode(e... | def ExpandUser(path):
'''
os.path.expanduser wrapper, necessary because it cannot handle unicode strings properly.
This is not necessary in Python 3.
:param path:
.. seealso:: os.path.expanduser
'''
if six.PY2:
encoding = sys.getfilesystemencoding()
path = path.encode(e... | [
"os",
".",
"path",
".",
"expanduser",
"wrapper",
"necessary",
"because",
"it",
"cannot",
"handle",
"unicode",
"strings",
"properly",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1782-L1797 | [
"def",
"ExpandUser",
"(",
"path",
")",
":",
"if",
"six",
".",
"PY2",
":",
"encoding",
"=",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"path",
"=",
"path",
".",
"encode",
"(",
"encoding",
")",
"result",
"=",
"os",
".",
"path",
".",
"expanduser",
"... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | DumpDirHashToStringIO | Helper to iterate over the files in a directory putting those in the passed StringIO in ini
format.
:param unicode directory:
The directory for which the hash should be done.
:param StringIO stringio:
The string to which the dump should be put.
:param unicode base:
If provided... | zerotk/easyfs/_easyfs.py | def DumpDirHashToStringIO(directory, stringio, base='', exclude=None, include=None):
'''
Helper to iterate over the files in a directory putting those in the passed StringIO in ini
format.
:param unicode directory:
The directory for which the hash should be done.
:param StringIO stringio:
... | def DumpDirHashToStringIO(directory, stringio, base='', exclude=None, include=None):
'''
Helper to iterate over the files in a directory putting those in the passed StringIO in ini
format.
:param unicode directory:
The directory for which the hash should be done.
:param StringIO stringio:
... | [
"Helper",
"to",
"iterate",
"over",
"the",
"files",
"in",
"a",
"directory",
"putting",
"those",
"in",
"the",
"passed",
"StringIO",
"in",
"ini",
"format",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1804-L1842 | [
"def",
"DumpDirHashToStringIO",
"(",
"directory",
",",
"stringio",
",",
"base",
"=",
"''",
",",
"exclude",
"=",
"None",
",",
"include",
"=",
"None",
")",
":",
"import",
"fnmatch",
"import",
"os",
"files",
"=",
"[",
"(",
"os",
".",
"path",
".",
"join",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | Md5Hex | :param unicode filename:
The file from which the md5 should be calculated. If the filename is given, the contents
should NOT be given.
:param unicode contents:
The contents for which the md5 should be calculated. If the contents are given, the filename
should NOT be given.
:rty... | zerotk/easyfs/_easyfs.py | def Md5Hex(filename=None, contents=None):
'''
:param unicode filename:
The file from which the md5 should be calculated. If the filename is given, the contents
should NOT be given.
:param unicode contents:
The contents for which the md5 should be calculated. If the contents are give... | def Md5Hex(filename=None, contents=None):
'''
:param unicode filename:
The file from which the md5 should be calculated. If the filename is given, the contents
should NOT be given.
:param unicode contents:
The contents for which the md5 should be calculated. If the contents are give... | [
":",
"param",
"unicode",
"filename",
":",
"The",
"file",
"from",
"which",
"the",
"md5",
"should",
"be",
"calculated",
".",
"If",
"the",
"filename",
"is",
"given",
"the",
"contents",
"should",
"NOT",
"be",
"given",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1849-L1881 | [
"def",
"Md5Hex",
"(",
"filename",
"=",
"None",
",",
"contents",
"=",
"None",
")",
":",
"import",
"io",
"import",
"hashlib",
"md5",
"=",
"hashlib",
".",
"md5",
"(",
")",
"if",
"filename",
":",
"stream",
"=",
"io",
".",
"open",
"(",
"filename",
",",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | IterHashes | Iterator for random hexadecimal hashes
:param iterator_size:
Amount of hashes return before this iterator stops.
Goes on forever if `iterator_size` is negative.
:param int hash_length:
Size of each hash returned.
:return generator(unicode): | zerotk/easyfs/_easyfs.py | def IterHashes(iterator_size, hash_length=7):
'''
Iterator for random hexadecimal hashes
:param iterator_size:
Amount of hashes return before this iterator stops.
Goes on forever if `iterator_size` is negative.
:param int hash_length:
Size of each hash returned.
:return ge... | def IterHashes(iterator_size, hash_length=7):
'''
Iterator for random hexadecimal hashes
:param iterator_size:
Amount of hashes return before this iterator stops.
Goes on forever if `iterator_size` is negative.
:param int hash_length:
Size of each hash returned.
:return ge... | [
"Iterator",
"for",
"random",
"hexadecimal",
"hashes"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1904-L1923 | [
"def",
"IterHashes",
"(",
"iterator_size",
",",
"hash_length",
"=",
"7",
")",
":",
"if",
"not",
"isinstance",
"(",
"iterator_size",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'iterator_size must be integer.'",
")",
"count",
"=",
"0",
"while",
"count",
... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | PushPopItem | A context manager to replace and restore a value using a getter and setter.
:param object obj: The object to replace/restore.
:param object key: The key to replace/restore in the object.
:param object value: The value to replace.
Example::
with PushPop2(sys.modules, 'alpha', None):
pyte... | zerotk/easyfs/_easyfs.py | def PushPopItem(obj, key, value):
'''
A context manager to replace and restore a value using a getter and setter.
:param object obj: The object to replace/restore.
:param object key: The key to replace/restore in the object.
:param object value: The value to replace.
Example::
with Push... | def PushPopItem(obj, key, value):
'''
A context manager to replace and restore a value using a getter and setter.
:param object obj: The object to replace/restore.
:param object key: The key to replace/restore in the object.
:param object value: The value to replace.
Example::
with Push... | [
"A",
"context",
"manager",
"to",
"replace",
"and",
"restore",
"a",
"value",
"using",
"a",
"getter",
"and",
"setter",
"."
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1930-L1953 | [
"def",
"PushPopItem",
"(",
"obj",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"obj",
":",
"old_value",
"=",
"obj",
"[",
"key",
"]",
"obj",
"[",
"key",
"]",
"=",
"value",
"yield",
"value",
"obj",
"[",
"key",
"]",
"=",
"old_value",
"else... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | ExtendedPathMask.Split | Splits the given path into their components: recursive, dirname, in_filters and out_filters
:param str: extended_path_mask:
The "extended path mask" to split
:rtype: tuple(bool,bool,str,list(str),list(str))
:returns:
Returns the extended path 5 components:
-... | zerotk/easyfs/_easyfs.py | def Split(cls, extended_path_mask):
'''
Splits the given path into their components: recursive, dirname, in_filters and out_filters
:param str: extended_path_mask:
The "extended path mask" to split
:rtype: tuple(bool,bool,str,list(str),list(str))
:returns:
... | def Split(cls, extended_path_mask):
'''
Splits the given path into their components: recursive, dirname, in_filters and out_filters
:param str: extended_path_mask:
The "extended path mask" to split
:rtype: tuple(bool,bool,str,list(str),list(str))
:returns:
... | [
"Splits",
"the",
"given",
"path",
"into",
"their",
"components",
":",
"recursive",
"dirname",
"in_filters",
"and",
"out_filters"
] | zerotk/easyfs | python | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1654-L1682 | [
"def",
"Split",
"(",
"cls",
",",
"extended_path_mask",
")",
":",
"import",
"os",
".",
"path",
"r_tree_recurse",
"=",
"extended_path_mask",
"[",
"0",
"]",
"in",
"'+-'",
"r_flat_recurse",
"=",
"extended_path_mask",
"[",
"0",
"]",
"in",
"'-'",
"r_dirname",
",",... | 140923db51fb91d5a5847ad17412e8bce51ba3da |
valid | MessageFactory.GetMessages | Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message classes. This will include
any dep... | typy/google/protobuf/message_factory.py | def GetMessages(self, files):
"""Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message cla... | def GetMessages(self, files):
"""Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message cla... | [
"Gets",
"all",
"the",
"messages",
"from",
"a",
"specified",
"file",
"."
] | ibelie/typy | python | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/message_factory.py#L89-L128 | [
"def",
"GetMessages",
"(",
"self",
",",
"files",
")",
":",
"result",
"=",
"{",
"}",
"for",
"file_name",
"in",
"files",
":",
"file_desc",
"=",
"self",
".",
"pool",
".",
"FindFileByName",
"(",
"file_name",
")",
"for",
"name",
",",
"msg",
"in",
"file_desc... | 3616845fb91459aacd8df6bf82c5d91f4542bee7 |
valid | multinest | **MultiNest Nested Sampling**
via `PyMultiNest <http://johannesbuchner.github.com/PyMultiNest/index.html>`_.
:param parameter_names: name of parameters; not directly used here,
but for multinest_marginal.py plotting tool. | jbopt/mn.py | def multinest(parameter_names, transform, loglikelihood, output_basename, **problem):
"""
**MultiNest Nested Sampling**
via `PyMultiNest <http://johannesbuchner.github.com/PyMultiNest/index.html>`_.
:param parameter_names: name of parameters; not directly used here,
but for multinest_marginal.py plotting too... | def multinest(parameter_names, transform, loglikelihood, output_basename, **problem):
"""
**MultiNest Nested Sampling**
via `PyMultiNest <http://johannesbuchner.github.com/PyMultiNest/index.html>`_.
:param parameter_names: name of parameters; not directly used here,
but for multinest_marginal.py plotting too... | [
"**",
"MultiNest",
"Nested",
"Sampling",
"**",
"via",
"PyMultiNest",
"<http",
":",
"//",
"johannesbuchner",
".",
"github",
".",
"com",
"/",
"PyMultiNest",
"/",
"index",
".",
"html",
">",
"_",
".",
":",
"param",
"parameter_names",
":",
"name",
"of",
"parame... | JohannesBuchner/jbopt | python | https://github.com/JohannesBuchner/jbopt/blob/11b721ea001625ad7820f71ff684723c71216646/jbopt/mn.py#L5-L69 | [
"def",
"multinest",
"(",
"parameter_names",
",",
"transform",
",",
"loglikelihood",
",",
"output_basename",
",",
"*",
"*",
"problem",
")",
":",
"import",
"numpy",
"from",
"numpy",
"import",
"log",
",",
"exp",
"import",
"pymultinest",
"# n observations",
"# numbe... | 11b721ea001625ad7820f71ff684723c71216646 |
valid | specifier_to_db | Return the database string for a database specifier.
The database specifier takes a custom format for specifying local and remote
databases. A local database is specified by the following format:
local:<db_name>
For example, a database called 'sessions' would be specified by the s... | relax/couchdb/__init__.py | def specifier_to_db(db_spec):
"""
Return the database string for a database specifier.
The database specifier takes a custom format for specifying local and remote
databases. A local database is specified by the following format:
local:<db_name>
For example, a database cal... | def specifier_to_db(db_spec):
"""
Return the database string for a database specifier.
The database specifier takes a custom format for specifying local and remote
databases. A local database is specified by the following format:
local:<db_name>
For example, a database cal... | [
"Return",
"the",
"database",
"string",
"for",
"a",
"database",
"specifier",
".",
"The",
"database",
"specifier",
"takes",
"a",
"custom",
"format",
"for",
"specifying",
"local",
"and",
"remote",
"databases",
".",
"A",
"local",
"database",
"is",
"specified",
"by... | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/couchdb/__init__.py#L25-L68 | [
"def",
"specifier_to_db",
"(",
"db_spec",
")",
":",
"local_match",
"=",
"LOCAL_RE",
".",
"match",
"(",
"db_spec",
")",
"remote_match",
"=",
"REMOTE_RE",
".",
"match",
"(",
"db_spec",
")",
"plain_match",
"=",
"PLAIN_RE",
".",
"match",
"(",
"db_spec",
")",
"... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | db_to_specifier | Return the database specifier for a database string.
This accepts a database name or URL, and returns a database specifier in the
format accepted by ``specifier_to_db``. It is recommended that you consult
the documentation for that function for an explanation of the format. | relax/couchdb/__init__.py | def db_to_specifier(db_string):
"""
Return the database specifier for a database string.
This accepts a database name or URL, and returns a database specifier in the
format accepted by ``specifier_to_db``. It is recommended that you consult
the documentation for that function for an explanation... | def db_to_specifier(db_string):
"""
Return the database specifier for a database string.
This accepts a database name or URL, and returns a database specifier in the
format accepted by ``specifier_to_db``. It is recommended that you consult
the documentation for that function for an explanation... | [
"Return",
"the",
"database",
"specifier",
"for",
"a",
"database",
"string",
".",
"This",
"accepts",
"a",
"database",
"name",
"or",
"URL",
"and",
"returns",
"a",
"database",
"specifier",
"in",
"the",
"format",
"accepted",
"by",
"specifier_to_db",
".",
"It",
"... | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/couchdb/__init__.py#L71-L97 | [
"def",
"db_to_specifier",
"(",
"db_string",
")",
":",
"local_match",
"=",
"PLAIN_RE",
".",
"match",
"(",
"db_string",
")",
"remote_match",
"=",
"URL_RE",
".",
"match",
"(",
"db_string",
")",
"# If this looks like a local specifier:",
"if",
"local_match",
":",
"ret... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | get_db_from_db | Return a CouchDB database instance from a database string. | relax/couchdb/__init__.py | def get_db_from_db(db_string):
"""Return a CouchDB database instance from a database string."""
server = get_server_from_db(db_string)
local_match = PLAIN_RE.match(db_string)
remote_match = URL_RE.match(db_string)
# If this looks like a local specifier:
if local_match:
return server[loca... | def get_db_from_db(db_string):
"""Return a CouchDB database instance from a database string."""
server = get_server_from_db(db_string)
local_match = PLAIN_RE.match(db_string)
remote_match = URL_RE.match(db_string)
# If this looks like a local specifier:
if local_match:
return server[loca... | [
"Return",
"a",
"CouchDB",
"database",
"instance",
"from",
"a",
"database",
"string",
"."
] | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/couchdb/__init__.py#L122-L132 | [
"def",
"get_db_from_db",
"(",
"db_string",
")",
":",
"server",
"=",
"get_server_from_db",
"(",
"db_string",
")",
"local_match",
"=",
"PLAIN_RE",
".",
"match",
"(",
"db_string",
")",
"remote_match",
"=",
"URL_RE",
".",
"match",
"(",
"db_string",
")",
"# If this... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | ensure_specifier_exists | Make sure a DB specifier exists, creating it if necessary. | relax/couchdb/__init__.py | def ensure_specifier_exists(db_spec):
"""Make sure a DB specifier exists, creating it if necessary."""
local_match = LOCAL_RE.match(db_spec)
remote_match = REMOTE_RE.match(db_spec)
plain_match = PLAIN_RE.match(db_spec)
if local_match:
db_name = local_match.groupdict().get('database')
... | def ensure_specifier_exists(db_spec):
"""Make sure a DB specifier exists, creating it if necessary."""
local_match = LOCAL_RE.match(db_spec)
remote_match = REMOTE_RE.match(db_spec)
plain_match = PLAIN_RE.match(db_spec)
if local_match:
db_name = local_match.groupdict().get('database')
... | [
"Make",
"sure",
"a",
"DB",
"specifier",
"exists",
"creating",
"it",
"if",
"necessary",
"."
] | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/couchdb/__init__.py#L138-L163 | [
"def",
"ensure_specifier_exists",
"(",
"db_spec",
")",
":",
"local_match",
"=",
"LOCAL_RE",
".",
"match",
"(",
"db_spec",
")",
"remote_match",
"=",
"REMOTE_RE",
".",
"match",
"(",
"db_spec",
")",
"plain_match",
"=",
"PLAIN_RE",
".",
"match",
"(",
"db_spec",
... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | coerce | Exclude NoSet objec
.. code-block::
>>> coerce(NoSet, 'value')
'value' | src/custom_settings/utils.py | def coerce(value1, value2, default=None):
"""Exclude NoSet objec
.. code-block::
>>> coerce(NoSet, 'value')
'value'
"""
if value1 is not NoSet:
return value1
elif value2 is not NoSet:
return value2
else:
return default | def coerce(value1, value2, default=None):
"""Exclude NoSet objec
.. code-block::
>>> coerce(NoSet, 'value')
'value'
"""
if value1 is not NoSet:
return value1
elif value2 is not NoSet:
return value2
else:
return default | [
"Exclude",
"NoSet",
"objec"
] | TakesxiSximada/custom_settings | python | https://github.com/TakesxiSximada/custom_settings/blob/0e478ea2b5d7ad46eb1ece705b649e5651cd20ad/src/custom_settings/utils.py#L8-L22 | [
"def",
"coerce",
"(",
"value1",
",",
"value2",
",",
"default",
"=",
"None",
")",
":",
"if",
"value1",
"is",
"not",
"NoSet",
":",
"return",
"value1",
"elif",
"value2",
"is",
"not",
"NoSet",
":",
"return",
"value2",
"else",
":",
"return",
"default"
] | 0e478ea2b5d7ad46eb1ece705b649e5651cd20ad |
valid | DposNode.get_events_vote_cluster | Returns all transactions and forged blocks by voters clustered around a single delegate_address | dpostools/dbtools.py | def get_events_vote_cluster(self, delegate_address):
''' Returns all transactions and forged blocks by voters clustered around a single delegate_address'''
delegate_pubkey = self.account_details(address=delegate_address)['public_key']
plusvote = '+{delegate_pubkey}'.format(delegate_pubkey=dele... | def get_events_vote_cluster(self, delegate_address):
''' Returns all transactions and forged blocks by voters clustered around a single delegate_address'''
delegate_pubkey = self.account_details(address=delegate_address)['public_key']
plusvote = '+{delegate_pubkey}'.format(delegate_pubkey=dele... | [
"Returns",
"all",
"transactions",
"and",
"forged",
"blocks",
"by",
"voters",
"clustered",
"around",
"a",
"single",
"delegate_address"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/dbtools.py#L416-L517 | [
"def",
"get_events_vote_cluster",
"(",
"self",
",",
"delegate_address",
")",
":",
"delegate_pubkey",
"=",
"self",
".",
"account_details",
"(",
"address",
"=",
"delegate_address",
")",
"[",
"'public_key'",
"]",
"plusvote",
"=",
"'+{delegate_pubkey}'",
".",
"format",
... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | DposNode.tbw | This function doesn't work yet. Instead use legacy.trueshare() for a functional tbw script | dpostools/dbtools.py | def tbw(self, delegate_address, blacklist=None, share_fees=False, compound_interest=False):
"""This function doesn't work yet. Instead use legacy.trueshare() for a functional tbw script"""
if not blacklist:
blacklist = []
delegate_public_key = self.account_details(address=delegate_a... | def tbw(self, delegate_address, blacklist=None, share_fees=False, compound_interest=False):
"""This function doesn't work yet. Instead use legacy.trueshare() for a functional tbw script"""
if not blacklist:
blacklist = []
delegate_public_key = self.account_details(address=delegate_a... | [
"This",
"function",
"doesn",
"t",
"work",
"yet",
".",
"Instead",
"use",
"legacy",
".",
"trueshare",
"()",
"for",
"a",
"functional",
"tbw",
"script"
] | BlockHub/blockhubdpostools | python | https://github.com/BlockHub/blockhubdpostools/blob/27712cd97cd3658ee54a4330ff3135b51a01d7d1/dpostools/dbtools.py#L519-L654 | [
"def",
"tbw",
"(",
"self",
",",
"delegate_address",
",",
"blacklist",
"=",
"None",
",",
"share_fees",
"=",
"False",
",",
"compound_interest",
"=",
"False",
")",
":",
"if",
"not",
"blacklist",
":",
"blacklist",
"=",
"[",
"]",
"delegate_public_key",
"=",
"se... | 27712cd97cd3658ee54a4330ff3135b51a01d7d1 |
valid | classical | **Classic optimization methods**
:param start: start position vector (before transform)
:param ftol: accuracy required to stop at optimum
:param disp: verbosity
:param nsteps: number of steps
:param method: string
neldermead, cobyla (via `scipy.optimize <http://docs.scipy.org/doc/scipy/reference/tutorial/optimi... | jbopt/classic.py | def classical(transform, loglikelihood, parameter_names, prior,
start = 0.5, ftol=0.1, disp=0, nsteps=40000,
method='neldermead', **args):
"""
**Classic optimization methods**
:param start: start position vector (before transform)
:param ftol: accuracy required to stop at optimum
:param disp: verbosity
:param... | def classical(transform, loglikelihood, parameter_names, prior,
start = 0.5, ftol=0.1, disp=0, nsteps=40000,
method='neldermead', **args):
"""
**Classic optimization methods**
:param start: start position vector (before transform)
:param ftol: accuracy required to stop at optimum
:param disp: verbosity
:param... | [
"**",
"Classic",
"optimization",
"methods",
"**"
] | JohannesBuchner/jbopt | python | https://github.com/JohannesBuchner/jbopt/blob/11b721ea001625ad7820f71ff684723c71216646/jbopt/classic.py#L7-L125 | [
"def",
"classical",
"(",
"transform",
",",
"loglikelihood",
",",
"parameter_names",
",",
"prior",
",",
"start",
"=",
"0.5",
",",
"ftol",
"=",
"0.1",
",",
"disp",
"=",
"0",
",",
"nsteps",
"=",
"40000",
",",
"method",
"=",
"'neldermead'",
",",
"*",
"*",
... | 11b721ea001625ad7820f71ff684723c71216646 |
valid | onebyone | **Convex optimization based on Brent's method**
A strict assumption of one optimum between the parameter limits is used.
The bounds are narrowed until it is found, i.e. the likelihood function is flat
within the bounds.
* If optimum outside bracket, expands bracket until contained.
* Thus guaranteed to return lo... | jbopt/classic.py | def onebyone(transform, loglikelihood, parameter_names, prior, start = 0.5, ftol=0.1, disp=0, nsteps=40000,
parallel=False, find_uncertainties=False, **args):
"""
**Convex optimization based on Brent's method**
A strict assumption of one optimum between the parameter limits is used.
The bounds are narrowed until... | def onebyone(transform, loglikelihood, parameter_names, prior, start = 0.5, ftol=0.1, disp=0, nsteps=40000,
parallel=False, find_uncertainties=False, **args):
"""
**Convex optimization based on Brent's method**
A strict assumption of one optimum between the parameter limits is used.
The bounds are narrowed until... | [
"**",
"Convex",
"optimization",
"based",
"on",
"Brent",
"s",
"method",
"**",
"A",
"strict",
"assumption",
"of",
"one",
"optimum",
"between",
"the",
"parameter",
"limits",
"is",
"used",
".",
"The",
"bounds",
"are",
"narrowed",
"until",
"it",
"is",
"found",
... | JohannesBuchner/jbopt | python | https://github.com/JohannesBuchner/jbopt/blob/11b721ea001625ad7820f71ff684723c71216646/jbopt/classic.py#L128-L196 | [
"def",
"onebyone",
"(",
"transform",
",",
"loglikelihood",
",",
"parameter_names",
",",
"prior",
",",
"start",
"=",
"0.5",
",",
"ftol",
"=",
"0.1",
",",
"disp",
"=",
"0",
",",
"nsteps",
"=",
"40000",
",",
"parallel",
"=",
"False",
",",
"find_uncertaintie... | 11b721ea001625ad7820f71ff684723c71216646 |
valid | parse_hub_key | Parse a hub key into a dictionary of component parts
:param key: str, a hub key
:returns: dict, hub key split into parts
:raises: ValueError | bass/hubkey.py | def parse_hub_key(key):
"""Parse a hub key into a dictionary of component parts
:param key: str, a hub key
:returns: dict, hub key split into parts
:raises: ValueError
"""
if key is None:
raise ValueError('Not a valid key')
match = re.match(PATTERN, key)
if not match:
m... | def parse_hub_key(key):
"""Parse a hub key into a dictionary of component parts
:param key: str, a hub key
:returns: dict, hub key split into parts
:raises: ValueError
"""
if key is None:
raise ValueError('Not a valid key')
match = re.match(PATTERN, key)
if not match:
m... | [
"Parse",
"a",
"hub",
"key",
"into",
"a",
"dictionary",
"of",
"component",
"parts"
] | openpermissions/bass | python | https://github.com/openpermissions/bass/blob/fb606d3804e1f86b90253b25363bdfa8758ccf39/bass/hubkey.py#L81-L99 | [
"def",
"parse_hub_key",
"(",
"key",
")",
":",
"if",
"key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Not a valid key'",
")",
"match",
"=",
"re",
".",
"match",
"(",
"PATTERN",
",",
"key",
")",
"if",
"not",
"match",
":",
"match",
"=",
"re",
".",... | fb606d3804e1f86b90253b25363bdfa8758ccf39 |
valid | match_part | Raise an exception if string doesn't match a part's regex
:param string: str
:param part: a key in the PARTS dict
:raises: ValueError, TypeError | bass/hubkey.py | def match_part(string, part):
"""Raise an exception if string doesn't match a part's regex
:param string: str
:param part: a key in the PARTS dict
:raises: ValueError, TypeError
"""
if not string or not re.match('^(' + PARTS[part] + ')$', string):
raise ValueError('{} should match {}'.f... | def match_part(string, part):
"""Raise an exception if string doesn't match a part's regex
:param string: str
:param part: a key in the PARTS dict
:raises: ValueError, TypeError
"""
if not string or not re.match('^(' + PARTS[part] + ')$', string):
raise ValueError('{} should match {}'.f... | [
"Raise",
"an",
"exception",
"if",
"string",
"doesn",
"t",
"match",
"a",
"part",
"s",
"regex"
] | openpermissions/bass | python | https://github.com/openpermissions/bass/blob/fb606d3804e1f86b90253b25363bdfa8758ccf39/bass/hubkey.py#L114-L122 | [
"def",
"match_part",
"(",
"string",
",",
"part",
")",
":",
"if",
"not",
"string",
"or",
"not",
"re",
".",
"match",
"(",
"'^('",
"+",
"PARTS",
"[",
"part",
"]",
"+",
"')$'",
",",
"string",
")",
":",
"raise",
"ValueError",
"(",
"'{} should match {}'",
... | fb606d3804e1f86b90253b25363bdfa8758ccf39 |
valid | generate_hub_key | Create and return an array of hub keys
:param resolver_id: the service that can resolve this key
:param hub_id: the unique id of the hub
:param repository_id: the type of id that the provider recognises
:param entity_type: the type of the entity to which the key refers.
:param entity_id: ID of entit... | bass/hubkey.py | def generate_hub_key(resolver_id, hub_id, repository_id, entity_type, entity_id=None):
"""Create and return an array of hub keys
:param resolver_id: the service that can resolve this key
:param hub_id: the unique id of the hub
:param repository_id: the type of id that the provider recognises
:param ... | def generate_hub_key(resolver_id, hub_id, repository_id, entity_type, entity_id=None):
"""Create and return an array of hub keys
:param resolver_id: the service that can resolve this key
:param hub_id: the unique id of the hub
:param repository_id: the type of id that the provider recognises
:param ... | [
"Create",
"and",
"return",
"an",
"array",
"of",
"hub",
"keys",
":",
"param",
"resolver_id",
":",
"the",
"service",
"that",
"can",
"resolve",
"this",
"key",
":",
"param",
"hub_id",
":",
"the",
"unique",
"id",
"of",
"the",
"hub",
":",
"param",
"repository_... | openpermissions/bass | python | https://github.com/openpermissions/bass/blob/fb606d3804e1f86b90253b25363bdfa8758ccf39/bass/hubkey.py#L145-L181 | [
"def",
"generate_hub_key",
"(",
"resolver_id",
",",
"hub_id",
",",
"repository_id",
",",
"entity_type",
",",
"entity_id",
"=",
"None",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"resolver_id",
")",
"if",
"not",
"parsed",
".",
"scheme",
":",
"parsed",
"=",
"... | fb606d3804e1f86b90253b25363bdfa8758ccf39 |
valid | compact | Compact a CouchDB database with optional synchronicity.
The ``compact`` function will compact a CouchDB database stored on an
running CouchDB server. By default, this process occurs *asynchronously*,
meaning that the compaction will occur in the background. Often, you'll want
to know when the proce... | relax/couchdb/compact.py | def compact(db_spec, poll_interval=0):
"""
Compact a CouchDB database with optional synchronicity.
The ``compact`` function will compact a CouchDB database stored on an
running CouchDB server. By default, this process occurs *asynchronously*,
meaning that the compaction will occur in the b... | def compact(db_spec, poll_interval=0):
"""
Compact a CouchDB database with optional synchronicity.
The ``compact`` function will compact a CouchDB database stored on an
running CouchDB server. By default, this process occurs *asynchronously*,
meaning that the compaction will occur in the b... | [
"Compact",
"a",
"CouchDB",
"database",
"with",
"optional",
"synchronicity",
".",
"The",
"compact",
"function",
"will",
"compact",
"a",
"CouchDB",
"database",
"stored",
"on",
"an",
"running",
"CouchDB",
"server",
".",
"By",
"default",
"this",
"process",
"occurs",... | zvoase/django-relax | python | https://github.com/zvoase/django-relax/blob/10bb37bf3a512b290816856a6877c17fa37e930f/relax/couchdb/compact.py#L18-L91 | [
"def",
"compact",
"(",
"db_spec",
",",
"poll_interval",
"=",
"0",
")",
":",
"server",
"=",
"get_server_from_specifier",
"(",
"db_spec",
")",
"db",
"=",
"get_db_from_specifier",
"(",
"db_spec",
")",
"# Get logger",
"logger",
"=",
"logging",
".",
"getLogger",
"(... | 10bb37bf3a512b290816856a6877c17fa37e930f |
valid | Clifier.apply_defaults | apply default settings to commands
not static, shadow "self" in eval | clifier/clifier.py | def apply_defaults(self, commands):
""" apply default settings to commands
not static, shadow "self" in eval
"""
for command in commands:
if 'action' in command and "()" in command['action']:
command['action'] = eval("self.{}".format(command['action']))
... | def apply_defaults(self, commands):
""" apply default settings to commands
not static, shadow "self" in eval
"""
for command in commands:
if 'action' in command and "()" in command['action']:
command['action'] = eval("self.{}".format(command['action']))
... | [
"apply",
"default",
"settings",
"to",
"commands",
"not",
"static",
"shadow",
"self",
"in",
"eval"
] | xnuinside/clifier | python | https://github.com/xnuinside/clifier/blob/3d704a30dc985bea3b876216accc53c19dc8b0df/clifier/clifier.py#L48-L57 | [
"def",
"apply_defaults",
"(",
"self",
",",
"commands",
")",
":",
"for",
"command",
"in",
"commands",
":",
"if",
"'action'",
"in",
"command",
"and",
"\"()\"",
"in",
"command",
"[",
"'action'",
"]",
":",
"command",
"[",
"'action'",
"]",
"=",
"eval",
"(",
... | 3d704a30dc985bea3b876216accc53c19dc8b0df |
valid | Clifier.create_commands | add commands to parser | clifier/clifier.py | def create_commands(self, commands, parser):
""" add commands to parser """
self.apply_defaults(commands)
def create_single_command(command):
keys = command['keys']
del command['keys']
kwargs = {}
for item in command:
kwargs[item] =... | def create_commands(self, commands, parser):
""" add commands to parser """
self.apply_defaults(commands)
def create_single_command(command):
keys = command['keys']
del command['keys']
kwargs = {}
for item in command:
kwargs[item] =... | [
"add",
"commands",
"to",
"parser"
] | xnuinside/clifier | python | https://github.com/xnuinside/clifier/blob/3d704a30dc985bea3b876216accc53c19dc8b0df/clifier/clifier.py#L59-L74 | [
"def",
"create_commands",
"(",
"self",
",",
"commands",
",",
"parser",
")",
":",
"self",
".",
"apply_defaults",
"(",
"commands",
")",
"def",
"create_single_command",
"(",
"command",
")",
":",
"keys",
"=",
"command",
"[",
"'keys'",
"]",
"del",
"command",
"[... | 3d704a30dc985bea3b876216accc53c19dc8b0df |
valid | Clifier.create_subparsers | get config for subparser and create commands | clifier/clifier.py | def create_subparsers(self, parser):
""" get config for subparser and create commands"""
subparsers = parser.add_subparsers()
for name in self.config['subparsers']:
subparser = subparsers.add_parser(name)
self.create_commands(self.config['subparsers'][name], subparser) | def create_subparsers(self, parser):
""" get config for subparser and create commands"""
subparsers = parser.add_subparsers()
for name in self.config['subparsers']:
subparser = subparsers.add_parser(name)
self.create_commands(self.config['subparsers'][name], subparser) | [
"get",
"config",
"for",
"subparser",
"and",
"create",
"commands"
] | xnuinside/clifier | python | https://github.com/xnuinside/clifier/blob/3d704a30dc985bea3b876216accc53c19dc8b0df/clifier/clifier.py#L77-L82 | [
"def",
"create_subparsers",
"(",
"self",
",",
"parser",
")",
":",
"subparsers",
"=",
"parser",
".",
"add_subparsers",
"(",
")",
"for",
"name",
"in",
"self",
".",
"config",
"[",
"'subparsers'",
"]",
":",
"subparser",
"=",
"subparsers",
".",
"add_parser",
"(... | 3d704a30dc985bea3b876216accc53c19dc8b0df |
valid | Clifier.show_version | custom command line action to show version | clifier/clifier.py | def show_version(self):
""" custom command line action to show version """
class ShowVersionAction(argparse.Action):
def __init__(inner_self, nargs=0, **kw):
super(ShowVersionAction, inner_self).__init__(nargs=nargs, **kw)
def __call__(inner_self, parser, args, ... | def show_version(self):
""" custom command line action to show version """
class ShowVersionAction(argparse.Action):
def __init__(inner_self, nargs=0, **kw):
super(ShowVersionAction, inner_self).__init__(nargs=nargs, **kw)
def __call__(inner_self, parser, args, ... | [
"custom",
"command",
"line",
"action",
"to",
"show",
"version"
] | xnuinside/clifier | python | https://github.com/xnuinside/clifier/blob/3d704a30dc985bea3b876216accc53c19dc8b0df/clifier/clifier.py#L97-L108 | [
"def",
"show_version",
"(",
"self",
")",
":",
"class",
"ShowVersionAction",
"(",
"argparse",
".",
"Action",
")",
":",
"def",
"__init__",
"(",
"inner_self",
",",
"nargs",
"=",
"0",
",",
"*",
"*",
"kw",
")",
":",
"super",
"(",
"ShowVersionAction",
",",
"... | 3d704a30dc985bea3b876216accc53c19dc8b0df |
valid | Clifier.check_path_action | custom command line action to check file exist | clifier/clifier.py | def check_path_action(self):
""" custom command line action to check file exist """
class CheckPathAction(argparse.Action):
def __call__(self, parser, args, value, option_string=None):
if type(value) is list:
value = value[0]
user_value = v... | def check_path_action(self):
""" custom command line action to check file exist """
class CheckPathAction(argparse.Action):
def __call__(self, parser, args, value, option_string=None):
if type(value) is list:
value = value[0]
user_value = v... | [
"custom",
"command",
"line",
"action",
"to",
"check",
"file",
"exist"
] | xnuinside/clifier | python | https://github.com/xnuinside/clifier/blob/3d704a30dc985bea3b876216accc53c19dc8b0df/clifier/clifier.py#L110-L141 | [
"def",
"check_path_action",
"(",
"self",
")",
":",
"class",
"CheckPathAction",
"(",
"argparse",
".",
"Action",
")",
":",
"def",
"__call__",
"(",
"self",
",",
"parser",
",",
"args",
",",
"value",
",",
"option_string",
"=",
"None",
")",
":",
"if",
"type",
... | 3d704a30dc985bea3b876216accc53c19dc8b0df |
valid | new_user | Return the consumer and oauth tokens with three-legged OAuth process and
save in a yaml file in the user's home directory. | interactive_console.py | def new_user(yaml_path):
'''
Return the consumer and oauth tokens with three-legged OAuth process and
save in a yaml file in the user's home directory.
'''
print 'Retrieve API Key from https://www.shirts.io/accounts/api_console/'
api_key = raw_input('Shirts.io API Key: ')
tokens = {
... | def new_user(yaml_path):
'''
Return the consumer and oauth tokens with three-legged OAuth process and
save in a yaml file in the user's home directory.
'''
print 'Retrieve API Key from https://www.shirts.io/accounts/api_console/'
api_key = raw_input('Shirts.io API Key: ')
tokens = {
... | [
"Return",
"the",
"consumer",
"and",
"oauth",
"tokens",
"with",
"three",
"-",
"legged",
"OAuth",
"process",
"and",
"save",
"in",
"a",
"yaml",
"file",
"in",
"the",
"user",
"s",
"home",
"directory",
"."
] | tklovett/PyShirtsIO | python | https://github.com/tklovett/PyShirtsIO/blob/ff2f2d3b5e4ab2813abbce8545b27319c6af0def/interactive_console.py#L8-L25 | [
"def",
"new_user",
"(",
"yaml_path",
")",
":",
"print",
"'Retrieve API Key from https://www.shirts.io/accounts/api_console/'",
"api_key",
"=",
"raw_input",
"(",
"'Shirts.io API Key: '",
")",
"tokens",
"=",
"{",
"'api_key'",
":",
"api_key",
",",
"}",
"yaml_file",
"=",
... | ff2f2d3b5e4ab2813abbce8545b27319c6af0def |
valid | _AddPropertiesForExtensions | Adds properties for all fields in this protocol message type. | typy/google/protobuf/internal/python_message.py | def _AddPropertiesForExtensions(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
extension_dict = descriptor.extensions_by_name
for extension_name, extension_field in extension_dict.items():
constant_name = extension_name.upper() + "_FIELD_NUMBER"
setattr(cls, constant... | def _AddPropertiesForExtensions(descriptor, cls):
"""Adds properties for all fields in this protocol message type."""
extension_dict = descriptor.extensions_by_name
for extension_name, extension_field in extension_dict.items():
constant_name = extension_name.upper() + "_FIELD_NUMBER"
setattr(cls, constant... | [
"Adds",
"properties",
"for",
"all",
"fields",
"in",
"this",
"protocol",
"message",
"type",
"."
] | ibelie/typy | python | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/internal/python_message.py#L743-L748 | [
"def",
"_AddPropertiesForExtensions",
"(",
"descriptor",
",",
"cls",
")",
":",
"extension_dict",
"=",
"descriptor",
".",
"extensions_by_name",
"for",
"extension_name",
",",
"extension_field",
"in",
"extension_dict",
".",
"items",
"(",
")",
":",
"constant_name",
"=",... | 3616845fb91459aacd8df6bf82c5d91f4542bee7 |
valid | _InternalUnpackAny | Unpacks Any message and returns the unpacked message.
This internal method is differnt from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
Args:
msg: An Any message to be... | typy/google/protobuf/internal/python_message.py | def _InternalUnpackAny(msg):
"""Unpacks Any message and returns the unpacked message.
This internal method is differnt from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
A... | def _InternalUnpackAny(msg):
"""Unpacks Any message and returns the unpacked message.
This internal method is differnt from public Any Unpack method which takes
the target message as argument. _InternalUnpackAny method does not have
target message type and need to find the message type in descriptor pool.
A... | [
"Unpacks",
"Any",
"message",
"and",
"returns",
"the",
"unpacked",
"message",
"."
] | ibelie/typy | python | https://github.com/ibelie/typy/blob/3616845fb91459aacd8df6bf82c5d91f4542bee7/typy/google/protobuf/internal/python_message.py#L916-L947 | [
"def",
"_InternalUnpackAny",
"(",
"msg",
")",
":",
"type_url",
"=",
"msg",
".",
"type_url",
"db",
"=",
"symbol_database",
".",
"Default",
"(",
")",
"if",
"not",
"type_url",
":",
"return",
"None",
"# TODO(haberman): For now we just strip the hostname. Better logic wil... | 3616845fb91459aacd8df6bf82c5d91f4542bee7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.