repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
resonai/ybt
yabt/config.py
Config.get_build_file_path
def get_build_file_path(self, build_module) -> str: """Return a full path to the build file of `build_module`. The returned path will always be OS-native, regardless of the format of project_root (native) and build_module (with '/'). """ project_root = Path(self.project_root) ...
python
def get_build_file_path(self, build_module) -> str: """Return a full path to the build file of `build_module`. The returned path will always be OS-native, regardless of the format of project_root (native) and build_module (with '/'). """ project_root = Path(self.project_root) ...
[ "def", "get_build_file_path", "(", "self", ",", "build_module", ")", "->", "str", ":", "project_root", "=", "Path", "(", "self", ".", "project_root", ")", "build_module", "=", "norm_proj_path", "(", "build_module", ",", "''", ")", "return", "str", "(", "proj...
Return a full path to the build file of `build_module`. The returned path will always be OS-native, regardless of the format of project_root (native) and build_module (with '/').
[ "Return", "a", "full", "path", "to", "the", "build", "file", "of", "build_module", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/config.py#L107-L117
resonai/ybt
yabt/builders/custom_installer.py
guess_uri_type
def guess_uri_type(uri: str, hint: str=None): """Return a guess for the URI type based on the URI string `uri`. If `hint` is given, it is assumed to be the correct type. Otherwise, the URI is inspected using urlparse, and we try to guess whether it's a remote Git repository, a remote downloadable archi...
python
def guess_uri_type(uri: str, hint: str=None): """Return a guess for the URI type based on the URI string `uri`. If `hint` is given, it is assumed to be the correct type. Otherwise, the URI is inspected using urlparse, and we try to guess whether it's a remote Git repository, a remote downloadable archi...
[ "def", "guess_uri_type", "(", "uri", ":", "str", ",", "hint", ":", "str", "=", "None", ")", ":", "# TODO(itamar): do this better", "if", "hint", ":", "return", "hint", "norm_uri", "=", "uri", ".", "lower", "(", ")", "parsed_uri", "=", "urlparse", "(", "n...
Return a guess for the URI type based on the URI string `uri`. If `hint` is given, it is assumed to be the correct type. Otherwise, the URI is inspected using urlparse, and we try to guess whether it's a remote Git repository, a remote downloadable archive, or a local-only data.
[ "Return", "a", "guess", "for", "the", "URI", "type", "based", "on", "the", "URI", "string", "uri", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L69-L89
resonai/ybt
yabt/builders/custom_installer.py
git_handler
def git_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote Git repository URI. Clone the repository under the private builder workspace (unless already cloned), and add it to the package tar (filtering out git internals). TODO(itamar): Support branches / tags / specific c...
python
def git_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote Git repository URI. Clone the repository under the private builder workspace (unless already cloned), and add it to the package tar (filtering out git internals). TODO(itamar): Support branches / tags / specific c...
[ "def", "git_handler", "(", "unused_build_context", ",", "target", ",", "fetch", ",", "package_dir", ",", "tar", ")", ":", "target_name", "=", "split_name", "(", "target", ".", "name", ")", "# clone the repository under a private builder workspace", "repo_dir", "=", ...
Handle remote Git repository URI. Clone the repository under the private builder workspace (unless already cloned), and add it to the package tar (filtering out git internals). TODO(itamar): Support branches / tags / specific commit hashes TODO(itamar): Support updating a cloned repository TODO(it...
[ "Handle", "remote", "Git", "repository", "URI", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L99-L118
resonai/ybt
yabt/builders/custom_installer.py
fetch_url
def fetch_url(url, dest, parent_to_remove_before_fetch): """Helper function to fetch a file from a URL.""" logger.debug('Downloading file {} from {}', dest, url) try: shutil.rmtree(parent_to_remove_before_fetch) except FileNotFoundError: pass os.makedirs(parent_to_remove_before_fetch...
python
def fetch_url(url, dest, parent_to_remove_before_fetch): """Helper function to fetch a file from a URL.""" logger.debug('Downloading file {} from {}', dest, url) try: shutil.rmtree(parent_to_remove_before_fetch) except FileNotFoundError: pass os.makedirs(parent_to_remove_before_fetch...
[ "def", "fetch_url", "(", "url", ",", "dest", ",", "parent_to_remove_before_fetch", ")", ":", "logger", ".", "debug", "(", "'Downloading file {} from {}'", ",", "dest", ",", "url", ")", "try", ":", "shutil", ".", "rmtree", "(", "parent_to_remove_before_fetch", ")...
Helper function to fetch a file from a URL.
[ "Helper", "function", "to", "fetch", "a", "file", "from", "a", "URL", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L121-L134
resonai/ybt
yabt/builders/custom_installer.py
archive_handler
def archive_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote downloadable archive URI. Download the archive and cache it under the private builer workspace (unless already downloaded), extract it, and add the content to the package tar. TODO(itamar): Support re-down...
python
def archive_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote downloadable archive URI. Download the archive and cache it under the private builer workspace (unless already downloaded), extract it, and add the content to the package tar. TODO(itamar): Support re-down...
[ "def", "archive_handler", "(", "unused_build_context", ",", "target", ",", "fetch", ",", "package_dir", ",", "tar", ")", ":", "package_dest", "=", "join", "(", "package_dir", ",", "basename", "(", "urlparse", "(", "fetch", ".", "uri", ")", ".", "path", ")"...
Handle remote downloadable archive URI. Download the archive and cache it under the private builer workspace (unless already downloaded), extract it, and add the content to the package tar. TODO(itamar): Support re-downloading if remote changed compared to local. TODO(itamar): Support more archive...
[ "Handle", "remote", "downloadable", "archive", "URI", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L137-L164
resonai/ybt
yabt/builders/custom_installer.py
fetch_file_handler
def fetch_file_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote downloadable file URI. Download the file and cache it under the private builer workspace (unless already downloaded), and add it to the package tar. TODO(itamar): Support re-downloading if remote changed co...
python
def fetch_file_handler(unused_build_context, target, fetch, package_dir, tar): """Handle remote downloadable file URI. Download the file and cache it under the private builer workspace (unless already downloaded), and add it to the package tar. TODO(itamar): Support re-downloading if remote changed co...
[ "def", "fetch_file_handler", "(", "unused_build_context", ",", "target", ",", "fetch", ",", "package_dir", ",", "tar", ")", ":", "dl_dir", "=", "join", "(", "package_dir", ",", "fetch", ".", "name", ")", "if", "fetch", ".", "name", "else", "package_dir", "...
Handle remote downloadable file URI. Download the file and cache it under the private builer workspace (unless already downloaded), and add it to the package tar. TODO(itamar): Support re-downloading if remote changed compared to local.
[ "Handle", "remote", "downloadable", "file", "URI", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L167-L179
resonai/ybt
yabt/builders/custom_installer.py
get_installer_desc
def get_installer_desc(build_context, target) -> tuple: """Return a target_name, script_name, package_tarball tuple for `target`""" workspace_dir = build_context.get_workspace('CustomInstaller', target.name) target_name = split_name(target.name) script_name = basename(target.props.script) package_ta...
python
def get_installer_desc(build_context, target) -> tuple: """Return a target_name, script_name, package_tarball tuple for `target`""" workspace_dir = build_context.get_workspace('CustomInstaller', target.name) target_name = split_name(target.name) script_name = basename(target.props.script) package_ta...
[ "def", "get_installer_desc", "(", "build_context", ",", "target", ")", "->", "tuple", ":", "workspace_dir", "=", "build_context", ".", "get_workspace", "(", "'CustomInstaller'", ",", "target", ".", "name", ")", "target_name", "=", "split_name", "(", "target", "....
Return a target_name, script_name, package_tarball tuple for `target`
[ "Return", "a", "target_name", "script_name", "package_tarball", "tuple", "for", "target" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/custom_installer.py#L186-L192
resonai/ybt
yabt/caching.py
get_prebuilt_targets
def get_prebuilt_targets(build_context): """Return set of target names that are contained within cached base images These targets may be considered "pre-built", and skipped during build. """ logger.info('Scanning for cached base images') # deps that are part of cached based images contained_dep...
python
def get_prebuilt_targets(build_context): """Return set of target names that are contained within cached base images These targets may be considered "pre-built", and skipped during build. """ logger.info('Scanning for cached base images') # deps that are part of cached based images contained_dep...
[ "def", "get_prebuilt_targets", "(", "build_context", ")", ":", "logger", ".", "info", "(", "'Scanning for cached base images'", ")", "# deps that are part of cached based images", "contained_deps", "=", "set", "(", ")", "# deps that are needed by images that are going to be built...
Return set of target names that are contained within cached base images These targets may be considered "pre-built", and skipped during build.
[ "Return", "set", "of", "target", "names", "that", "are", "contained", "within", "cached", "base", "images" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L70-L104
resonai/ybt
yabt/caching.py
write_summary
def write_summary(summary: dict, cache_dir: str): """Write the `summary` JSON to `cache_dir`. Updated the accessed timestamp to now before writing. """ # update the summary last-accessed timestamp summary['accessed'] = time() with open(join(cache_dir, 'summary.json'), 'w') as summary_file: ...
python
def write_summary(summary: dict, cache_dir: str): """Write the `summary` JSON to `cache_dir`. Updated the accessed timestamp to now before writing. """ # update the summary last-accessed timestamp summary['accessed'] = time() with open(join(cache_dir, 'summary.json'), 'w') as summary_file: ...
[ "def", "write_summary", "(", "summary", ":", "dict", ",", "cache_dir", ":", "str", ")", ":", "# update the summary last-accessed timestamp", "summary", "[", "'accessed'", "]", "=", "time", "(", ")", "with", "open", "(", "join", "(", "cache_dir", ",", "'summary...
Write the `summary` JSON to `cache_dir`. Updated the accessed timestamp to now before writing.
[ "Write", "the", "summary", "JSON", "to", "cache_dir", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L107-L115
resonai/ybt
yabt/caching.py
load_target_from_cache
def load_target_from_cache(target: Target, build_context) -> (bool, bool): """Load `target` from build cache, restoring cached artifacts & summary. Return (build_cached, test_cached) tuple. `build_cached` is True if target restored successfully. `test_cached` is True if build is cached and test_time...
python
def load_target_from_cache(target: Target, build_context) -> (bool, bool): """Load `target` from build cache, restoring cached artifacts & summary. Return (build_cached, test_cached) tuple. `build_cached` is True if target restored successfully. `test_cached` is True if build is cached and test_time...
[ "def", "load_target_from_cache", "(", "target", ":", "Target", ",", "build_context", ")", "->", "(", "bool", ",", "bool", ")", ":", "cache_dir", "=", "build_context", ".", "conf", ".", "get_cache_dir", "(", "target", ",", "build_context", ")", "if", "not", ...
Load `target` from build cache, restoring cached artifacts & summary. Return (build_cached, test_cached) tuple. `build_cached` is True if target restored successfully. `test_cached` is True if build is cached and test_time metadata is valid.
[ "Load", "target", "from", "build", "cache", "restoring", "cached", "artifacts", "&", "summary", ".", "Return", "(", "build_cached", "test_cached", ")", "tuple", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L118-L174
resonai/ybt
yabt/caching.py
copy_artifact
def copy_artifact(src_path: str, artifact_hash: str, conf: Config): """Copy the artifact at `src_path` with hash `artifact_hash` to artifacts cache dir. If an artifact already exists at that location, it is assumed to be identical (since it's based on hash), and the copy is skipped. TODO: pruni...
python
def copy_artifact(src_path: str, artifact_hash: str, conf: Config): """Copy the artifact at `src_path` with hash `artifact_hash` to artifacts cache dir. If an artifact already exists at that location, it is assumed to be identical (since it's based on hash), and the copy is skipped. TODO: pruni...
[ "def", "copy_artifact", "(", "src_path", ":", "str", ",", "artifact_hash", ":", "str", ",", "conf", ":", "Config", ")", ":", "cache_dir", "=", "conf", ".", "get_artifacts_cache_dir", "(", ")", "if", "not", "isdir", "(", "cache_dir", ")", ":", "makedirs", ...
Copy the artifact at `src_path` with hash `artifact_hash` to artifacts cache dir. If an artifact already exists at that location, it is assumed to be identical (since it's based on hash), and the copy is skipped. TODO: pruning policy to limit cache size.
[ "Copy", "the", "artifact", "at", "src_path", "with", "hash", "artifact_hash", "to", "artifacts", "cache", "dir", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L177-L197
resonai/ybt
yabt/caching.py
restore_artifact
def restore_artifact(src_path: str, artifact_hash: str, conf: Config): """Restore the artifact whose hash is `artifact_hash` to `src_path`. Return True if cached artifact is found, valid, and restored successfully. Otherwise return False. """ cache_dir = conf.get_artifacts_cache_dir() if not is...
python
def restore_artifact(src_path: str, artifact_hash: str, conf: Config): """Restore the artifact whose hash is `artifact_hash` to `src_path`. Return True if cached artifact is found, valid, and restored successfully. Otherwise return False. """ cache_dir = conf.get_artifacts_cache_dir() if not is...
[ "def", "restore_artifact", "(", "src_path", ":", "str", ",", "artifact_hash", ":", "str", ",", "conf", ":", "Config", ")", ":", "cache_dir", "=", "conf", ".", "get_artifacts_cache_dir", "(", ")", "if", "not", "isdir", "(", "cache_dir", ")", ":", "return", ...
Restore the artifact whose hash is `artifact_hash` to `src_path`. Return True if cached artifact is found, valid, and restored successfully. Otherwise return False.
[ "Restore", "the", "artifact", "whose", "hash", "is", "artifact_hash", "to", "src_path", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L200-L236
resonai/ybt
yabt/caching.py
save_target_in_cache
def save_target_in_cache(target: Target, build_context): """Save `target` to build cache for future reuse. The target hash is used to determine its cache location, where the target metadata and artifacts metadata are seriazlied to JSON. In addition, relevant artifacts produced by the target are copied ...
python
def save_target_in_cache(target: Target, build_context): """Save `target` to build cache for future reuse. The target hash is used to determine its cache location, where the target metadata and artifacts metadata are seriazlied to JSON. In addition, relevant artifacts produced by the target are copied ...
[ "def", "save_target_in_cache", "(", "target", ":", "Target", ",", "build_context", ")", ":", "cache_dir", "=", "build_context", ".", "conf", ".", "get_cache_dir", "(", "target", ",", "build_context", ")", "if", "isdir", "(", "cache_dir", ")", ":", "rmtree", ...
Save `target` to build cache for future reuse. The target hash is used to determine its cache location, where the target metadata and artifacts metadata are seriazlied to JSON. In addition, relevant artifacts produced by the target are copied under the artifacts cache dir by their content hash. TO...
[ "Save", "target", "to", "build", "cache", "for", "future", "reuse", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L239-L287
resonai/ybt
yabt/caching.py
CachedDescendants.get
def get(self, key): """Return set of descendants of node named `key` in `target_graph`. Returns from cached dict if exists, otherwise compute over the graph and cache results in the dict. """ if key not in self: self[key] = set(get_descendants(self._target_graph, key...
python
def get(self, key): """Return set of descendants of node named `key` in `target_graph`. Returns from cached dict if exists, otherwise compute over the graph and cache results in the dict. """ if key not in self: self[key] = set(get_descendants(self._target_graph, key...
[ "def", "get", "(", "self", ",", "key", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "set", "(", "get_descendants", "(", "self", ".", "_target_graph", ",", "key", ")", ")", "return", "self", "[", "key", "]" ]
Return set of descendants of node named `key` in `target_graph`. Returns from cached dict if exists, otherwise compute over the graph and cache results in the dict.
[ "Return", "set", "of", "descendants", "of", "node", "named", "key", "in", "target_graph", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/caching.py#L59-L67
resonai/ybt
yabt/utils.py
fatal
def fatal(msg, *args, **kwargs): """Print a red `msg` to STDERR and exit. To be used in a context of an exception, also prints out the exception. The message is formatted with `args` & `kwargs`. """ exc_str = format_exc() if exc_str.strip() != 'NoneType: None': logger.info('{}', format_e...
python
def fatal(msg, *args, **kwargs): """Print a red `msg` to STDERR and exit. To be used in a context of an exception, also prints out the exception. The message is formatted with `args` & `kwargs`. """ exc_str = format_exc() if exc_str.strip() != 'NoneType: None': logger.info('{}', format_e...
[ "def", "fatal", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "exc_str", "=", "format_exc", "(", ")", "if", "exc_str", ".", "strip", "(", ")", "!=", "'NoneType: None'", ":", "logger", ".", "info", "(", "'{}'", ",", "format_exc", ...
Print a red `msg` to STDERR and exit. To be used in a context of an exception, also prints out the exception. The message is formatted with `args` & `kwargs`.
[ "Print", "a", "red", "msg", "to", "STDERR", "and", "exit", ".", "To", "be", "used", "in", "a", "context", "of", "an", "exception", "also", "prints", "out", "the", "exception", ".", "The", "message", "is", "formatted", "with", "args", "&", "kwargs", "."...
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L43-L51
resonai/ybt
yabt/utils.py
fatal_noexc
def fatal_noexc(msg, *args, **kwargs): """Print a red `msg` to STDERR and exit. The message is formatted with `args` & `kwargs`. """ print(Fore.RED + 'Fatal: ' + msg.format(*args, **kwargs) + Style.RESET_ALL, file=sys.stderr) sys.exit(1)
python
def fatal_noexc(msg, *args, **kwargs): """Print a red `msg` to STDERR and exit. The message is formatted with `args` & `kwargs`. """ print(Fore.RED + 'Fatal: ' + msg.format(*args, **kwargs) + Style.RESET_ALL, file=sys.stderr) sys.exit(1)
[ "def", "fatal_noexc", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "Fore", ".", "RED", "+", "'Fatal: '", "+", "msg", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", "+", "Style", ".", "RESET_ALL", ...
Print a red `msg` to STDERR and exit. The message is formatted with `args` & `kwargs`.
[ "Print", "a", "red", "msg", "to", "STDERR", "and", "exit", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L54-L61
resonai/ybt
yabt/utils.py
rmnode
def rmnode(path: str): """Forcibly remove file or directory tree at `path`. Fail silently if base dir doesn't exist.""" if isdir(path): rmtree(path) elif isfile(path): os.remove(path)
python
def rmnode(path: str): """Forcibly remove file or directory tree at `path`. Fail silently if base dir doesn't exist.""" if isdir(path): rmtree(path) elif isfile(path): os.remove(path)
[ "def", "rmnode", "(", "path", ":", "str", ")", ":", "if", "isdir", "(", "path", ")", ":", "rmtree", "(", "path", ")", "elif", "isfile", "(", "path", ")", ":", "os", ".", "remove", "(", "path", ")" ]
Forcibly remove file or directory tree at `path`. Fail silently if base dir doesn't exist.
[ "Forcibly", "remove", "file", "or", "directory", "tree", "at", "path", ".", "Fail", "silently", "if", "base", "dir", "doesn", "t", "exist", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L64-L70
resonai/ybt
yabt/utils.py
link_node
def link_node(abs_src: str, abs_dest: str, force: bool=False): """Sync source node (file / dir) to destination path using hard links.""" dest_parent_dir = split(abs_dest)[0] if not isdir(dest_parent_dir): # exist_ok=True in case of concurrent creation of the same # parent dir os.make...
python
def link_node(abs_src: str, abs_dest: str, force: bool=False): """Sync source node (file / dir) to destination path using hard links.""" dest_parent_dir = split(abs_dest)[0] if not isdir(dest_parent_dir): # exist_ok=True in case of concurrent creation of the same # parent dir os.make...
[ "def", "link_node", "(", "abs_src", ":", "str", ",", "abs_dest", ":", "str", ",", "force", ":", "bool", "=", "False", ")", ":", "dest_parent_dir", "=", "split", "(", "abs_dest", ")", "[", "0", "]", "if", "not", "isdir", "(", "dest_parent_dir", ")", "...
Sync source node (file / dir) to destination path using hard links.
[ "Sync", "source", "node", "(", "file", "/", "dir", ")", "to", "destination", "path", "using", "hard", "links", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L94-L111
resonai/ybt
yabt/utils.py
link_files
def link_files(files: set, workspace_src_dir: str, common_parent: str, conf): """Sync the list of files and directories in `files` to destination directory specified by `workspace_src_dir`. "Sync" in the sense that every file given in `files` will be hard-linked under `workspace_src_d...
python
def link_files(files: set, workspace_src_dir: str, common_parent: str, conf): """Sync the list of files and directories in `files` to destination directory specified by `workspace_src_dir`. "Sync" in the sense that every file given in `files` will be hard-linked under `workspace_src_d...
[ "def", "link_files", "(", "files", ":", "set", ",", "workspace_src_dir", ":", "str", ",", "common_parent", ":", "str", ",", "conf", ")", ":", "norm_dir", "=", "normpath", "(", "workspace_src_dir", ")", "base_dir", "=", "''", "if", "common_parent", ":", "co...
Sync the list of files and directories in `files` to destination directory specified by `workspace_src_dir`. "Sync" in the sense that every file given in `files` will be hard-linked under `workspace_src_dir` after this function returns, and no other files will exist under `workspace_src_dir`. F...
[ "Sync", "the", "list", "of", "files", "and", "directories", "in", "files", "to", "destination", "directory", "specified", "by", "workspace_src_dir", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L114-L157
resonai/ybt
yabt/utils.py
norm_proj_path
def norm_proj_path(path, build_module): """Return a normalized path for the `path` observed in `build_module`. The normalized path is "normalized" (in the `os.path.normpath` sense), relative from the project root directory, and OS-native. Supports making references from project root directory by prefi...
python
def norm_proj_path(path, build_module): """Return a normalized path for the `path` observed in `build_module`. The normalized path is "normalized" (in the `os.path.normpath` sense), relative from the project root directory, and OS-native. Supports making references from project root directory by prefi...
[ "def", "norm_proj_path", "(", "path", ",", "build_module", ")", ":", "if", "path", "==", "'//'", ":", "return", "''", "if", "path", ".", "startswith", "(", "'//'", ")", ":", "norm", "=", "normpath", "(", "path", "[", "2", ":", "]", ")", "if", "norm...
Return a normalized path for the `path` observed in `build_module`. The normalized path is "normalized" (in the `os.path.normpath` sense), relative from the project root directory, and OS-native. Supports making references from project root directory by prefixing the path with "//". :raises Value...
[ "Return", "a", "normalized", "path", "for", "the", "path", "observed", "in", "build_module", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L160-L191
resonai/ybt
yabt/utils.py
search_for_parent_dir
def search_for_parent_dir(start_at: str=None, with_files: set=None, with_dirs: set=None) -> str: """Return absolute path of first parent directory of `start_at` that contains all files `with_files` and all dirs `with_dirs` (including `start_at`). If `start_at` not specif...
python
def search_for_parent_dir(start_at: str=None, with_files: set=None, with_dirs: set=None) -> str: """Return absolute path of first parent directory of `start_at` that contains all files `with_files` and all dirs `with_dirs` (including `start_at`). If `start_at` not specif...
[ "def", "search_for_parent_dir", "(", "start_at", ":", "str", "=", "None", ",", "with_files", ":", "set", "=", "None", ",", "with_dirs", ":", "set", "=", "None", ")", "->", "str", ":", "if", "not", "start_at", ":", "start_at", "=", "os", ".", "path", ...
Return absolute path of first parent directory of `start_at` that contains all files `with_files` and all dirs `with_dirs` (including `start_at`). If `start_at` not specified, start at current working directory. :param start_at: Initial path for searching for the project build file. Returns...
[ "Return", "absolute", "path", "of", "first", "parent", "directory", "of", "start_at", "that", "contains", "all", "files", "with_files", "and", "all", "dirs", "with_dirs", "(", "including", "start_at", ")", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L194-L225
resonai/ybt
yabt/utils.py
acc_hash
def acc_hash(filepath: str, hasher): """Accumulate content of file at `filepath` in `hasher`.""" with open(filepath, 'rb') as f: while True: chunk = f.read(_BUF_SIZE) if not chunk: break hasher.update(chunk)
python
def acc_hash(filepath: str, hasher): """Accumulate content of file at `filepath` in `hasher`.""" with open(filepath, 'rb') as f: while True: chunk = f.read(_BUF_SIZE) if not chunk: break hasher.update(chunk)
[ "def", "acc_hash", "(", "filepath", ":", "str", ",", "hasher", ")", ":", "with", "open", "(", "filepath", ",", "'rb'", ")", "as", "f", ":", "while", "True", ":", "chunk", "=", "f", ".", "read", "(", "_BUF_SIZE", ")", "if", "not", "chunk", ":", "b...
Accumulate content of file at `filepath` in `hasher`.
[ "Accumulate", "content", "of", "file", "at", "filepath", "in", "hasher", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L238-L245
resonai/ybt
yabt/utils.py
hash_file
def hash_file(filepath: str) -> str: """Return the hexdigest MD5 hash of content of file at `filepath`.""" md5 = hashlib.md5() acc_hash(filepath, md5) return md5.hexdigest()
python
def hash_file(filepath: str) -> str: """Return the hexdigest MD5 hash of content of file at `filepath`.""" md5 = hashlib.md5() acc_hash(filepath, md5) return md5.hexdigest()
[ "def", "hash_file", "(", "filepath", ":", "str", ")", "->", "str", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "acc_hash", "(", "filepath", ",", "md5", ")", "return", "md5", ".", "hexdigest", "(", ")" ]
Return the hexdigest MD5 hash of content of file at `filepath`.
[ "Return", "the", "hexdigest", "MD5", "hash", "of", "content", "of", "file", "at", "filepath", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L248-L252
resonai/ybt
yabt/utils.py
hash_tree
def hash_tree(filepath: str) -> str: """Return the hexdigest MD5 hash of file or directory at `filepath`. If file - just hash file content. If directory - walk the directory, and accumulate hashes of all the relative paths + contents of files under the directory. """ if isfile(filepath): ...
python
def hash_tree(filepath: str) -> str: """Return the hexdigest MD5 hash of file or directory at `filepath`. If file - just hash file content. If directory - walk the directory, and accumulate hashes of all the relative paths + contents of files under the directory. """ if isfile(filepath): ...
[ "def", "hash_tree", "(", "filepath", ":", "str", ")", "->", "str", ":", "if", "isfile", "(", "filepath", ")", ":", "return", "hash_file", "(", "filepath", ")", "if", "isdir", "(", "filepath", ")", ":", "base_dir", "=", "filepath", "md5", "=", "hashlib"...
Return the hexdigest MD5 hash of file or directory at `filepath`. If file - just hash file content. If directory - walk the directory, and accumulate hashes of all the relative paths + contents of files under the directory.
[ "Return", "the", "hexdigest", "MD5", "hash", "of", "file", "or", "directory", "at", "filepath", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/utils.py#L255-L276
resonai/ybt
yabt/artifact.py
ArtifactStore.add
def add(self, artifact_type: ArtifactType, src_path: str, dst_path: str=None): """Add an artifact of type `artifact_type` at `src_path`. `src_path` should be the path of the file relative to project root. `dst_path`, if given, is the desired path of the artifact in dependent ...
python
def add(self, artifact_type: ArtifactType, src_path: str, dst_path: str=None): """Add an artifact of type `artifact_type` at `src_path`. `src_path` should be the path of the file relative to project root. `dst_path`, if given, is the desired path of the artifact in dependent ...
[ "def", "add", "(", "self", ",", "artifact_type", ":", "ArtifactType", ",", "src_path", ":", "str", ",", "dst_path", ":", "str", "=", "None", ")", ":", "if", "dst_path", "is", "None", ":", "dst_path", "=", "src_path", "other_src_path", "=", "self", ".", ...
Add an artifact of type `artifact_type` at `src_path`. `src_path` should be the path of the file relative to project root. `dst_path`, if given, is the desired path of the artifact in dependent targets, relative to its base path (by type).
[ "Add", "an", "artifact", "of", "type", "artifact_type", "at", "src_path", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/artifact.py#L89-L105
resonai/ybt
yabt/artifact.py
ArtifactStore.extend
def extend(self, artifact_type: ArtifactType, src_paths: list): """Add all `src_paths` as artifact of type `artifact_type`.""" for src_path in src_paths: self.add(artifact_type, src_path, src_path)
python
def extend(self, artifact_type: ArtifactType, src_paths: list): """Add all `src_paths` as artifact of type `artifact_type`.""" for src_path in src_paths: self.add(artifact_type, src_path, src_path)
[ "def", "extend", "(", "self", ",", "artifact_type", ":", "ArtifactType", ",", "src_paths", ":", "list", ")", ":", "for", "src_path", "in", "src_paths", ":", "self", ".", "add", "(", "artifact_type", ",", "src_path", ",", "src_path", ")" ]
Add all `src_paths` as artifact of type `artifact_type`.
[ "Add", "all", "src_paths", "as", "artifact", "of", "type", "artifact_type", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/artifact.py#L107-L110
resonai/ybt
yabt/artifact.py
ArtifactStore.link_types
def link_types(self, base_dir: str, types: list, conf: Config) -> int: """Link all artifacts with types `types` under `base_dir` and return the number of linked artifacts.""" num_linked = 0 for kind in types: artifact_map = self._artifacts.get(kind) if not arti...
python
def link_types(self, base_dir: str, types: list, conf: Config) -> int: """Link all artifacts with types `types` under `base_dir` and return the number of linked artifacts.""" num_linked = 0 for kind in types: artifact_map = self._artifacts.get(kind) if not arti...
[ "def", "link_types", "(", "self", ",", "base_dir", ":", "str", ",", "types", ":", "list", ",", "conf", ":", "Config", ")", "->", "int", ":", "num_linked", "=", "0", "for", "kind", "in", "types", ":", "artifact_map", "=", "self", ".", "_artifacts", "....
Link all artifacts with types `types` under `base_dir` and return the number of linked artifacts.
[ "Link", "all", "artifacts", "with", "types", "types", "under", "base_dir", "and", "return", "the", "number", "of", "linked", "artifacts", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/artifact.py#L123-L133
resonai/ybt
yabt/artifact.py
ArtifactStore.link_for_image
def link_for_image(self, base_dir: str, conf: Config) -> int: """Link all artifacts required for a Docker image under `base_dir` and return the number of linked artifacts.""" return self.link_types( base_dir, [ArtifactType.app, ArtifactType.binary, ArtifactType.gen_py]...
python
def link_for_image(self, base_dir: str, conf: Config) -> int: """Link all artifacts required for a Docker image under `base_dir` and return the number of linked artifacts.""" return self.link_types( base_dir, [ArtifactType.app, ArtifactType.binary, ArtifactType.gen_py]...
[ "def", "link_for_image", "(", "self", ",", "base_dir", ":", "str", ",", "conf", ":", "Config", ")", "->", "int", ":", "return", "self", ".", "link_types", "(", "base_dir", ",", "[", "ArtifactType", ".", "app", ",", "ArtifactType", ".", "binary", ",", "...
Link all artifacts required for a Docker image under `base_dir` and return the number of linked artifacts.
[ "Link", "all", "artifacts", "required", "for", "a", "Docker", "image", "under", "base_dir", "and", "return", "the", "number", "of", "linked", "artifacts", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/artifact.py#L135-L141
resonai/ybt
yabt/artifact.py
ArtifactStore._link
def _link(self, base_dir: str, artifact_map: dict, conf: Config): """Link all artifacts in `artifact_map` under `base_dir` and return the number of artifacts linked.""" num_linked = 0 for dst, src in artifact_map.items(): abs_src = join(conf.project_root, src) ...
python
def _link(self, base_dir: str, artifact_map: dict, conf: Config): """Link all artifacts in `artifact_map` under `base_dir` and return the number of artifacts linked.""" num_linked = 0 for dst, src in artifact_map.items(): abs_src = join(conf.project_root, src) ...
[ "def", "_link", "(", "self", ",", "base_dir", ":", "str", ",", "artifact_map", ":", "dict", ",", "conf", ":", "Config", ")", ":", "num_linked", "=", "0", "for", "dst", ",", "src", "in", "artifact_map", ".", "items", "(", ")", ":", "abs_src", "=", "...
Link all artifacts in `artifact_map` under `base_dir` and return the number of artifacts linked.
[ "Link", "all", "artifacts", "in", "artifact_map", "under", "base_dir", "and", "return", "the", "number", "of", "artifacts", "linked", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/artifact.py#L143-L152
resonai/ybt
setup.py
get_readme
def get_readme(): """Read and return the content of the project README file.""" base_dir = path.abspath(path.dirname(__file__)) with open(path.join(base_dir, 'README.md'), encoding='utf-8') as readme_f: return readme_f.read()
python
def get_readme(): """Read and return the content of the project README file.""" base_dir = path.abspath(path.dirname(__file__)) with open(path.join(base_dir, 'README.md'), encoding='utf-8') as readme_f: return readme_f.read()
[ "def", "get_readme", "(", ")", ":", "base_dir", "=", "path", ".", "abspath", "(", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "open", "(", "path", ".", "join", "(", "base_dir", ",", "'README.md'", ")", ",", "encoding", "=", "'utf-8'", ...
Read and return the content of the project README file.
[ "Read", "and", "return", "the", "content", "of", "the", "project", "README", "file", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/setup.py#L16-L20
resonai/ybt
yabt/target_extraction.py
args_to_props
def args_to_props(target: Target, builder: Builder, args: list, kwargs: dict): """Convert build file `args` and `kwargs` to `target` props. Use builder signature to validate builder usage in build-file, raising appropriate exceptions on signature-mismatches. Use builder signature default values to ass...
python
def args_to_props(target: Target, builder: Builder, args: list, kwargs: dict): """Convert build file `args` and `kwargs` to `target` props. Use builder signature to validate builder usage in build-file, raising appropriate exceptions on signature-mismatches. Use builder signature default values to ass...
[ "def", "args_to_props", "(", "target", ":", "Target", ",", "builder", ":", "Builder", ",", "args", ":", "list", ",", "kwargs", ":", "dict", ")", ":", "if", "len", "(", "args", ")", ">", "len", "(", "builder", ".", "sig", ")", ":", "# too many positio...
Convert build file `args` and `kwargs` to `target` props. Use builder signature to validate builder usage in build-file, raising appropriate exceptions on signature-mismatches. Use builder signature default values to assign props values to args that were not passed in the build-file call. This fu...
[ "Convert", "build", "file", "args", "and", "kwargs", "to", "target", "props", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_extraction.py#L50-L107
resonai/ybt
yabt/target_extraction.py
extractor
def extractor( builder_name: str, builder: Builder, build_file_path: str, build_context) -> types.FunctionType: """Return a target extraction function for a specific builder and a specific build file.""" build_module = to_build_module(build_file_path, build_context.conf) def extract_...
python
def extractor( builder_name: str, builder: Builder, build_file_path: str, build_context) -> types.FunctionType: """Return a target extraction function for a specific builder and a specific build file.""" build_module = to_build_module(build_file_path, build_context.conf) def extract_...
[ "def", "extractor", "(", "builder_name", ":", "str", ",", "builder", ":", "Builder", ",", "build_file_path", ":", "str", ",", "build_context", ")", "->", "types", ".", "FunctionType", ":", "build_module", "=", "to_build_module", "(", "build_file_path", ",", "b...
Return a target extraction function for a specific builder and a specific build file.
[ "Return", "a", "target", "extraction", "function", "for", "a", "specific", "builder", "and", "a", "specific", "build", "file", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_extraction.py#L163-L193
softwarefactory-project/rdopkg
rdopkg/cli.py
rdopkg_runner
def rdopkg_runner(): """ default rdopkg action runner including rdopkg action modules """ aman = ActionManager() # assume all actions.* modules are action modules aman.add_actions_modules(actions) aman.fill_aliases() # additional rdopkg action module logic should go here return Actio...
python
def rdopkg_runner(): """ default rdopkg action runner including rdopkg action modules """ aman = ActionManager() # assume all actions.* modules are action modules aman.add_actions_modules(actions) aman.fill_aliases() # additional rdopkg action module logic should go here return Actio...
[ "def", "rdopkg_runner", "(", ")", ":", "aman", "=", "ActionManager", "(", ")", "# assume all actions.* modules are action modules", "aman", ".", "add_actions_modules", "(", "actions", ")", "aman", ".", "fill_aliases", "(", ")", "# additional rdopkg action module logic sho...
default rdopkg action runner including rdopkg action modules
[ "default", "rdopkg", "action", "runner", "including", "rdopkg", "action", "modules" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/cli.py#L10-L19
softwarefactory-project/rdopkg
rdopkg/cli.py
rdopkg
def rdopkg(*cargs): """ rdopkg CLI interface Execute rdopkg action with specified arguments and return shell friendly exit code. This is the default high level way to interact with rdopkg. py> rdopkg('new-version', '1.2.3') is equivalent to $> rdopkg new-version 1.2.3 ""...
python
def rdopkg(*cargs): """ rdopkg CLI interface Execute rdopkg action with specified arguments and return shell friendly exit code. This is the default high level way to interact with rdopkg. py> rdopkg('new-version', '1.2.3') is equivalent to $> rdopkg new-version 1.2.3 ""...
[ "def", "rdopkg", "(", "*", "cargs", ")", ":", "runner", "=", "rdopkg_runner", "(", ")", "return", "shell", ".", "run", "(", "runner", ",", "cargs", "=", "cargs", ",", "prog", "=", "'rdopkg'", ",", "version", "=", "__version__", ")" ]
rdopkg CLI interface Execute rdopkg action with specified arguments and return shell friendly exit code. This is the default high level way to interact with rdopkg. py> rdopkg('new-version', '1.2.3') is equivalent to $> rdopkg new-version 1.2.3
[ "rdopkg", "CLI", "interface" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/cli.py#L22-L41
infothrill/python-dyndnsc
dyndnsc/core.py
getDynDnsClientForConfig
def getDynDnsClientForConfig(config, plugins=None): """Instantiate and return a complete and working dyndns client. :param config: a dictionary with configuration keys :param plugins: an object that implements PluginManager """ initparams = {} if "interval" in config: initparams["detect...
python
def getDynDnsClientForConfig(config, plugins=None): """Instantiate and return a complete and working dyndns client. :param config: a dictionary with configuration keys :param plugins: an object that implements PluginManager """ initparams = {} if "interval" in config: initparams["detect...
[ "def", "getDynDnsClientForConfig", "(", "config", ",", "plugins", "=", "None", ")", ":", "initparams", "=", "{", "}", "if", "\"interval\"", "in", "config", ":", "initparams", "[", "\"detect_interval\"", "]", "=", "config", "[", "\"interval\"", "]", "if", "pl...
Instantiate and return a complete and working dyndns client. :param config: a dictionary with configuration keys :param plugins: an object that implements PluginManager
[ "Instantiate", "and", "return", "a", "complete", "and", "working", "dyndns", "client", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L163-L192
infothrill/python-dyndnsc
dyndnsc/core.py
DynDnsClient.sync
def sync(self): """ Synchronize the registered IP with the detected IP (if needed). This can be expensive, mostly depending on the detector, but also because updating the dynamic ip in itself is costly. Therefore, this method should usually only be called on startup or when the ...
python
def sync(self): """ Synchronize the registered IP with the detected IP (if needed). This can be expensive, mostly depending on the detector, but also because updating the dynamic ip in itself is costly. Therefore, this method should usually only be called on startup or when the ...
[ "def", "sync", "(", "self", ")", ":", "detected_ip", "=", "self", ".", "detector", ".", "detect", "(", ")", "if", "detected_ip", "is", "None", ":", "LOG", ".", "debug", "(", "\"Couldn't detect the current IP using detector %r\"", ",", "self", ".", "detector", ...
Synchronize the registered IP with the detected IP (if needed). This can be expensive, mostly depending on the detector, but also because updating the dynamic ip in itself is costly. Therefore, this method should usually only be called on startup or when the state changes.
[ "Synchronize", "the", "registered", "IP", "with", "the", "detected", "IP", "(", "if", "needed", ")", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L61-L83
infothrill/python-dyndnsc
dyndnsc/core.py
DynDnsClient.has_state_changed
def has_state_changed(self): """ Detect changes in offline detector and real DNS value. Detect a change either in the offline detector or a difference between the real DNS value and what the online detector last got. This is efficient, since it only generates minimal dns...
python
def has_state_changed(self): """ Detect changes in offline detector and real DNS value. Detect a change either in the offline detector or a difference between the real DNS value and what the online detector last got. This is efficient, since it only generates minimal dns...
[ "def", "has_state_changed", "(", "self", ")", ":", "self", ".", "lastcheck", "=", "time", ".", "time", "(", ")", "# prefer offline state change detection:", "if", "self", ".", "detector", ".", "can_detect_offline", "(", ")", ":", "self", ".", "detector", ".", ...
Detect changes in offline detector and real DNS value. Detect a change either in the offline detector or a difference between the real DNS value and what the online detector last got. This is efficient, since it only generates minimal dns traffic for online detectors and no traf...
[ "Detect", "changes", "in", "offline", "detector", "and", "real", "DNS", "value", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L85-L113
infothrill/python-dyndnsc
dyndnsc/core.py
DynDnsClient.needs_check
def needs_check(self): """ Check if enough time has elapsed to perform a check(). If this time has elapsed, a state change check through has_state_changed() should be performed and eventually a sync(). :rtype: boolean """ if self.lastcheck is None: r...
python
def needs_check(self): """ Check if enough time has elapsed to perform a check(). If this time has elapsed, a state change check through has_state_changed() should be performed and eventually a sync(). :rtype: boolean """ if self.lastcheck is None: r...
[ "def", "needs_check", "(", "self", ")", ":", "if", "self", ".", "lastcheck", "is", "None", ":", "return", "True", "return", "time", ".", "time", "(", ")", "-", "self", ".", "lastcheck", ">=", "self", ".", "ipchangedetection_sleep" ]
Check if enough time has elapsed to perform a check(). If this time has elapsed, a state change check through has_state_changed() should be performed and eventually a sync(). :rtype: boolean
[ "Check", "if", "enough", "time", "has", "elapsed", "to", "perform", "a", "check", "()", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L115-L126
infothrill/python-dyndnsc
dyndnsc/core.py
DynDnsClient.needs_sync
def needs_sync(self): """ Check if enough time has elapsed to perform a sync(). A call to sync() should be performed every now and then, no matter what has_state_changed() says. This is really just a safety thing to enforce consistency in case the state gets messed up. ...
python
def needs_sync(self): """ Check if enough time has elapsed to perform a sync(). A call to sync() should be performed every now and then, no matter what has_state_changed() says. This is really just a safety thing to enforce consistency in case the state gets messed up. ...
[ "def", "needs_sync", "(", "self", ")", ":", "if", "self", ".", "lastforce", "is", "None", ":", "self", ".", "lastforce", "=", "time", ".", "time", "(", ")", "return", "time", ".", "time", "(", ")", "-", "self", ".", "lastforce", ">=", "self", ".", ...
Check if enough time has elapsed to perform a sync(). A call to sync() should be performed every now and then, no matter what has_state_changed() says. This is really just a safety thing to enforce consistency in case the state gets messed up. :rtype: boolean
[ "Check", "if", "enough", "time", "has", "elapsed", "to", "perform", "a", "sync", "()", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L128-L140
infothrill/python-dyndnsc
dyndnsc/core.py
DynDnsClient.check
def check(self): """ Check if the detector changed and call sync() accordingly. If the sleep time has elapsed, this method will see if the attached detector has had a state change and call sync() accordingly. """ if self.needs_check(): if self.has_state_chang...
python
def check(self): """ Check if the detector changed and call sync() accordingly. If the sleep time has elapsed, this method will see if the attached detector has had a state change and call sync() accordingly. """ if self.needs_check(): if self.has_state_chang...
[ "def", "check", "(", "self", ")", ":", "if", "self", ".", "needs_check", "(", ")", ":", "if", "self", ".", "has_state_changed", "(", ")", ":", "LOG", ".", "debug", "(", "\"state changed, syncing...\"", ")", "self", ".", "sync", "(", ")", "elif", "self"...
Check if the detector changed and call sync() accordingly. If the sleep time has elapsed, this method will see if the attached detector has had a state change and call sync() accordingly.
[ "Check", "if", "the", "detector", "changed", "and", "call", "sync", "()", "accordingly", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/core.py#L142-L160
infothrill/python-dyndnsc
dyndnsc/detector/webcheck.py
_parser_jsonip
def _parser_jsonip(text): """Parse response text like the one returned by http://jsonip.com/.""" import json try: return str(json.loads(text).get("ip")) except ValueError as exc: LOG.debug("Text '%s' could not be parsed", exc_info=exc) return None
python
def _parser_jsonip(text): """Parse response text like the one returned by http://jsonip.com/.""" import json try: return str(json.loads(text).get("ip")) except ValueError as exc: LOG.debug("Text '%s' could not be parsed", exc_info=exc) return None
[ "def", "_parser_jsonip", "(", "text", ")", ":", "import", "json", "try", ":", "return", "str", "(", "json", ".", "loads", "(", "text", ")", ".", "get", "(", "\"ip\"", ")", ")", "except", "ValueError", "as", "exc", ":", "LOG", ".", "debug", "(", "\"...
Parse response text like the one returned by http://jsonip.com/.
[ "Parse", "response", "text", "like", "the", "one", "returned", "by", "http", ":", "//", "jsonip", ".", "com", "/", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/webcheck.py#L63-L70
infothrill/python-dyndnsc
dyndnsc/detector/webcheck.py
IPDetectorWebCheckBase.detect
def detect(self): """ Try to contact a remote webservice and parse the returned output. Determine the IP address from the parsed output and return. """ if self.opts_url and self.opts_parser: url = self.opts_url parser = self.opts_parser else: ...
python
def detect(self): """ Try to contact a remote webservice and parse the returned output. Determine the IP address from the parsed output and return. """ if self.opts_url and self.opts_parser: url = self.opts_url parser = self.opts_parser else: ...
[ "def", "detect", "(", "self", ")", ":", "if", "self", ".", "opts_url", "and", "self", ".", "opts_parser", ":", "url", "=", "self", ".", "opts_url", "parser", "=", "self", ".", "opts_parser", "else", ":", "url", ",", "parser", "=", "choice", "(", "sel...
Try to contact a remote webservice and parse the returned output. Determine the IP address from the parsed output and return.
[ "Try", "to", "contact", "a", "remote", "webservice", "and", "parse", "the", "returned", "output", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/webcheck.py#L95-L111
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
PluginProxy.add_plugin
def add_plugin(self, plugin, call): """Add plugin to list of plugins. Will be added if it has the attribute I'm bound to. """ meth = getattr(plugin, call, None) if meth is not None: self.plugins.append((plugin, meth))
python
def add_plugin(self, plugin, call): """Add plugin to list of plugins. Will be added if it has the attribute I'm bound to. """ meth = getattr(plugin, call, None) if meth is not None: self.plugins.append((plugin, meth))
[ "def", "add_plugin", "(", "self", ",", "plugin", ",", "call", ")", ":", "meth", "=", "getattr", "(", "plugin", ",", "call", ",", "None", ")", "if", "meth", "is", "not", "None", ":", "self", ".", "plugins", ".", "append", "(", "(", "plugin", ",", ...
Add plugin to list of plugins. Will be added if it has the attribute I'm bound to.
[ "Add", "plugin", "to", "list", "of", "plugins", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L38-L45
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
PluginProxy.listcall
def listcall(self, *arg, **kw): """Call each plugin sequentially. Return the first result that is not None. """ final_result = None for _, meth in self.plugins: result = meth(*arg, **kw) if final_result is None and result is not None: fina...
python
def listcall(self, *arg, **kw): """Call each plugin sequentially. Return the first result that is not None. """ final_result = None for _, meth in self.plugins: result = meth(*arg, **kw) if final_result is None and result is not None: fina...
[ "def", "listcall", "(", "self", ",", "*", "arg", ",", "*", "*", "kw", ")", ":", "final_result", "=", "None", "for", "_", ",", "meth", "in", "self", ".", "plugins", ":", "result", "=", "meth", "(", "*", "arg", ",", "*", "*", "kw", ")", "if", "...
Call each plugin sequentially. Return the first result that is not None.
[ "Call", "each", "plugin", "sequentially", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L47-L57
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
PluginManager.add_plugin
def add_plugin(self, plugin): """Add the given plugin.""" # allow plugins loaded via entry points to override builtin plugins new_name = self.plugin_name(plugin) self._plugins[:] = [p for p in self._plugins if self.plugin_name(p) != new_name] self._plu...
python
def add_plugin(self, plugin): """Add the given plugin.""" # allow plugins loaded via entry points to override builtin plugins new_name = self.plugin_name(plugin) self._plugins[:] = [p for p in self._plugins if self.plugin_name(p) != new_name] self._plu...
[ "def", "add_plugin", "(", "self", ",", "plugin", ")", ":", "# allow plugins loaded via entry points to override builtin plugins", "new_name", "=", "self", ".", "plugin_name", "(", "plugin", ")", "self", ".", "_plugins", "[", ":", "]", "=", "[", "p", "for", "p", ...
Add the given plugin.
[ "Add", "the", "given", "plugin", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L129-L135
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
PluginManager.configure
def configure(self, args): """Configure the set of plugins with the given args. After configuration, disabled plugins are removed from the plugins list. """ for plug in self._plugins: plug_name = self.plugin_name(plug) plug.enabled = getattr(args, "plugin_%s" % p...
python
def configure(self, args): """Configure the set of plugins with the given args. After configuration, disabled plugins are removed from the plugins list. """ for plug in self._plugins: plug_name = self.plugin_name(plug) plug.enabled = getattr(args, "plugin_%s" % p...
[ "def", "configure", "(", "self", ",", "args", ")", ":", "for", "plug", "in", "self", ".", "_plugins", ":", "plug_name", "=", "self", ".", "plugin_name", "(", "plug", ")", "plug", ".", "enabled", "=", "getattr", "(", "args", ",", "\"plugin_%s\"", "%", ...
Configure the set of plugins with the given args. After configuration, disabled plugins are removed from the plugins list.
[ "Configure", "the", "set", "of", "plugins", "with", "the", "given", "args", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L147-L160
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
PluginManager.options
def options(self, parser, env): """Register commandline options with the given parser. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --with-$name option to be registered, be sure to call supe...
python
def options(self, parser, env): """Register commandline options with the given parser. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --with-$name option to be registered, be sure to call supe...
[ "def", "options", "(", "self", ",", "parser", ",", "env", ")", ":", "def", "get_help", "(", "plug", ")", ":", "\"\"\"Extract the help docstring from the given plugin.\"\"\"", "import", "textwrap", "if", "plug", ".", "__class__", ".", "__doc__", ":", "# doc section...
Register commandline options with the given parser. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --with-$name option to be registered, be sure to call super(). :param parser: argparse parse...
[ "Register", "commandline", "options", "with", "the", "given", "parser", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L162-L187
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
EntryPointPluginManager.load_plugins
def load_plugins(self): """Load plugins from entry point(s).""" from pkg_resources import iter_entry_points seen = set() for entry_point in self.entry_points: for ep in iter_entry_points(entry_point): if ep.name in seen: continue ...
python
def load_plugins(self): """Load plugins from entry point(s).""" from pkg_resources import iter_entry_points seen = set() for entry_point in self.entry_points: for ep in iter_entry_points(entry_point): if ep.name in seen: continue ...
[ "def", "load_plugins", "(", "self", ")", ":", "from", "pkg_resources", "import", "iter_entry_points", "seen", "=", "set", "(", ")", "for", "entry_point", "in", "self", ".", "entry_points", ":", "for", "ep", "in", "iter_entry_points", "(", "entry_point", ")", ...
Load plugins from entry point(s).
[ "Load", "plugins", "from", "entry", "point", "(", "s", ")", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L212-L230
infothrill/python-dyndnsc
dyndnsc/plugins/manager.py
BuiltinPluginManager.load_plugins
def load_plugins(self): """Load plugins from `dyndnsc.plugins.builtin`.""" from dyndnsc.plugins.builtin import PLUGINS for plugin in PLUGINS: self.add_plugin(plugin()) super(BuiltinPluginManager, self).load_plugins()
python
def load_plugins(self): """Load plugins from `dyndnsc.plugins.builtin`.""" from dyndnsc.plugins.builtin import PLUGINS for plugin in PLUGINS: self.add_plugin(plugin()) super(BuiltinPluginManager, self).load_plugins()
[ "def", "load_plugins", "(", "self", ")", ":", "from", "dyndnsc", ".", "plugins", ".", "builtin", "import", "PLUGINS", "for", "plugin", "in", "PLUGINS", ":", "self", ".", "add_plugin", "(", "plugin", "(", ")", ")", "super", "(", "BuiltinPluginManager", ",",...
Load plugins from `dyndnsc.plugins.builtin`.
[ "Load", "plugins", "from", "dyndnsc", ".", "plugins", ".", "builtin", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/plugins/manager.py#L239-L244
infothrill/python-dyndnsc
dyndnsc/updater/dnsimple.py
UpdateProtocolDnsimple.update
def update(self, ip): """Update the IP on the remote service.""" return self.handler.update_record(name=self._recordname, address=ip)
python
def update(self, ip): """Update the IP on the remote service.""" return self.handler.update_record(name=self._recordname, address=ip)
[ "def", "update", "(", "self", ",", "ip", ")", ":", "return", "self", ".", "handler", ".", "update_record", "(", "name", "=", "self", ".", "_recordname", ",", "address", "=", "ip", ")" ]
Update the IP on the remote service.
[ "Update", "the", "IP", "on", "the", "remote", "service", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/dnsimple.py#L39-L42
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config.load
def load(self): """(Re)Load config file.""" try: with open(self.config_file) as configfile: self.config = yaml.load(configfile) except TypeError: # no config file (use environment variables) pass if self.config: self.prefix ...
python
def load(self): """(Re)Load config file.""" try: with open(self.config_file) as configfile: self.config = yaml.load(configfile) except TypeError: # no config file (use environment variables) pass if self.config: self.prefix ...
[ "def", "load", "(", "self", ")", ":", "try", ":", "with", "open", "(", "self", ".", "config_file", ")", "as", "configfile", ":", "self", ".", "config", "=", "yaml", ".", "load", "(", "configfile", ")", "except", "TypeError", ":", "# no config file (use e...
(Re)Load config file.
[ "(", "Re", ")", "Load", "config", "file", "." ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L75-L101
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config.get
def get(self, var, section=None, **kwargs): """Retrieve a config var. Return environment variable if it exists (ie [self.prefix + _] + [section + _] + var) otherwise var from config file. If both are null and no default is set a ConfigError will be raised, otherwise defa...
python
def get(self, var, section=None, **kwargs): """Retrieve a config var. Return environment variable if it exists (ie [self.prefix + _] + [section + _] + var) otherwise var from config file. If both are null and no default is set a ConfigError will be raised, otherwise defa...
[ "def", "get", "(", "self", ",", "var", ",", "section", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# default is not a specified keyword argument so we can distinguish", "# between a default set to None and no default sets", "if", "not", "section", "and", "self", "....
Retrieve a config var. Return environment variable if it exists (ie [self.prefix + _] + [section + _] + var) otherwise var from config file. If both are null and no default is set a ConfigError will be raised, otherwise default will be returned. :param var: key to look ...
[ "Retrieve", "a", "config", "var", ".", "Return", "environment", "variable", "if", "it", "exists", "(", "ie", "[", "self", ".", "prefix", "+", "_", "]", "+", "[", "section", "+", "_", "]", "+", "var", ")", "otherwise", "var", "from", "config", "file",...
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L103-L140
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config.keys
def keys(self, section=None): """Provide dict like keys method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.keys()
python
def keys(self, section=None): """Provide dict like keys method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.keys()
[ "def", "keys", "(", "self", ",", "section", "=", "None", ")", ":", "if", "not", "section", "and", "self", ".", "section", ":", "section", "=", "self", ".", "section", "config", "=", "self", ".", "config", ".", "get", "(", "section", ",", "{", "}", ...
Provide dict like keys method
[ "Provide", "dict", "like", "keys", "method" ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L142-L147
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config.items
def items(self, section=None): """Provide dict like items method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.items()
python
def items(self, section=None): """Provide dict like items method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.items()
[ "def", "items", "(", "self", ",", "section", "=", "None", ")", ":", "if", "not", "section", "and", "self", ".", "section", ":", "section", "=", "self", ".", "section", "config", "=", "self", ".", "config", ".", "get", "(", "section", ",", "{", "}",...
Provide dict like items method
[ "Provide", "dict", "like", "items", "method" ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L149-L154
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config.values
def values(self, section=None): """Provide dict like values method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.values()
python
def values(self, section=None): """Provide dict like values method""" if not section and self.section: section = self.section config = self.config.get(section, {}) if section else self.config return config.values()
[ "def", "values", "(", "self", ",", "section", "=", "None", ")", ":", "if", "not", "section", "and", "self", ".", "section", ":", "section", "=", "self", ".", "section", "config", "=", "self", ".", "config", ".", "get", "(", "section", ",", "{", "}"...
Provide dict like values method
[ "Provide", "dict", "like", "values", "method" ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L156-L161
GreenBuildingRegistry/yaml-config
yamlconf/config.py
Config._get_filepath
def _get_filepath(self, filename=None, config_dir=None): """ Get config file. :param filename: name of config file (not path) :param config_dir: dir name prepended to file name. Note: we use e.g. GBR_CONFIG_DIR here, this is the default value in GBR but it is ac...
python
def _get_filepath(self, filename=None, config_dir=None): """ Get config file. :param filename: name of config file (not path) :param config_dir: dir name prepended to file name. Note: we use e.g. GBR_CONFIG_DIR here, this is the default value in GBR but it is ac...
[ "def", "_get_filepath", "(", "self", ",", "filename", "=", "None", ",", "config_dir", "=", "None", ")", ":", "# pylint: disable=no-self-use", "config_file", "=", "None", "config_dir_env_var", "=", "self", ".", "env_prefix", "+", "'_DIR'", "if", "not", "filename"...
Get config file. :param filename: name of config file (not path) :param config_dir: dir name prepended to file name. Note: we use e.g. GBR_CONFIG_DIR here, this is the default value in GBR but it is actually self.env_prefix + '_DIR' etc. If config_dir is not supplied i...
[ "Get", "config", "file", "." ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/config.py#L177-L225
infothrill/python-dyndnsc
dyndnsc/updater/duckdns.py
UpdateProtocolDuckdns.update
def update(self, ip): """Update the IP on the remote service.""" timeout = 60 LOG.debug("Updating '%s' to '%s' at service '%s'", self.hostname, ip, self._updateurl) params = {"domains": self.hostname.partition(".")[0], "token": self.__token} if ip is None: params["ip"...
python
def update(self, ip): """Update the IP on the remote service.""" timeout = 60 LOG.debug("Updating '%s' to '%s' at service '%s'", self.hostname, ip, self._updateurl) params = {"domains": self.hostname.partition(".")[0], "token": self.__token} if ip is None: params["ip"...
[ "def", "update", "(", "self", ",", "ip", ")", ":", "timeout", "=", "60", "LOG", ".", "debug", "(", "\"Updating '%s' to '%s' at service '%s'\"", ",", "self", ".", "hostname", ",", "ip", ",", "self", ".", "_updateurl", ")", "params", "=", "{", "\"domains\"",...
Update the IP on the remote service.
[ "Update", "the", "IP", "on", "the", "remote", "service", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/duckdns.py#L46-L64
infothrill/python-dyndnsc
dyndnsc/detector/dns.py
resolve
def resolve(hostname, family=AF_UNSPEC): """ Resolve hostname to one or more IP addresses through the operating system. Resolution is carried out for the given address family. If no address family is specified, only IPv4 and IPv6 addresses are returned. If multiple IP addresses are found, all are r...
python
def resolve(hostname, family=AF_UNSPEC): """ Resolve hostname to one or more IP addresses through the operating system. Resolution is carried out for the given address family. If no address family is specified, only IPv4 and IPv6 addresses are returned. If multiple IP addresses are found, all are r...
[ "def", "resolve", "(", "hostname", ",", "family", "=", "AF_UNSPEC", ")", ":", "af_ok", "=", "(", "AF_INET", ",", "AF_INET6", ")", "if", "family", "!=", "AF_UNSPEC", "and", "family", "not", "in", "af_ok", ":", "raise", "ValueError", "(", "\"Invalid family '...
Resolve hostname to one or more IP addresses through the operating system. Resolution is carried out for the given address family. If no address family is specified, only IPv4 and IPv6 addresses are returned. If multiple IP addresses are found, all are returned. :param family: AF_INET or AF_INET6 or A...
[ "Resolve", "hostname", "to", "one", "or", "more", "IP", "addresses", "through", "the", "operating", "system", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/dns.py#L13-L40
infothrill/python-dyndnsc
dyndnsc/detector/dns.py
IPDetector_DNS.detect
def detect(self): """ Resolve the hostname to an IP address through the operating system. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. If multiple IP addresses are found, the first one is returned. :return: ip address """ ...
python
def detect(self): """ Resolve the hostname to an IP address through the operating system. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. If multiple IP addresses are found, the first one is returned. :return: ip address """ ...
[ "def", "detect", "(", "self", ")", ":", "theip", "=", "next", "(", "iter", "(", "resolve", "(", "self", ".", "opts_hostname", ",", "self", ".", "opts_family", ")", ")", ",", "None", ")", "self", ".", "set_current_value", "(", "theip", ")", "return", ...
Resolve the hostname to an IP address through the operating system. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. If multiple IP addresses are found, the first one is returned. :return: ip address
[ "Resolve", "the", "hostname", "to", "an", "IP", "address", "through", "the", "operating", "system", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/dns.py#L70-L83
infothrill/python-dyndnsc
dyndnsc/cli.py
list_presets
def list_presets(cfg, out=sys.stdout): """Write a human readable list of available presets to out. :param cfg: ConfigParser instance :param out: file object to write to """ for section in cfg.sections(): if section.startswith("preset:"): out.write((section.replace("preset:", "")...
python
def list_presets(cfg, out=sys.stdout): """Write a human readable list of available presets to out. :param cfg: ConfigParser instance :param out: file object to write to """ for section in cfg.sections(): if section.startswith("preset:"): out.write((section.replace("preset:", "")...
[ "def", "list_presets", "(", "cfg", ",", "out", "=", "sys", ".", "stdout", ")", ":", "for", "section", "in", "cfg", ".", "sections", "(", ")", ":", "if", "section", ".", "startswith", "(", "\"preset:\"", ")", ":", "out", ".", "write", "(", "(", "sec...
Write a human readable list of available presets to out. :param cfg: ConfigParser instance :param out: file object to write to
[ "Write", "a", "human", "readable", "list", "of", "available", "presets", "to", "out", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/cli.py#L23-L33
infothrill/python-dyndnsc
dyndnsc/cli.py
create_argparser
def create_argparser(): """Instantiate an `argparse.ArgumentParser`. Adds all basic cli options including default values. """ parser = argparse.ArgumentParser() arg_defaults = { "daemon": False, "loop": False, "listpresets": False, "config": None, "debug": Fa...
python
def create_argparser(): """Instantiate an `argparse.ArgumentParser`. Adds all basic cli options including default values. """ parser = argparse.ArgumentParser() arg_defaults = { "daemon": False, "loop": False, "listpresets": False, "config": None, "debug": Fa...
[ "def", "create_argparser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_defaults", "=", "{", "\"daemon\"", ":", "False", ",", "\"loop\"", ":", "False", ",", "\"listpresets\"", ":", "False", ",", "\"config\"", ":", "None", ...
Instantiate an `argparse.ArgumentParser`. Adds all basic cli options including default values.
[ "Instantiate", "an", "argparse", ".", "ArgumentParser", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/cli.py#L36-L78
infothrill/python-dyndnsc
dyndnsc/cli.py
run_forever
def run_forever(dyndnsclients): """ Run an endless loop accross the give dynamic dns clients. :param dyndnsclients: list of DynDnsClients """ while True: try: # Do small sleeps in the main loop, needs_check() is cheap and does # the rest. time.sleep(15) ...
python
def run_forever(dyndnsclients): """ Run an endless loop accross the give dynamic dns clients. :param dyndnsclients: list of DynDnsClients """ while True: try: # Do small sleeps in the main loop, needs_check() is cheap and does # the rest. time.sleep(15) ...
[ "def", "run_forever", "(", "dyndnsclients", ")", ":", "while", "True", ":", "try", ":", "# Do small sleeps in the main loop, needs_check() is cheap and does", "# the rest.", "time", ".", "sleep", "(", "15", ")", "for", "dyndnsclient", "in", "dyndnsclients", ":", "dynd...
Run an endless loop accross the give dynamic dns clients. :param dyndnsclients: list of DynDnsClients
[ "Run", "an", "endless", "loop", "accross", "the", "give", "dynamic", "dns", "clients", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/cli.py#L81-L98
infothrill/python-dyndnsc
dyndnsc/cli.py
main
def main(): """ Run the main CLI program. Initializes the stack, parses command line arguments, and fires requested logic. """ plugins = DefaultPluginManager() plugins.load_plugins() parser, _ = create_argparser() # add the updater protocol options to the CLI: for kls in update...
python
def main(): """ Run the main CLI program. Initializes the stack, parses command line arguments, and fires requested logic. """ plugins = DefaultPluginManager() plugins.load_plugins() parser, _ = create_argparser() # add the updater protocol options to the CLI: for kls in update...
[ "def", "main", "(", ")", ":", "plugins", "=", "DefaultPluginManager", "(", ")", "plugins", ".", "load_plugins", "(", ")", "parser", ",", "_", "=", "create_argparser", "(", ")", "# add the updater protocol options to the CLI:", "for", "kls", "in", "updater_classes"...
Run the main CLI program. Initializes the stack, parses command line arguments, and fires requested logic.
[ "Run", "the", "main", "CLI", "program", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/cli.py#L101-L189
softwarefactory-project/rdopkg
rdopkg/utils/__init__.py
tidy_ssh_user
def tidy_ssh_user(url=None, user=None): """make sure a git repo ssh:// url has a user set""" if url and url.startswith('ssh://'): # is there a user already ? match = re.compile('ssh://([^@]+)@.+').match(url) if match: ssh_user = match.group(1) if user and ssh_user...
python
def tidy_ssh_user(url=None, user=None): """make sure a git repo ssh:// url has a user set""" if url and url.startswith('ssh://'): # is there a user already ? match = re.compile('ssh://([^@]+)@.+').match(url) if match: ssh_user = match.group(1) if user and ssh_user...
[ "def", "tidy_ssh_user", "(", "url", "=", "None", ",", "user", "=", "None", ")", ":", "if", "url", "and", "url", ".", "startswith", "(", "'ssh://'", ")", ":", "# is there a user already ?", "match", "=", "re", ".", "compile", "(", "'ssh://([^@]+)@.+'", ")",...
make sure a git repo ssh:// url has a user set
[ "make", "sure", "a", "git", "repo", "ssh", ":", "//", "url", "has", "a", "user", "set" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/__init__.py#L4-L19
softwarefactory-project/rdopkg
rdopkg/utils/git.py
Git.get_commit_bzs
def get_commit_bzs(self, from_revision, to_revision=None): """ Return a list of tuples, one per commit. Each tuple is (sha1, subject, bz_list). bz_list is a (possibly zero-length) list of numbers. """ rng = self.rev_range(from_revision, to_revision) GIT_COMMIT_FIELDS = ['...
python
def get_commit_bzs(self, from_revision, to_revision=None): """ Return a list of tuples, one per commit. Each tuple is (sha1, subject, bz_list). bz_list is a (possibly zero-length) list of numbers. """ rng = self.rev_range(from_revision, to_revision) GIT_COMMIT_FIELDS = ['...
[ "def", "get_commit_bzs", "(", "self", ",", "from_revision", ",", "to_revision", "=", "None", ")", ":", "rng", "=", "self", ".", "rev_range", "(", "from_revision", ",", "to_revision", ")", "GIT_COMMIT_FIELDS", "=", "[", "'id'", ",", "'subject'", ",", "'body'"...
Return a list of tuples, one per commit. Each tuple is (sha1, subject, bz_list). bz_list is a (possibly zero-length) list of numbers.
[ "Return", "a", "list", "of", "tuples", "one", "per", "commit", ".", "Each", "tuple", "is", "(", "sha1", "subject", "bz_list", ")", ".", "bz_list", "is", "a", "(", "possibly", "zero", "-", "length", ")", "list", "of", "numbers", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/git.py#L200-L222
softwarefactory-project/rdopkg
rdopkg/utils/git.py
Git.config_get
def config_get(self, param, default=None): '''Return the value of a git configuration option. This will return the value of the default parameter (which defaults to None) if the given option does not exist.''' try: return self("config", "--get", param, ...
python
def config_get(self, param, default=None): '''Return the value of a git configuration option. This will return the value of the default parameter (which defaults to None) if the given option does not exist.''' try: return self("config", "--get", param, ...
[ "def", "config_get", "(", "self", ",", "param", ",", "default", "=", "None", ")", ":", "try", ":", "return", "self", "(", "\"config\"", ",", "\"--get\"", ",", "param", ",", "log_fail", "=", "False", ",", "log_cmd", "=", "False", ")", "except", "excepti...
Return the value of a git configuration option. This will return the value of the default parameter (which defaults to None) if the given option does not exist.
[ "Return", "the", "value", "of", "a", "git", "configuration", "option", ".", "This", "will", "return", "the", "value", "of", "the", "default", "parameter", "(", "which", "defaults", "to", "None", ")", "if", "the", "given", "option", "does", "not", "exist", ...
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/git.py#L252-L261
infothrill/python-dyndnsc
dyndnsc/conf.py
get_configuration
def get_configuration(config_file=None): """Return an initialized ConfigParser. If no config filename is presented, `DEFAULT_USER_INI` is used if present. Also reads the built-in presets. :param config_file: string path """ parser = configparser.ConfigParser() if config_file is None: ...
python
def get_configuration(config_file=None): """Return an initialized ConfigParser. If no config filename is presented, `DEFAULT_USER_INI` is used if present. Also reads the built-in presets. :param config_file: string path """ parser = configparser.ConfigParser() if config_file is None: ...
[ "def", "get_configuration", "(", "config_file", "=", "None", ")", ":", "parser", "=", "configparser", ".", "ConfigParser", "(", ")", "if", "config_file", "is", "None", ":", "# fallback to default user config file", "config_file", "=", "os", ".", "path", ".", "jo...
Return an initialized ConfigParser. If no config filename is presented, `DEFAULT_USER_INI` is used if present. Also reads the built-in presets. :param config_file: string path
[ "Return", "an", "initialized", "ConfigParser", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/conf.py#L20-L45
infothrill/python-dyndnsc
dyndnsc/conf.py
_iraw_client_configs
def _iraw_client_configs(cfg): """ Generate (client_name, client_cfg_dict) tuples from the configuration. Conflates the presets and removes traces of the preset configuration so that the returned dict can be used directly on a dyndnsc factory. :param cfg: ConfigParser """ client_names = cf...
python
def _iraw_client_configs(cfg): """ Generate (client_name, client_cfg_dict) tuples from the configuration. Conflates the presets and removes traces of the preset configuration so that the returned dict can be used directly on a dyndnsc factory. :param cfg: ConfigParser """ client_names = cf...
[ "def", "_iraw_client_configs", "(", "cfg", ")", ":", "client_names", "=", "cfg", ".", "get", "(", "\"dyndnsc\"", ",", "\"configs\"", ")", ".", "split", "(", "\",\"", ")", "_preset_prefix", "=", "\"preset:\"", "_use_preset", "=", "\"use_preset\"", "for", "clien...
Generate (client_name, client_cfg_dict) tuples from the configuration. Conflates the presets and removes traces of the preset configuration so that the returned dict can be used directly on a dyndnsc factory. :param cfg: ConfigParser
[ "Generate", "(", "client_name", "client_cfg_dict", ")", "tuples", "from", "the", "configuration", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/conf.py#L48-L73
infothrill/python-dyndnsc
dyndnsc/conf.py
collect_config
def collect_config(cfg): """ Construct configuration dictionary from configparser. Resolves presets and returns a dictionary containing: .. code-block:: bash { "client_name": { "detector": ("detector_name", detector_opts), "updater": [ ...
python
def collect_config(cfg): """ Construct configuration dictionary from configparser. Resolves presets and returns a dictionary containing: .. code-block:: bash { "client_name": { "detector": ("detector_name", detector_opts), "updater": [ ...
[ "def", "collect_config", "(", "cfg", ")", ":", "collected_configs", "=", "{", "}", "_updater_str", "=", "\"updater\"", "_detector_str", "=", "\"detector\"", "_dash", "=", "\"-\"", "for", "client_name", ",", "client_cfg_dict", "in", "_iraw_client_configs", "(", "cf...
Construct configuration dictionary from configparser. Resolves presets and returns a dictionary containing: .. code-block:: bash { "client_name": { "detector": ("detector_name", detector_opts), "updater": [ ("updater_name", updater_opts)...
[ "Construct", "configuration", "dictionary", "from", "configparser", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/conf.py#L76-L126
infothrill/python-dyndnsc
dyndnsc/detector/command.py
IPDetector_Command.detect
def detect(self): """Detect and return the IP address.""" if PY3: # py23 import subprocess # noqa: S404 @UnresolvedImport pylint: disable=import-error else: import commands as subprocess # @UnresolvedImport pylint: disable=import-error try: theip = ...
python
def detect(self): """Detect and return the IP address.""" if PY3: # py23 import subprocess # noqa: S404 @UnresolvedImport pylint: disable=import-error else: import commands as subprocess # @UnresolvedImport pylint: disable=import-error try: theip = ...
[ "def", "detect", "(", "self", ")", ":", "if", "PY3", ":", "# py23", "import", "subprocess", "# noqa: S404 @UnresolvedImport pylint: disable=import-error", "else", ":", "import", "commands", "as", "subprocess", "# @UnresolvedImport pylint: disable=import-error", "try", ":", ...
Detect and return the IP address.
[ "Detect", "and", "return", "the", "IP", "address", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/command.py#L35-L46
infothrill/python-dyndnsc
dyndnsc/detector/dnswanip.py
find_ip
def find_ip(family=AF_INET, flavour="opendns"): """Find the publicly visible IP address of the current system. This uses public DNS infrastructure that implement a special DNS "hack" to return the IP address of the requester rather than some other address. :param family: address family, optional, defa...
python
def find_ip(family=AF_INET, flavour="opendns"): """Find the publicly visible IP address of the current system. This uses public DNS infrastructure that implement a special DNS "hack" to return the IP address of the requester rather than some other address. :param family: address family, optional, defa...
[ "def", "find_ip", "(", "family", "=", "AF_INET", ",", "flavour", "=", "\"opendns\"", ")", ":", "flavours", "=", "{", "\"opendns\"", ":", "{", "AF_INET", ":", "{", "\"@\"", ":", "(", "\"resolver1.opendns.com\"", ",", "\"resolver2.opendns.com\"", ")", ",", "\"...
Find the publicly visible IP address of the current system. This uses public DNS infrastructure that implement a special DNS "hack" to return the IP address of the requester rather than some other address. :param family: address family, optional, default AF_INET (ipv4) :param flavour: selector for pub...
[ "Find", "the", "publicly", "visible", "IP", "address", "of", "the", "current", "system", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/dnswanip.py#L19-L51
infothrill/python-dyndnsc
dyndnsc/detector/dnswanip.py
IPDetector_DnsWanIp.detect
def detect(self): """ Detect the WAN IP of the current process through DNS. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. :return: ip address """ theip = find_ip(family=self.opts_family) self.set_current_value(theip) ...
python
def detect(self): """ Detect the WAN IP of the current process through DNS. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. :return: ip address """ theip = find_ip(family=self.opts_family) self.set_current_value(theip) ...
[ "def", "detect", "(", "self", ")", ":", "theip", "=", "find_ip", "(", "family", "=", "self", ".", "opts_family", ")", "self", ".", "set_current_value", "(", "theip", ")", "return", "theip" ]
Detect the WAN IP of the current process through DNS. Depending on the 'family' option, either ipv4 or ipv6 resolution is carried out. :return: ip address
[ "Detect", "the", "WAN", "IP", "of", "the", "current", "process", "through", "DNS", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/dnswanip.py#L76-L87
infothrill/python-dyndnsc
dyndnsc/detector/base.py
IPDetector.set_current_value
def set_current_value(self, value): """Set the detected IP in the current run (if any).""" self._oldvalue = self.get_current_value() self._currentvalue = value if self._oldvalue != value: # self.notify_observers("new_ip_detected", {"ip": value}) LOG.debug("%s.set_...
python
def set_current_value(self, value): """Set the detected IP in the current run (if any).""" self._oldvalue = self.get_current_value() self._currentvalue = value if self._oldvalue != value: # self.notify_observers("new_ip_detected", {"ip": value}) LOG.debug("%s.set_...
[ "def", "set_current_value", "(", "self", ",", "value", ")", ":", "self", ".", "_oldvalue", "=", "self", ".", "get_current_value", "(", ")", "self", ".", "_currentvalue", "=", "value", "if", "self", ".", "_oldvalue", "!=", "value", ":", "# self.notify_observe...
Set the detected IP in the current run (if any).
[ "Set", "the", "detected", "IP", "in", "the", "current", "run", "(", "if", "any", ")", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/base.py#L75-L82
infothrill/python-dyndnsc
dyndnsc/common/dynamiccli.py
parse_cmdline_args
def parse_cmdline_args(args, classes): """ Parse all updater and detector related arguments from args. Returns a list of ("name", { "k": "v"}) :param args: argparse arguments """ if args is None: raise ValueError("args must not be None") parsed_args = {} for kls in classes: ...
python
def parse_cmdline_args(args, classes): """ Parse all updater and detector related arguments from args. Returns a list of ("name", { "k": "v"}) :param args: argparse arguments """ if args is None: raise ValueError("args must not be None") parsed_args = {} for kls in classes: ...
[ "def", "parse_cmdline_args", "(", "args", ",", "classes", ")", ":", "if", "args", "is", "None", ":", "raise", "ValueError", "(", "\"args must not be None\"", ")", "parsed_args", "=", "{", "}", "for", "kls", "in", "classes", ":", "prefix", "=", "kls", ".", ...
Parse all updater and detector related arguments from args. Returns a list of ("name", { "k": "v"}) :param args: argparse arguments
[ "Parse", "all", "updater", "and", "detector", "related", "arguments", "from", "args", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/dynamiccli.py#L11-L37
infothrill/python-dyndnsc
dyndnsc/common/dynamiccli.py
DynamicCliMixin.register_arguments
def register_arguments(cls, parser): """Register command line options. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --$name option(s) to be registered, be sure to call super(). """ ...
python
def register_arguments(cls, parser): """Register command line options. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --$name option(s) to be registered, be sure to call super(). """ ...
[ "def", "register_arguments", "(", "cls", ",", "parser", ")", ":", "if", "hasattr", "(", "cls", ",", "\"_dont_register_arguments\"", ")", ":", "return", "prefix", "=", "cls", ".", "configuration_key_prefix", "(", ")", "cfgkey", "=", "cls", ".", "configuration_k...
Register command line options. Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default --$name option(s) to be registered, be sure to call super().
[ "Register", "command", "line", "options", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/dynamiccli.py#L60-L87
softwarefactory-project/rdopkg
rdopkg/actions/distgit/actions.py
tag_patches_branch
def tag_patches_branch(package, local_patches_branch, patches_branch, force=False, push=False): """ Tag the local_patches_branch with this package's NVR. """ vr = specfile.Spec().get_vr(epoch=False) nvr_tag = package + '-' + vr tag_cmd = ['tag', nvr_tag, local_patches_branch] ...
python
def tag_patches_branch(package, local_patches_branch, patches_branch, force=False, push=False): """ Tag the local_patches_branch with this package's NVR. """ vr = specfile.Spec().get_vr(epoch=False) nvr_tag = package + '-' + vr tag_cmd = ['tag', nvr_tag, local_patches_branch] ...
[ "def", "tag_patches_branch", "(", "package", ",", "local_patches_branch", ",", "patches_branch", ",", "force", "=", "False", ",", "push", "=", "False", ")", ":", "vr", "=", "specfile", ".", "Spec", "(", ")", ".", "get_vr", "(", "epoch", "=", "False", ")"...
Tag the local_patches_branch with this package's NVR.
[ "Tag", "the", "local_patches_branch", "with", "this", "package", "s", "NVR", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actions/distgit/actions.py#L1014-L1027
infothrill/python-dyndnsc
dyndnsc/common/load.py
load_class
def load_class(module_name, class_name): """Return class object specified by module name and class name. Return None if module failed to be imported. :param module_name: string module name :param class_name: string class name """ try: plugmod = import_module(module_name) except Exc...
python
def load_class(module_name, class_name): """Return class object specified by module name and class name. Return None if module failed to be imported. :param module_name: string module name :param class_name: string class name """ try: plugmod = import_module(module_name) except Exc...
[ "def", "load_class", "(", "module_name", ",", "class_name", ")", ":", "try", ":", "plugmod", "=", "import_module", "(", "module_name", ")", "except", "Exception", "as", "exc", ":", "warn", "(", "\"Importing built-in plugin %s.%s raised an exception: %r\"", "%", "(",...
Return class object specified by module name and class name. Return None if module failed to be imported. :param module_name: string module name :param class_name: string class name
[ "Return", "class", "object", "specified", "by", "module", "name", "and", "class", "name", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/load.py#L9-L24
infothrill/python-dyndnsc
dyndnsc/common/load.py
find_class
def find_class(name, classes): """Return class in ``classes`` identified by configuration key ``name``.""" name = name.lower() cls = next((c for c in classes if c.configuration_key == name), None) if cls is None: raise ValueError("No class named '%s' could be found" % name) return cls
python
def find_class(name, classes): """Return class in ``classes`` identified by configuration key ``name``.""" name = name.lower() cls = next((c for c in classes if c.configuration_key == name), None) if cls is None: raise ValueError("No class named '%s' could be found" % name) return cls
[ "def", "find_class", "(", "name", ",", "classes", ")", ":", "name", "=", "name", ".", "lower", "(", ")", "cls", "=", "next", "(", "(", "c", "for", "c", "in", "classes", "if", "c", ".", "configuration_key", "==", "name", ")", ",", "None", ")", "if...
Return class in ``classes`` identified by configuration key ``name``.
[ "Return", "class", "in", "classes", "identified", "by", "configuration", "key", "name", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/load.py#L27-L33
GreenBuildingRegistry/yaml-config
yamlconf/utils.py
alphasnake
def alphasnake(string): """Convert to snakecase removing non alpha numerics Word #word -> word_word. """ if string: string = " ".join( [re.sub(r'\W+', '', word) for word in string.split()] ) string = decamel_to_snake(string) return string
python
def alphasnake(string): """Convert to snakecase removing non alpha numerics Word #word -> word_word. """ if string: string = " ".join( [re.sub(r'\W+', '', word) for word in string.split()] ) string = decamel_to_snake(string) return string
[ "def", "alphasnake", "(", "string", ")", ":", "if", "string", ":", "string", "=", "\" \"", ".", "join", "(", "[", "re", ".", "sub", "(", "r'\\W+'", ",", "''", ",", "word", ")", "for", "word", "in", "string", ".", "split", "(", ")", "]", ")", "s...
Convert to snakecase removing non alpha numerics Word #word -> word_word.
[ "Convert", "to", "snakecase", "removing", "non", "alpha", "numerics", "Word", "#word", "-", ">", "word_word", "." ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/utils.py#L36-L45
GreenBuildingRegistry/yaml-config
yamlconf/utils.py
decamel
def decamel(string): """"Split CamelCased words. CamelCase -> Camel Case, dromedaryCase -> dromedary Case. """ regex = re.compile(r'(\B[A-Z][a-z]*)') return regex.sub(r' \1', string)
python
def decamel(string): """"Split CamelCased words. CamelCase -> Camel Case, dromedaryCase -> dromedary Case. """ regex = re.compile(r'(\B[A-Z][a-z]*)') return regex.sub(r' \1', string)
[ "def", "decamel", "(", "string", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'(\\B[A-Z][a-z]*)'", ")", "return", "regex", ".", "sub", "(", "r' \\1'", ",", "string", ")" ]
Split CamelCased words. CamelCase -> Camel Case, dromedaryCase -> dromedary Case.
[ "Split", "CamelCased", "words", "." ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/utils.py#L48-L54
GreenBuildingRegistry/yaml-config
yamlconf/utils.py
decamel_to_snake
def decamel_to_snake(string): """Convert to lower case, join camel case with underscore. CamelCase -> camel_case. Camel Case -> camel_case. """ strings = [decamel(word) if not word.isupper() else word.lower() for word in string.split()] return "_".join([snake(dstring)for dstring in st...
python
def decamel_to_snake(string): """Convert to lower case, join camel case with underscore. CamelCase -> camel_case. Camel Case -> camel_case. """ strings = [decamel(word) if not word.isupper() else word.lower() for word in string.split()] return "_".join([snake(dstring)for dstring in st...
[ "def", "decamel_to_snake", "(", "string", ")", ":", "strings", "=", "[", "decamel", "(", "word", ")", "if", "not", "word", ".", "isupper", "(", ")", "else", "word", ".", "lower", "(", ")", "for", "word", "in", "string", ".", "split", "(", ")", "]",...
Convert to lower case, join camel case with underscore. CamelCase -> camel_case. Camel Case -> camel_case.
[ "Convert", "to", "lower", "case", "join", "camel", "case", "with", "underscore", ".", "CamelCase", "-", ">", "camel_case", ".", "Camel", "Case", "-", ">", "camel_case", "." ]
train
https://github.com/GreenBuildingRegistry/yaml-config/blob/3d4bf4cadd07d4c3b71674077bd7cf16efb6ea10/yamlconf/utils.py#L57-L63
softwarefactory-project/rdopkg
rdopkg/actionmods/rdoinfo.py
info_file
def info_file(distro=None): """Return default distroinfo info file""" if not distro: distro = cfg['DISTRO'] info_file_conf = distro.upper() + 'INFO_FILE' try: return cfg[info_file_conf] except KeyError: raise exception.InvalidUsage( why="Couldn't find config optio...
python
def info_file(distro=None): """Return default distroinfo info file""" if not distro: distro = cfg['DISTRO'] info_file_conf = distro.upper() + 'INFO_FILE' try: return cfg[info_file_conf] except KeyError: raise exception.InvalidUsage( why="Couldn't find config optio...
[ "def", "info_file", "(", "distro", "=", "None", ")", ":", "if", "not", "distro", ":", "distro", "=", "cfg", "[", "'DISTRO'", "]", "info_file_conf", "=", "distro", ".", "upper", "(", ")", "+", "'INFO_FILE'", "try", ":", "return", "cfg", "[", "info_file_...
Return default distroinfo info file
[ "Return", "default", "distroinfo", "info", "file" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actionmods/rdoinfo.py#L87-L97
softwarefactory-project/rdopkg
rdopkg/actionmods/rdoinfo.py
get_distroinfo
def get_distroinfo(distro=None): """Get DistroInfo initialized from configuration""" if not distro: distro = cfg['DISTRO'] _info_file = info_file(distro) # prefer git fetcher if available git_info_url_conf = distro.upper() + 'INFO_REPO' try: remote_git_info = cfg[git_info_url_con...
python
def get_distroinfo(distro=None): """Get DistroInfo initialized from configuration""" if not distro: distro = cfg['DISTRO'] _info_file = info_file(distro) # prefer git fetcher if available git_info_url_conf = distro.upper() + 'INFO_REPO' try: remote_git_info = cfg[git_info_url_con...
[ "def", "get_distroinfo", "(", "distro", "=", "None", ")", ":", "if", "not", "distro", ":", "distro", "=", "cfg", "[", "'DISTRO'", "]", "_info_file", "=", "info_file", "(", "distro", ")", "# prefer git fetcher if available", "git_info_url_conf", "=", "distro", ...
Get DistroInfo initialized from configuration
[ "Get", "DistroInfo", "initialized", "from", "configuration" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actionmods/rdoinfo.py#L100-L120
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
split_filename
def split_filename(filename): """ Received a standard style rpm fullname and returns name, version, release, epoch, arch Example: foo-1.0-1.i386.rpm returns foo, 1.0, 1, i386 1:bar-9-123a.ia64.rpm returns bar, 9, 123a, 1, ia64 This function replaces rpmUtils.miscutils.splitFilename, se...
python
def split_filename(filename): """ Received a standard style rpm fullname and returns name, version, release, epoch, arch Example: foo-1.0-1.i386.rpm returns foo, 1.0, 1, i386 1:bar-9-123a.ia64.rpm returns bar, 9, 123a, 1, ia64 This function replaces rpmUtils.miscutils.splitFilename, se...
[ "def", "split_filename", "(", "filename", ")", ":", "# Remove .rpm suffix", "if", "filename", ".", "endswith", "(", "'.rpm'", ")", ":", "filename", "=", "filename", ".", "split", "(", "'.rpm'", ")", "[", "0", "]", "# is there an epoch?", "components", "=", "...
Received a standard style rpm fullname and returns name, version, release, epoch, arch Example: foo-1.0-1.i386.rpm returns foo, 1.0, 1, i386 1:bar-9-123a.ia64.rpm returns bar, 9, 123a, 1, ia64 This function replaces rpmUtils.miscutils.splitFilename, see https://bugzilla.redhat.com/1452801
[ "Received", "a", "standard", "style", "rpm", "fullname", "and", "returns", "name", "version", "release", "epoch", "arch", "Example", ":", "foo", "-", "1", ".", "0", "-", "1", ".", "i386", ".", "rpm", "returns", "foo", "1", ".", "0", "1", "i386", "1",...
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L25-L54
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
string_to_version
def string_to_version(verstring): """ Return a tuple of (epoch, version, release) from a version string This function replaces rpmUtils.miscutils.stringToVersion, see https://bugzilla.redhat.com/1364504 """ # is there an epoch? components = verstring.split(':') if len(components) > 1: ...
python
def string_to_version(verstring): """ Return a tuple of (epoch, version, release) from a version string This function replaces rpmUtils.miscutils.stringToVersion, see https://bugzilla.redhat.com/1364504 """ # is there an epoch? components = verstring.split(':') if len(components) > 1: ...
[ "def", "string_to_version", "(", "verstring", ")", ":", "# is there an epoch?", "components", "=", "verstring", ".", "split", "(", "':'", ")", "if", "len", "(", "components", ")", ">", "1", ":", "epoch", "=", "components", "[", "0", "]", "else", ":", "ep...
Return a tuple of (epoch, version, release) from a version string This function replaces rpmUtils.miscutils.stringToVersion, see https://bugzilla.redhat.com/1364504
[ "Return", "a", "tuple", "of", "(", "epoch", "version", "release", ")", "from", "a", "version", "string" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L57-L75
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
spec_fn
def spec_fn(spec_dir='.'): """ Return the filename for a .spec file in this directory. """ specs = [f for f in os.listdir(spec_dir) if os.path.isfile(f) and f.endswith('.spec')] if not specs: raise exception.SpecFileNotFound() if len(specs) != 1: raise exception.Mult...
python
def spec_fn(spec_dir='.'): """ Return the filename for a .spec file in this directory. """ specs = [f for f in os.listdir(spec_dir) if os.path.isfile(f) and f.endswith('.spec')] if not specs: raise exception.SpecFileNotFound() if len(specs) != 1: raise exception.Mult...
[ "def", "spec_fn", "(", "spec_dir", "=", "'.'", ")", ":", "specs", "=", "[", "f", "for", "f", "in", "os", ".", "listdir", "(", "spec_dir", ")", "if", "os", ".", "path", ".", "isfile", "(", "f", ")", "and", "f", ".", "endswith", "(", "'.spec'", "...
Return the filename for a .spec file in this directory.
[ "Return", "the", "filename", "for", "a", ".", "spec", "file", "in", "this", "directory", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L78-L88
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
version_parts
def version_parts(version): """ Split a version string into numeric X.Y.Z part and the rest (milestone). """ m = re.match(r'(\d+(?:\.\d+)*)([.%]|$)(.*)', version) if m: numver = m.group(1) rest = m.group(2) + m.group(3) return numver, rest else: return version, ''
python
def version_parts(version): """ Split a version string into numeric X.Y.Z part and the rest (milestone). """ m = re.match(r'(\d+(?:\.\d+)*)([.%]|$)(.*)', version) if m: numver = m.group(1) rest = m.group(2) + m.group(3) return numver, rest else: return version, ''
[ "def", "version_parts", "(", "version", ")", ":", "m", "=", "re", ".", "match", "(", "r'(\\d+(?:\\.\\d+)*)([.%]|$)(.*)'", ",", "version", ")", "if", "m", ":", "numver", "=", "m", ".", "group", "(", "1", ")", "rest", "=", "m", ".", "group", "(", "2", ...
Split a version string into numeric X.Y.Z part and the rest (milestone).
[ "Split", "a", "version", "string", "into", "numeric", "X", ".", "Y", ".", "Z", "part", "and", "the", "rest", "(", "milestone", ")", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L112-L122
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
release_parts
def release_parts(version): """ Split RPM Release string into (numeric X.Y.Z part, milestone, rest). :returns: a three-element tuple (number, milestone, rest). If we cannot determine the "milestone" or "rest", those will be an empty string. """ numver, tail = version_par...
python
def release_parts(version): """ Split RPM Release string into (numeric X.Y.Z part, milestone, rest). :returns: a three-element tuple (number, milestone, rest). If we cannot determine the "milestone" or "rest", those will be an empty string. """ numver, tail = version_par...
[ "def", "release_parts", "(", "version", ")", ":", "numver", ",", "tail", "=", "version_parts", "(", "version", ")", "if", "numver", "and", "not", "re", ".", "match", "(", "r'\\d'", ",", "numver", ")", ":", "# entire release is macro a la %{release}", "tail", ...
Split RPM Release string into (numeric X.Y.Z part, milestone, rest). :returns: a three-element tuple (number, milestone, rest). If we cannot determine the "milestone" or "rest", those will be an empty string.
[ "Split", "RPM", "Release", "string", "into", "(", "numeric", "X", ".", "Y", ".", "Z", "part", "milestone", "rest", ")", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L125-L145
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.get_magic_comment
def get_magic_comment(self, name, expand_macros=False): """Return a value of # name=value comment in spec or None.""" match = re.search(r'^#\s*?%s\s?=\s?(\S+)' % re.escape(name), self.txt, flags=re.M) if not match: return None val = match.group(1) ...
python
def get_magic_comment(self, name, expand_macros=False): """Return a value of # name=value comment in spec or None.""" match = re.search(r'^#\s*?%s\s?=\s?(\S+)' % re.escape(name), self.txt, flags=re.M) if not match: return None val = match.group(1) ...
[ "def", "get_magic_comment", "(", "self", ",", "name", ",", "expand_macros", "=", "False", ")", ":", "match", "=", "re", ".", "search", "(", "r'^#\\s*?%s\\s?=\\s?(\\S+)'", "%", "re", ".", "escape", "(", "name", ")", ",", "self", ".", "txt", ",", "flags", ...
Return a value of # name=value comment in spec or None.
[ "Return", "a", "value", "of", "#", "name", "=", "value", "comment", "in", "spec", "or", "None", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L272-L283
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.get_patches_base
def get_patches_base(self, expand_macros=False): """Return a tuple (version, number_of_commits) that are parsed from the patches_base in the specfile. """ match = re.search(r'(?<=patches_base=)[\w.+?%{}]+', self.txt) if not match: return None, 0 patches_base ...
python
def get_patches_base(self, expand_macros=False): """Return a tuple (version, number_of_commits) that are parsed from the patches_base in the specfile. """ match = re.search(r'(?<=patches_base=)[\w.+?%{}]+', self.txt) if not match: return None, 0 patches_base ...
[ "def", "get_patches_base", "(", "self", ",", "expand_macros", "=", "False", ")", ":", "match", "=", "re", ".", "search", "(", "r'(?<=patches_base=)[\\w.+?%{}]+'", ",", "self", ".", "txt", ")", "if", "not", "match", ":", "return", "None", ",", "0", "patches...
Return a tuple (version, number_of_commits) that are parsed from the patches_base in the specfile.
[ "Return", "a", "tuple", "(", "version", "number_of_commits", ")", "that", "are", "parsed", "from", "the", "patches_base", "in", "the", "specfile", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L285-L303
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.get_patches_ignore_regex
def get_patches_ignore_regex(self): """Returns a string representing a regex for filtering out patches This string is parsed from a comment in the specfile that contains the word filter-out followed by an equal sign. For example, a comment as such: # patches_ignore=(regex) ...
python
def get_patches_ignore_regex(self): """Returns a string representing a regex for filtering out patches This string is parsed from a comment in the specfile that contains the word filter-out followed by an equal sign. For example, a comment as such: # patches_ignore=(regex) ...
[ "def", "get_patches_ignore_regex", "(", "self", ")", ":", "match", "=", "re", ".", "search", "(", "r'# *patches_ignore=([\\w *.+?[\\]|{,}\\-_]+)'", ",", "self", ".", "txt", ")", "if", "not", "match", ":", "return", "None", "regex_string", "=", "match", ".", "g...
Returns a string representing a regex for filtering out patches This string is parsed from a comment in the specfile that contains the word filter-out followed by an equal sign. For example, a comment as such: # patches_ignore=(regex) would mean this method returns the str...
[ "Returns", "a", "string", "representing", "a", "regex", "for", "filtering", "out", "patches" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L305-L327
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.recognized_release
def recognized_release(self): """ Check if this Release value is something we can parse. :rtype: bool """ _, _, rest = self.get_release_parts() # If "rest" is not a well-known value here, then this package is # using a Release value pattern we cannot recognize. ...
python
def recognized_release(self): """ Check if this Release value is something we can parse. :rtype: bool """ _, _, rest = self.get_release_parts() # If "rest" is not a well-known value here, then this package is # using a Release value pattern we cannot recognize. ...
[ "def", "recognized_release", "(", "self", ")", ":", "_", ",", "_", ",", "rest", "=", "self", ".", "get_release_parts", "(", ")", "# If \"rest\" is not a well-known value here, then this package is", "# using a Release value pattern we cannot recognize.", "if", "rest", "==",...
Check if this Release value is something we can parse. :rtype: bool
[ "Check", "if", "this", "Release", "value", "is", "something", "we", "can", "parse", ".", ":", "rtype", ":", "bool" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L473-L483
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.get_vr
def get_vr(self, epoch=None): """get VR string from .spec Version, Release and Epoch epoch is None: prefix epoch if present (default) epoch is True: prefix epoch even if not present (0:) epoch is False: omit epoch even if present """ version = self.get_tag('Version', exp...
python
def get_vr(self, epoch=None): """get VR string from .spec Version, Release and Epoch epoch is None: prefix epoch if present (default) epoch is True: prefix epoch even if not present (0:) epoch is False: omit epoch even if present """ version = self.get_tag('Version', exp...
[ "def", "get_vr", "(", "self", ",", "epoch", "=", "None", ")", ":", "version", "=", "self", ".", "get_tag", "(", "'Version'", ",", "expand_macros", "=", "True", ")", "e", "=", "None", "if", "epoch", "is", "None", "or", "epoch", ":", "try", ":", "e",...
get VR string from .spec Version, Release and Epoch epoch is None: prefix epoch if present (default) epoch is True: prefix epoch even if not present (0:) epoch is False: omit epoch even if present
[ "get", "VR", "string", "from", ".", "spec", "Version", "Release", "and", "Epoch" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L583-L608
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.get_nvr
def get_nvr(self, epoch=None): """get NVR string from .spec Name, Version, Release and Epoch""" name = self.get_tag('Name', expand_macros=True) vr = self.get_vr(epoch=epoch) return '%s-%s' % (name, vr)
python
def get_nvr(self, epoch=None): """get NVR string from .spec Name, Version, Release and Epoch""" name = self.get_tag('Name', expand_macros=True) vr = self.get_vr(epoch=epoch) return '%s-%s' % (name, vr)
[ "def", "get_nvr", "(", "self", ",", "epoch", "=", "None", ")", ":", "name", "=", "self", ".", "get_tag", "(", "'Name'", ",", "expand_macros", "=", "True", ")", "vr", "=", "self", ".", "get_vr", "(", "epoch", "=", "epoch", ")", "return", "'%s-%s'", ...
get NVR string from .spec Name, Version, Release and Epoch
[ "get", "NVR", "string", "from", ".", "spec", "Name", "Version", "Release", "and", "Epoch" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L610-L614
softwarefactory-project/rdopkg
rdopkg/utils/specfile.py
Spec.save
def save(self): """ Write the textual content (self._txt) to .spec file (self.fn). """ if not self.txt: # no changes return if not self.fn: raise exception.InvalidAction( "Can't save .spec file without its file name specified.") f = cod...
python
def save(self): """ Write the textual content (self._txt) to .spec file (self.fn). """ if not self.txt: # no changes return if not self.fn: raise exception.InvalidAction( "Can't save .spec file without its file name specified.") f = cod...
[ "def", "save", "(", "self", ")", ":", "if", "not", "self", ".", "txt", ":", "# no changes", "return", "if", "not", "self", ".", "fn", ":", "raise", "exception", ".", "InvalidAction", "(", "\"Can't save .spec file without its file name specified.\"", ")", "f", ...
Write the textual content (self._txt) to .spec file (self.fn).
[ "Write", "the", "textual", "content", "(", "self", ".", "_txt", ")", "to", ".", "spec", "file", "(", "self", ".", "fn", ")", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/utils/specfile.py#L626-L637
infothrill/python-dyndnsc
dyndnsc/common/detect_ip.py
detect_ip
def detect_ip(kind): """ Detect IP address. kind can be: IPV4 - returns IPv4 address IPV6_ANY - returns any IPv6 address (no preference) IPV6_PUBLIC - returns public IPv6 address IPV6_TMP - returns temporary IPV6 address (privacy extensions) This function either returns...
python
def detect_ip(kind): """ Detect IP address. kind can be: IPV4 - returns IPv4 address IPV6_ANY - returns any IPv6 address (no preference) IPV6_PUBLIC - returns public IPv6 address IPV6_TMP - returns temporary IPV6 address (privacy extensions) This function either returns...
[ "def", "detect_ip", "(", "kind", ")", ":", "if", "kind", "not", "in", "(", "IPV4", ",", "IPV6_PUBLIC", ",", "IPV6_TMP", ",", "IPV6_ANY", ")", ":", "raise", "ValueError", "(", "\"invalid kind specified\"", ")", "# We create an UDP socket and connect it to a public ho...
Detect IP address. kind can be: IPV4 - returns IPv4 address IPV6_ANY - returns any IPv6 address (no preference) IPV6_PUBLIC - returns public IPv6 address IPV6_TMP - returns temporary IPV6 address (privacy extensions) This function either returns an IP address (str) or raise...
[ "Detect", "IP", "address", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/detect_ip.py#L51-L97
softwarefactory-project/rdopkg
rdopkg/actionmods/cbsbuild.py
setup_kojiclient
def setup_kojiclient(profile): """Setup koji client session """ opts = koji.read_config(profile) for k, v in opts.iteritems(): opts[k] = os.path.expanduser(v) if type(v) is str else v kojiclient = koji.ClientSession(opts['server'], opts=opts) kojiclient.ssl_login(opts['cert'], None, opts...
python
def setup_kojiclient(profile): """Setup koji client session """ opts = koji.read_config(profile) for k, v in opts.iteritems(): opts[k] = os.path.expanduser(v) if type(v) is str else v kojiclient = koji.ClientSession(opts['server'], opts=opts) kojiclient.ssl_login(opts['cert'], None, opts...
[ "def", "setup_kojiclient", "(", "profile", ")", ":", "opts", "=", "koji", ".", "read_config", "(", "profile", ")", "for", "k", ",", "v", "in", "opts", ".", "iteritems", "(", ")", ":", "opts", "[", "k", "]", "=", "os", ".", "path", ".", "expanduser"...
Setup koji client session
[ "Setup", "koji", "client", "session" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actionmods/cbsbuild.py#L31-L39
softwarefactory-project/rdopkg
rdopkg/actionmods/cbsbuild.py
retrieve_sources
def retrieve_sources(): """Retrieve sources using spectool """ spectool = find_executable('spectool') if not spectool: log.warn('spectool is not installed') return try: specfile = spec_fn() except Exception: return cmd = [spectool, "-g", specfile] output ...
python
def retrieve_sources(): """Retrieve sources using spectool """ spectool = find_executable('spectool') if not spectool: log.warn('spectool is not installed') return try: specfile = spec_fn() except Exception: return cmd = [spectool, "-g", specfile] output ...
[ "def", "retrieve_sources", "(", ")", ":", "spectool", "=", "find_executable", "(", "'spectool'", ")", "if", "not", "spectool", ":", "log", ".", "warn", "(", "'spectool is not installed'", ")", "return", "try", ":", "specfile", "=", "spec_fn", "(", ")", "exce...
Retrieve sources using spectool
[ "Retrieve", "sources", "using", "spectool" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actionmods/cbsbuild.py#L91-L105
softwarefactory-project/rdopkg
rdopkg/actionmods/cbsbuild.py
create_srpm
def create_srpm(dist='el7'): """Create an srpm Requires that sources are available in local directory dist: set package dist tag (default: el7) """ if not RPM_AVAILABLE: raise RpmModuleNotAvailable() path = os.getcwd() try: specfile = spec_fn() spec = Spec(specfile) ...
python
def create_srpm(dist='el7'): """Create an srpm Requires that sources are available in local directory dist: set package dist tag (default: el7) """ if not RPM_AVAILABLE: raise RpmModuleNotAvailable() path = os.getcwd() try: specfile = spec_fn() spec = Spec(specfile) ...
[ "def", "create_srpm", "(", "dist", "=", "'el7'", ")", ":", "if", "not", "RPM_AVAILABLE", ":", "raise", "RpmModuleNotAvailable", "(", ")", "path", "=", "os", ".", "getcwd", "(", ")", "try", ":", "specfile", "=", "spec_fn", "(", ")", "spec", "=", "Spec",...
Create an srpm Requires that sources are available in local directory dist: set package dist tag (default: el7)
[ "Create", "an", "srpm", "Requires", "that", "sources", "are", "available", "in", "local", "directory" ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/actionmods/cbsbuild.py#L108-L148
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
compute_auth_key
def compute_auth_key(userid, password): """ Compute the authentication key for freedns.afraid.org. This is the SHA1 hash of the string b'userid|password'. :param userid: ascii username :param password: ascii password :return: ascii authentication key (SHA1 at this point) """ import sys...
python
def compute_auth_key(userid, password): """ Compute the authentication key for freedns.afraid.org. This is the SHA1 hash of the string b'userid|password'. :param userid: ascii username :param password: ascii password :return: ascii authentication key (SHA1 at this point) """ import sys...
[ "def", "compute_auth_key", "(", "userid", ",", "password", ")", ":", "import", "sys", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "return", "hashlib", ".", "sha1", "(", "b\"|\"", ".", "join", "(", "(", "userid", ".", "encode...
Compute the authentication key for freedns.afraid.org. This is the SHA1 hash of the string b'userid|password'. :param userid: ascii username :param password: ascii password :return: ascii authentication key (SHA1 at this point)
[ "Compute", "the", "authentication", "key", "for", "freedns", ".", "afraid", ".", "org", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L60-L74