repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
user-cont/conu
conu/backend/podman/container.py
PodmanContainer.wait_for_port
def wait_for_port(self, port, timeout=10, **probe_kwargs): """ block until specified port starts accepting connections, raises an exc ProbeTimeout if timeout is reached :param port: int, port number :param timeout: int or float (seconds), time to wait for establishing the connec...
python
def wait_for_port(self, port, timeout=10, **probe_kwargs): """ block until specified port starts accepting connections, raises an exc ProbeTimeout if timeout is reached :param port: int, port number :param timeout: int or float (seconds), time to wait for establishing the connec...
[ "def", "wait_for_port", "(", "self", ",", "port", ",", "timeout", "=", "10", ",", "*", "*", "probe_kwargs", ")", ":", "Probe", "(", "timeout", "=", "timeout", ",", "fnc", "=", "functools", ".", "partial", "(", "self", ".", "is_port_open", ",", "port", ...
block until specified port starts accepting connections, raises an exc ProbeTimeout if timeout is reached :param port: int, port number :param timeout: int or float (seconds), time to wait for establishing the connection :param probe_kwargs: arguments passed to Probe constructor ...
[ "block", "until", "specified", "port", "starts", "accepting", "connections", "raises", "an", "exc", "ProbeTimeout", "if", "timeout", "is", "reached" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L221-L231
train
user-cont/conu
conu/backend/podman/container.py
PodmanContainer.mount
def mount(self, mount_point=None): """ mount container filesystem :return: str, the location of the mounted file system """ cmd = ["podman", "mount", self._id or self.get_id()] output = run_cmd(cmd, return_output=True).rstrip("\n\r") return output
python
def mount(self, mount_point=None): """ mount container filesystem :return: str, the location of the mounted file system """ cmd = ["podman", "mount", self._id or self.get_id()] output = run_cmd(cmd, return_output=True).rstrip("\n\r") return output
[ "def", "mount", "(", "self", ",", "mount_point", "=", "None", ")", ":", "cmd", "=", "[", "\"podman\"", ",", "\"mount\"", ",", "self", ".", "_id", "or", "self", ".", "get_id", "(", ")", "]", "output", "=", "run_cmd", "(", "cmd", ",", "return_output", ...
mount container filesystem :return: str, the location of the mounted file system
[ "mount", "container", "filesystem" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L244-L252
train
user-cont/conu
conu/backend/podman/container.py
PodmanContainer.wait
def wait(self, timeout=None): """ Block until the container stops, then return its exit code. Similar to the ``podman wait`` command. :param timeout: int, microseconds to wait before polling for completion :return: int, exit code """ timeout = ["--interval=%s" % ...
python
def wait(self, timeout=None): """ Block until the container stops, then return its exit code. Similar to the ``podman wait`` command. :param timeout: int, microseconds to wait before polling for completion :return: int, exit code """ timeout = ["--interval=%s" % ...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "timeout", "=", "[", "\"--interval=%s\"", "%", "timeout", "]", "if", "timeout", "else", "[", "]", "cmdline", "=", "[", "\"podman\"", ",", "\"wait\"", "]", "+", "timeout", "+", "[", "s...
Block until the container stops, then return its exit code. Similar to the ``podman wait`` command. :param timeout: int, microseconds to wait before polling for completion :return: int, exit code
[ "Block", "until", "the", "container", "stops", "then", "return", "its", "exit", "code", ".", "Similar", "to", "the", "podman", "wait", "command", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L306-L316
train
user-cont/conu
conu/apidefs/filesystem.py
Filesystem.read_file
def read_file(self, file_path): """ read file specified via 'file_path' and return its content - raises an ConuException if there is an issue accessing the file :param file_path: str, path to the file to read :return: str (not bytes), content of the file """ try:...
python
def read_file(self, file_path): """ read file specified via 'file_path' and return its content - raises an ConuException if there is an issue accessing the file :param file_path: str, path to the file to read :return: str (not bytes), content of the file """ try:...
[ "def", "read_file", "(", "self", ",", "file_path", ")", ":", "try", ":", "with", "open", "(", "self", ".", "p", "(", "file_path", ")", ")", "as", "fd", ":", "return", "fd", ".", "read", "(", ")", "except", "IOError", "as", "ex", ":", "logger", "....
read file specified via 'file_path' and return its content - raises an ConuException if there is an issue accessing the file :param file_path: str, path to the file to read :return: str (not bytes), content of the file
[ "read", "file", "specified", "via", "file_path", "and", "return", "its", "content", "-", "raises", "an", "ConuException", "if", "there", "is", "an", "issue", "accessing", "the", "file" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L106-L119
train
user-cont/conu
conu/apidefs/filesystem.py
Filesystem.get_file
def get_file(self, file_path, mode="r"): """ provide File object specified via 'file_path' :param file_path: str, path to the file :param mode: str, mode used when opening the file :return: File instance """ return open(self.p(file_path), mode=mode)
python
def get_file(self, file_path, mode="r"): """ provide File object specified via 'file_path' :param file_path: str, path to the file :param mode: str, mode used when opening the file :return: File instance """ return open(self.p(file_path), mode=mode)
[ "def", "get_file", "(", "self", ",", "file_path", ",", "mode", "=", "\"r\"", ")", ":", "return", "open", "(", "self", ".", "p", "(", "file_path", ")", ",", "mode", "=", "mode", ")" ]
provide File object specified via 'file_path' :param file_path: str, path to the file :param mode: str, mode used when opening the file :return: File instance
[ "provide", "File", "object", "specified", "via", "file_path" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L121-L129
train
user-cont/conu
conu/apidefs/filesystem.py
Filesystem.file_is_present
def file_is_present(self, file_path): """ check if file 'file_path' is present, raises IOError if file_path is not a file :param file_path: str, path to the file :return: True if file exists, False if file does not exist """ p = self.p(file_path) if not o...
python
def file_is_present(self, file_path): """ check if file 'file_path' is present, raises IOError if file_path is not a file :param file_path: str, path to the file :return: True if file exists, False if file does not exist """ p = self.p(file_path) if not o...
[ "def", "file_is_present", "(", "self", ",", "file_path", ")", ":", "p", "=", "self", ".", "p", "(", "file_path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "p", ")", ":", "return", "False", "if", "not", "os", ".", "path", ".", "isfi...
check if file 'file_path' is present, raises IOError if file_path is not a file :param file_path: str, path to the file :return: True if file exists, False if file does not exist
[ "check", "if", "file", "file_path", "is", "present", "raises", "IOError", "if", "file_path", "is", "not", "a", "file" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L131-L144
train
user-cont/conu
conu/apidefs/filesystem.py
Filesystem.directory_is_present
def directory_is_present(self, directory_path): """ check if directory 'directory_path' is present, raise IOError if it's not a directory :param directory_path: str, directory to check :return: True if directory exists, False if directory does not exist """ p = self.p(di...
python
def directory_is_present(self, directory_path): """ check if directory 'directory_path' is present, raise IOError if it's not a directory :param directory_path: str, directory to check :return: True if directory exists, False if directory does not exist """ p = self.p(di...
[ "def", "directory_is_present", "(", "self", ",", "directory_path", ")", ":", "p", "=", "self", ".", "p", "(", "directory_path", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "p", ")", ":", "return", "False", "if", "not", "os", ".", "path",...
check if directory 'directory_path' is present, raise IOError if it's not a directory :param directory_path: str, directory to check :return: True if directory exists, False if directory does not exist
[ "check", "if", "directory", "directory_path", "is", "present", "raise", "IOError", "if", "it", "s", "not", "a", "directory" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L146-L158
train
user-cont/conu
conu/apidefs/filesystem.py
Filesystem.get_selinux_context
def get_selinux_context(self, file_path): """ Get SELinux file context of the selected file. :param file_path: str, path to the file :return: str, name of the SELinux file context """ # what if SELinux is not enabled? p = self.p(file_path) if not HAS_XATT...
python
def get_selinux_context(self, file_path): """ Get SELinux file context of the selected file. :param file_path: str, path to the file :return: str, name of the SELinux file context """ # what if SELinux is not enabled? p = self.p(file_path) if not HAS_XATT...
[ "def", "get_selinux_context", "(", "self", ",", "file_path", ")", ":", "# what if SELinux is not enabled?", "p", "=", "self", ".", "p", "(", "file_path", ")", "if", "not", "HAS_XATTR", ":", "raise", "RuntimeError", "(", "\"'xattr' python module is not available, hence...
Get SELinux file context of the selected file. :param file_path: str, path to the file :return: str, name of the SELinux file context
[ "Get", "SELinux", "file", "context", "of", "the", "selected", "file", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L160-L174
train
user-cont/conu
conu/utils/probes.py
Probe._wrapper
def _wrapper(self, q, start): """ _wrapper checks return status of Probe.fnc and provides the result for process managing :param q: Queue for function results :param start: Time of function run (used for logging) :return: Return value or Exception """ tr...
python
def _wrapper(self, q, start): """ _wrapper checks return status of Probe.fnc and provides the result for process managing :param q: Queue for function results :param start: Time of function run (used for logging) :return: Return value or Exception """ tr...
[ "def", "_wrapper", "(", "self", ",", "q", ",", "start", ")", ":", "try", ":", "func_name", "=", "self", ".", "fnc", ".", "__name__", "except", "AttributeError", ":", "func_name", "=", "str", "(", "self", ".", "fnc", ")", "logger", ".", "debug", "(", ...
_wrapper checks return status of Probe.fnc and provides the result for process managing :param q: Queue for function results :param start: Time of function run (used for logging) :return: Return value or Exception
[ "_wrapper", "checks", "return", "status", "of", "Probe", ".", "fnc", "and", "provides", "the", "result", "for", "process", "managing" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/probes.py#L92-L116
train
user-cont/conu
conu/backend/docker/skopeo.py
transport_param
def transport_param(image): """ Parse DockerImage info into skopeo parameter :param image: DockerImage :return: string. skopeo parameter specifying image """ transports = {SkopeoTransport.CONTAINERS_STORAGE: "containers-storage:", SkopeoTransport.DIRECTORY: "dir:", ...
python
def transport_param(image): """ Parse DockerImage info into skopeo parameter :param image: DockerImage :return: string. skopeo parameter specifying image """ transports = {SkopeoTransport.CONTAINERS_STORAGE: "containers-storage:", SkopeoTransport.DIRECTORY: "dir:", ...
[ "def", "transport_param", "(", "image", ")", ":", "transports", "=", "{", "SkopeoTransport", ".", "CONTAINERS_STORAGE", ":", "\"containers-storage:\"", ",", "SkopeoTransport", ".", "DIRECTORY", ":", "\"dir:\"", ",", "SkopeoTransport", ".", "DOCKER", ":", "\"docker:/...
Parse DockerImage info into skopeo parameter :param image: DockerImage :return: string. skopeo parameter specifying image
[ "Parse", "DockerImage", "info", "into", "skopeo", "parameter" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/skopeo.py#L23-L65
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.is_running
def is_running(self): """ return True when container is running, otherwise return False :return: bool """ cmd = ["machinectl", "--no-pager", "status", self.name] try: subprocess.check_call(cmd) return True except subprocess.CalledProcessEr...
python
def is_running(self): """ return True when container is running, otherwise return False :return: bool """ cmd = ["machinectl", "--no-pager", "status", self.name] try: subprocess.check_call(cmd) return True except subprocess.CalledProcessEr...
[ "def", "is_running", "(", "self", ")", ":", "cmd", "=", "[", "\"machinectl\"", ",", "\"--no-pager\"", ",", "\"status\"", ",", "self", ".", "name", "]", "try", ":", "subprocess", ".", "check_call", "(", "cmd", ")", "return", "True", "except", "subprocess", ...
return True when container is running, otherwise return False :return: bool
[ "return", "True", "when", "container", "is", "running", "otherwise", "return", "False" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L147-L160
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.copy_from
def copy_from(self, src, dest): """ copy a file or a directory from container or image to host system. :param src: str, path to a file or a directory within container or image :param dest: str, path to a file or a directory on host system :return: None """ logger...
python
def copy_from(self, src, dest): """ copy a file or a directory from container or image to host system. :param src: str, path to a file or a directory within container or image :param dest: str, path to a file or a directory on host system :return: None """ logger...
[ "def", "copy_from", "(", "self", ",", "src", ",", "dest", ")", ":", "logger", ".", "debug", "(", "\"copying %s from host to container at %s\"", ",", "src", ",", "dest", ")", "cmd", "=", "[", "\"machinectl\"", ",", "\"--no-pager\"", ",", "\"copy-from\"", ",", ...
copy a file or a directory from container or image to host system. :param src: str, path to a file or a directory within container or image :param dest: str, path to a file or a directory on host system :return: None
[ "copy", "a", "file", "or", "a", "directory", "from", "container", "or", "image", "to", "host", "system", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L174-L184
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.delete
def delete(self, force=False, volumes=False): """ delete underlying image :param force: bool - force delete, do not care about errors :param volumes: not used anyhow :return: None """ try: self.image.rmi() except ConuException as ime: ...
python
def delete(self, force=False, volumes=False): """ delete underlying image :param force: bool - force delete, do not care about errors :param volumes: not used anyhow :return: None """ try: self.image.rmi() except ConuException as ime: ...
[ "def", "delete", "(", "self", ",", "force", "=", "False", ",", "volumes", "=", "False", ")", ":", "try", ":", "self", ".", "image", ".", "rmi", "(", ")", "except", "ConuException", "as", "ime", ":", "if", "not", "force", ":", "raise", "ime", "else"...
delete underlying image :param force: bool - force delete, do not care about errors :param volumes: not used anyhow :return: None
[ "delete", "underlying", "image" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L220-L234
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.cleanup
def cleanup(self, force=False, delete=False): """ Stop container and delete image if given param delete :param force: bool, force stop and delete, no errors raised :param delete: delete images :return: None """ # TODO: this method could be part of API, like: ...
python
def cleanup(self, force=False, delete=False): """ Stop container and delete image if given param delete :param force: bool, force stop and delete, no errors raised :param delete: delete images :return: None """ # TODO: this method could be part of API, like: ...
[ "def", "cleanup", "(", "self", ",", "force", "=", "False", ",", "delete", "=", "False", ")", ":", "# TODO: this method could be part of API, like:", "try", ":", "self", ".", "stop", "(", ")", "except", "subprocess", ".", "CalledProcessError", "as", "stop", ":"...
Stop container and delete image if given param delete :param force: bool, force stop and delete, no errors raised :param delete: delete images :return: None
[ "Stop", "container", "and", "delete", "image", "if", "given", "param", "delete" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L236-L257
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.run_systemdrun
def run_systemdrun( self, command, internal_background=False, return_full_dict=False, **kwargs): """ execute command via systemd-run inside container :param command: list of command params :param internal_background: not used now :param kwargs: pass param...
python
def run_systemdrun( self, command, internal_background=False, return_full_dict=False, **kwargs): """ execute command via systemd-run inside container :param command: list of command params :param internal_background: not used now :param kwargs: pass param...
[ "def", "run_systemdrun", "(", "self", ",", "command", ",", "internal_background", "=", "False", ",", "return_full_dict", "=", "False", ",", "*", "*", "kwargs", ")", ":", "internalkw", "=", "deepcopy", "(", "kwargs", ")", "or", "{", "}", "original_ignore_st",...
execute command via systemd-run inside container :param command: list of command params :param internal_background: not used now :param kwargs: pass params to subprocess :return: dict with result
[ "execute", "command", "via", "systemd", "-", "run", "inside", "container" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L306-L374
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer._wait_for_machine_booted
def _wait_for_machine_booted(name, suffictinet_texts=None): """ Internal method wait until machine is ready, in common case means there is running systemd-logind :param name: str with machine name :param suffictinet_texts: alternative text to check in output :return: Tru...
python
def _wait_for_machine_booted(name, suffictinet_texts=None): """ Internal method wait until machine is ready, in common case means there is running systemd-logind :param name: str with machine name :param suffictinet_texts: alternative text to check in output :return: Tru...
[ "def", "_wait_for_machine_booted", "(", "name", ",", "suffictinet_texts", "=", "None", ")", ":", "# TODO: rewrite it using probes module in utils", "suffictinet_texts", "=", "suffictinet_texts", "or", "[", "\"systemd-logind\"", "]", "# optionally use: \"Unit: machine\"", "for",...
Internal method wait until machine is ready, in common case means there is running systemd-logind :param name: str with machine name :param suffictinet_texts: alternative text to check in output :return: True or exception
[ "Internal", "method", "wait", "until", "machine", "is", "ready", "in", "common", "case", "means", "there", "is", "running", "systemd", "-", "logind" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L408-L431
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer._internal_reschedule
def _internal_reschedule(callback, retry=3, sleep_time=constants.DEFAULT_SLEEP): """ workaround method for internal_run_container method It sometimes fails because of Dbus or whatever, so try to start it moretimes :param callback: callback method list :param retry: how many time...
python
def _internal_reschedule(callback, retry=3, sleep_time=constants.DEFAULT_SLEEP): """ workaround method for internal_run_container method It sometimes fails because of Dbus or whatever, so try to start it moretimes :param callback: callback method list :param retry: how many time...
[ "def", "_internal_reschedule", "(", "callback", ",", "retry", "=", "3", ",", "sleep_time", "=", "constants", ".", "DEFAULT_SLEEP", ")", ":", "for", "foo", "in", "range", "(", "retry", ")", ":", "container_process", "=", "callback", "[", "0", "]", "(", "c...
workaround method for internal_run_container method It sometimes fails because of Dbus or whatever, so try to start it moretimes :param callback: callback method list :param retry: how many times try to invoke command :param sleep_time: how long wait before subprocess.poll() to find if ...
[ "workaround", "method", "for", "internal_run_container", "method", "It", "sometimes", "fails", "because", "of", "Dbus", "or", "whatever", "so", "try", "to", "start", "it", "moretimes" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L434-L451
train
user-cont/conu
conu/backend/nspawn/container.py
NspawnContainer.internal_run_container
def internal_run_container(name, callback_method, foreground=False): """ Internal method what runs container process :param name: str - name of container :param callback_method: list - how to invoke container :param foreground: bool run in background by default :return: ...
python
def internal_run_container(name, callback_method, foreground=False): """ Internal method what runs container process :param name: str - name of container :param callback_method: list - how to invoke container :param foreground: bool run in background by default :return: ...
[ "def", "internal_run_container", "(", "name", ",", "callback_method", ",", "foreground", "=", "False", ")", ":", "if", "not", "foreground", ":", "logger", ".", "info", "(", "\"Stating machine (boot nspawn container) {}\"", ".", "format", "(", "name", ")", ")", "...
Internal method what runs container process :param name: str - name of container :param callback_method: list - how to invoke container :param foreground: bool run in background by default :return: suprocess instance
[ "Internal", "method", "what", "runs", "container", "process" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L455-L474
train
user-cont/conu
conu/helpers/docker_backend.py
get_container_output
def get_container_output(backend, image_name, command, image_tag="latest", additional_opts=None): """ Create a throw-away container based on provided image and tag, run the supplied command in it and return output. The container is stopped and removed after it exits. :param bac...
python
def get_container_output(backend, image_name, command, image_tag="latest", additional_opts=None): """ Create a throw-away container based on provided image and tag, run the supplied command in it and return output. The container is stopped and removed after it exits. :param bac...
[ "def", "get_container_output", "(", "backend", ",", "image_name", ",", "command", ",", "image_tag", "=", "\"latest\"", ",", "additional_opts", "=", "None", ")", ":", "image", "=", "backend", ".", "ImageClass", "(", "image_name", ",", "tag", "=", "image_tag", ...
Create a throw-away container based on provided image and tag, run the supplied command in it and return output. The container is stopped and removed after it exits. :param backend: instance of DockerBackend :param image_name: str, name of the container image :param command: list of str, command to run...
[ "Create", "a", "throw", "-", "away", "container", "based", "on", "provided", "image", "and", "tag", "run", "the", "supplied", "command", "in", "it", "and", "return", "output", ".", "The", "container", "is", "stopped", "and", "removed", "after", "it", "exit...
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/helpers/docker_backend.py#L4-L28
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.pull
def pull(self): """ Pull this image from registry. Raises an exception if the image is not found in the registry. :return: None """ for json_e in self.d.pull(repository=self.name, tag=self.tag, stream=True, decode=True): logger.debug(json_e) statu...
python
def pull(self): """ Pull this image from registry. Raises an exception if the image is not found in the registry. :return: None """ for json_e in self.d.pull(repository=self.name, tag=self.tag, stream=True, decode=True): logger.debug(json_e) statu...
[ "def", "pull", "(", "self", ")", ":", "for", "json_e", "in", "self", ".", "d", ".", "pull", "(", "repository", "=", "self", ".", "name", ",", "tag", "=", "self", ".", "tag", ",", "stream", "=", "True", ",", "decode", "=", "True", ")", ":", "log...
Pull this image from registry. Raises an exception if the image is not found in the registry. :return: None
[ "Pull", "this", "image", "from", "registry", ".", "Raises", "an", "exception", "if", "the", "image", "is", "not", "found", "in", "the", "registry", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L185-L202
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.using_transport
def using_transport(self, transport=None, path=None, logs=True): """ change used transport :param transport: from where will be this image copied :param path in filesystem :param logs enable/disable :return: self """ if not transport: return self ...
python
def using_transport(self, transport=None, path=None, logs=True): """ change used transport :param transport: from where will be this image copied :param path in filesystem :param logs enable/disable :return: self """ if not transport: return self ...
[ "def", "using_transport", "(", "self", ",", "transport", "=", "None", ",", "path", "=", "None", ",", "logs", "=", "True", ")", ":", "if", "not", "transport", ":", "return", "self", "if", "self", ".", "transport", "==", "transport", "and", "self", ".", ...
change used transport :param transport: from where will be this image copied :param path in filesystem :param logs enable/disable :return: self
[ "change", "used", "transport" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L230-L264
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.save_to
def save_to(self, image): """ Save this image to another DockerImage :param image: DockerImage :return: """ if not isinstance(image, self.__class__): raise ConuException("Invalid target image type", type(image)) self.copy(image.name, image.tag, ...
python
def save_to(self, image): """ Save this image to another DockerImage :param image: DockerImage :return: """ if not isinstance(image, self.__class__): raise ConuException("Invalid target image type", type(image)) self.copy(image.name, image.tag, ...
[ "def", "save_to", "(", "self", ",", "image", ")", ":", "if", "not", "isinstance", "(", "image", ",", "self", ".", "__class__", ")", ":", "raise", "ConuException", "(", "\"Invalid target image type\"", ",", "type", "(", "image", ")", ")", "self", ".", "co...
Save this image to another DockerImage :param image: DockerImage :return:
[ "Save", "this", "image", "to", "another", "DockerImage" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L266-L276
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.load_from
def load_from(self, image): """ Load from another DockerImage to this one :param image: :return: """ if not isinstance(image, self.__class__): raise ConuException("Invalid source image type", type(image)) image.save_to(self)
python
def load_from(self, image): """ Load from another DockerImage to this one :param image: :return: """ if not isinstance(image, self.__class__): raise ConuException("Invalid source image type", type(image)) image.save_to(self)
[ "def", "load_from", "(", "self", ",", "image", ")", ":", "if", "not", "isinstance", "(", "image", ",", "self", ".", "__class__", ")", ":", "raise", "ConuException", "(", "\"Invalid source image type\"", ",", "type", "(", "image", ")", ")", "image", ".", ...
Load from another DockerImage to this one :param image: :return:
[ "Load", "from", "another", "DockerImage", "to", "this", "one" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L278-L286
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.skopeo_pull
def skopeo_pull(self): """ Pull image from Docker to local Docker daemon using skopeo :return: pulled image """ return self.copy(self.name, self.tag, SkopeoTransport.DOCKER, SkopeoTransport.DOCKER_DAEMON)\ .using_transport(SkopeoTransport.DOCKER_DAEM...
python
def skopeo_pull(self): """ Pull image from Docker to local Docker daemon using skopeo :return: pulled image """ return self.copy(self.name, self.tag, SkopeoTransport.DOCKER, SkopeoTransport.DOCKER_DAEMON)\ .using_transport(SkopeoTransport.DOCKER_DAEM...
[ "def", "skopeo_pull", "(", "self", ")", ":", "return", "self", ".", "copy", "(", "self", ".", "name", ",", "self", ".", "tag", ",", "SkopeoTransport", ".", "DOCKER", ",", "SkopeoTransport", ".", "DOCKER_DAEMON", ")", ".", "using_transport", "(", "SkopeoTra...
Pull image from Docker to local Docker daemon using skopeo :return: pulled image
[ "Pull", "image", "from", "Docker", "to", "local", "Docker", "daemon", "using", "skopeo" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L288-L295
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.skopeo_push
def skopeo_push(self, repository=None, tag=None): """ Push image from Docker daemon to Docker using skopeo :param repository: repository to be pushed to :param tag: tag :return: pushed image """ return self.copy(repository, tag, SkopeoTransport.DOCKER_DAEMON, SkopeoTrans...
python
def skopeo_push(self, repository=None, tag=None): """ Push image from Docker daemon to Docker using skopeo :param repository: repository to be pushed to :param tag: tag :return: pushed image """ return self.copy(repository, tag, SkopeoTransport.DOCKER_DAEMON, SkopeoTrans...
[ "def", "skopeo_push", "(", "self", ",", "repository", "=", "None", ",", "tag", "=", "None", ")", ":", "return", "self", ".", "copy", "(", "repository", ",", "tag", ",", "SkopeoTransport", ".", "DOCKER_DAEMON", ",", "SkopeoTransport", ".", "DOCKER", ")", ...
Push image from Docker daemon to Docker using skopeo :param repository: repository to be pushed to :param tag: tag :return: pushed image
[ "Push", "image", "from", "Docker", "daemon", "to", "Docker", "using", "skopeo" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L297-L305
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.copy
def copy(self, repository=None, tag=None, source_transport=None, target_transport=SkopeoTransport.DOCKER, source_path=None, target_path=None, logs=True): """ Copy this image :param repository to be copied to :param tag :param source_tr...
python
def copy(self, repository=None, tag=None, source_transport=None, target_transport=SkopeoTransport.DOCKER, source_path=None, target_path=None, logs=True): """ Copy this image :param repository to be copied to :param tag :param source_tr...
[ "def", "copy", "(", "self", ",", "repository", "=", "None", ",", "tag", "=", "None", ",", "source_transport", "=", "None", ",", "target_transport", "=", "SkopeoTransport", ".", "DOCKER", ",", "source_path", "=", "None", ",", "target_path", "=", "None", ","...
Copy this image :param repository to be copied to :param tag :param source_transport Transport :param target_transport Transport :param source_path needed to specify for dir, docker-archive or oci transport :param target_path needed to specify for dir, docker-archive or ...
[ "Copy", "this", "image" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L307-L340
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.tag_image
def tag_image(self, repository=None, tag=None): """ Apply additional tags to the image or even add a new name :param repository: str, see constructor :param tag: str, see constructor :return: instance of DockerImage """ if not (repository or tag): rai...
python
def tag_image(self, repository=None, tag=None): """ Apply additional tags to the image or even add a new name :param repository: str, see constructor :param tag: str, see constructor :return: instance of DockerImage """ if not (repository or tag): rai...
[ "def", "tag_image", "(", "self", ",", "repository", "=", "None", ",", "tag", "=", "None", ")", ":", "if", "not", "(", "repository", "or", "tag", ")", ":", "raise", "ValueError", "(", "\"You need to specify either repository or tag.\"", ")", "r", "=", "reposi...
Apply additional tags to the image or even add a new name :param repository: str, see constructor :param tag: str, see constructor :return: instance of DockerImage
[ "Apply", "additional", "tags", "to", "the", "image", "or", "even", "add", "a", "new", "name" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L342-L355
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.inspect
def inspect(self, refresh=True): """ provide metadata about the image; flip refresh=True if cached metadata are enough :param refresh: bool, update the metadata with up to date content :return: dict """ if refresh or not self._inspect_data: identifier = self....
python
def inspect(self, refresh=True): """ provide metadata about the image; flip refresh=True if cached metadata are enough :param refresh: bool, update the metadata with up to date content :return: dict """ if refresh or not self._inspect_data: identifier = self....
[ "def", "inspect", "(", "self", ",", "refresh", "=", "True", ")", ":", "if", "refresh", "or", "not", "self", ".", "_inspect_data", ":", "identifier", "=", "self", ".", "_id", "or", "self", ".", "get_full_name", "(", ")", "if", "not", "identifier", ":", ...
provide metadata about the image; flip refresh=True if cached metadata are enough :param refresh: bool, update the metadata with up to date content :return: dict
[ "provide", "metadata", "about", "the", "image", ";", "flip", "refresh", "=", "True", "if", "cached", "metadata", "are", "enough" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L357-L369
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.has_pkgs_signed_with
def has_pkgs_signed_with(self, allowed_keys): """ Check signature of packages installed in image. Raises exception when * rpm binary is not installed in image * parsing of rpm fails * there are packages in image that are not signed with one of allowed keys :para...
python
def has_pkgs_signed_with(self, allowed_keys): """ Check signature of packages installed in image. Raises exception when * rpm binary is not installed in image * parsing of rpm fails * there are packages in image that are not signed with one of allowed keys :para...
[ "def", "has_pkgs_signed_with", "(", "self", ",", "allowed_keys", ")", ":", "if", "not", "allowed_keys", "or", "not", "isinstance", "(", "allowed_keys", ",", "list", ")", ":", "raise", "ConuException", "(", "\"allowed_keys must be a list\"", ")", "command", "=", ...
Check signature of packages installed in image. Raises exception when * rpm binary is not installed in image * parsing of rpm fails * there are packages in image that are not signed with one of allowed keys :param allowed_keys: list of allowed keys :return: bool
[ "Check", "signature", "of", "packages", "installed", "in", "image", ".", "Raises", "exception", "when" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L639-L662
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.build
def build(cls, path, tag=None, dockerfile=None): """ Build the image from the provided dockerfile in path :param path : str, path to the directory containing the Dockerfile :param tag: str, A tag to add to the final image :param dockerfile: str, path within the build context to ...
python
def build(cls, path, tag=None, dockerfile=None): """ Build the image from the provided dockerfile in path :param path : str, path to the directory containing the Dockerfile :param tag: str, A tag to add to the final image :param dockerfile: str, path within the build context to ...
[ "def", "build", "(", "cls", ",", "path", ",", "tag", "=", "None", ",", "dockerfile", "=", "None", ")", ":", "if", "not", "path", ":", "raise", "ConuException", "(", "'Please specify path to the directory containing the Dockerfile'", ")", "client", "=", "get_clie...
Build the image from the provided dockerfile in path :param path : str, path to the directory containing the Dockerfile :param tag: str, A tag to add to the final image :param dockerfile: str, path within the build context to the Dockerfile :return: instance of DockerImage
[ "Build", "the", "image", "from", "the", "provided", "dockerfile", "in", "path" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L681-L711
train
user-cont/conu
conu/backend/docker/image.py
DockerImage.layers
def layers(self, rev=True): """ Get list of DockerImage for every layer in image :param rev: get layers rev :return: list of DockerImages """ image_layers = [ DockerImage(None, identifier=x, pull_policy=DockerImagePullPolicy.NEVER) for x in self.g...
python
def layers(self, rev=True): """ Get list of DockerImage for every layer in image :param rev: get layers rev :return: list of DockerImages """ image_layers = [ DockerImage(None, identifier=x, pull_policy=DockerImagePullPolicy.NEVER) for x in self.g...
[ "def", "layers", "(", "self", ",", "rev", "=", "True", ")", ":", "image_layers", "=", "[", "DockerImage", "(", "None", ",", "identifier", "=", "x", ",", "pull_policy", "=", "DockerImagePullPolicy", ".", "NEVER", ")", "for", "x", "in", "self", ".", "get...
Get list of DockerImage for every layer in image :param rev: get layers rev :return: list of DockerImages
[ "Get", "list", "of", "DockerImage", "for", "every", "layer", "in", "image" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L725-L738
train
user-cont/conu
conu/backend/docker/image.py
S2IDockerImage.extend
def extend(self, source, new_image_name, s2i_args=None): """ extend this s2i-enabled image using provided source, raises ConuException if `s2i build` fails :param source: str, source used to extend the image, can be path or url :param new_image_name: str, name of the new, extend...
python
def extend(self, source, new_image_name, s2i_args=None): """ extend this s2i-enabled image using provided source, raises ConuException if `s2i build` fails :param source: str, source used to extend the image, can be path or url :param new_image_name: str, name of the new, extend...
[ "def", "extend", "(", "self", ",", "source", ",", "new_image_name", ",", "s2i_args", "=", "None", ")", ":", "s2i_args", "=", "s2i_args", "or", "[", "]", "c", "=", "self", ".", "_s2i_command", "(", "[", "\"build\"", "]", "+", "s2i_args", "+", "[", "so...
extend this s2i-enabled image using provided source, raises ConuException if `s2i build` fails :param source: str, source used to extend the image, can be path or url :param new_image_name: str, name of the new, extended image :param s2i_args: list of str, additional options and argumen...
[ "extend", "this", "s2i", "-", "enabled", "image", "using", "provided", "source", "raises", "ConuException", "if", "s2i", "build", "fails" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L775-L793
train
user-cont/conu
conu/backend/docker/image.py
S2IDockerImage.usage
def usage(self): """ Provide output of `s2i usage` :return: str """ c = self._s2i_command(["usage", self.get_full_name()]) with open(os.devnull, "w") as fd: process = subprocess.Popen(c, stdout=fd, stderr=subprocess.PIPE) _, output = process.commu...
python
def usage(self): """ Provide output of `s2i usage` :return: str """ c = self._s2i_command(["usage", self.get_full_name()]) with open(os.devnull, "w") as fd: process = subprocess.Popen(c, stdout=fd, stderr=subprocess.PIPE) _, output = process.commu...
[ "def", "usage", "(", "self", ")", ":", "c", "=", "self", ".", "_s2i_command", "(", "[", "\"usage\"", ",", "self", ".", "get_full_name", "(", ")", "]", ")", "with", "open", "(", "os", ".", "devnull", ",", "\"w\"", ")", "as", "fd", ":", "process", ...
Provide output of `s2i usage` :return: str
[ "Provide", "output", "of", "s2i", "usage" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L795-L808
train
user-cont/conu
conu/backend/origin/backend.py
OpenshiftBackend.http_request
def http_request(self, path="/", method="GET", host=None, port=None, json=False, data=None): """ perform a HTTP request :param path: str, path within the request, e.g. "/api/version" :param method: str, HTTP method :param host: str, if None, set to 127.0.0.1 :param port:...
python
def http_request(self, path="/", method="GET", host=None, port=None, json=False, data=None): """ perform a HTTP request :param path: str, path within the request, e.g. "/api/version" :param method: str, HTTP method :param host: str, if None, set to 127.0.0.1 :param port:...
[ "def", "http_request", "(", "self", ",", "path", "=", "\"/\"", ",", "method", "=", "\"GET\"", ",", "host", "=", "None", ",", "port", "=", "None", ",", "json", "=", "False", ",", "data", "=", "None", ")", ":", "host", "=", "host", "or", "'127.0.0.1'...
perform a HTTP request :param path: str, path within the request, e.g. "/api/version" :param method: str, HTTP method :param host: str, if None, set to 127.0.0.1 :param port: str or int, if None, set to 8080 :param json: bool, should we expect json? :param data: data to ...
[ "perform", "a", "HTTP", "request" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/origin/backend.py#L62-L79
train
user-cont/conu
conu/backend/nspawn/image.py
NspawnImage.system_requirements
def system_requirements(): """ Check if all necessary packages are installed on system :return: None or raise exception if some tooling is missing """ command_exists("systemd-nspawn", ["systemd-nspawn", "--version"], "Command systemd-nspawn does not seems...
python
def system_requirements(): """ Check if all necessary packages are installed on system :return: None or raise exception if some tooling is missing """ command_exists("systemd-nspawn", ["systemd-nspawn", "--version"], "Command systemd-nspawn does not seems...
[ "def", "system_requirements", "(", ")", ":", "command_exists", "(", "\"systemd-nspawn\"", ",", "[", "\"systemd-nspawn\"", ",", "\"--version\"", "]", ",", "\"Command systemd-nspawn does not seems to be present on your system\"", "\"Do you have system with systemd\"", ")", "command...
Check if all necessary packages are installed on system :return: None or raise exception if some tooling is missing
[ "Check", "if", "all", "necessary", "packages", "are", "installed", "on", "system" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L156-L173
train
user-cont/conu
conu/backend/nspawn/image.py
NspawnImage._generate_id
def _generate_id(self): """ create new unique identifier """ name = self.name.replace(self.special_separator, "-").replace(".", "-") loc = "\/" if self.location: loc = self.location _id = "{PREFIX}{SEP}{NAME}{HASH}{SEP}".format( PREFIX=constants.CONU_ARTIF...
python
def _generate_id(self): """ create new unique identifier """ name = self.name.replace(self.special_separator, "-").replace(".", "-") loc = "\/" if self.location: loc = self.location _id = "{PREFIX}{SEP}{NAME}{HASH}{SEP}".format( PREFIX=constants.CONU_ARTIF...
[ "def", "_generate_id", "(", "self", ")", ":", "name", "=", "self", ".", "name", ".", "replace", "(", "self", ".", "special_separator", ",", "\"-\"", ")", ".", "replace", "(", "\".\"", ",", "\"-\"", ")", "loc", "=", "\"\\/\"", "if", "self", ".", "loca...
create new unique identifier
[ "create", "new", "unique", "identifier" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L209-L221
train
user-cont/conu
conu/backend/nspawn/image.py
NspawnImage.pull
def pull(self): """ Pull this image from URL. :return: None """ if not os.path.exists(CONU_IMAGES_STORE): os.makedirs(CONU_IMAGES_STORE) logger.debug( "Try to pull: {} -> {}".format(self.location, self.local_location)) if not self._is_loc...
python
def pull(self): """ Pull this image from URL. :return: None """ if not os.path.exists(CONU_IMAGES_STORE): os.makedirs(CONU_IMAGES_STORE) logger.debug( "Try to pull: {} -> {}".format(self.location, self.local_location)) if not self._is_loc...
[ "def", "pull", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "CONU_IMAGES_STORE", ")", ":", "os", ".", "makedirs", "(", "CONU_IMAGES_STORE", ")", "logger", ".", "debug", "(", "\"Try to pull: {} -> {}\"", ".", "format", "(", "...
Pull this image from URL. :return: None
[ "Pull", "this", "image", "from", "URL", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L232-L253
train
user-cont/conu
conu/backend/nspawn/image.py
NspawnImage.run_via_binary
def run_via_binary(self, command=None, foreground=False, volumes=None, additional_opts=None, default_options=None, name=None, *args, **kwargs): """ Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process object :param ...
python
def run_via_binary(self, command=None, foreground=False, volumes=None, additional_opts=None, default_options=None, name=None, *args, **kwargs): """ Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process object :param ...
[ "def", "run_via_binary", "(", "self", ",", "command", "=", "None", ",", "foreground", "=", "False", ",", "volumes", "=", "None", ",", "additional_opts", "=", "None", ",", "default_options", "=", "None", ",", "name", "=", "None", ",", "*", "args", ",", ...
Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process object :param command: list - command to run :param foreground: bool - run process at foreground :param volumes: list - put additional bind mounts :param additional_o...
[ "Create", "new", "instance", "NspawnContianer", "in", "case", "of", "not", "running", "at", "foreground", "in", "case", "foreground", "run", "return", "process", "object" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L345-L403
train
user-cont/conu
conu/utils/rpms.py
process_rpm_ql_line
def process_rpm_ql_line(line_str, allowed_keys): """ Checks single line of rpm-ql for correct keys :param line_str: line to process :param allowed_keys: list of allowed keys :return: bool """ try: name, key_str = line_str.split(' ', 1) except ValueError: logger.error("Fa...
python
def process_rpm_ql_line(line_str, allowed_keys): """ Checks single line of rpm-ql for correct keys :param line_str: line to process :param allowed_keys: list of allowed keys :return: bool """ try: name, key_str = line_str.split(' ', 1) except ValueError: logger.error("Fa...
[ "def", "process_rpm_ql_line", "(", "line_str", ",", "allowed_keys", ")", ":", "try", ":", "name", ",", "key_str", "=", "line_str", ".", "split", "(", "' '", ",", "1", ")", "except", "ValueError", ":", "logger", ".", "error", "(", "\"Failed to split line '{0}...
Checks single line of rpm-ql for correct keys :param line_str: line to process :param allowed_keys: list of allowed keys :return: bool
[ "Checks", "single", "line", "of", "rpm", "-", "ql", "for", "correct", "keys" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/rpms.py#L29-L55
train
user-cont/conu
conu/utils/rpms.py
check_signatures
def check_signatures(pkg_list, allowed_keys): """ Go through list of packages with signatures and check if all are properly signed :param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}' :param allowed_keys: list of allowed keys :return: bool """ all_passed = True for lin...
python
def check_signatures(pkg_list, allowed_keys): """ Go through list of packages with signatures and check if all are properly signed :param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}' :param allowed_keys: list of allowed keys :return: bool """ all_passed = True for lin...
[ "def", "check_signatures", "(", "pkg_list", ",", "allowed_keys", ")", ":", "all_passed", "=", "True", "for", "line_str", "in", "pkg_list", ":", "all_passed", "&=", "process_rpm_ql_line", "(", "line_str", ".", "strip", "(", ")", ",", "allowed_keys", ")", "if", ...
Go through list of packages with signatures and check if all are properly signed :param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}' :param allowed_keys: list of allowed keys :return: bool
[ "Go", "through", "list", "of", "packages", "with", "signatures", "and", "check", "if", "all", "are", "properly", "signed" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/rpms.py#L58-L72
train
user-cont/conu
conu/backend/docker/container.py
DockerContainer.get_ports
def get_ports(self): """ get ports specified in container metadata :return: list of str """ ports = [] container_ports = self.inspect(refresh=True)["NetworkSettings"]["Ports"] if not container_ports: return ports for p in container_ports: ...
python
def get_ports(self): """ get ports specified in container metadata :return: list of str """ ports = [] container_ports = self.inspect(refresh=True)["NetworkSettings"]["Ports"] if not container_ports: return ports for p in container_ports: ...
[ "def", "get_ports", "(", "self", ")", ":", "ports", "=", "[", "]", "container_ports", "=", "self", ".", "inspect", "(", "refresh", "=", "True", ")", "[", "\"NetworkSettings\"", "]", "[", "\"Ports\"", "]", "if", "not", "container_ports", ":", "return", "p...
get ports specified in container metadata :return: list of str
[ "get", "ports", "specified", "in", "container", "metadata" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/container.py#L350-L363
train
user-cont/conu
conu/apidefs/backend.py
Backend._clean_tmp_dirs
def _clean_tmp_dirs(self): """ Remove temporary dir associated with this backend instance. :return: None """ def onerror(fnc, path, excinfo): # we might not have rights to do this, the files could be owned by root self.logger.info("we were not able to re...
python
def _clean_tmp_dirs(self): """ Remove temporary dir associated with this backend instance. :return: None """ def onerror(fnc, path, excinfo): # we might not have rights to do this, the files could be owned by root self.logger.info("we were not able to re...
[ "def", "_clean_tmp_dirs", "(", "self", ")", ":", "def", "onerror", "(", "fnc", ",", "path", ",", "excinfo", ")", ":", "# we might not have rights to do this, the files could be owned by root", "self", ".", "logger", ".", "info", "(", "\"we were not able to remove tempor...
Remove temporary dir associated with this backend instance. :return: None
[ "Remove", "temporary", "dir", "associated", "with", "this", "backend", "instance", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/backend.py#L147-L161
train
user-cont/conu
conu/apidefs/backend.py
Backend._clean
def _clean(self): """ Method for cleaning according to object cleanup policy value :return: None """ if CleanupPolicy.EVERYTHING in self.cleanup: self.cleanup_containers() self.cleanup_volumes() self.cleanup_images() ...
python
def _clean(self): """ Method for cleaning according to object cleanup policy value :return: None """ if CleanupPolicy.EVERYTHING in self.cleanup: self.cleanup_containers() self.cleanup_volumes() self.cleanup_images() ...
[ "def", "_clean", "(", "self", ")", ":", "if", "CleanupPolicy", ".", "EVERYTHING", "in", "self", ".", "cleanup", ":", "self", ".", "cleanup_containers", "(", ")", "self", ".", "cleanup_volumes", "(", ")", "self", ".", "cleanup_images", "(", ")", "self", "...
Method for cleaning according to object cleanup policy value :return: None
[ "Method", "for", "cleaning", "according", "to", "object", "cleanup", "policy", "value" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/backend.py#L187-L206
train
user-cont/conu
conu/backend/nspawn/backend.py
NspawnBackend.list_containers
def list_containers(self): """ list all available nspawn containers :return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer` """ data = run_cmd(["machinectl", "list", "--no-legend", "--no-pager"], return_output=True) ...
python
def list_containers(self): """ list all available nspawn containers :return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer` """ data = run_cmd(["machinectl", "list", "--no-legend", "--no-pager"], return_output=True) ...
[ "def", "list_containers", "(", "self", ")", ":", "data", "=", "run_cmd", "(", "[", "\"machinectl\"", ",", "\"list\"", ",", "\"--no-legend\"", ",", "\"--no-pager\"", "]", ",", "return_output", "=", "True", ")", "output", "=", "[", "]", "reg", "=", "re", "...
list all available nspawn containers :return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer`
[ "list", "all", "available", "nspawn", "containers" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L44-L60
train
user-cont/conu
conu/backend/nspawn/backend.py
NspawnBackend.list_images
def list_images(self): """ list all available nspawn images :return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage` """ # Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \ # Sun 2017-11-05 08:30:10 CET data...
python
def list_images(self): """ list all available nspawn images :return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage` """ # Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \ # Sun 2017-11-05 08:30:10 CET data...
[ "def", "list_images", "(", "self", ")", ":", "# Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \\", "# Sun 2017-11-05 08:30:10 CET", "data", "=", "os", ".", "listdir", "(", "CONU_IMAGES_STORE", ")", "output", "=", "[", "]", "for", "name", "i...
list all available nspawn images :return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage`
[ "list", "all", "available", "nspawn", "images" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L62-L74
train
user-cont/conu
conu/backend/nspawn/backend.py
NspawnBackend.cleanup_containers
def cleanup_containers(self): """ stop all container created by conu :return: None """ for cont in self.list_containers(): if CONU_ARTIFACT_TAG in cont.name: try: logger.debug("removing container %s created by conu", cont) ...
python
def cleanup_containers(self): """ stop all container created by conu :return: None """ for cont in self.list_containers(): if CONU_ARTIFACT_TAG in cont.name: try: logger.debug("removing container %s created by conu", cont) ...
[ "def", "cleanup_containers", "(", "self", ")", ":", "for", "cont", "in", "self", ".", "list_containers", "(", ")", ":", "if", "CONU_ARTIFACT_TAG", "in", "cont", ".", "name", ":", "try", ":", "logger", ".", "debug", "(", "\"removing container %s created by conu...
stop all container created by conu :return: None
[ "stop", "all", "container", "created", "by", "conu" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L76-L89
train
user-cont/conu
conu/utils/__init__.py
check_port
def check_port(port, host, timeout=10): """ connect to port on host and return True on success :param port: int, port to check :param host: string, host address :param timeout: int, number of seconds spent trying :return: bool """ logger.info("trying to open connection to %s:%s", host, ...
python
def check_port(port, host, timeout=10): """ connect to port on host and return True on success :param port: int, port to check :param host: string, host address :param timeout: int, number of seconds spent trying :return: bool """ logger.info("trying to open connection to %s:%s", host, ...
[ "def", "check_port", "(", "port", ",", "host", ",", "timeout", "=", "10", ")", ":", "logger", ".", "info", "(", "\"trying to open connection to %s:%s\"", ",", "host", ",", "port", ")", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ...
connect to port on host and return True on success :param port: int, port to check :param host: string, host address :param timeout: int, number of seconds spent trying :return: bool
[ "connect", "to", "port", "on", "host", "and", "return", "True", "on", "success" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L54-L76
train
user-cont/conu
conu/utils/__init__.py
get_selinux_status
def get_selinux_status(): """ get SELinux status of host :return: string, one of Enforced, Permissive, Disabled """ getenforce_command_exists() # alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is # empty (why?) and enforce doesn't tell whether SELinu...
python
def get_selinux_status(): """ get SELinux status of host :return: string, one of Enforced, Permissive, Disabled """ getenforce_command_exists() # alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is # empty (why?) and enforce doesn't tell whether SELinu...
[ "def", "get_selinux_status", "(", ")", ":", "getenforce_command_exists", "(", ")", "# alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is", "# empty (why?) and enforce doesn't tell whether SELinux is disabled or not", "o", "=", "run_cmd", "(", "[", ...
get SELinux status of host :return: string, one of Enforced, Permissive, Disabled
[ "get", "SELinux", "status", "of", "host" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L79-L90
train
user-cont/conu
conu/utils/__init__.py
random_str
def random_str(size=10): """ create random string of selected size :param size: int, length of the string :return: the string """ return ''.join(random.choice(string.ascii_lowercase) for _ in range(size))
python
def random_str(size=10): """ create random string of selected size :param size: int, length of the string :return: the string """ return ''.join(random.choice(string.ascii_lowercase) for _ in range(size))
[ "def", "random_str", "(", "size", "=", "10", ")", ":", "return", "''", ".", "join", "(", "random", ".", "choice", "(", "string", ".", "ascii_lowercase", ")", "for", "_", "in", "range", "(", "size", ")", ")" ]
create random string of selected size :param size: int, length of the string :return: the string
[ "create", "random", "string", "of", "selected", "size" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L102-L109
train
user-cont/conu
conu/utils/__init__.py
run_cmd
def run_cmd(cmd, return_output=False, ignore_status=False, log_output=True, **kwargs): """ run provided command on host system using the same user as you invoked this code, raises subprocess.CalledProcessError if it fails :param cmd: list of str :param return_output: bool, return output of the comm...
python
def run_cmd(cmd, return_output=False, ignore_status=False, log_output=True, **kwargs): """ run provided command on host system using the same user as you invoked this code, raises subprocess.CalledProcessError if it fails :param cmd: list of str :param return_output: bool, return output of the comm...
[ "def", "run_cmd", "(", "cmd", ",", "return_output", "=", "False", ",", "ignore_status", "=", "False", ",", "log_output", "=", "True", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'command: \"%s\"'", "%", "' '", ".", "join", "(", "cm...
run provided command on host system using the same user as you invoked this code, raises subprocess.CalledProcessError if it fails :param cmd: list of str :param return_output: bool, return output of the command :param ignore_status: bool, do not fail in case nonzero return code :param log_output: ...
[ "run", "provided", "command", "on", "host", "system", "using", "the", "same", "user", "as", "you", "invoked", "this", "code", "raises", "subprocess", ".", "CalledProcessError", "if", "it", "fails" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L112-L141
train
user-cont/conu
conu/utils/__init__.py
command_exists
def command_exists(command, noop_invocation, exc_msg): """ Verify that the provided command exists. Raise CommandDoesNotExistException in case of an error or if the command does not exist. :param command: str, command to check (python 3 only) :param noop_invocation: list of str, command to check (p...
python
def command_exists(command, noop_invocation, exc_msg): """ Verify that the provided command exists. Raise CommandDoesNotExistException in case of an error or if the command does not exist. :param command: str, command to check (python 3 only) :param noop_invocation: list of str, command to check (p...
[ "def", "command_exists", "(", "command", ",", "noop_invocation", ",", "exc_msg", ")", ":", "try", ":", "found", "=", "bool", "(", "shutil", ".", "which", "(", "command", ")", ")", "# py3 only", "except", "AttributeError", ":", "# py2 branch", "try", ":", "...
Verify that the provided command exists. Raise CommandDoesNotExistException in case of an error or if the command does not exist. :param command: str, command to check (python 3 only) :param noop_invocation: list of str, command to check (python 2 only) :param exc_msg: str, message of exception when co...
[ "Verify", "that", "the", "provided", "command", "exists", ".", "Raise", "CommandDoesNotExistException", "in", "case", "of", "an", "error", "or", "if", "the", "command", "does", "not", "exist", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L173-L200
train
user-cont/conu
conu/utils/__init__.py
check_docker_command_works
def check_docker_command_works(): """ Verify that dockerd and docker binary works fine. This is performed by calling `docker version`, which also checks server API version. :return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException is thrown """ tr...
python
def check_docker_command_works(): """ Verify that dockerd and docker binary works fine. This is performed by calling `docker version`, which also checks server API version. :return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException is thrown """ tr...
[ "def", "check_docker_command_works", "(", ")", ":", "try", ":", "out", "=", "subprocess", ".", "check_output", "(", "[", "\"docker\"", ",", "\"version\"", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ",", "universal_newlines", "=", "True", ")", "exc...
Verify that dockerd and docker binary works fine. This is performed by calling `docker version`, which also checks server API version. :return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException is thrown
[ "Verify", "that", "dockerd", "and", "docker", "binary", "works", "fine", ".", "This", "is", "performed", "by", "calling", "docker", "version", "which", "also", "checks", "server", "API", "version", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L250-L277
train
user-cont/conu
conu/utils/__init__.py
export_docker_container_to_directory
def export_docker_container_to_directory(client, container, path): """ take selected docker container, create an archive out of it and unpack it to a selected location :param client: instance of docker.APIClient :param container: instance of DockerContainer :param path: str, path to a directory...
python
def export_docker_container_to_directory(client, container, path): """ take selected docker container, create an archive out of it and unpack it to a selected location :param client: instance of docker.APIClient :param container: instance of DockerContainer :param path: str, path to a directory...
[ "def", "export_docker_container_to_directory", "(", "client", ",", "container", ",", "path", ")", ":", "# we don't do this because of a bug in docker:", "# https://bugzilla.redhat.com/show_bug.cgi?id=1570828", "# stream, _ = client.get_archive(container.get_id(), \"/\")", "check_docker_com...
take selected docker container, create an archive out of it and unpack it to a selected location :param client: instance of docker.APIClient :param container: instance of DockerContainer :param path: str, path to a directory, doesn't need to exist :return: None
[ "take", "selected", "docker", "container", "create", "an", "archive", "out", "of", "it", "and", "unpack", "it", "to", "a", "selected", "location" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L335-L386
train
user-cont/conu
conu/backend/podman/backend.py
PodmanBackend.get_version
def get_version(self): """ return 3-tuple of version info or None :return: (str, str, str) """ raw_version = run_cmd(["podman", "version"], return_output=True) regex = re.compile(r"Version:\s*(\d+)\.(\d+)\.(\d+)") match = regex.findall(raw_version) try: ...
python
def get_version(self): """ return 3-tuple of version info or None :return: (str, str, str) """ raw_version = run_cmd(["podman", "version"], return_output=True) regex = re.compile(r"Version:\s*(\d+)\.(\d+)\.(\d+)") match = regex.findall(raw_version) try: ...
[ "def", "get_version", "(", "self", ")", ":", "raw_version", "=", "run_cmd", "(", "[", "\"podman\"", ",", "\"version\"", "]", ",", "return_output", "=", "True", ")", "regex", "=", "re", ".", "compile", "(", "r\"Version:\\s*(\\d+)\\.(\\d+)\\.(\\d+)\"", ")", "mat...
return 3-tuple of version info or None :return: (str, str, str)
[ "return", "3", "-", "tuple", "of", "version", "info", "or", "None" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L92-L105
train
user-cont/conu
conu/backend/podman/backend.py
PodmanBackend.list_containers
def list_containers(self): """ List all available podman containers. :return: collection of instances of :class:`conu.PodmanContainer` """ containers = [] for container in self._list_podman_containers(): identifier = container["ID"] name = contain...
python
def list_containers(self): """ List all available podman containers. :return: collection of instances of :class:`conu.PodmanContainer` """ containers = [] for container in self._list_podman_containers(): identifier = container["ID"] name = contain...
[ "def", "list_containers", "(", "self", ")", ":", "containers", "=", "[", "]", "for", "container", "in", "self", ".", "_list_podman_containers", "(", ")", ":", "identifier", "=", "container", "[", "\"ID\"", "]", "name", "=", "container", "[", "\"Names\"", "...
List all available podman containers. :return: collection of instances of :class:`conu.PodmanContainer`
[ "List", "all", "available", "podman", "containers", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L116-L137
train
user-cont/conu
conu/backend/podman/backend.py
PodmanBackend.list_images
def list_images(self): """ List all available podman images. :return: collection of instances of :class:`conu.PodmanImage` """ images = [] for image in self._list_all_podman_images(): try: i_name, tag = parse_reference(image["names"][0]) ...
python
def list_images(self): """ List all available podman images. :return: collection of instances of :class:`conu.PodmanImage` """ images = [] for image in self._list_all_podman_images(): try: i_name, tag = parse_reference(image["names"][0]) ...
[ "def", "list_images", "(", "self", ")", ":", "images", "=", "[", "]", "for", "image", "in", "self", ".", "_list_all_podman_images", "(", ")", ":", "try", ":", "i_name", ",", "tag", "=", "parse_reference", "(", "image", "[", "\"names\"", "]", "[", "0", ...
List all available podman images. :return: collection of instances of :class:`conu.PodmanImage`
[ "List", "all", "available", "podman", "images", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L139-L155
train
user-cont/conu
conu/backend/docker/utils.py
inspect_to_metadata
def inspect_to_metadata(metadata_object, inspect_data): """ process data from `docker inspect` and update provided metadata object :param metadata_object: instance of Metadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :return: instance of Metadata ""...
python
def inspect_to_metadata(metadata_object, inspect_data): """ process data from `docker inspect` and update provided metadata object :param metadata_object: instance of Metadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :return: instance of Metadata ""...
[ "def", "inspect_to_metadata", "(", "metadata_object", ",", "inspect_data", ")", ":", "identifier", "=", "graceful_get", "(", "inspect_data", ",", "'Id'", ")", "if", "identifier", ":", "if", "\":\"", "in", "identifier", ":", "# format of image name from docker inspect:...
process data from `docker inspect` and update provided metadata object :param metadata_object: instance of Metadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :return: instance of Metadata
[ "process", "data", "from", "docker", "inspect", "and", "update", "provided", "metadata", "object" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L13-L62
train
user-cont/conu
conu/backend/docker/utils.py
inspect_to_container_metadata
def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance): """ process data from `docker container inspect` and update provided container metadata object :param c_metadata_object: instance of ContainerMetadata :param inspect_data: dict, metadata from `docker inspect` or `docker...
python
def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance): """ process data from `docker container inspect` and update provided container metadata object :param c_metadata_object: instance of ContainerMetadata :param inspect_data: dict, metadata from `docker inspect` or `docker...
[ "def", "inspect_to_container_metadata", "(", "c_metadata_object", ",", "inspect_data", ",", "image_instance", ")", ":", "inspect_to_metadata", "(", "c_metadata_object", ",", "inspect_data", ")", "status", "=", "ContainerStatus", ".", "get_from_docker", "(", "graceful_get"...
process data from `docker container inspect` and update provided container metadata object :param c_metadata_object: instance of ContainerMetadata :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()` :param image_instance: instance of DockerImage :return: instance of C...
[ "process", "data", "from", "docker", "container", "inspect", "and", "update", "provided", "container", "metadata", "object" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L65-L132
train
user-cont/conu
conu/backend/k8s/backend.py
K8sBackend.list_pods
def list_pods(self, namespace=None): """ List all available pods. :param namespace: str, if not specified list pods for all namespaces :return: collection of instances of :class:`conu.backend.k8s.pod.Pod` """ if namespace: return [Pod(name=p.metadata.name, n...
python
def list_pods(self, namespace=None): """ List all available pods. :param namespace: str, if not specified list pods for all namespaces :return: collection of instances of :class:`conu.backend.k8s.pod.Pod` """ if namespace: return [Pod(name=p.metadata.name, n...
[ "def", "list_pods", "(", "self", ",", "namespace", "=", "None", ")", ":", "if", "namespace", ":", "return", "[", "Pod", "(", "name", "=", "p", ".", "metadata", ".", "name", ",", "namespace", "=", "namespace", ",", "spec", "=", "p", ".", "spec", ")"...
List all available pods. :param namespace: str, if not specified list pods for all namespaces :return: collection of instances of :class:`conu.backend.k8s.pod.Pod`
[ "List", "all", "available", "pods", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/k8s/backend.py#L70-L83
train
user-cont/conu
conu/backend/k8s/backend.py
K8sBackend.list_services
def list_services(self, namespace=None): """ List all available services. :param namespace: str, if not specified list services for all namespaces :return: collection of instances of :class:`conu.backend.k8s.service.Service` """ if namespace: return [Service...
python
def list_services(self, namespace=None): """ List all available services. :param namespace: str, if not specified list services for all namespaces :return: collection of instances of :class:`conu.backend.k8s.service.Service` """ if namespace: return [Service...
[ "def", "list_services", "(", "self", ",", "namespace", "=", "None", ")", ":", "if", "namespace", ":", "return", "[", "Service", "(", "name", "=", "s", ".", "metadata", ".", "name", ",", "ports", "=", "k8s_ports_to_metadata_ports", "(", "s", ".", "spec", ...
List all available services. :param namespace: str, if not specified list services for all namespaces :return: collection of instances of :class:`conu.backend.k8s.service.Service`
[ "List", "all", "available", "services", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/k8s/backend.py#L85-L104
train
user-cont/conu
conu/backend/k8s/backend.py
K8sBackend.list_deployments
def list_deployments(self, namespace=None): """ List all available deployments. :param namespace: str, if not specified list deployments for all namespaces :return: collection of instances of :class:`conu.backend.k8s.deployment.Deployment` """ if namespace: ...
python
def list_deployments(self, namespace=None): """ List all available deployments. :param namespace: str, if not specified list deployments for all namespaces :return: collection of instances of :class:`conu.backend.k8s.deployment.Deployment` """ if namespace: ...
[ "def", "list_deployments", "(", "self", ",", "namespace", "=", "None", ")", ":", "if", "namespace", ":", "return", "[", "Deployment", "(", "name", "=", "d", ".", "metadata", ".", "name", ",", "namespace", "=", "d", ".", "metadata", ".", "namespace", ",...
List all available deployments. :param namespace: str, if not specified list deployments for all namespaces :return: collection of instances of :class:`conu.backend.k8s.deployment.Deployment`
[ "List", "all", "available", "deployments", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/k8s/backend.py#L106-L127
train
user-cont/conu
conu/utils/http_client.py
get_url
def get_url(path, host, port, method="http"): """ make url from path, host and port :param method: str :param path: str, path within the request, e.g. "/api/version" :param host: str :param port: str or int :return: str """ return urlunsplit( (method, "%s:%s" % (host, port),...
python
def get_url(path, host, port, method="http"): """ make url from path, host and port :param method: str :param path: str, path within the request, e.g. "/api/version" :param host: str :param port: str or int :return: str """ return urlunsplit( (method, "%s:%s" % (host, port),...
[ "def", "get_url", "(", "path", ",", "host", ",", "port", ",", "method", "=", "\"http\"", ")", ":", "return", "urlunsplit", "(", "(", "method", ",", "\"%s:%s\"", "%", "(", "host", ",", "port", ")", ",", "path", ",", "\"\"", ",", "\"\"", ")", ")" ]
make url from path, host and port :param method: str :param path: str, path within the request, e.g. "/api/version" :param host: str :param port: str or int :return: str
[ "make", "url", "from", "path", "host", "and", "port" ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/http_client.py#L20-L32
train
user-cont/conu
conu/backend/docker/backend.py
DockerBackend.list_containers
def list_containers(self): """ List all available docker containers. Container objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. ...
python
def list_containers(self): """ List all available docker containers. Container objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. ...
[ "def", "list_containers", "(", "self", ")", ":", "result", "=", "[", "]", "for", "c", "in", "self", ".", "d", ".", "containers", "(", "all", "=", "True", ")", ":", "name", "=", "None", "names", "=", "c", ".", "get", "(", "\"Names\"", ",", "None",...
List all available docker containers. Container objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. :return: collection of instances of :class:...
[ "List", "all", "available", "docker", "containers", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/backend.py#L85-L106
train
user-cont/conu
conu/backend/docker/backend.py
DockerBackend.list_images
def list_images(self): """ List all available docker images. Image objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. :return:...
python
def list_images(self): """ List all available docker images. Image objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. :return:...
[ "def", "list_images", "(", "self", ")", ":", "response", "=", "[", "]", "for", "im", "in", "self", ".", "d", ".", "images", "(", ")", ":", "try", ":", "i_name", ",", "tag", "=", "parse_reference", "(", "im", "[", "\"RepoTags\"", "]", "[", "0", "]...
List all available docker images. Image objects returned from this methods will contain a limited amount of metadata in property `short_metadata`. These are just a subset of `.inspect()`, but don't require an API call against dockerd. :return: collection of instances of :class:`conu.Do...
[ "List", "all", "available", "docker", "images", "." ]
08caae7bb6bdd265b55bb106c3da6a7946a5a352
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/backend.py#L108-L129
train
mapbox/mapbox-cli-py
mapboxcli/scripts/mapmatching.py
match
def match(ctx, features, profile, gps_precision): """Mapbox Map Matching API lets you use snap your GPS traces to the OpenStreetMap road and path network. $ mapbox mapmatching trace.geojson An access token is required, see `mapbox --help`. """ access_token = (ctx.obj and ctx.obj.get('access_token'))...
python
def match(ctx, features, profile, gps_precision): """Mapbox Map Matching API lets you use snap your GPS traces to the OpenStreetMap road and path network. $ mapbox mapmatching trace.geojson An access token is required, see `mapbox --help`. """ access_token = (ctx.obj and ctx.obj.get('access_token'))...
[ "def", "match", "(", "ctx", ",", "features", ",", "profile", ",", "gps_precision", ")", ":", "access_token", "=", "(", "ctx", ".", "obj", "and", "ctx", ".", "obj", ".", "get", "(", "'access_token'", ")", ")", "or", "None", "features", "=", "list", "(...
Mapbox Map Matching API lets you use snap your GPS traces to the OpenStreetMap road and path network. $ mapbox mapmatching trace.geojson An access token is required, see `mapbox --help`.
[ "Mapbox", "Map", "Matching", "API", "lets", "you", "use", "snap", "your", "GPS", "traces", "to", "the", "OpenStreetMap", "road", "and", "path", "network", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/mapmatching.py#L15-L43
train
mapbox/mapbox-cli-py
mapboxcli/scripts/static.py
staticmap
def staticmap(ctx, mapid, output, features, lat, lon, zoom, size): """ Generate static map images from existing Mapbox map ids. Optionally overlay with geojson features. $ mapbox staticmap --features features.geojson mapbox.satellite out.png $ mapbox staticmap --lon -61.7 --lat 12.1 --zoom 12 m...
python
def staticmap(ctx, mapid, output, features, lat, lon, zoom, size): """ Generate static map images from existing Mapbox map ids. Optionally overlay with geojson features. $ mapbox staticmap --features features.geojson mapbox.satellite out.png $ mapbox staticmap --lon -61.7 --lat 12.1 --zoom 12 m...
[ "def", "staticmap", "(", "ctx", ",", "mapid", ",", "output", ",", "features", ",", "lat", ",", "lon", ",", "zoom", ",", "size", ")", ":", "access_token", "=", "(", "ctx", ".", "obj", "and", "ctx", ".", "obj", ".", "get", "(", "'access_token'", ")",...
Generate static map images from existing Mapbox map ids. Optionally overlay with geojson features. $ mapbox staticmap --features features.geojson mapbox.satellite out.png $ mapbox staticmap --lon -61.7 --lat 12.1 --zoom 12 mapbox.satellite out2.png An access token is required, see `mapbox --help`.
[ "Generate", "static", "map", "images", "from", "existing", "Mapbox", "map", "ids", ".", "Optionally", "overlay", "with", "geojson", "features", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/static.py#L18-L47
train
mapbox/mapbox-cli-py
mapboxcli/scripts/cli.py
main_group
def main_group(ctx, verbose, quiet, access_token, config): """This is the command line interface to Mapbox web services. Mapbox web services require an access token. Your token is shown on the https://www.mapbox.com/studio/account/tokens/ page when you are logged in. The token can be provided on the co...
python
def main_group(ctx, verbose, quiet, access_token, config): """This is the command line interface to Mapbox web services. Mapbox web services require an access token. Your token is shown on the https://www.mapbox.com/studio/account/tokens/ page when you are logged in. The token can be provided on the co...
[ "def", "main_group", "(", "ctx", ",", "verbose", ",", "quiet", ",", "access_token", ",", "config", ")", ":", "ctx", ".", "obj", "=", "{", "}", "config", "=", "config", "or", "os", ".", "path", ".", "join", "(", "click", ".", "get_app_dir", "(", "'m...
This is the command line interface to Mapbox web services. Mapbox web services require an access token. Your token is shown on the https://www.mapbox.com/studio/account/tokens/ page when you are logged in. The token can be provided on the command line $ mapbox --access-token MY_TOKEN ... as an ...
[ "This", "is", "the", "command", "line", "interface", "to", "Mapbox", "web", "services", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/cli.py#L43-L94
train
mapbox/mapbox-cli-py
mapboxcli/scripts/config.py
config
def config(ctx): """Show access token and other configuration settings. The access token and command verbosity level can be set on the command line, as environment variables, and in mapbox.ini config files. """ ctx.default_map = ctx.obj['cfg'] click.echo("CLI:") click.echo("access-token...
python
def config(ctx): """Show access token and other configuration settings. The access token and command verbosity level can be set on the command line, as environment variables, and in mapbox.ini config files. """ ctx.default_map = ctx.obj['cfg'] click.echo("CLI:") click.echo("access-token...
[ "def", "config", "(", "ctx", ")", ":", "ctx", ".", "default_map", "=", "ctx", ".", "obj", "[", "'cfg'", "]", "click", ".", "echo", "(", "\"CLI:\"", ")", "click", ".", "echo", "(", "\"access-token = {0}\"", ".", "format", "(", "ctx", ".", "obj", "[", ...
Show access token and other configuration settings. The access token and command verbosity level can be set on the command line, as environment variables, and in mapbox.ini config files.
[ "Show", "access", "token", "and", "other", "configuration", "settings", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/config.py#L8-L37
train
mapbox/mapbox-cli-py
mapboxcli/scripts/geocoding.py
echo_headers
def echo_headers(headers, file=None): """Echo headers, sorted.""" for k, v in sorted(headers.items()): click.echo("{0}: {1}".format(k.title(), v), file=file) click.echo(file=file)
python
def echo_headers(headers, file=None): """Echo headers, sorted.""" for k, v in sorted(headers.items()): click.echo("{0}: {1}".format(k.title(), v), file=file) click.echo(file=file)
[ "def", "echo_headers", "(", "headers", ",", "file", "=", "None", ")", ":", "for", "k", ",", "v", "in", "sorted", "(", "headers", ".", "items", "(", ")", ")", ":", "click", ".", "echo", "(", "\"{0}: {1}\"", ".", "format", "(", "k", ".", "title", "...
Echo headers, sorted.
[ "Echo", "headers", "sorted", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/geocoding.py#L34-L38
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
datasets
def datasets(ctx): """Read and write GeoJSON from Mapbox-hosted datasets All endpoints require authentication. An access token with appropriate dataset scopes is required, see `mapbox --help`. Note that this API is currently a limited-access beta. """ access_token = (ctx.obj and ctx.obj.get('...
python
def datasets(ctx): """Read and write GeoJSON from Mapbox-hosted datasets All endpoints require authentication. An access token with appropriate dataset scopes is required, see `mapbox --help`. Note that this API is currently a limited-access beta. """ access_token = (ctx.obj and ctx.obj.get('...
[ "def", "datasets", "(", "ctx", ")", ":", "access_token", "=", "(", "ctx", ".", "obj", "and", "ctx", ".", "obj", ".", "get", "(", "'access_token'", ")", ")", "or", "None", "service", "=", "mapbox", ".", "Datasets", "(", "access_token", "=", "access_toke...
Read and write GeoJSON from Mapbox-hosted datasets All endpoints require authentication. An access token with appropriate dataset scopes is required, see `mapbox --help`. Note that this API is currently a limited-access beta.
[ "Read", "and", "write", "GeoJSON", "from", "Mapbox", "-", "hosted", "datasets" ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L13-L24
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
create
def create(ctx, name, description): """Create a new dataset. Prints a JSON object containing the attributes of the new dataset. $ mapbox datasets create All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. """ service...
python
def create(ctx, name, description): """Create a new dataset. Prints a JSON object containing the attributes of the new dataset. $ mapbox datasets create All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. """ service...
[ "def", "create", "(", "ctx", ",", "name", ",", "description", ")", ":", "service", "=", "ctx", ".", "obj", ".", "get", "(", "'service'", ")", "res", "=", "service", ".", "create", "(", "name", ",", "description", ")", "if", "res", ".", "status_code",...
Create a new dataset. Prints a JSON object containing the attributes of the new dataset. $ mapbox datasets create All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`.
[ "Create", "a", "new", "dataset", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L56-L74
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
read_dataset
def read_dataset(ctx, dataset, output): """Read the attributes of a dataset. Prints a JSON object containing the attributes of a dataset. The attributes: owner (a Mapbox account), id (dataset id), created (Unix timestamp), modified (timestamp), name (string), and description (string). $ ma...
python
def read_dataset(ctx, dataset, output): """Read the attributes of a dataset. Prints a JSON object containing the attributes of a dataset. The attributes: owner (a Mapbox account), id (dataset id), created (Unix timestamp), modified (timestamp), name (string), and description (string). $ ma...
[ "def", "read_dataset", "(", "ctx", ",", "dataset", ",", "output", ")", ":", "stdout", "=", "click", ".", "open_file", "(", "output", ",", "'w'", ")", "service", "=", "ctx", ".", "obj", ".", "get", "(", "'service'", ")", "res", "=", "service", ".", ...
Read the attributes of a dataset. Prints a JSON object containing the attributes of a dataset. The attributes: owner (a Mapbox account), id (dataset id), created (Unix timestamp), modified (timestamp), name (string), and description (string). $ mapbox datasets read-dataset dataset-id All ...
[ "Read", "the", "attributes", "of", "a", "dataset", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L82-L103
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
list_features
def list_features(ctx, dataset, reverse, start, limit, output): """Get features of a dataset. Prints the features of the dataset as a GeoJSON feature collection. $ mapbox datasets list-features dataset-id All endpoints require authentication. An access token with `datasets:read` scope is requ...
python
def list_features(ctx, dataset, reverse, start, limit, output): """Get features of a dataset. Prints the features of the dataset as a GeoJSON feature collection. $ mapbox datasets list-features dataset-id All endpoints require authentication. An access token with `datasets:read` scope is requ...
[ "def", "list_features", "(", "ctx", ",", "dataset", ",", "reverse", ",", "start", ",", "limit", ",", "output", ")", ":", "stdout", "=", "click", ".", "open_file", "(", "output", ",", "'w'", ")", "service", "=", "ctx", ".", "obj", ".", "get", "(", "...
Get features of a dataset. Prints the features of the dataset as a GeoJSON feature collection. $ mapbox datasets list-features dataset-id All endpoints require authentication. An access token with `datasets:read` scope is required, see `mapbox --help`.
[ "Get", "features", "of", "a", "dataset", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L165-L183
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
put_feature
def put_feature(ctx, dataset, fid, feature, input): """Create or update a dataset feature. The semantics of HTTP PUT apply: if the dataset has no feature with the given `fid` a new feature will be created. Returns a GeoJSON representation of the new or updated feature. $ mapbox datasets put-fe...
python
def put_feature(ctx, dataset, fid, feature, input): """Create or update a dataset feature. The semantics of HTTP PUT apply: if the dataset has no feature with the given `fid` a new feature will be created. Returns a GeoJSON representation of the new or updated feature. $ mapbox datasets put-fe...
[ "def", "put_feature", "(", "ctx", ",", "dataset", ",", "fid", ",", "feature", ",", "input", ")", ":", "if", "feature", "is", "None", ":", "stdin", "=", "click", ".", "open_file", "(", "input", ",", "'r'", ")", "feature", "=", "stdin", ".", "read", ...
Create or update a dataset feature. The semantics of HTTP PUT apply: if the dataset has no feature with the given `fid` a new feature will be created. Returns a GeoJSON representation of the new or updated feature. $ mapbox datasets put-feature dataset-id feature-id 'geojson-feature' All endp...
[ "Create", "or", "update", "a", "dataset", "feature", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L221-L246
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
delete_feature
def delete_feature(ctx, dataset, fid): """Delete a feature. $ mapbox datasets delete-feature dataset-id feature-id All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. """ service = ctx.obj.get('service') res = service.del...
python
def delete_feature(ctx, dataset, fid): """Delete a feature. $ mapbox datasets delete-feature dataset-id feature-id All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`. """ service = ctx.obj.get('service') res = service.del...
[ "def", "delete_feature", "(", "ctx", ",", "dataset", ",", "fid", ")", ":", "service", "=", "ctx", ".", "obj", ".", "get", "(", "'service'", ")", "res", "=", "service", ".", "delete_feature", "(", "dataset", ",", "fid", ")", "if", "res", ".", "status_...
Delete a feature. $ mapbox datasets delete-feature dataset-id feature-id All endpoints require authentication. An access token with `datasets:write` scope is required, see `mapbox --help`.
[ "Delete", "a", "feature", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L254-L267
train
mapbox/mapbox-cli-py
mapboxcli/scripts/datasets.py
create_tileset
def create_tileset(ctx, dataset, tileset, name): """Create a vector tileset from a dataset. $ mapbox datasets create-tileset dataset-id username.data Note that the tileset must start with your username and the dataset must be one that you own. To view processing status, visit https://www.mapbo...
python
def create_tileset(ctx, dataset, tileset, name): """Create a vector tileset from a dataset. $ mapbox datasets create-tileset dataset-id username.data Note that the tileset must start with your username and the dataset must be one that you own. To view processing status, visit https://www.mapbo...
[ "def", "create_tileset", "(", "ctx", ",", "dataset", ",", "tileset", ",", "name", ")", ":", "access_token", "=", "(", "ctx", ".", "obj", "and", "ctx", ".", "obj", ".", "get", "(", "'access_token'", ")", ")", "or", "None", "service", "=", "mapbox", "....
Create a vector tileset from a dataset. $ mapbox datasets create-tileset dataset-id username.data Note that the tileset must start with your username and the dataset must be one that you own. To view processing status, visit https://www.mapbox.com/data/. You may not generate another tilesets f...
[ "Create", "a", "vector", "tileset", "from", "a", "dataset", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/datasets.py#L276-L301
train
mapbox/mapbox-cli-py
mapboxcli/scripts/directions.py
directions
def directions(ctx, features, profile, alternatives, geometries, overview, steps, continue_straight, waypoint_snapping, annotations, language, output): """The Mapbox Directions API will show you how to get where you're going. mapbox directions "[0, 0]" "[1, 1]" ...
python
def directions(ctx, features, profile, alternatives, geometries, overview, steps, continue_straight, waypoint_snapping, annotations, language, output): """The Mapbox Directions API will show you how to get where you're going. mapbox directions "[0, 0]" "[1, 1]" ...
[ "def", "directions", "(", "ctx", ",", "features", ",", "profile", ",", "alternatives", ",", "geometries", ",", "overview", ",", "steps", ",", "continue_straight", ",", "waypoint_snapping", ",", "annotations", ",", "language", ",", "output", ")", ":", "access_t...
The Mapbox Directions API will show you how to get where you're going. mapbox directions "[0, 0]" "[1, 1]" An access token is required. See "mapbox --help".
[ "The", "Mapbox", "Directions", "API", "will", "show", "you", "how", "to", "get", "where", "you", "re", "going", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/directions.py#L163-L218
train
mapbox/mapbox-cli-py
mapboxcli/scripts/uploads.py
upload
def upload(ctx, tileset, datasource, name, patch): """Upload data to Mapbox accounts. Uploaded data lands at https://www.mapbox.com/data/ and can be used in new or existing projects. All endpoints require authentication. You can specify the tileset id and input file $ mapbox upload username.dat...
python
def upload(ctx, tileset, datasource, name, patch): """Upload data to Mapbox accounts. Uploaded data lands at https://www.mapbox.com/data/ and can be used in new or existing projects. All endpoints require authentication. You can specify the tileset id and input file $ mapbox upload username.dat...
[ "def", "upload", "(", "ctx", ",", "tileset", ",", "datasource", ",", "name", ",", "patch", ")", ":", "access_token", "=", "(", "ctx", ".", "obj", "and", "ctx", ".", "obj", ".", "get", "(", "'access_token'", ")", ")", "or", "None", "service", "=", "...
Upload data to Mapbox accounts. Uploaded data lands at https://www.mapbox.com/data/ and can be used in new or existing projects. All endpoints require authentication. You can specify the tileset id and input file $ mapbox upload username.data mydata.geojson Or specify just the tileset id and t...
[ "Upload", "data", "to", "Mapbox", "accounts", "." ]
b75544a2f83a4fda79d78b5673058e16e64a4f6d
https://github.com/mapbox/mapbox-cli-py/blob/b75544a2f83a4fda79d78b5673058e16e64a4f6d/mapboxcli/scripts/uploads.py#L17-L76
train
aaren/notedown
notedown/contentsmanager.py
NotedownContentsManager._save_notebook
def _save_notebook(self, os_path, nb): """Save a notebook to an os_path.""" with self.atomic_writing(os_path, encoding='utf-8') as f: if ftdetect(os_path) == 'notebook': nbformat.write(nb, f, version=nbformat.NO_CONVERT) elif ftdetect(os_path) == 'markdown': ...
python
def _save_notebook(self, os_path, nb): """Save a notebook to an os_path.""" with self.atomic_writing(os_path, encoding='utf-8') as f: if ftdetect(os_path) == 'notebook': nbformat.write(nb, f, version=nbformat.NO_CONVERT) elif ftdetect(os_path) == 'markdown': ...
[ "def", "_save_notebook", "(", "self", ",", "os_path", ",", "nb", ")", ":", "with", "self", ".", "atomic_writing", "(", "os_path", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "if", "ftdetect", "(", "os_path", ")", "==", "'notebook'", ":", "nbf...
Save a notebook to an os_path.
[ "Save", "a", "notebook", "to", "an", "os_path", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/contentsmanager.py#L52-L63
train
aaren/notedown
notedown/main.py
ftdetect
def ftdetect(filename): """Determine if filename is markdown or notebook, based on the file extension. """ _, extension = os.path.splitext(filename) md_exts = ['.md', '.markdown', '.mkd', '.mdown', '.mkdn', '.Rmd'] nb_exts = ['.ipynb'] if extension in md_exts: return 'markdown' e...
python
def ftdetect(filename): """Determine if filename is markdown or notebook, based on the file extension. """ _, extension = os.path.splitext(filename) md_exts = ['.md', '.markdown', '.mkd', '.mdown', '.mkdn', '.Rmd'] nb_exts = ['.ipynb'] if extension in md_exts: return 'markdown' e...
[ "def", "ftdetect", "(", "filename", ")", ":", "_", ",", "extension", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "md_exts", "=", "[", "'.md'", ",", "'.markdown'", ",", "'.mkd'", ",", "'.mdown'", ",", "'.mkdn'", ",", "'.Rmd'", "]", ...
Determine if filename is markdown or notebook, based on the file extension.
[ "Determine", "if", "filename", "is", "markdown", "or", "notebook", "based", "on", "the", "file", "extension", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/main.py#L107-L119
train
aaren/notedown
notedown/notedown.py
strip
def strip(notebook): """Remove outputs from a notebook.""" for cell in notebook.cells: if cell.cell_type == 'code': cell.outputs = [] cell.execution_count = None
python
def strip(notebook): """Remove outputs from a notebook.""" for cell in notebook.cells: if cell.cell_type == 'code': cell.outputs = [] cell.execution_count = None
[ "def", "strip", "(", "notebook", ")", ":", "for", "cell", "in", "notebook", ".", "cells", ":", "if", "cell", ".", "cell_type", "==", "'code'", ":", "cell", ".", "outputs", "=", "[", "]", "cell", ".", "execution_count", "=", "None" ]
Remove outputs from a notebook.
[ "Remove", "outputs", "from", "a", "notebook", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L38-L43
train
aaren/notedown
notedown/notedown.py
get_caption_comments
def get_caption_comments(content): """Retrieve an id and a caption from a code cell. If the code cell content begins with a commented block that looks like ## fig:id # multi-line or single-line # caption then the 'fig:id' and the caption will be returned. The '#' are stripped. """...
python
def get_caption_comments(content): """Retrieve an id and a caption from a code cell. If the code cell content begins with a commented block that looks like ## fig:id # multi-line or single-line # caption then the 'fig:id' and the caption will be returned. The '#' are stripped. """...
[ "def", "get_caption_comments", "(", "content", ")", ":", "if", "not", "content", ".", "startswith", "(", "'## fig:'", ")", ":", "return", "None", ",", "None", "content", "=", "content", ".", "splitlines", "(", ")", "id", "=", "content", "[", "0", "]", ...
Retrieve an id and a caption from a code cell. If the code cell content begins with a commented block that looks like ## fig:id # multi-line or single-line # caption then the 'fig:id' and the caption will be returned. The '#' are stripped.
[ "Retrieve", "an", "id", "and", "a", "caption", "from", "a", "code", "cell", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L648-L679
train
aaren/notedown
notedown/notedown.py
MarkdownReader.new_code_block
def new_code_block(self, **kwargs): """Create a new code block.""" proto = {'content': '', 'type': self.code, 'IO': '', 'attributes': ''} proto.update(**kwargs) return proto
python
def new_code_block(self, **kwargs): """Create a new code block.""" proto = {'content': '', 'type': self.code, 'IO': '', 'attributes': ''} proto.update(**kwargs) return proto
[ "def", "new_code_block", "(", "self", ",", "*", "*", "kwargs", ")", ":", "proto", "=", "{", "'content'", ":", "''", ",", "'type'", ":", "self", ".", "code", ",", "'IO'", ":", "''", ",", "'attributes'", ":", "''", "}", "proto", ".", "update", "(", ...
Create a new code block.
[ "Create", "a", "new", "code", "block", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L147-L154
train
aaren/notedown
notedown/notedown.py
MarkdownReader.new_text_block
def new_text_block(self, **kwargs): """Create a new text block.""" proto = {'content': '', 'type': self.markdown} proto.update(**kwargs) return proto
python
def new_text_block(self, **kwargs): """Create a new text block.""" proto = {'content': '', 'type': self.markdown} proto.update(**kwargs) return proto
[ "def", "new_text_block", "(", "self", ",", "*", "*", "kwargs", ")", ":", "proto", "=", "{", "'content'", ":", "''", ",", "'type'", ":", "self", ".", "markdown", "}", "proto", ".", "update", "(", "*", "*", "kwargs", ")", "return", "proto" ]
Create a new text block.
[ "Create", "a", "new", "text", "block", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L156-L160
train
aaren/notedown
notedown/notedown.py
MarkdownReader.pre_process_code_block
def pre_process_code_block(block): """Preprocess the content of a code block, modifying the code block in place. Just dedents indented code. """ if 'indent' in block and block['indent']: indent = r'^' + block['indent'] block['content'] = re.sub(indent, ''...
python
def pre_process_code_block(block): """Preprocess the content of a code block, modifying the code block in place. Just dedents indented code. """ if 'indent' in block and block['indent']: indent = r'^' + block['indent'] block['content'] = re.sub(indent, ''...
[ "def", "pre_process_code_block", "(", "block", ")", ":", "if", "'indent'", "in", "block", "and", "block", "[", "'indent'", "]", ":", "indent", "=", "r'^'", "+", "block", "[", "'indent'", "]", "block", "[", "'content'", "]", "=", "re", ".", "sub", "(", ...
Preprocess the content of a code block, modifying the code block in place. Just dedents indented code.
[ "Preprocess", "the", "content", "of", "a", "code", "block", "modifying", "the", "code", "block", "in", "place", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L169-L178
train
aaren/notedown
notedown/notedown.py
MarkdownReader.process_code_block
def process_code_block(self, block): """Parse block attributes""" if block['type'] != self.code: return block attr = PandocAttributes(block['attributes'], 'markdown') if self.match == 'all': pass elif self.match == 'fenced' and block.get('indent'): ...
python
def process_code_block(self, block): """Parse block attributes""" if block['type'] != self.code: return block attr = PandocAttributes(block['attributes'], 'markdown') if self.match == 'all': pass elif self.match == 'fenced' and block.get('indent'): ...
[ "def", "process_code_block", "(", "self", ",", "block", ")", ":", "if", "block", "[", "'type'", "]", "!=", "self", ".", "code", ":", "return", "block", "attr", "=", "PandocAttributes", "(", "block", "[", "'attributes'", "]", ",", "'markdown'", ")", "if",...
Parse block attributes
[ "Parse", "block", "attributes" ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L189-L248
train
aaren/notedown
notedown/notedown.py
MarkdownReader.parse_blocks
def parse_blocks(self, text): """Extract the code and non-code blocks from given markdown text. Returns a list of block dictionaries. Each dictionary has at least the keys 'type' and 'content', containing the type of the block ('markdown', 'code') and the contents of the block....
python
def parse_blocks(self, text): """Extract the code and non-code blocks from given markdown text. Returns a list of block dictionaries. Each dictionary has at least the keys 'type' and 'content', containing the type of the block ('markdown', 'code') and the contents of the block....
[ "def", "parse_blocks", "(", "self", ",", "text", ")", ":", "code_matches", "=", "[", "m", "for", "m", "in", "self", ".", "code_pattern", ".", "finditer", "(", "text", ")", "]", "# determine where the limits of the non code bits are", "# based on the code block edges...
Extract the code and non-code blocks from given markdown text. Returns a list of block dictionaries. Each dictionary has at least the keys 'type' and 'content', containing the type of the block ('markdown', 'code') and the contents of the block. Additional keys may be parsed a...
[ "Extract", "the", "code", "and", "non", "-", "code", "blocks", "from", "given", "markdown", "text", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L250-L302
train
aaren/notedown
notedown/notedown.py
MarkdownReader.create_code_cell
def create_code_cell(block): """Create a notebook code cell from a block.""" code_cell = nbbase.new_code_cell(source=block['content']) attr = block['attributes'] if not attr.is_empty: code_cell.metadata \ = nbbase.NotebookNode({'attributes': attr.to_dict()}) ...
python
def create_code_cell(block): """Create a notebook code cell from a block.""" code_cell = nbbase.new_code_cell(source=block['content']) attr = block['attributes'] if not attr.is_empty: code_cell.metadata \ = nbbase.NotebookNode({'attributes': attr.to_dict()}) ...
[ "def", "create_code_cell", "(", "block", ")", ":", "code_cell", "=", "nbbase", ".", "new_code_cell", "(", "source", "=", "block", "[", "'content'", "]", ")", "attr", "=", "block", "[", "'attributes'", "]", "if", "not", "attr", ".", "is_empty", ":", "code...
Create a notebook code cell from a block.
[ "Create", "a", "notebook", "code", "cell", "from", "a", "block", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L305-L319
train
aaren/notedown
notedown/notedown.py
MarkdownReader.create_markdown_cell
def create_markdown_cell(block): """Create a markdown cell from a block.""" kwargs = {'cell_type': block['type'], 'source': block['content']} markdown_cell = nbbase.new_markdown_cell(**kwargs) return markdown_cell
python
def create_markdown_cell(block): """Create a markdown cell from a block.""" kwargs = {'cell_type': block['type'], 'source': block['content']} markdown_cell = nbbase.new_markdown_cell(**kwargs) return markdown_cell
[ "def", "create_markdown_cell", "(", "block", ")", ":", "kwargs", "=", "{", "'cell_type'", ":", "block", "[", "'type'", "]", ",", "'source'", ":", "block", "[", "'content'", "]", "}", "markdown_cell", "=", "nbbase", ".", "new_markdown_cell", "(", "*", "*", ...
Create a markdown cell from a block.
[ "Create", "a", "markdown", "cell", "from", "a", "block", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L322-L327
train
aaren/notedown
notedown/notedown.py
MarkdownReader.create_cells
def create_cells(self, blocks): """Turn the list of blocks into a list of notebook cells.""" cells = [] for block in blocks: if (block['type'] == self.code) and (block['IO'] == 'input'): code_cell = self.create_code_cell(block) cells.append(code_cell) ...
python
def create_cells(self, blocks): """Turn the list of blocks into a list of notebook cells.""" cells = [] for block in blocks: if (block['type'] == self.code) and (block['IO'] == 'input'): code_cell = self.create_code_cell(block) cells.append(code_cell) ...
[ "def", "create_cells", "(", "self", ",", "blocks", ")", ":", "cells", "=", "[", "]", "for", "block", "in", "blocks", ":", "if", "(", "block", "[", "'type'", "]", "==", "self", ".", "code", ")", "and", "(", "block", "[", "'IO'", "]", "==", "'input...
Turn the list of blocks into a list of notebook cells.
[ "Turn", "the", "list", "of", "blocks", "into", "a", "list", "of", "notebook", "cells", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L337-L358
train
aaren/notedown
notedown/notedown.py
MarkdownReader.to_notebook
def to_notebook(self, s, **kwargs): """Convert the markdown string s to an IPython notebook. Returns a notebook. """ all_blocks = self.parse_blocks(s) if self.pre_code_block['content']: # TODO: if first block is markdown, place after? all_blocks.insert(0,...
python
def to_notebook(self, s, **kwargs): """Convert the markdown string s to an IPython notebook. Returns a notebook. """ all_blocks = self.parse_blocks(s) if self.pre_code_block['content']: # TODO: if first block is markdown, place after? all_blocks.insert(0,...
[ "def", "to_notebook", "(", "self", ",", "s", ",", "*", "*", "kwargs", ")", ":", "all_blocks", "=", "self", ".", "parse_blocks", "(", "s", ")", "if", "self", ".", "pre_code_block", "[", "'content'", "]", ":", "# TODO: if first block is markdown, place after?", ...
Convert the markdown string s to an IPython notebook. Returns a notebook.
[ "Convert", "the", "markdown", "string", "s", "to", "an", "IPython", "notebook", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L360-L376
train
aaren/notedown
notedown/notedown.py
MarkdownWriter.write_resources
def write_resources(self, resources): """Write the output data in resources returned by exporter to files. """ for filename, data in list(resources.get('outputs', {}).items()): # Determine where to write the file to dest = os.path.join(self.output_dir, filename) ...
python
def write_resources(self, resources): """Write the output data in resources returned by exporter to files. """ for filename, data in list(resources.get('outputs', {}).items()): # Determine where to write the file to dest = os.path.join(self.output_dir, filename) ...
[ "def", "write_resources", "(", "self", ",", "resources", ")", ":", "for", "filename", ",", "data", "in", "list", "(", "resources", ".", "get", "(", "'outputs'", ",", "{", "}", ")", ".", "items", "(", ")", ")", ":", "# Determine where to write the file to",...
Write the output data in resources returned by exporter to files.
[ "Write", "the", "output", "data", "in", "resources", "returned", "by", "exporter", "to", "files", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L445-L458
train
aaren/notedown
notedown/notedown.py
MarkdownWriter.string2json
def string2json(self, string): """Convert json into its string representation. Used for writing outputs to markdown.""" kwargs = { 'cls': BytesEncoder, # use the IPython bytes encoder 'indent': 1, 'sort_keys': True, 'separators': (',', ': '), ...
python
def string2json(self, string): """Convert json into its string representation. Used for writing outputs to markdown.""" kwargs = { 'cls': BytesEncoder, # use the IPython bytes encoder 'indent': 1, 'sort_keys': True, 'separators': (',', ': '), ...
[ "def", "string2json", "(", "self", ",", "string", ")", ":", "kwargs", "=", "{", "'cls'", ":", "BytesEncoder", ",", "# use the IPython bytes encoder", "'indent'", ":", "1", ",", "'sort_keys'", ":", "True", ",", "'separators'", ":", "(", "','", ",", "': '", ...
Convert json into its string representation. Used for writing outputs to markdown.
[ "Convert", "json", "into", "its", "string", "representation", ".", "Used", "for", "writing", "outputs", "to", "markdown", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L461-L470
train
aaren/notedown
notedown/notedown.py
MarkdownWriter.create_attributes
def create_attributes(self, cell, cell_type=None): """Turn the attribute dict into an attribute string for the code block. """ if self.strip_outputs or not hasattr(cell, 'execution_count'): return 'python' attrs = cell.metadata.get('attributes') attr = Pandoc...
python
def create_attributes(self, cell, cell_type=None): """Turn the attribute dict into an attribute string for the code block. """ if self.strip_outputs or not hasattr(cell, 'execution_count'): return 'python' attrs = cell.metadata.get('attributes') attr = Pandoc...
[ "def", "create_attributes", "(", "self", ",", "cell", ",", "cell_type", "=", "None", ")", ":", "if", "self", ".", "strip_outputs", "or", "not", "hasattr", "(", "cell", ",", "'execution_count'", ")", ":", "return", "'python'", "attrs", "=", "cell", ".", "...
Turn the attribute dict into an attribute string for the code block.
[ "Turn", "the", "attribute", "dict", "into", "an", "attribute", "string", "for", "the", "code", "block", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L493-L523
train
aaren/notedown
notedown/notedown.py
MarkdownWriter.dequote
def dequote(s): """Remove excess quotes from a string.""" if len(s) < 2: return s elif (s[0] == s[-1]) and s.startswith(('"', "'")): return s[1: -1] else: return s
python
def dequote(s): """Remove excess quotes from a string.""" if len(s) < 2: return s elif (s[0] == s[-1]) and s.startswith(('"', "'")): return s[1: -1] else: return s
[ "def", "dequote", "(", "s", ")", ":", "if", "len", "(", "s", ")", "<", "2", ":", "return", "s", "elif", "(", "s", "[", "0", "]", "==", "s", "[", "-", "1", "]", ")", "and", "s", ".", "startswith", "(", "(", "'\"'", ",", "\"'\"", ")", ")", ...
Remove excess quotes from a string.
[ "Remove", "excess", "quotes", "from", "a", "string", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L526-L533
train
aaren/notedown
notedown/notedown.py
MarkdownWriter.data2uri
def data2uri(data, data_type): """Convert base64 data into a data uri with the given data_type.""" MIME_MAP = { 'image/jpeg': 'jpeg', 'image/png': 'png', 'text/plain': 'text', 'text/html': 'html', 'text/latex': 'latex', 'application...
python
def data2uri(data, data_type): """Convert base64 data into a data uri with the given data_type.""" MIME_MAP = { 'image/jpeg': 'jpeg', 'image/png': 'png', 'text/plain': 'text', 'text/html': 'html', 'text/latex': 'latex', 'application...
[ "def", "data2uri", "(", "data", ",", "data_type", ")", ":", "MIME_MAP", "=", "{", "'image/jpeg'", ":", "'jpeg'", ",", "'image/png'", ":", "'png'", ",", "'text/plain'", ":", "'text'", ",", "'text/html'", ":", "'html'", ",", "'text/latex'", ":", "'latex'", "...
Convert base64 data into a data uri with the given data_type.
[ "Convert", "base64", "data", "into", "a", "data", "uri", "with", "the", "given", "data_type", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L536-L551
train
aaren/notedown
notedown/notedown.py
CodeMagician.magic
def magic(self, alias): """Returns the appropriate IPython code magic when called with an alias for a language. """ if alias in self.aliases: return self.aliases[alias] else: return "%%{}\n".format(alias)
python
def magic(self, alias): """Returns the appropriate IPython code magic when called with an alias for a language. """ if alias in self.aliases: return self.aliases[alias] else: return "%%{}\n".format(alias)
[ "def", "magic", "(", "self", ",", "alias", ")", ":", "if", "alias", "in", "self", ".", "aliases", ":", "return", "self", ".", "aliases", "[", "alias", "]", "else", ":", "return", "\"%%{}\\n\"", ".", "format", "(", "alias", ")" ]
Returns the appropriate IPython code magic when called with an alias for a language.
[ "Returns", "the", "appropriate", "IPython", "code", "magic", "when", "called", "with", "an", "alias", "for", "a", "language", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L565-L572
train
aaren/notedown
notedown/notedown.py
Knitr.knit
def knit(self, input_file, opts_chunk='eval=FALSE'): """Use Knitr to convert the r-markdown input_file into markdown, returning a file object. """ # use temporary files at both ends to allow stdin / stdout tmp_in = tempfile.NamedTemporaryFile(mode='w+') tmp_out = tempfile...
python
def knit(self, input_file, opts_chunk='eval=FALSE'): """Use Knitr to convert the r-markdown input_file into markdown, returning a file object. """ # use temporary files at both ends to allow stdin / stdout tmp_in = tempfile.NamedTemporaryFile(mode='w+') tmp_out = tempfile...
[ "def", "knit", "(", "self", ",", "input_file", ",", "opts_chunk", "=", "'eval=FALSE'", ")", ":", "# use temporary files at both ends to allow stdin / stdout", "tmp_in", "=", "tempfile", ".", "NamedTemporaryFile", "(", "mode", "=", "'w+'", ")", "tmp_out", "=", "tempf...
Use Knitr to convert the r-markdown input_file into markdown, returning a file object.
[ "Use", "Knitr", "to", "convert", "the", "r", "-", "markdown", "input_file", "into", "markdown", "returning", "a", "file", "object", "." ]
1e920c7e4ecbe47420c12eed3d5bcae735121222
https://github.com/aaren/notedown/blob/1e920c7e4ecbe47420c12eed3d5bcae735121222/notedown/notedown.py#L602-L616
train
cyface/django-termsandconditions
termsandconditions/middleware.py
is_path_protected
def is_path_protected(path): """ returns True if given path is to be protected, otherwise False The path is not to be protected when it appears on: TERMS_EXCLUDE_URL_PREFIX_LIST, TERMS_EXCLUDE_URL_LIST, TERMS_EXCLUDE_URL_CONTAINS_LIST or as ACCEPT_TERMS_PATH """ protected = True for ex...
python
def is_path_protected(path): """ returns True if given path is to be protected, otherwise False The path is not to be protected when it appears on: TERMS_EXCLUDE_URL_PREFIX_LIST, TERMS_EXCLUDE_URL_LIST, TERMS_EXCLUDE_URL_CONTAINS_LIST or as ACCEPT_TERMS_PATH """ protected = True for ex...
[ "def", "is_path_protected", "(", "path", ")", ":", "protected", "=", "True", "for", "exclude_path", "in", "TERMS_EXCLUDE_URL_PREFIX_LIST", ":", "if", "path", ".", "startswith", "(", "exclude_path", ")", ":", "protected", "=", "False", "for", "contains_path", "in...
returns True if given path is to be protected, otherwise False The path is not to be protected when it appears on: TERMS_EXCLUDE_URL_PREFIX_LIST, TERMS_EXCLUDE_URL_LIST, TERMS_EXCLUDE_URL_CONTAINS_LIST or as ACCEPT_TERMS_PATH
[ "returns", "True", "if", "given", "path", "is", "to", "be", "protected", "otherwise", "False" ]
e18f06d0bad1e047f99222d1153f6e2b3bd5224f
https://github.com/cyface/django-termsandconditions/blob/e18f06d0bad1e047f99222d1153f6e2b3bd5224f/termsandconditions/middleware.py#L49-L74
train
cyface/django-termsandconditions
termsandconditions/middleware.py
TermsAndConditionsRedirectMiddleware.process_request
def process_request(self, request): """Process each request to app to ensure terms have been accepted""" LOGGER.debug('termsandconditions.middleware') current_path = request.META['PATH_INFO'] if DJANGO_VERSION <= (2, 0, 0): user_authenticated = request.user.is_authenticate...
python
def process_request(self, request): """Process each request to app to ensure terms have been accepted""" LOGGER.debug('termsandconditions.middleware') current_path = request.META['PATH_INFO'] if DJANGO_VERSION <= (2, 0, 0): user_authenticated = request.user.is_authenticate...
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "LOGGER", ".", "debug", "(", "'termsandconditions.middleware'", ")", "current_path", "=", "request", ".", "META", "[", "'PATH_INFO'", "]", "if", "DJANGO_VERSION", "<=", "(", "2", ",", "0", ",",...
Process each request to app to ensure terms have been accepted
[ "Process", "each", "request", "to", "app", "to", "ensure", "terms", "have", "been", "accepted" ]
e18f06d0bad1e047f99222d1153f6e2b3bd5224f
https://github.com/cyface/django-termsandconditions/blob/e18f06d0bad1e047f99222d1153f6e2b3bd5224f/termsandconditions/middleware.py#L27-L46
train