partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | _nginx_stream_spec | This will output the nginx stream config string for specific port spec | dusty/compiler/nginx/__init__.py | def _nginx_stream_spec(port_spec, bridge_ip):
"""This will output the nginx stream config string for specific port spec """
server_string_spec = "\t server {\n"
server_string_spec += "\t \t {}\n".format(_nginx_listen_string(port_spec))
server_string_spec += "\t \t {}\n".format(_nginx_proxy_string(port_s... | def _nginx_stream_spec(port_spec, bridge_ip):
"""This will output the nginx stream config string for specific port spec """
server_string_spec = "\t server {\n"
server_string_spec += "\t \t {}\n".format(_nginx_listen_string(port_spec))
server_string_spec += "\t \t {}\n".format(_nginx_proxy_string(port_s... | [
"This",
"will",
"output",
"the",
"nginx",
"stream",
"config",
"string",
"for",
"specific",
"port",
"spec"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/nginx/__init__.py#L49-L55 | [
"def",
"_nginx_stream_spec",
"(",
"port_spec",
",",
"bridge_ip",
")",
":",
"server_string_spec",
"=",
"\"\\t server {\\n\"",
"server_string_spec",
"+=",
"\"\\t \\t {}\\n\"",
".",
"format",
"(",
"_nginx_listen_string",
"(",
"port_spec",
")",
")",
"server_string_spec",
"+... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_nginx_configuration_spec | This function will take in a port spec as specified by the port_spec compiler and
will output an nginx web proxy config string. This string can then be written to a file
and used running nginx | dusty/compiler/nginx/__init__.py | def get_nginx_configuration_spec(port_spec_dict, docker_bridge_ip):
"""This function will take in a port spec as specified by the port_spec compiler and
will output an nginx web proxy config string. This string can then be written to a file
and used running nginx """
nginx_http_config, nginx_stream_conf... | def get_nginx_configuration_spec(port_spec_dict, docker_bridge_ip):
"""This function will take in a port spec as specified by the port_spec compiler and
will output an nginx web proxy config string. This string can then be written to a file
and used running nginx """
nginx_http_config, nginx_stream_conf... | [
"This",
"function",
"will",
"take",
"in",
"a",
"port",
"spec",
"as",
"specified",
"by",
"the",
"port_spec",
"compiler",
"and",
"will",
"output",
"an",
"nginx",
"web",
"proxy",
"config",
"string",
".",
"This",
"string",
"can",
"then",
"be",
"written",
"to",... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/nginx/__init__.py#L57-L67 | [
"def",
"get_nginx_configuration_spec",
"(",
"port_spec_dict",
",",
"docker_bridge_ip",
")",
":",
"nginx_http_config",
",",
"nginx_stream_config",
"=",
"\"\"",
",",
"\"\"",
"for",
"port_spec",
"in",
"port_spec_dict",
"[",
"'nginx'",
"]",
":",
"if",
"port_spec",
"[",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | memoized | Decorator. Caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned
(not reevaluated). The cache lasts for the duration of each request. | dusty/memoize.py | def memoized(fn):
"""
Decorator. Caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned
(not reevaluated). The cache lasts for the duration of each request.
"""
@functools.wraps(fn)
def memoizer(*args, **kwargs):
... | def memoized(fn):
"""
Decorator. Caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned
(not reevaluated). The cache lasts for the duration of each request.
"""
@functools.wraps(fn)
def memoizer(*args, **kwargs):
... | [
"Decorator",
".",
"Caches",
"a",
"function",
"s",
"return",
"value",
"each",
"time",
"it",
"is",
"called",
".",
"If",
"called",
"later",
"with",
"the",
"same",
"arguments",
"the",
"cached",
"value",
"is",
"returned",
"(",
"not",
"reevaluated",
")",
".",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/memoize.py#L12-L24 | [
"def",
"memoized",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"memoizer",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"function_key",
"(",
"fn",
")",
"+",
"pickle",
".",
"dumps",
"(",
"args",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _load_ssh_auth_post_yosemite | Starting with Yosemite, launchd was rearchitected and now only one
launchd process runs for all users. This allows us to much more easily
impersonate a user through launchd and extract the environment
variables from their running processes. | dusty/config.py | def _load_ssh_auth_post_yosemite(mac_username):
"""Starting with Yosemite, launchd was rearchitected and now only one
launchd process runs for all users. This allows us to much more easily
impersonate a user through launchd and extract the environment
variables from their running processes."""
user_... | def _load_ssh_auth_post_yosemite(mac_username):
"""Starting with Yosemite, launchd was rearchitected and now only one
launchd process runs for all users. This allows us to much more easily
impersonate a user through launchd and extract the environment
variables from their running processes."""
user_... | [
"Starting",
"with",
"Yosemite",
"launchd",
"was",
"rearchitected",
"and",
"now",
"only",
"one",
"launchd",
"process",
"runs",
"for",
"all",
"users",
".",
"This",
"allows",
"us",
"to",
"much",
"more",
"easily",
"impersonate",
"a",
"user",
"through",
"launchd",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/config.py#L87-L94 | [
"def",
"_load_ssh_auth_post_yosemite",
"(",
"mac_username",
")",
":",
"user_id",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'id'",
",",
"'-u'",
",",
"mac_username",
"]",
")",
"ssh_auth_sock",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'launchctl'... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _load_ssh_auth_pre_yosemite | For OS X versions before Yosemite, many launchd processes run simultaneously under
different users and different permission models. The simpler `asuser` trick we use
in Yosemite doesn't work, since it gets routed to the wrong launchd. We instead need
to find the running ssh-agent process and use its PID to ... | dusty/config.py | def _load_ssh_auth_pre_yosemite():
"""For OS X versions before Yosemite, many launchd processes run simultaneously under
different users and different permission models. The simpler `asuser` trick we use
in Yosemite doesn't work, since it gets routed to the wrong launchd. We instead need
to find the run... | def _load_ssh_auth_pre_yosemite():
"""For OS X versions before Yosemite, many launchd processes run simultaneously under
different users and different permission models. The simpler `asuser` trick we use
in Yosemite doesn't work, since it gets routed to the wrong launchd. We instead need
to find the run... | [
"For",
"OS",
"X",
"versions",
"before",
"Yosemite",
"many",
"launchd",
"processes",
"run",
"simultaneously",
"under",
"different",
"users",
"and",
"different",
"permission",
"models",
".",
"The",
"simpler",
"asuser",
"trick",
"we",
"use",
"in",
"Yosemite",
"does... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/config.py#L96-L109 | [
"def",
"_load_ssh_auth_pre_yosemite",
"(",
")",
":",
"for",
"process",
"in",
"psutil",
".",
"process_iter",
"(",
")",
":",
"if",
"process",
".",
"name",
"(",
")",
"==",
"'ssh-agent'",
":",
"ssh_auth_sock",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | check_and_load_ssh_auth | Will check the mac_username config value; if it is present, will load that user's
SSH_AUTH_SOCK environment variable to the current environment. This allows git clones
to behave the same for the daemon as they do for the user | dusty/config.py | def check_and_load_ssh_auth():
"""
Will check the mac_username config value; if it is present, will load that user's
SSH_AUTH_SOCK environment variable to the current environment. This allows git clones
to behave the same for the daemon as they do for the user
"""
mac_username = get_config_val... | def check_and_load_ssh_auth():
"""
Will check the mac_username config value; if it is present, will load that user's
SSH_AUTH_SOCK environment variable to the current environment. This allows git clones
to behave the same for the daemon as they do for the user
"""
mac_username = get_config_val... | [
"Will",
"check",
"the",
"mac_username",
"config",
"value",
";",
"if",
"it",
"is",
"present",
"will",
"load",
"that",
"user",
"s",
"SSH_AUTH_SOCK",
"environment",
"variable",
"to",
"the",
"current",
"environment",
".",
"This",
"allows",
"git",
"clones",
"to",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/config.py#L120-L138 | [
"def",
"check_and_load_ssh_auth",
"(",
")",
":",
"mac_username",
"=",
"get_config_value",
"(",
"constants",
".",
"CONFIG_MAC_USERNAME_KEY",
")",
"if",
"not",
"mac_username",
":",
"logging",
".",
"info",
"(",
"\"Can't setup ssh authorization; no mac_username specified\"",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _cleanup_path | Recursively delete a path upon exiting this context
manager. Supports targets that are files or directories. | dusty/commands/cp.py | def _cleanup_path(path):
"""Recursively delete a path upon exiting this context
manager. Supports targets that are files or directories."""
try:
yield
finally:
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path)
else:
... | def _cleanup_path(path):
"""Recursively delete a path upon exiting this context
manager. Supports targets that are files or directories."""
try:
yield
finally:
if os.path.exists(path):
if os.path.isdir(path):
shutil.rmtree(path)
else:
... | [
"Recursively",
"delete",
"a",
"path",
"upon",
"exiting",
"this",
"context",
"manager",
".",
"Supports",
"targets",
"that",
"are",
"files",
"or",
"directories",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/commands/cp.py#L16-L26 | [
"def",
"_cleanup_path",
"(",
"path",
")",
":",
"try",
":",
"yield",
"finally",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"path",... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | copy_between_containers | Copy a file from the source container to an intermediate staging
area on the local filesystem, then from that staging area to the
destination container.
These moves take place without demotion for two reasons:
1. There should be no permissions vulnerabilities with copying
between containers ... | dusty/commands/cp.py | def copy_between_containers(source_name, source_path, dest_name, dest_path):
"""Copy a file from the source container to an intermediate staging
area on the local filesystem, then from that staging area to the
destination container.
These moves take place without demotion for two reasons:
1. Ther... | def copy_between_containers(source_name, source_path, dest_name, dest_path):
"""Copy a file from the source container to an intermediate staging
area on the local filesystem, then from that staging area to the
destination container.
These moves take place without demotion for two reasons:
1. Ther... | [
"Copy",
"a",
"file",
"from",
"the",
"source",
"container",
"to",
"an",
"intermediate",
"staging",
"area",
"on",
"the",
"local",
"filesystem",
"then",
"from",
"that",
"staging",
"area",
"to",
"the",
"destination",
"container",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/commands/cp.py#L29-L46 | [
"def",
"copy_between_containers",
"(",
"source_name",
",",
"source_path",
",",
"dest_name",
",",
"dest_path",
")",
":",
"if",
"not",
"container_path_exists",
"(",
"source_name",
",",
"source_path",
")",
":",
"raise",
"RuntimeError",
"(",
"'ERROR: Path {} does not exis... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | copy_from_local | Copy a path from the local filesystem to a path inside a Dusty
container. The files on the local filesystem must be accessible
by the user specified in mac_username. | dusty/commands/cp.py | def copy_from_local(local_path, remote_name, remote_path, demote=True):
"""Copy a path from the local filesystem to a path inside a Dusty
container. The files on the local filesystem must be accessible
by the user specified in mac_username."""
if not os.path.exists(local_path):
raise RuntimeErro... | def copy_from_local(local_path, remote_name, remote_path, demote=True):
"""Copy a path from the local filesystem to a path inside a Dusty
container. The files on the local filesystem must be accessible
by the user specified in mac_username."""
if not os.path.exists(local_path):
raise RuntimeErro... | [
"Copy",
"a",
"path",
"from",
"the",
"local",
"filesystem",
"to",
"a",
"path",
"inside",
"a",
"Dusty",
"container",
".",
"The",
"files",
"on",
"the",
"local",
"filesystem",
"must",
"be",
"accessible",
"by",
"the",
"user",
"specified",
"in",
"mac_username",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/commands/cp.py#L49-L61 | [
"def",
"copy_from_local",
"(",
"local_path",
",",
"remote_name",
",",
"remote_path",
",",
"demote",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"local_path",
")",
":",
"raise",
"RuntimeError",
"(",
"'ERROR: Path {} does not exist... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | copy_to_local | Copy a path from inside a Dusty container to a path on the
local filesystem. The path on the local filesystem must be
wrist-accessible by the user specified in mac_username. | dusty/commands/cp.py | def copy_to_local(local_path, remote_name, remote_path, demote=True):
"""Copy a path from inside a Dusty container to a path on the
local filesystem. The path on the local filesystem must be
wrist-accessible by the user specified in mac_username."""
if not container_path_exists(remote_name, remote_path)... | def copy_to_local(local_path, remote_name, remote_path, demote=True):
"""Copy a path from inside a Dusty container to a path on the
local filesystem. The path on the local filesystem must be
wrist-accessible by the user specified in mac_username."""
if not container_path_exists(remote_name, remote_path)... | [
"Copy",
"a",
"path",
"from",
"inside",
"a",
"Dusty",
"container",
"to",
"a",
"path",
"on",
"the",
"local",
"filesystem",
".",
"The",
"path",
"on",
"the",
"local",
"filesystem",
"must",
"be",
"wrist",
"-",
"accessible",
"by",
"the",
"user",
"specified",
"... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/commands/cp.py#L64-L74 | [
"def",
"copy_to_local",
"(",
"local_path",
",",
"remote_name",
",",
"remote_path",
",",
"demote",
"=",
"True",
")",
":",
"if",
"not",
"container_path_exists",
"(",
"remote_name",
",",
"remote_path",
")",
":",
"raise",
"RuntimeError",
"(",
"'ERROR: Path {} does not... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _mount_repo | This function will create the VM directory where a repo will be mounted, if it
doesn't exist. If wait_for_server is set, it will wait up to 10 seconds for
the nfs server to start, by retrying mounts that fail with 'Connection Refused'.
If wait_for_server is not set, it will attempt to run the mount comman... | dusty/systems/nfs/client.py | def _mount_repo(repo, wait_for_server=False):
"""
This function will create the VM directory where a repo will be mounted, if it
doesn't exist. If wait_for_server is set, it will wait up to 10 seconds for
the nfs server to start, by retrying mounts that fail with 'Connection Refused'.
If wait_for_... | def _mount_repo(repo, wait_for_server=False):
"""
This function will create the VM directory where a repo will be mounted, if it
doesn't exist. If wait_for_server is set, it will wait up to 10 seconds for
the nfs server to start, by retrying mounts that fail with 'Connection Refused'.
If wait_for_... | [
"This",
"function",
"will",
"create",
"the",
"VM",
"directory",
"where",
"a",
"repo",
"will",
"be",
"mounted",
"if",
"it",
"doesn",
"t",
"exist",
".",
"If",
"wait_for_server",
"is",
"set",
"it",
"will",
"wait",
"up",
"to",
"10",
"seconds",
"for",
"the",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/nfs/client.py#L41-L65 | [
"def",
"_mount_repo",
"(",
"repo",
",",
"wait_for_server",
"=",
"False",
")",
":",
"check_call_on_vm",
"(",
"'sudo mkdir -p {}'",
".",
"format",
"(",
"repo",
".",
"vm_path",
")",
")",
"if",
"wait_for_server",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_port_spec_document | Given a dictionary containing the expanded dusty DAG specs this function will
return a dictionary containing the port mappings needed by downstream methods. Currently
this includes docker_compose, virtualbox, nginx and hosts_file. | dusty/compiler/port_spec/__init__.py | def get_port_spec_document(expanded_active_specs, docker_vm_ip):
""" Given a dictionary containing the expanded dusty DAG specs this function will
return a dictionary containing the port mappings needed by downstream methods. Currently
this includes docker_compose, virtualbox, nginx and hosts_file."""
... | def get_port_spec_document(expanded_active_specs, docker_vm_ip):
""" Given a dictionary containing the expanded dusty DAG specs this function will
return a dictionary containing the port mappings needed by downstream methods. Currently
this includes docker_compose, virtualbox, nginx and hosts_file."""
... | [
"Given",
"a",
"dictionary",
"containing",
"the",
"expanded",
"dusty",
"DAG",
"specs",
"this",
"function",
"will",
"return",
"a",
"dictionary",
"containing",
"the",
"port",
"mappings",
"needed",
"by",
"downstream",
"methods",
".",
"Currently",
"this",
"includes",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/port_spec/__init__.py#L39-L64 | [
"def",
"get_port_spec_document",
"(",
"expanded_active_specs",
",",
"docker_vm_ip",
")",
":",
"forwarding_port",
"=",
"65000",
"port_spec",
"=",
"{",
"'docker_compose'",
":",
"{",
"}",
",",
"'nginx'",
":",
"[",
"]",
",",
"'hosts_file'",
":",
"[",
"]",
"}",
"... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | init_yaml_constructor | This dark magic is used to make yaml.safe_load encode all strings as utf-8,
where otherwise python unicode strings would be returned for non-ascii chars | dusty/payload.py | def init_yaml_constructor():
"""
This dark magic is used to make yaml.safe_load encode all strings as utf-8,
where otherwise python unicode strings would be returned for non-ascii chars
"""
def utf_encoding_string_constructor(loader, node):
return loader.construct_scalar(node).encode('utf-8'... | def init_yaml_constructor():
"""
This dark magic is used to make yaml.safe_load encode all strings as utf-8,
where otherwise python unicode strings would be returned for non-ascii chars
"""
def utf_encoding_string_constructor(loader, node):
return loader.construct_scalar(node).encode('utf-8'... | [
"This",
"dark",
"magic",
"is",
"used",
"to",
"make",
"yaml",
".",
"safe_load",
"encode",
"all",
"strings",
"as",
"utf",
"-",
"8",
"where",
"otherwise",
"python",
"unicode",
"strings",
"would",
"be",
"returned",
"for",
"non",
"-",
"ascii",
"chars"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/payload.py#L52-L59 | [
"def",
"init_yaml_constructor",
"(",
")",
":",
"def",
"utf_encoding_string_constructor",
"(",
"loader",
",",
"node",
")",
":",
"return",
"loader",
".",
"construct_scalar",
"(",
"node",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"yaml",
".",
"SafeLoader",
".",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | registry_from_image | Returns the Docker registry host associated with
a given image name. | dusty/systems/docker/config.py | def registry_from_image(image_name):
"""Returns the Docker registry host associated with
a given image name."""
if '/' not in image_name: # official image
return constants.PUBLIC_DOCKER_REGISTRY
prefix = image_name.split('/')[0]
if '.' not in prefix: # user image on official repository, e.g.... | def registry_from_image(image_name):
"""Returns the Docker registry host associated with
a given image name."""
if '/' not in image_name: # official image
return constants.PUBLIC_DOCKER_REGISTRY
prefix = image_name.split('/')[0]
if '.' not in prefix: # user image on official repository, e.g.... | [
"Returns",
"the",
"Docker",
"registry",
"host",
"associated",
"with",
"a",
"given",
"image",
"name",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/docker/config.py#L15-L23 | [
"def",
"registry_from_image",
"(",
"image_name",
")",
":",
"if",
"'/'",
"not",
"in",
"image_name",
":",
"# official image",
"return",
"constants",
".",
"PUBLIC_DOCKER_REGISTRY",
"prefix",
"=",
"image_name",
".",
"split",
"(",
"'/'",
")",
"[",
"0",
"]",
"if",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_authed_registries | Reads the local Docker client config for the current user
and returns all registries to which the user may be logged in.
This is intended to be run client-side, not by the daemon. | dusty/systems/docker/config.py | def get_authed_registries():
"""Reads the local Docker client config for the current user
and returns all registries to which the user may be logged in.
This is intended to be run client-side, not by the daemon."""
result = set()
if not os.path.exists(constants.DOCKER_CONFIG_PATH):
return re... | def get_authed_registries():
"""Reads the local Docker client config for the current user
and returns all registries to which the user may be logged in.
This is intended to be run client-side, not by the daemon."""
result = set()
if not os.path.exists(constants.DOCKER_CONFIG_PATH):
return re... | [
"Reads",
"the",
"local",
"Docker",
"client",
"config",
"for",
"the",
"current",
"user",
"and",
"returns",
"all",
"registries",
"to",
"which",
"the",
"user",
"may",
"be",
"logged",
"in",
".",
"This",
"is",
"intended",
"to",
"be",
"run",
"client",
"-",
"si... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/docker/config.py#L26-L46 | [
"def",
"get_authed_registries",
"(",
")",
":",
"result",
"=",
"set",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"constants",
".",
"DOCKER_CONFIG_PATH",
")",
":",
"return",
"result",
"config",
"=",
"json",
".",
"load",
"(",
"open",
"(... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | streaming_to_client | Puts the client logger into streaming mode, which sends
unbuffered input through to the socket one character at a time.
We also disable propagation so the root logger does not
receive many one-byte emissions. This context handler
was originally created for streaming Compose up's
terminal output thro... | dusty/log.py | def streaming_to_client():
"""Puts the client logger into streaming mode, which sends
unbuffered input through to the socket one character at a time.
We also disable propagation so the root logger does not
receive many one-byte emissions. This context handler
was originally created for streaming Com... | def streaming_to_client():
"""Puts the client logger into streaming mode, which sends
unbuffered input through to the socket one character at a time.
We also disable propagation so the root logger does not
receive many one-byte emissions. This context handler
was originally created for streaming Com... | [
"Puts",
"the",
"client",
"logger",
"into",
"streaming",
"mode",
"which",
"sends",
"unbuffered",
"input",
"through",
"to",
"the",
"socket",
"one",
"character",
"at",
"a",
"time",
".",
"We",
"also",
"disable",
"propagation",
"so",
"the",
"root",
"logger",
"doe... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/log.py#L67-L88 | [
"def",
"streaming_to_client",
"(",
")",
":",
"for",
"handler",
"in",
"client_logger",
".",
"handlers",
":",
"if",
"hasattr",
"(",
"handler",
",",
"'append_newlines'",
")",
":",
"break",
"else",
":",
"handler",
"=",
"None",
"old_propagate",
"=",
"client_logger"... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | pty_fork | Runs a subprocess with a PTY attached via fork and exec.
The output from the PTY is streamed through log_to_client.
This should not be necessary for most subprocesses, we
built this to handle Compose up which only streams pull
progress if it is attached to a TTY. | dusty/commands/utils.py | def pty_fork(*args):
"""Runs a subprocess with a PTY attached via fork and exec.
The output from the PTY is streamed through log_to_client.
This should not be necessary for most subprocesses, we
built this to handle Compose up which only streams pull
progress if it is attached to a TTY."""
upda... | def pty_fork(*args):
"""Runs a subprocess with a PTY attached via fork and exec.
The output from the PTY is streamed through log_to_client.
This should not be necessary for most subprocesses, we
built this to handle Compose up which only streams pull
progress if it is attached to a TTY."""
upda... | [
"Runs",
"a",
"subprocess",
"with",
"a",
"PTY",
"attached",
"via",
"fork",
"and",
"exec",
".",
"The",
"output",
"from",
"the",
"PTY",
"is",
"streamed",
"through",
"log_to_client",
".",
"This",
"should",
"not",
"be",
"necessary",
"for",
"most",
"subprocesses",... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/commands/utils.py#L30-L56 | [
"def",
"pty_fork",
"(",
"*",
"args",
")",
":",
"updated_env",
"=",
"copy",
"(",
"os",
".",
"environ",
")",
"updated_env",
".",
"update",
"(",
"get_docker_env",
"(",
")",
")",
"args",
"+=",
"(",
"updated_env",
",",
")",
"executable",
"=",
"args",
"[",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _compile_docker_commands | This is used to compile the command that will be run when the docker container starts
up. This command has to install any libs that the app uses, run the `always` command, and
run the `once` command if the container is being launched for the first time | dusty/command_file.py | def _compile_docker_commands(app_name, assembled_specs, port_spec):
""" This is used to compile the command that will be run when the docker container starts
up. This command has to install any libs that the app uses, run the `always` command, and
run the `once` command if the container is being launched fo... | def _compile_docker_commands(app_name, assembled_specs, port_spec):
""" This is used to compile the command that will be run when the docker container starts
up. This command has to install any libs that the app uses, run the `always` command, and
run the `once` command if the container is being launched fo... | [
"This",
"is",
"used",
"to",
"compile",
"the",
"command",
"that",
"will",
"be",
"run",
"when",
"the",
"docker",
"container",
"starts",
"up",
".",
"This",
"command",
"has",
"to",
"install",
"any",
"libs",
"that",
"the",
"app",
"uses",
"run",
"the",
"always... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/command_file.py#L91-L104 | [
"def",
"_compile_docker_commands",
"(",
"app_name",
",",
"assembled_specs",
",",
"port_spec",
")",
":",
"app_spec",
"=",
"assembled_specs",
"[",
"'apps'",
"]",
"[",
"app_name",
"]",
"commands",
"=",
"[",
"'set -e'",
"]",
"commands",
"+=",
"_lib_install_commands_fo... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _increase_file_handle_limit | Raise the open file handles permitted by the Dusty daemon process
and its child processes. The number we choose here needs to be within
the OS X default kernel hard limit, which is 10240. | dusty/daemon.py | def _increase_file_handle_limit():
"""Raise the open file handles permitted by the Dusty daemon process
and its child processes. The number we choose here needs to be within
the OS X default kernel hard limit, which is 10240."""
logging.info('Increasing file handle limit to {}'.format(constants.FILE_HAN... | def _increase_file_handle_limit():
"""Raise the open file handles permitted by the Dusty daemon process
and its child processes. The number we choose here needs to be within
the OS X default kernel hard limit, which is 10240."""
logging.info('Increasing file handle limit to {}'.format(constants.FILE_HAN... | [
"Raise",
"the",
"open",
"file",
"handles",
"permitted",
"by",
"the",
"Dusty",
"daemon",
"process",
"and",
"its",
"child",
"processes",
".",
"The",
"number",
"we",
"choose",
"here",
"needs",
"to",
"be",
"within",
"the",
"OS",
"X",
"default",
"kernel",
"hard... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/daemon.py#L68-L74 | [
"def",
"_increase_file_handle_limit",
"(",
")",
":",
"logging",
".",
"info",
"(",
"'Increasing file handle limit to {}'",
".",
"format",
"(",
"constants",
".",
"FILE_HANDLE_LIMIT",
")",
")",
"resource",
".",
"setrlimit",
"(",
"resource",
".",
"RLIMIT_NOFILE",
",",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _start_http_server | Start the daemon's HTTP server on a separate thread.
This server is only used for servicing container status
requests from Dusty's custom 502 page. | dusty/daemon.py | def _start_http_server():
"""Start the daemon's HTTP server on a separate thread.
This server is only used for servicing container status
requests from Dusty's custom 502 page."""
logging.info('Starting HTTP server at {}:{}'.format(constants.DAEMON_HTTP_BIND_IP,
... | def _start_http_server():
"""Start the daemon's HTTP server on a separate thread.
This server is only used for servicing container status
requests from Dusty's custom 502 page."""
logging.info('Starting HTTP server at {}:{}'.format(constants.DAEMON_HTTP_BIND_IP,
... | [
"Start",
"the",
"daemon",
"s",
"HTTP",
"server",
"on",
"a",
"separate",
"thread",
".",
"This",
"server",
"is",
"only",
"used",
"for",
"servicing",
"container",
"status",
"requests",
"from",
"Dusty",
"s",
"custom",
"502",
"page",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/daemon.py#L88-L97 | [
"def",
"_start_http_server",
"(",
")",
":",
"logging",
".",
"info",
"(",
"'Starting HTTP server at {}:{}'",
".",
"format",
"(",
"constants",
".",
"DAEMON_HTTP_BIND_IP",
",",
"constants",
".",
"DAEMON_HTTP_BIND_PORT",
")",
")",
"thread",
"=",
"threading",
".",
"Thr... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_dusty_images | Returns all images listed in dusty specs (apps + bundles), in the form repository:tag. Tag will be set to latest
if no tag is specified in the specs | dusty/systems/docker/__init__.py | def get_dusty_images():
"""Returns all images listed in dusty specs (apps + bundles), in the form repository:tag. Tag will be set to latest
if no tag is specified in the specs"""
specs = get_specs()
dusty_image_names = [spec['image'] for spec in specs['apps'].values() + specs['services'].values() if 'i... | def get_dusty_images():
"""Returns all images listed in dusty specs (apps + bundles), in the form repository:tag. Tag will be set to latest
if no tag is specified in the specs"""
specs = get_specs()
dusty_image_names = [spec['image'] for spec in specs['apps'].values() + specs['services'].values() if 'i... | [
"Returns",
"all",
"images",
"listed",
"in",
"dusty",
"specs",
"(",
"apps",
"+",
"bundles",
")",
"in",
"the",
"form",
"repository",
":",
"tag",
".",
"Tag",
"will",
"be",
"set",
"to",
"latest",
"if",
"no",
"tag",
"is",
"specified",
"in",
"the",
"specs"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/docker/__init__.py#L18-L24 | [
"def",
"get_dusty_images",
"(",
")",
":",
"specs",
"=",
"get_specs",
"(",
")",
"dusty_image_names",
"=",
"[",
"spec",
"[",
"'image'",
"]",
"for",
"spec",
"in",
"specs",
"[",
"'apps'",
"]",
".",
"values",
"(",
")",
"+",
"specs",
"[",
"'services'",
"]",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_docker_client | Ripped off and slightly modified based on docker-py's
kwargs_from_env utility function. | dusty/systems/docker/__init__.py | def get_docker_client():
"""Ripped off and slightly modified based on docker-py's
kwargs_from_env utility function."""
env = get_docker_env()
host, cert_path, tls_verify = env['DOCKER_HOST'], env['DOCKER_CERT_PATH'], env['DOCKER_TLS_VERIFY']
params = {'base_url': host.replace('tcp://', 'https://'),... | def get_docker_client():
"""Ripped off and slightly modified based on docker-py's
kwargs_from_env utility function."""
env = get_docker_env()
host, cert_path, tls_verify = env['DOCKER_HOST'], env['DOCKER_CERT_PATH'], env['DOCKER_TLS_VERIFY']
params = {'base_url': host.replace('tcp://', 'https://'),... | [
"Ripped",
"off",
"and",
"slightly",
"modified",
"based",
"on",
"docker",
"-",
"py",
"s",
"kwargs_from_env",
"utility",
"function",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/docker/__init__.py#L42-L59 | [
"def",
"get_docker_client",
"(",
")",
":",
"env",
"=",
"get_docker_env",
"(",
")",
"host",
",",
"cert_path",
",",
"tls_verify",
"=",
"env",
"[",
"'DOCKER_HOST'",
"]",
",",
"env",
"[",
"'DOCKER_CERT_PATH'",
"]",
",",
"env",
"[",
"'DOCKER_TLS_VERIFY'",
"]",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_dusty_containers | Get a list of containers associated with the list
of services. If no services are provided, attempts to
return all containers associated with Dusty. | dusty/systems/docker/__init__.py | def get_dusty_containers(services, include_exited=False):
"""Get a list of containers associated with the list
of services. If no services are provided, attempts to
return all containers associated with Dusty."""
client = get_docker_client()
if services:
containers = [get_container_for_app_o... | def get_dusty_containers(services, include_exited=False):
"""Get a list of containers associated with the list
of services. If no services are provided, attempts to
return all containers associated with Dusty."""
client = get_docker_client()
if services:
containers = [get_container_for_app_o... | [
"Get",
"a",
"list",
"of",
"containers",
"associated",
"with",
"the",
"list",
"of",
"services",
".",
"If",
"no",
"services",
"are",
"provided",
"attempts",
"to",
"return",
"all",
"containers",
"associated",
"with",
"Dusty",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/docker/__init__.py#L61-L72 | [
"def",
"get_dusty_containers",
"(",
"services",
",",
"include_exited",
"=",
"False",
")",
":",
"client",
"=",
"get_docker_client",
"(",
")",
"if",
"services",
":",
"containers",
"=",
"[",
"get_container_for_app_or_service",
"(",
"service",
",",
"include_exited",
"... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | configure_nfs_server | This function is used with `dusty up`. It will check all active repos to see if
they are exported. If any are missing, it will replace current dusty exports with
exports that are needed for currently active repos, and restart
the nfs server | dusty/systems/nfs/server.py | def configure_nfs_server():
"""
This function is used with `dusty up`. It will check all active repos to see if
they are exported. If any are missing, it will replace current dusty exports with
exports that are needed for currently active repos, and restart
the nfs server
"""
repos_for_exp... | def configure_nfs_server():
"""
This function is used with `dusty up`. It will check all active repos to see if
they are exported. If any are missing, it will replace current dusty exports with
exports that are needed for currently active repos, and restart
the nfs server
"""
repos_for_exp... | [
"This",
"function",
"is",
"used",
"with",
"dusty",
"up",
".",
"It",
"will",
"check",
"all",
"active",
"repos",
"to",
"see",
"if",
"they",
"are",
"exported",
".",
"If",
"any",
"are",
"missing",
"it",
"will",
"replace",
"current",
"dusty",
"exports",
"with... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/nfs/server.py#L15-L35 | [
"def",
"configure_nfs_server",
"(",
")",
":",
"repos_for_export",
"=",
"get_all_repos",
"(",
"active_only",
"=",
"True",
",",
"include_specs_repo",
"=",
"False",
")",
"current_exports",
"=",
"_get_current_exports",
"(",
")",
"needed_exports",
"=",
"_get_exports_for_re... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | add_exports_for_repos | This function will add needed entries to /etc/exports. It will not remove any
entries from the file. It will then restart the server if necessary | dusty/systems/nfs/server.py | def add_exports_for_repos(repos):
"""
This function will add needed entries to /etc/exports. It will not remove any
entries from the file. It will then restart the server if necessary
"""
current_exports = _get_current_exports()
needed_exports = _get_exports_for_repos(repos)
if not needed... | def add_exports_for_repos(repos):
"""
This function will add needed entries to /etc/exports. It will not remove any
entries from the file. It will then restart the server if necessary
"""
current_exports = _get_current_exports()
needed_exports = _get_exports_for_repos(repos)
if not needed... | [
"This",
"function",
"will",
"add",
"needed",
"entries",
"to",
"/",
"etc",
"/",
"exports",
".",
"It",
"will",
"not",
"remove",
"any",
"entries",
"from",
"the",
"file",
".",
"It",
"will",
"then",
"restart",
"the",
"server",
"if",
"necessary"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/nfs/server.py#L37-L51 | [
"def",
"add_exports_for_repos",
"(",
"repos",
")",
":",
"current_exports",
"=",
"_get_current_exports",
"(",
")",
"needed_exports",
"=",
"_get_exports_for_repos",
"(",
"repos",
")",
"if",
"not",
"needed_exports",
".",
"difference",
"(",
"current_exports",
")",
":",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _ensure_managed_repos_dir_exists | Our exports file will be invalid if this folder doesn't exist, and the NFS server
will not run correctly. | dusty/systems/nfs/server.py | def _ensure_managed_repos_dir_exists():
"""
Our exports file will be invalid if this folder doesn't exist, and the NFS server
will not run correctly.
"""
if not os.path.exists(constants.REPOS_DIR):
os.makedirs(constants.REPOS_DIR) | def _ensure_managed_repos_dir_exists():
"""
Our exports file will be invalid if this folder doesn't exist, and the NFS server
will not run correctly.
"""
if not os.path.exists(constants.REPOS_DIR):
os.makedirs(constants.REPOS_DIR) | [
"Our",
"exports",
"file",
"will",
"be",
"invalid",
"if",
"this",
"folder",
"doesn",
"t",
"exist",
"and",
"the",
"NFS",
"server",
"will",
"not",
"run",
"correctly",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/nfs/server.py#L53-L59 | [
"def",
"_ensure_managed_repos_dir_exists",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"constants",
".",
"REPOS_DIR",
")",
":",
"os",
".",
"makedirs",
"(",
"constants",
".",
"REPOS_DIR",
")"
] | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | register_consumer | Given a hostname and port attempting to be accessed,
return a unique consumer ID for accessing logs from
the referenced container. | dusty/http_server.py | def register_consumer():
"""Given a hostname and port attempting to be accessed,
return a unique consumer ID for accessing logs from
the referenced container."""
global _consumers
hostname, port = request.form['hostname'], request.form['port']
app_name = _app_name_from_forwarding_info(hostname,... | def register_consumer():
"""Given a hostname and port attempting to be accessed,
return a unique consumer ID for accessing logs from
the referenced container."""
global _consumers
hostname, port = request.form['hostname'], request.form['port']
app_name = _app_name_from_forwarding_info(hostname,... | [
"Given",
"a",
"hostname",
"and",
"port",
"attempting",
"to",
"be",
"accessed",
"return",
"a",
"unique",
"consumer",
"ID",
"for",
"accessing",
"logs",
"from",
"the",
"referenced",
"container",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/http_server.py#L38-L58 | [
"def",
"register_consumer",
"(",
")",
":",
"global",
"_consumers",
"hostname",
",",
"port",
"=",
"request",
".",
"form",
"[",
"'hostname'",
"]",
",",
"request",
".",
"form",
"[",
"'port'",
"]",
"app_name",
"=",
"_app_name_from_forwarding_info",
"(",
"hostname"... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | consume | Given an existing consumer ID, return any new lines from the
log since the last time the consumer was consumed. | dusty/http_server.py | def consume(consumer_id):
"""Given an existing consumer ID, return any new lines from the
log since the last time the consumer was consumed."""
global _consumers
consumer = _consumers[consumer_id]
client = get_docker_client()
try:
status = client.inspect_container(consumer.container_id)... | def consume(consumer_id):
"""Given an existing consumer ID, return any new lines from the
log since the last time the consumer was consumed."""
global _consumers
consumer = _consumers[consumer_id]
client = get_docker_client()
try:
status = client.inspect_container(consumer.container_id)... | [
"Given",
"an",
"existing",
"consumer",
"ID",
"return",
"any",
"new",
"lines",
"from",
"the",
"log",
"since",
"the",
"last",
"time",
"the",
"consumer",
"was",
"consumed",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/http_server.py#L61-L85 | [
"def",
"consume",
"(",
"consumer_id",
")",
":",
"global",
"_consumers",
"consumer",
"=",
"_consumers",
"[",
"consumer_id",
"]",
"client",
"=",
"get_docker_client",
"(",
")",
"try",
":",
"status",
"=",
"client",
".",
"inspect_container",
"(",
"consumer",
".",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_app_volume_mounts | This returns a list of formatted volume specs for an app. These mounts declared in the apps' spec
and mounts declared in all lib specs the app depends on | dusty/compiler/compose/common.py | def get_app_volume_mounts(app_name, assembled_specs, test=False):
""" This returns a list of formatted volume specs for an app. These mounts declared in the apps' spec
and mounts declared in all lib specs the app depends on"""
app_spec = assembled_specs['apps'][app_name]
volumes = [get_command_files_vol... | def get_app_volume_mounts(app_name, assembled_specs, test=False):
""" This returns a list of formatted volume specs for an app. These mounts declared in the apps' spec
and mounts declared in all lib specs the app depends on"""
app_spec = assembled_specs['apps'][app_name]
volumes = [get_command_files_vol... | [
"This",
"returns",
"a",
"list",
"of",
"formatted",
"volume",
"specs",
"for",
"an",
"app",
".",
"These",
"mounts",
"declared",
"in",
"the",
"apps",
"spec",
"and",
"mounts",
"declared",
"in",
"all",
"lib",
"specs",
"the",
"app",
"depends",
"on"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/compose/common.py#L18-L28 | [
"def",
"get_app_volume_mounts",
"(",
"app_name",
",",
"assembled_specs",
",",
"test",
"=",
"False",
")",
":",
"app_spec",
"=",
"assembled_specs",
"[",
"'apps'",
"]",
"[",
"app_name",
"]",
"volumes",
"=",
"[",
"get_command_files_volume_mount",
"(",
"app_name",
",... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | get_lib_volume_mounts | Returns a list of the formatted volume specs for a lib | dusty/compiler/compose/common.py | def get_lib_volume_mounts(base_lib_name, assembled_specs):
""" Returns a list of the formatted volume specs for a lib"""
volumes = [_get_lib_repo_volume_mount(assembled_specs['libs'][base_lib_name])]
volumes.append(get_command_files_volume_mount(base_lib_name, test=True))
for lib_name in assembled_specs... | def get_lib_volume_mounts(base_lib_name, assembled_specs):
""" Returns a list of the formatted volume specs for a lib"""
volumes = [_get_lib_repo_volume_mount(assembled_specs['libs'][base_lib_name])]
volumes.append(get_command_files_volume_mount(base_lib_name, test=True))
for lib_name in assembled_specs... | [
"Returns",
"a",
"list",
"of",
"the",
"formatted",
"volume",
"specs",
"for",
"a",
"lib"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/compose/common.py#L30-L37 | [
"def",
"get_lib_volume_mounts",
"(",
"base_lib_name",
",",
"assembled_specs",
")",
":",
"volumes",
"=",
"[",
"_get_lib_repo_volume_mount",
"(",
"assembled_specs",
"[",
"'libs'",
"]",
"[",
"base_lib_name",
"]",
")",
"]",
"volumes",
".",
"append",
"(",
"get_command_... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _get_app_libs_volume_mounts | Returns a list of the formatted volume mounts for all libs that an app uses | dusty/compiler/compose/common.py | def _get_app_libs_volume_mounts(app_name, assembled_specs):
""" Returns a list of the formatted volume mounts for all libs that an app uses """
volumes = []
for lib_name in assembled_specs['apps'][app_name]['depends']['libs']:
lib_spec = assembled_specs['libs'][lib_name]
volumes.append("{}:{... | def _get_app_libs_volume_mounts(app_name, assembled_specs):
""" Returns a list of the formatted volume mounts for all libs that an app uses """
volumes = []
for lib_name in assembled_specs['apps'][app_name]['depends']['libs']:
lib_spec = assembled_specs['libs'][lib_name]
volumes.append("{}:{... | [
"Returns",
"a",
"list",
"of",
"the",
"formatted",
"volume",
"mounts",
"for",
"all",
"libs",
"that",
"an",
"app",
"uses"
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/compose/common.py#L55-L61 | [
"def",
"_get_app_libs_volume_mounts",
"(",
"app_name",
",",
"assembled_specs",
")",
":",
"volumes",
"=",
"[",
"]",
"for",
"lib_name",
"in",
"assembled_specs",
"[",
"'apps'",
"]",
"[",
"app_name",
"]",
"[",
"'depends'",
"]",
"[",
"'libs'",
"]",
":",
"lib_spec... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _dusty_vm_exists | We use VBox directly instead of Docker Machine because it
shaves about 0.5 seconds off the runtime of this check. | dusty/systems/virtualbox/__init__.py | def _dusty_vm_exists():
"""We use VBox directly instead of Docker Machine because it
shaves about 0.5 seconds off the runtime of this check."""
existing_vms = check_output_demoted(['VBoxManage', 'list', 'vms'])
for line in existing_vms.splitlines():
if '"{}"'.format(constants.VM_MACHINE_NAME) in... | def _dusty_vm_exists():
"""We use VBox directly instead of Docker Machine because it
shaves about 0.5 seconds off the runtime of this check."""
existing_vms = check_output_demoted(['VBoxManage', 'list', 'vms'])
for line in existing_vms.splitlines():
if '"{}"'.format(constants.VM_MACHINE_NAME) in... | [
"We",
"use",
"VBox",
"directly",
"instead",
"of",
"Docker",
"Machine",
"because",
"it",
"shaves",
"about",
"0",
".",
"5",
"seconds",
"off",
"the",
"runtime",
"of",
"this",
"check",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L64-L71 | [
"def",
"_dusty_vm_exists",
"(",
")",
":",
"existing_vms",
"=",
"check_output_demoted",
"(",
"[",
"'VBoxManage'",
",",
"'list'",
",",
"'vms'",
"]",
")",
"for",
"line",
"in",
"existing_vms",
".",
"splitlines",
"(",
")",
":",
"if",
"'\"{}\"'",
".",
"format",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _init_docker_vm | Initialize the Dusty VM if it does not already exist. | dusty/systems/virtualbox/__init__.py | def _init_docker_vm():
"""Initialize the Dusty VM if it does not already exist."""
if not _dusty_vm_exists():
log_to_client('Initializing new Dusty VM with Docker Machine')
machine_options = ['--driver', 'virtualbox',
'--virtualbox-cpu-count', '-1',
... | def _init_docker_vm():
"""Initialize the Dusty VM if it does not already exist."""
if not _dusty_vm_exists():
log_to_client('Initializing new Dusty VM with Docker Machine')
machine_options = ['--driver', 'virtualbox',
'--virtualbox-cpu-count', '-1',
... | [
"Initialize",
"the",
"Dusty",
"VM",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L93-L103 | [
"def",
"_init_docker_vm",
"(",
")",
":",
"if",
"not",
"_dusty_vm_exists",
"(",
")",
":",
"log_to_client",
"(",
"'Initializing new Dusty VM with Docker Machine'",
")",
"machine_options",
"=",
"[",
"'--driver'",
",",
"'virtualbox'",
",",
"'--virtualbox-cpu-count'",
",",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _start_docker_vm | Start the Dusty VM if it is not already running. | dusty/systems/virtualbox/__init__.py | def _start_docker_vm():
"""Start the Dusty VM if it is not already running."""
is_running = docker_vm_is_running()
if not is_running:
log_to_client('Starting docker-machine VM {}'.format(constants.VM_MACHINE_NAME))
_apply_nat_dns_host_resolver()
_apply_nat_net_less_greedy_subnet()
... | def _start_docker_vm():
"""Start the Dusty VM if it is not already running."""
is_running = docker_vm_is_running()
if not is_running:
log_to_client('Starting docker-machine VM {}'.format(constants.VM_MACHINE_NAME))
_apply_nat_dns_host_resolver()
_apply_nat_net_less_greedy_subnet()
... | [
"Start",
"the",
"Dusty",
"VM",
"if",
"it",
"is",
"not",
"already",
"running",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L105-L113 | [
"def",
"_start_docker_vm",
"(",
")",
":",
"is_running",
"=",
"docker_vm_is_running",
"(",
")",
"if",
"not",
"is_running",
":",
"log_to_client",
"(",
"'Starting docker-machine VM {}'",
".",
"format",
"(",
"constants",
".",
"VM_MACHINE_NAME",
")",
")",
"_apply_nat_dns... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | docker_vm_is_running | Using VBoxManage is 0.5 seconds or so faster than Machine. | dusty/systems/virtualbox/__init__.py | def docker_vm_is_running():
"""Using VBoxManage is 0.5 seconds or so faster than Machine."""
running_vms = check_output_demoted(['VBoxManage', 'list', 'runningvms'])
for line in running_vms.splitlines():
if '"{}"'.format(constants.VM_MACHINE_NAME) in line:
return True
return False | def docker_vm_is_running():
"""Using VBoxManage is 0.5 seconds or so faster than Machine."""
running_vms = check_output_demoted(['VBoxManage', 'list', 'runningvms'])
for line in running_vms.splitlines():
if '"{}"'.format(constants.VM_MACHINE_NAME) in line:
return True
return False | [
"Using",
"VBoxManage",
"is",
"0",
".",
"5",
"seconds",
"or",
"so",
"faster",
"than",
"Machine",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L123-L129 | [
"def",
"docker_vm_is_running",
"(",
")",
":",
"running_vms",
"=",
"check_output_demoted",
"(",
"[",
"'VBoxManage'",
",",
"'list'",
",",
"'runningvms'",
"]",
")",
"for",
"line",
"in",
"running_vms",
".",
"splitlines",
"(",
")",
":",
"if",
"'\"{}\"'",
".",
"fo... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _get_localhost_ssh_port | Something in the VM chain, either VirtualBox or Machine, helpfully
sets up localhost-to-VM forwarding on port 22. We can inspect this
rule to determine the port on localhost which gets forwarded to
22 in the VM. | dusty/systems/virtualbox/__init__.py | def _get_localhost_ssh_port():
"""Something in the VM chain, either VirtualBox or Machine, helpfully
sets up localhost-to-VM forwarding on port 22. We can inspect this
rule to determine the port on localhost which gets forwarded to
22 in the VM."""
for line in _get_vm_config():
if line.start... | def _get_localhost_ssh_port():
"""Something in the VM chain, either VirtualBox or Machine, helpfully
sets up localhost-to-VM forwarding on port 22. We can inspect this
rule to determine the port on localhost which gets forwarded to
22 in the VM."""
for line in _get_vm_config():
if line.start... | [
"Something",
"in",
"the",
"VM",
"chain",
"either",
"VirtualBox",
"or",
"Machine",
"helpfully",
"sets",
"up",
"localhost",
"-",
"to",
"-",
"VM",
"forwarding",
"on",
"port",
"22",
".",
"We",
"can",
"inspect",
"this",
"rule",
"to",
"determine",
"the",
"port",... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L194-L205 | [
"def",
"_get_localhost_ssh_port",
"(",
")",
":",
"for",
"line",
"in",
"_get_vm_config",
"(",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"'Forwarding'",
")",
":",
"spec",
"=",
"line",
".",
"split",
"(",
"'='",
")",
"[",
"1",
"]",
".",
"strip",
"(... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _get_host_only_mac_address | Returns the MAC address assigned to the host-only adapter,
using output from VBoxManage. Returned MAC address has no colons
and is lower-cased. | dusty/systems/virtualbox/__init__.py | def _get_host_only_mac_address():
"""Returns the MAC address assigned to the host-only adapter,
using output from VBoxManage. Returned MAC address has no colons
and is lower-cased."""
# Get the number of the host-only adapter
vm_config = _get_vm_config()
for line in vm_config:
if line.st... | def _get_host_only_mac_address():
"""Returns the MAC address assigned to the host-only adapter,
using output from VBoxManage. Returned MAC address has no colons
and is lower-cased."""
# Get the number of the host-only adapter
vm_config = _get_vm_config()
for line in vm_config:
if line.st... | [
"Returns",
"the",
"MAC",
"address",
"assigned",
"to",
"the",
"host",
"-",
"only",
"adapter",
"using",
"output",
"from",
"VBoxManage",
".",
"Returned",
"MAC",
"address",
"has",
"no",
"colons",
"and",
"is",
"lower",
"-",
"cased",
"."
] | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L207-L223 | [
"def",
"_get_host_only_mac_address",
"(",
")",
":",
"# Get the number of the host-only adapter",
"vm_config",
"=",
"_get_vm_config",
"(",
")",
"for",
"line",
"in",
"vm_config",
":",
"if",
"line",
".",
"startswith",
"(",
"'hostonlyadapter'",
")",
":",
"adapter_number",... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _ip_for_mac_from_ip_addr_show | Given the rather-complex output from an 'ip addr show' command
on the VM, parse the output to determine the IP address
assigned to the interface with the given MAC. | dusty/systems/virtualbox/__init__.py | def _ip_for_mac_from_ip_addr_show(ip_addr_show, target_mac):
"""Given the rather-complex output from an 'ip addr show' command
on the VM, parse the output to determine the IP address
assigned to the interface with the given MAC."""
return_next_ip = False
for line in ip_addr_show.splitlines():
... | def _ip_for_mac_from_ip_addr_show(ip_addr_show, target_mac):
"""Given the rather-complex output from an 'ip addr show' command
on the VM, parse the output to determine the IP address
assigned to the interface with the given MAC."""
return_next_ip = False
for line in ip_addr_show.splitlines():
... | [
"Given",
"the",
"rather",
"-",
"complex",
"output",
"from",
"an",
"ip",
"addr",
"show",
"command",
"on",
"the",
"VM",
"parse",
"the",
"output",
"to",
"determine",
"the",
"IP",
"address",
"assigned",
"to",
"the",
"interface",
"with",
"the",
"given",
"MAC",
... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L225-L238 | [
"def",
"_ip_for_mac_from_ip_addr_show",
"(",
"ip_addr_show",
",",
"target_mac",
")",
":",
"return_next_ip",
"=",
"False",
"for",
"line",
"in",
"ip_addr_show",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
".",
... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | _get_host_only_ip | Determine the host-only IP of the Dusty VM through Virtualbox and SSH
directly, bypassing Docker Machine. We do this because Docker Machine is
much slower, taking about 600ms total. We are basically doing the same
flow Docker Machine does in its own code. | dusty/systems/virtualbox/__init__.py | def _get_host_only_ip():
"""Determine the host-only IP of the Dusty VM through Virtualbox and SSH
directly, bypassing Docker Machine. We do this because Docker Machine is
much slower, taking about 600ms total. We are basically doing the same
flow Docker Machine does in its own code."""
mac = _get_ho... | def _get_host_only_ip():
"""Determine the host-only IP of the Dusty VM through Virtualbox and SSH
directly, bypassing Docker Machine. We do this because Docker Machine is
much slower, taking about 600ms total. We are basically doing the same
flow Docker Machine does in its own code."""
mac = _get_ho... | [
"Determine",
"the",
"host",
"-",
"only",
"IP",
"of",
"the",
"Dusty",
"VM",
"through",
"Virtualbox",
"and",
"SSH",
"directly",
"bypassing",
"Docker",
"Machine",
".",
"We",
"do",
"this",
"because",
"Docker",
"Machine",
"is",
"much",
"slower",
"taking",
"about"... | gamechanger/dusty | python | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/systems/virtualbox/__init__.py#L240-L250 | [
"def",
"_get_host_only_ip",
"(",
")",
":",
"mac",
"=",
"_get_host_only_mac_address",
"(",
")",
"ip_addr_show",
"=",
"check_output_demoted",
"(",
"[",
"'ssh'",
",",
"'-o'",
",",
"'StrictHostKeyChecking=no'",
",",
"'-o'",
",",
"'UserKnownHostsFile=/dev/null'",
",",
"'... | dc12de90bb6945023d6f43a8071e984313a1d984 |
valid | create_local_copy | Make a local copy of the sqlite cookie database and return the new filename.
This is necessary in case this database is still being written to while the user browses
to avoid sqlite locking errors. | __init__.py | def create_local_copy(cookie_file):
"""Make a local copy of the sqlite cookie database and return the new filename.
This is necessary in case this database is still being written to while the user browses
to avoid sqlite locking errors.
"""
# if type of cookie_file is a list, use the first element i... | def create_local_copy(cookie_file):
"""Make a local copy of the sqlite cookie database and return the new filename.
This is necessary in case this database is still being written to while the user browses
to avoid sqlite locking errors.
"""
# if type of cookie_file is a list, use the first element i... | [
"Make",
"a",
"local",
"copy",
"of",
"the",
"sqlite",
"cookie",
"database",
"and",
"return",
"the",
"new",
"filename",
".",
"This",
"is",
"necessary",
"in",
"case",
"this",
"database",
"is",
"still",
"being",
"written",
"to",
"while",
"the",
"user",
"browse... | borisbabic/browser_cookie3 | python | https://github.com/borisbabic/browser_cookie3/blob/e695777c54509c286991c5bb5ca65f043d748f55/__init__.py#L34-L50 | [
"def",
"create_local_copy",
"(",
"cookie_file",
")",
":",
"# if type of cookie_file is a list, use the first element in the list",
"if",
"isinstance",
"(",
"cookie_file",
",",
"list",
")",
":",
"cookie_file",
"=",
"cookie_file",
"[",
"0",
"]",
"# check if cookie file exists... | e695777c54509c286991c5bb5ca65f043d748f55 |
valid | create_cookie | Shortcut function to create a cookie | __init__.py | def create_cookie(host, path, secure, expires, name, value):
"""Shortcut function to create a cookie
"""
return http.cookiejar.Cookie(0, name, value, None, False, host, host.startswith('.'), host.startswith('.'), path,
True, secure, expires, False, None, None, {}) | def create_cookie(host, path, secure, expires, name, value):
"""Shortcut function to create a cookie
"""
return http.cookiejar.Cookie(0, name, value, None, False, host, host.startswith('.'), host.startswith('.'), path,
True, secure, expires, False, None, None, {}) | [
"Shortcut",
"function",
"to",
"create",
"a",
"cookie"
] | borisbabic/browser_cookie3 | python | https://github.com/borisbabic/browser_cookie3/blob/e695777c54509c286991c5bb5ca65f043d748f55/__init__.py#L274-L278 | [
"def",
"create_cookie",
"(",
"host",
",",
"path",
",",
"secure",
",",
"expires",
",",
"name",
",",
"value",
")",
":",
"return",
"http",
".",
"cookiejar",
".",
"Cookie",
"(",
"0",
",",
"name",
",",
"value",
",",
"None",
",",
"False",
",",
"host",
",... | e695777c54509c286991c5bb5ca65f043d748f55 |
valid | load | Try to load cookies from all supported browsers and return combined cookiejar
Optionally pass in a domain name to only load cookies from the specified domain | __init__.py | def load(domain_name=""):
"""Try to load cookies from all supported browsers and return combined cookiejar
Optionally pass in a domain name to only load cookies from the specified domain
"""
cj = http.cookiejar.CookieJar()
for cookie_fn in [chrome, firefox]:
try:
for cookie in co... | def load(domain_name=""):
"""Try to load cookies from all supported browsers and return combined cookiejar
Optionally pass in a domain name to only load cookies from the specified domain
"""
cj = http.cookiejar.CookieJar()
for cookie_fn in [chrome, firefox]:
try:
for cookie in co... | [
"Try",
"to",
"load",
"cookies",
"from",
"all",
"supported",
"browsers",
"and",
"return",
"combined",
"cookiejar",
"Optionally",
"pass",
"in",
"a",
"domain",
"name",
"to",
"only",
"load",
"cookies",
"from",
"the",
"specified",
"domain"
] | borisbabic/browser_cookie3 | python | https://github.com/borisbabic/browser_cookie3/blob/e695777c54509c286991c5bb5ca65f043d748f55/__init__.py#L295-L306 | [
"def",
"load",
"(",
"domain_name",
"=",
"\"\"",
")",
":",
"cj",
"=",
"http",
".",
"cookiejar",
".",
"CookieJar",
"(",
")",
"for",
"cookie_fn",
"in",
"[",
"chrome",
",",
"firefox",
"]",
":",
"try",
":",
"for",
"cookie",
"in",
"cookie_fn",
"(",
"domain... | e695777c54509c286991c5bb5ca65f043d748f55 |
valid | Chrome.load | Load sqlite cookies into a cookiejar | __init__.py | def load(self):
"""Load sqlite cookies into a cookiejar
"""
con = sqlite3.connect(self.tmp_cookie_file)
cur = con.cursor()
try:
# chrome <=55
cur.execute('SELECT host_key, path, secure, expires_utc, name, value, encrypted_value '
'F... | def load(self):
"""Load sqlite cookies into a cookiejar
"""
con = sqlite3.connect(self.tmp_cookie_file)
cur = con.cursor()
try:
# chrome <=55
cur.execute('SELECT host_key, path, secure, expires_utc, name, value, encrypted_value '
'F... | [
"Load",
"sqlite",
"cookies",
"into",
"a",
"cookiejar"
] | borisbabic/browser_cookie3 | python | https://github.com/borisbabic/browser_cookie3/blob/e695777c54509c286991c5bb5ca65f043d748f55/__init__.py#L147-L168 | [
"def",
"load",
"(",
"self",
")",
":",
"con",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"tmp_cookie_file",
")",
"cur",
"=",
"con",
".",
"cursor",
"(",
")",
"try",
":",
"# chrome <=55",
"cur",
".",
"execute",
"(",
"'SELECT host_key, path, secure, exp... | e695777c54509c286991c5bb5ca65f043d748f55 |
valid | Chrome._decrypt | Decrypt encoded cookies | __init__.py | def _decrypt(self, value, encrypted_value):
"""Decrypt encoded cookies
"""
if sys.platform == 'win32':
return self._decrypt_windows_chrome(value, encrypted_value)
if value or (encrypted_value[:3] != b'v10'):
return value
# Encrypted cookies should be pr... | def _decrypt(self, value, encrypted_value):
"""Decrypt encoded cookies
"""
if sys.platform == 'win32':
return self._decrypt_windows_chrome(value, encrypted_value)
if value or (encrypted_value[:3] != b'v10'):
return value
# Encrypted cookies should be pr... | [
"Decrypt",
"encoded",
"cookies"
] | borisbabic/browser_cookie3 | python | https://github.com/borisbabic/browser_cookie3/blob/e695777c54509c286991c5bb5ca65f043d748f55/__init__.py#L183-L202 | [
"def",
"_decrypt",
"(",
"self",
",",
"value",
",",
"encrypted_value",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"return",
"self",
".",
"_decrypt_windows_chrome",
"(",
"value",
",",
"encrypted_value",
")",
"if",
"value",
"or",
"(",
"encr... | e695777c54509c286991c5bb5ca65f043d748f55 |
valid | _gen | docstring for _gen | exrex.py | def _gen(d, limit=20, count=False, grouprefs=None):
"""docstring for _gen"""
if grouprefs is None:
grouprefs = {}
ret = ['']
strings = 0
literal = False
for i in d:
if i[0] == sre_parse.IN:
subs = _in(i[1])
if count:
strings = (strings or 1... | def _gen(d, limit=20, count=False, grouprefs=None):
"""docstring for _gen"""
if grouprefs is None:
grouprefs = {}
ret = ['']
strings = 0
literal = False
for i in d:
if i[0] == sre_parse.IN:
subs = _in(i[1])
if count:
strings = (strings or 1... | [
"docstring",
"for",
"_gen"
] | asciimoo/exrex | python | https://github.com/asciimoo/exrex/blob/69733409042b526da584c675907a316ad708a8d4/exrex.py#L161-L243 | [
"def",
"_gen",
"(",
"d",
",",
"limit",
"=",
"20",
",",
"count",
"=",
"False",
",",
"grouprefs",
"=",
"None",
")",
":",
"if",
"grouprefs",
"is",
"None",
":",
"grouprefs",
"=",
"{",
"}",
"ret",
"=",
"[",
"''",
"]",
"strings",
"=",
"0",
"literal",
... | 69733409042b526da584c675907a316ad708a8d4 |
valid | _randone | docstring for _randone | exrex.py | def _randone(d, limit=20, grouprefs=None):
if grouprefs is None:
grouprefs = {}
"""docstring for _randone"""
ret = ''
for i in d:
if i[0] == sre_parse.IN:
ret += choice(_in(i[1]))
elif i[0] == sre_parse.LITERAL:
ret += unichr(i[1])
elif i[0] == sre... | def _randone(d, limit=20, grouprefs=None):
if grouprefs is None:
grouprefs = {}
"""docstring for _randone"""
ret = ''
for i in d:
if i[0] == sre_parse.IN:
ret += choice(_in(i[1]))
elif i[0] == sre_parse.LITERAL:
ret += unichr(i[1])
elif i[0] == sre... | [
"docstring",
"for",
"_randone"
] | asciimoo/exrex | python | https://github.com/asciimoo/exrex/blob/69733409042b526da584c675907a316ad708a8d4/exrex.py#L246-L291 | [
"def",
"_randone",
"(",
"d",
",",
"limit",
"=",
"20",
",",
"grouprefs",
"=",
"None",
")",
":",
"if",
"grouprefs",
"is",
"None",
":",
"grouprefs",
"=",
"{",
"}",
"ret",
"=",
"''",
"for",
"i",
"in",
"d",
":",
"if",
"i",
"[",
"0",
"]",
"==",
"sr... | 69733409042b526da584c675907a316ad708a8d4 |
valid | sre_to_string | sre_parse object to string
:param sre_obj: Output of sre_parse.parse()
:type sre_obj: list
:rtype: str | exrex.py | def sre_to_string(sre_obj, paren=True):
"""sre_parse object to string
:param sre_obj: Output of sre_parse.parse()
:type sre_obj: list
:rtype: str
"""
ret = u''
for i in sre_obj:
if i[0] == sre_parse.IN:
prefix = ''
if len(i[1]) and i[1][0][0] == sre_parse.NEG... | def sre_to_string(sre_obj, paren=True):
"""sre_parse object to string
:param sre_obj: Output of sre_parse.parse()
:type sre_obj: list
:rtype: str
"""
ret = u''
for i in sre_obj:
if i[0] == sre_parse.IN:
prefix = ''
if len(i[1]) and i[1][0][0] == sre_parse.NEG... | [
"sre_parse",
"object",
"to",
"string"
] | asciimoo/exrex | python | https://github.com/asciimoo/exrex/blob/69733409042b526da584c675907a316ad708a8d4/exrex.py#L294-L382 | [
"def",
"sre_to_string",
"(",
"sre_obj",
",",
"paren",
"=",
"True",
")",
":",
"ret",
"=",
"u''",
"for",
"i",
"in",
"sre_obj",
":",
"if",
"i",
"[",
"0",
"]",
"==",
"sre_parse",
".",
"IN",
":",
"prefix",
"=",
"''",
"if",
"len",
"(",
"i",
"[",
"1",... | 69733409042b526da584c675907a316ad708a8d4 |
valid | parse | Regular expression parser
:param s: Regular expression
:type s: str
:rtype: list | exrex.py | def parse(s):
"""Regular expression parser
:param s: Regular expression
:type s: str
:rtype: list
"""
if IS_PY3:
r = sre_parse.parse(s, flags=U)
else:
r = sre_parse.parse(s.decode('utf-8'), flags=U)
return list(r) | def parse(s):
"""Regular expression parser
:param s: Regular expression
:type s: str
:rtype: list
"""
if IS_PY3:
r = sre_parse.parse(s, flags=U)
else:
r = sre_parse.parse(s.decode('utf-8'), flags=U)
return list(r) | [
"Regular",
"expression",
"parser"
] | asciimoo/exrex | python | https://github.com/asciimoo/exrex/blob/69733409042b526da584c675907a316ad708a8d4/exrex.py#L396-L407 | [
"def",
"parse",
"(",
"s",
")",
":",
"if",
"IS_PY3",
":",
"r",
"=",
"sre_parse",
".",
"parse",
"(",
"s",
",",
"flags",
"=",
"U",
")",
"else",
":",
"r",
"=",
"sre_parse",
".",
"parse",
"(",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
",",
"flags",
... | 69733409042b526da584c675907a316ad708a8d4 |
valid | ib64_patched | Patch isBase64 to prevent Base64 encoding of JSON content | pyzotero/zotero.py | def ib64_patched(self, attrsD, contentparams):
""" Patch isBase64 to prevent Base64 encoding of JSON content
"""
if attrsD.get("mode", "") == "base64":
return 0
if self.contentparams["type"].startswith("text/"):
return 0
if self.contentparams["type"].endswith("+xml"):
return ... | def ib64_patched(self, attrsD, contentparams):
""" Patch isBase64 to prevent Base64 encoding of JSON content
"""
if attrsD.get("mode", "") == "base64":
return 0
if self.contentparams["type"].startswith("text/"):
return 0
if self.contentparams["type"].endswith("+xml"):
return ... | [
"Patch",
"isBase64",
"to",
"prevent",
"Base64",
"encoding",
"of",
"JSON",
"content"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L78-L91 | [
"def",
"ib64_patched",
"(",
"self",
",",
"attrsD",
",",
"contentparams",
")",
":",
"if",
"attrsD",
".",
"get",
"(",
"\"mode\"",
",",
"\"\"",
")",
"==",
"\"base64\"",
":",
"return",
"0",
"if",
"self",
".",
"contentparams",
"[",
"\"type\"",
"]",
".",
"st... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | cleanwrap | Wrapper for Zotero._cleanup | pyzotero/zotero.py | def cleanwrap(func):
""" Wrapper for Zotero._cleanup
"""
def enc(self, *args, **kwargs):
""" Send each item to _cleanup() """
return (func(self, item, **kwargs) for item in args)
return enc | def cleanwrap(func):
""" Wrapper for Zotero._cleanup
"""
def enc(self, *args, **kwargs):
""" Send each item to _cleanup() """
return (func(self, item, **kwargs) for item in args)
return enc | [
"Wrapper",
"for",
"Zotero",
".",
"_cleanup"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L104-L112 | [
"def",
"cleanwrap",
"(",
"func",
")",
":",
"def",
"enc",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\" Send each item to _cleanup() \"\"\"",
"return",
"(",
"func",
"(",
"self",
",",
"item",
",",
"*",
"*",
"kwargs",
")",
"for... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | retrieve | Decorator for Zotero read API methods; calls _retrieve_data() and passes
the result to the correct processor, based on a lookup | pyzotero/zotero.py | def retrieve(func):
"""
Decorator for Zotero read API methods; calls _retrieve_data() and passes
the result to the correct processor, based on a lookup
"""
def wrapped_f(self, *args, **kwargs):
"""
Returns result of _retrieve_data()
func's return value is part of a URI, and... | def retrieve(func):
"""
Decorator for Zotero read API methods; calls _retrieve_data() and passes
the result to the correct processor, based on a lookup
"""
def wrapped_f(self, *args, **kwargs):
"""
Returns result of _retrieve_data()
func's return value is part of a URI, and... | [
"Decorator",
"for",
"Zotero",
"read",
"API",
"methods",
";",
"calls",
"_retrieve_data",
"()",
"and",
"passes",
"the",
"result",
"to",
"the",
"correct",
"processor",
"based",
"on",
"a",
"lookup"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L121-L207 | [
"def",
"retrieve",
"(",
"func",
")",
":",
"def",
"wrapped_f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n Returns result of _retrieve_data()\n\n func's return value is part of a URI, and it's this\n which is intercepted and p... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | ss_wrap | ensure that a SavedSearch object exists | pyzotero/zotero.py | def ss_wrap(func):
""" ensure that a SavedSearch object exists """
def wrapper(self, *args, **kwargs):
if not self.savedsearch:
self.savedsearch = SavedSearch(self)
return func(self, *args, **kwargs)
return wrapper | def ss_wrap(func):
""" ensure that a SavedSearch object exists """
def wrapper(self, *args, **kwargs):
if not self.savedsearch:
self.savedsearch = SavedSearch(self)
return func(self, *args, **kwargs)
return wrapper | [
"ensure",
"that",
"a",
"SavedSearch",
"object",
"exists"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L210-L218 | [
"def",
"ss_wrap",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"savedsearch",
":",
"self",
".",
"savedsearch",
"=",
"SavedSearch",
"(",
"self",
")",
"return",
"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | error_handler | Error handler for HTTP requests | pyzotero/zotero.py | def error_handler(req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEnti... | def error_handler(req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEnti... | [
"Error",
"handler",
"for",
"HTTP",
"requests"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1541-L1589 | [
"def",
"error_handler",
"(",
"req",
")",
":",
"error_codes",
"=",
"{",
"400",
":",
"ze",
".",
"UnsupportedParams",
",",
"401",
":",
"ze",
".",
"UserNotAuthorised",
",",
"403",
":",
"ze",
".",
"UserNotAuthorised",
",",
"404",
":",
"ze",
".",
"ResourceNotF... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.default_headers | It's always OK to include these headers | pyzotero/zotero.py | def default_headers(self):
"""
It's always OK to include these headers
"""
_headers = {
"User-Agent": "Pyzotero/%s" % __version__,
"Zotero-API-Version": "%s" % __api_version__,
}
if self.api_key:
_headers["Authorization"] = "Bearer %s" ... | def default_headers(self):
"""
It's always OK to include these headers
"""
_headers = {
"User-Agent": "Pyzotero/%s" % __version__,
"Zotero-API-Version": "%s" % __api_version__,
}
if self.api_key:
_headers["Authorization"] = "Bearer %s" ... | [
"It",
"s",
"always",
"OK",
"to",
"include",
"these",
"headers"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L281-L291 | [
"def",
"default_headers",
"(",
"self",
")",
":",
"_headers",
"=",
"{",
"\"User-Agent\"",
":",
"\"Pyzotero/%s\"",
"%",
"__version__",
",",
"\"Zotero-API-Version\"",
":",
"\"%s\"",
"%",
"__api_version__",
",",
"}",
"if",
"self",
".",
"api_key",
":",
"_headers",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._cache | Add a retrieved template to the cache for 304 checking
accepts a dict and key name, adds the retrieval time, and adds both
to self.templates as a new dict using the specified key | pyzotero/zotero.py | def _cache(self, response, key):
"""
Add a retrieved template to the cache for 304 checking
accepts a dict and key name, adds the retrieval time, and adds both
to self.templates as a new dict using the specified key
"""
# cache template and retrieval time for subsequent c... | def _cache(self, response, key):
"""
Add a retrieved template to the cache for 304 checking
accepts a dict and key name, adds the retrieval time, and adds both
to self.templates as a new dict using the specified key
"""
# cache template and retrieval time for subsequent c... | [
"Add",
"a",
"retrieved",
"template",
"to",
"the",
"cache",
"for",
"304",
"checking",
"accepts",
"a",
"dict",
"and",
"key",
"name",
"adds",
"the",
"retrieval",
"time",
"and",
"adds",
"both",
"to",
"self",
".",
"templates",
"as",
"a",
"new",
"dict",
"using... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L293-L302 | [
"def",
"_cache",
"(",
"self",
",",
"response",
",",
"key",
")",
":",
"# cache template and retrieval time for subsequent calls",
"thetime",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"timezone",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._cleanup | Remove keys we added for internal use | pyzotero/zotero.py | def _cleanup(self, to_clean, allow=()):
""" Remove keys we added for internal use
"""
# this item's been retrieved from the API, we only need the 'data'
# entry
if to_clean.keys() == ["links", "library", "version", "meta", "key", "data"]:
to_clean = to_clean["data"]
... | def _cleanup(self, to_clean, allow=()):
""" Remove keys we added for internal use
"""
# this item's been retrieved from the API, we only need the 'data'
# entry
if to_clean.keys() == ["links", "library", "version", "meta", "key", "data"]:
to_clean = to_clean["data"]
... | [
"Remove",
"keys",
"we",
"added",
"for",
"internal",
"use"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L305-L318 | [
"def",
"_cleanup",
"(",
"self",
",",
"to_clean",
",",
"allow",
"=",
"(",
")",
")",
":",
"# this item's been retrieved from the API, we only need the 'data'",
"# entry",
"if",
"to_clean",
".",
"keys",
"(",
")",
"==",
"[",
"\"links\"",
",",
"\"library\"",
",",
"\"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._retrieve_data | Retrieve Zotero items via the API
Combine endpoint and request to access the specific resource
Returns a JSON document | pyzotero/zotero.py | def _retrieve_data(self, request=None):
"""
Retrieve Zotero items via the API
Combine endpoint and request to access the specific resource
Returns a JSON document
"""
full_url = "%s%s" % (self.endpoint, request)
# The API doesn't return this any more, so we have t... | def _retrieve_data(self, request=None):
"""
Retrieve Zotero items via the API
Combine endpoint and request to access the specific resource
Returns a JSON document
"""
full_url = "%s%s" % (self.endpoint, request)
# The API doesn't return this any more, so we have t... | [
"Retrieve",
"Zotero",
"items",
"via",
"the",
"API",
"Combine",
"endpoint",
"and",
"request",
"to",
"access",
"the",
"specific",
"resource",
"Returns",
"a",
"JSON",
"document"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L320-L335 | [
"def",
"_retrieve_data",
"(",
"self",
",",
"request",
"=",
"None",
")",
":",
"full_url",
"=",
"\"%s%s\"",
"%",
"(",
"self",
".",
"endpoint",
",",
"request",
")",
"# The API doesn't return this any more, so we have to cheat",
"self",
".",
"self_link",
"=",
"request... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._extract_links | Extract self, first, next, last links from a request response | pyzotero/zotero.py | def _extract_links(self):
"""
Extract self, first, next, last links from a request response
"""
extracted = dict()
try:
for key, value in self.request.links.items():
parsed = urlparse(value["url"])
fragment = "{path}?{query}".format(pat... | def _extract_links(self):
"""
Extract self, first, next, last links from a request response
"""
extracted = dict()
try:
for key, value in self.request.links.items():
parsed = urlparse(value["url"])
fragment = "{path}?{query}".format(pat... | [
"Extract",
"self",
"first",
"next",
"last",
"links",
"from",
"a",
"request",
"response"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L337-L365 | [
"def",
"_extract_links",
"(",
"self",
")",
":",
"extracted",
"=",
"dict",
"(",
")",
"try",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"request",
".",
"links",
".",
"items",
"(",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"value",
"[",
"\"ur... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._updated | Generic call to see if a template request returns 304
accepts:
- a string to combine with the API endpoint
- a dict of format values, in case they're required by 'url'
- a template name to check for
As per the API docs, a template less than 1 hour old is
assumed to be fre... | pyzotero/zotero.py | def _updated(self, url, payload, template=None):
"""
Generic call to see if a template request returns 304
accepts:
- a string to combine with the API endpoint
- a dict of format values, in case they're required by 'url'
- a template name to check for
As per the A... | def _updated(self, url, payload, template=None):
"""
Generic call to see if a template request returns 304
accepts:
- a string to combine with the API endpoint
- a dict of format values, in case they're required by 'url'
- a template name to check for
As per the A... | [
"Generic",
"call",
"to",
"see",
"if",
"a",
"template",
"request",
"returns",
"304",
"accepts",
":",
"-",
"a",
"string",
"to",
"combine",
"with",
"the",
"API",
"endpoint",
"-",
"a",
"dict",
"of",
"format",
"values",
"in",
"case",
"they",
"re",
"required",... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L367-L402 | [
"def",
"_updated",
"(",
"self",
",",
"url",
",",
"payload",
",",
"template",
"=",
"None",
")",
":",
"# If the template is more than an hour old, try a 304",
"if",
"(",
"abs",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tz... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.add_parameters | Add URL parameters
Also ensure that only valid format/content combinations are requested | pyzotero/zotero.py | def add_parameters(self, **params):
"""
Add URL parameters
Also ensure that only valid format/content combinations are requested
"""
self.url_params = None
# we want JSON by default
if not params.get("format"):
params["format"] = "json"
# non-s... | def add_parameters(self, **params):
"""
Add URL parameters
Also ensure that only valid format/content combinations are requested
"""
self.url_params = None
# we want JSON by default
if not params.get("format"):
params["format"] = "json"
# non-s... | [
"Add",
"URL",
"parameters",
"Also",
"ensure",
"that",
"only",
"valid",
"format",
"/",
"content",
"combinations",
"are",
"requested"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L404-L427 | [
"def",
"add_parameters",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"self",
".",
"url_params",
"=",
"None",
"# we want JSON by default",
"if",
"not",
"params",
".",
"get",
"(",
"\"format\"",
")",
":",
"params",
"[",
"\"format\"",
"]",
"=",
"\"json\"",... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._build_query | Set request parameters. Will always add the user ID if it hasn't
been specifically set by an API method | pyzotero/zotero.py | def _build_query(self, query_string, no_params=False):
"""
Set request parameters. Will always add the user ID if it hasn't
been specifically set by an API method
"""
try:
query = quote(query_string.format(u=self.library_id, t=self.library_type))
except KeyErr... | def _build_query(self, query_string, no_params=False):
"""
Set request parameters. Will always add the user ID if it hasn't
been specifically set by an API method
"""
try:
query = quote(query_string.format(u=self.library_id, t=self.library_type))
except KeyErr... | [
"Set",
"request",
"parameters",
".",
"Will",
"always",
"add",
"the",
"user",
"ID",
"if",
"it",
"hasn",
"t",
"been",
"specifically",
"set",
"by",
"an",
"API",
"method"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L429-L443 | [
"def",
"_build_query",
"(",
"self",
",",
"query_string",
",",
"no_params",
"=",
"False",
")",
":",
"try",
":",
"query",
"=",
"quote",
"(",
"query_string",
".",
"format",
"(",
"u",
"=",
"self",
".",
"library_id",
",",
"t",
"=",
"self",
".",
"library_typ... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.publications | Return the contents of My Publications | pyzotero/zotero.py | def publications(self):
""" Return the contents of My Publications
"""
if self.library_type != "users":
raise ze.CallDoesNotExist(
"This API call does not exist for group libraries"
)
query_string = "/{t}/{u}/publications/items"
return self... | def publications(self):
""" Return the contents of My Publications
"""
if self.library_type != "users":
raise ze.CallDoesNotExist(
"This API call does not exist for group libraries"
)
query_string = "/{t}/{u}/publications/items"
return self... | [
"Return",
"the",
"contents",
"of",
"My",
"Publications"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L446-L454 | [
"def",
"publications",
"(",
"self",
")",
":",
"if",
"self",
".",
"library_type",
"!=",
"\"users\"",
":",
"raise",
"ze",
".",
"CallDoesNotExist",
"(",
"\"This API call does not exist for group libraries\"",
")",
"query_string",
"=",
"\"/{t}/{u}/publications/items\"",
"re... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.num_collectionitems | Return the total number of items in the specified collection | pyzotero/zotero.py | def num_collectionitems(self, collection):
""" Return the total number of items in the specified collection
"""
query = "/{t}/{u}/collections/{c}/items".format(
u=self.library_id, t=self.library_type, c=collection.upper()
)
return self._totals(query) | def num_collectionitems(self, collection):
""" Return the total number of items in the specified collection
"""
query = "/{t}/{u}/collections/{c}/items".format(
u=self.library_id, t=self.library_type, c=collection.upper()
)
return self._totals(query) | [
"Return",
"the",
"total",
"number",
"of",
"items",
"in",
"the",
"specified",
"collection"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L469-L475 | [
"def",
"num_collectionitems",
"(",
"self",
",",
"collection",
")",
":",
"query",
"=",
"\"/{t}/{u}/collections/{c}/items\"",
".",
"format",
"(",
"u",
"=",
"self",
".",
"library_id",
",",
"t",
"=",
"self",
".",
"library_type",
",",
"c",
"=",
"collection",
".",... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.num_tagitems | Return the total number of items for the specified tag | pyzotero/zotero.py | def num_tagitems(self, tag):
""" Return the total number of items for the specified tag
"""
query = "/{t}/{u}/tags/{ta}/items".format(
u=self.library_id, t=self.library_type, ta=tag
)
return self._totals(query) | def num_tagitems(self, tag):
""" Return the total number of items for the specified tag
"""
query = "/{t}/{u}/tags/{ta}/items".format(
u=self.library_id, t=self.library_type, ta=tag
)
return self._totals(query) | [
"Return",
"the",
"total",
"number",
"of",
"items",
"for",
"the",
"specified",
"tag"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L477-L483 | [
"def",
"num_tagitems",
"(",
"self",
",",
"tag",
")",
":",
"query",
"=",
"\"/{t}/{u}/tags/{ta}/items\"",
".",
"format",
"(",
"u",
"=",
"self",
".",
"library_id",
",",
"t",
"=",
"self",
".",
"library_type",
",",
"ta",
"=",
"tag",
")",
"return",
"self",
"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._totals | General method for returning total counts | pyzotero/zotero.py | def _totals(self, query):
""" General method for returning total counts
"""
self.add_parameters(limit=1)
query = self._build_query(query)
self._retrieve_data(query)
self.url_params = None
# extract the 'total items' figure
return int(self.request.headers["... | def _totals(self, query):
""" General method for returning total counts
"""
self.add_parameters(limit=1)
query = self._build_query(query)
self._retrieve_data(query)
self.url_params = None
# extract the 'total items' figure
return int(self.request.headers["... | [
"General",
"method",
"for",
"returning",
"total",
"counts"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L485-L493 | [
"def",
"_totals",
"(",
"self",
",",
"query",
")",
":",
"self",
".",
"add_parameters",
"(",
"limit",
"=",
"1",
")",
"query",
"=",
"self",
".",
"_build_query",
"(",
"query",
")",
"self",
".",
"_retrieve_data",
"(",
"query",
")",
"self",
".",
"url_params"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.key_info | Retrieve info about the permissions associated with the
key associated to the given Zotero instance | pyzotero/zotero.py | def key_info(self, **kwargs):
"""
Retrieve info about the permissions associated with the
key associated to the given Zotero instance
"""
query_string = "/keys/{k}".format(k=self.api_key)
return self._build_query(query_string) | def key_info(self, **kwargs):
"""
Retrieve info about the permissions associated with the
key associated to the given Zotero instance
"""
query_string = "/keys/{k}".format(k=self.api_key)
return self._build_query(query_string) | [
"Retrieve",
"info",
"about",
"the",
"permissions",
"associated",
"with",
"the",
"key",
"associated",
"to",
"the",
"given",
"Zotero",
"instance"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L496-L502 | [
"def",
"key_info",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"\"/keys/{k}\"",
".",
"format",
"(",
"k",
"=",
"self",
".",
"api_key",
")",
"return",
"self",
".",
"_build_query",
"(",
"query_string",
")"
] | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.fulltext_item | Get full-text content for an item | pyzotero/zotero.py | def fulltext_item(self, itemkey, **kwargs):
""" Get full-text content for an item"""
query_string = "/{t}/{u}/items/{itemkey}/fulltext".format(
t=self.library_type, u=self.library_id, itemkey=itemkey
)
return self._build_query(query_string) | def fulltext_item(self, itemkey, **kwargs):
""" Get full-text content for an item"""
query_string = "/{t}/{u}/items/{itemkey}/fulltext".format(
t=self.library_type, u=self.library_id, itemkey=itemkey
)
return self._build_query(query_string) | [
"Get",
"full",
"-",
"text",
"content",
"for",
"an",
"item"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L512-L517 | [
"def",
"fulltext_item",
"(",
"self",
",",
"itemkey",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"\"/{t}/{u}/items/{itemkey}/fulltext\"",
".",
"format",
"(",
"t",
"=",
"self",
".",
"library_type",
",",
"u",
"=",
"self",
".",
"library_id",
",",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.set_fulltext | Set full-text data for an item
<itemkey> should correspond to an existing attachment item.
payload should be a dict containing three keys:
'content': the full-text content and either
For text documents, 'indexedChars' and 'totalChars' OR
For PDFs, 'indexedPages' and 'totalPages'. | pyzotero/zotero.py | def set_fulltext(self, itemkey, payload):
""""
Set full-text data for an item
<itemkey> should correspond to an existing attachment item.
payload should be a dict containing three keys:
'content': the full-text content and either
For text documents, 'indexedChars' and 'to... | def set_fulltext(self, itemkey, payload):
""""
Set full-text data for an item
<itemkey> should correspond to an existing attachment item.
payload should be a dict containing three keys:
'content': the full-text content and either
For text documents, 'indexedChars' and 'to... | [
"Set",
"full",
"-",
"text",
"data",
"for",
"an",
"item",
"<itemkey",
">",
"should",
"correspond",
"to",
"an",
"existing",
"attachment",
"item",
".",
"payload",
"should",
"be",
"a",
"dict",
"containing",
"three",
"keys",
":",
"content",
":",
"the",
"full",
... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L519-L543 | [
"def",
"set_fulltext",
"(",
"self",
",",
"itemkey",
",",
"payload",
")",
":",
"headers",
"=",
"self",
".",
"default_headers",
"(",
")",
"headers",
".",
"update",
"(",
"{",
"\"Content-Type\"",
":",
"\"application/json\"",
"}",
")",
"req",
"=",
"requests",
"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.new_fulltext | Retrieve list of full-text content items and versions which are newer
than <version> | pyzotero/zotero.py | def new_fulltext(self, version):
"""
Retrieve list of full-text content items and versions which are newer
than <version>
"""
query_string = "/{t}/{u}/fulltext".format(
t=self.library_type, u=self.library_id
)
headers = {"since": str(version)}
... | def new_fulltext(self, version):
"""
Retrieve list of full-text content items and versions which are newer
than <version>
"""
query_string = "/{t}/{u}/fulltext".format(
t=self.library_type, u=self.library_id
)
headers = {"since": str(version)}
... | [
"Retrieve",
"list",
"of",
"full",
"-",
"text",
"content",
"items",
"and",
"versions",
"which",
"are",
"newer",
"than",
"<version",
">"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L545-L560 | [
"def",
"new_fulltext",
"(",
"self",
",",
"version",
")",
":",
"query_string",
"=",
"\"/{t}/{u}/fulltext\"",
".",
"format",
"(",
"t",
"=",
"self",
".",
"library_type",
",",
"u",
"=",
"self",
".",
"library_id",
")",
"headers",
"=",
"{",
"\"since\"",
":",
"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.last_modified_version | Get the last modified version | pyzotero/zotero.py | def last_modified_version(self, **kwargs):
""" Get the last modified version
"""
self.items(**kwargs)
return int(self.request.headers.get("last-modified-version", 0)) | def last_modified_version(self, **kwargs):
""" Get the last modified version
"""
self.items(**kwargs)
return int(self.request.headers.get("last-modified-version", 0)) | [
"Get",
"the",
"last",
"modified",
"version"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L582-L586 | [
"def",
"last_modified_version",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"items",
"(",
"*",
"*",
"kwargs",
")",
"return",
"int",
"(",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"last-modified-version\"",
",",
"0",
")... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.file | Get the file from an specific item | pyzotero/zotero.py | def file(self, item, **kwargs):
""" Get the file from an specific item
"""
query_string = "/{t}/{u}/items/{i}/file".format(
u=self.library_id, t=self.library_type, i=item.upper()
)
return self._build_query(query_string, no_params=True) | def file(self, item, **kwargs):
""" Get the file from an specific item
"""
query_string = "/{t}/{u}/items/{i}/file".format(
u=self.library_id, t=self.library_type, i=item.upper()
)
return self._build_query(query_string, no_params=True) | [
"Get",
"the",
"file",
"from",
"an",
"specific",
"item"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L630-L636 | [
"def",
"file",
"(",
"self",
",",
"item",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"\"/{t}/{u}/items/{i}/file\"",
".",
"format",
"(",
"u",
"=",
"self",
".",
"library_id",
",",
"t",
"=",
"self",
".",
"library_type",
",",
"i",
"=",
"item",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.dump | Dump a file attachment to disk, with optional filename and path | pyzotero/zotero.py | def dump(self, itemkey, filename=None, path=None):
"""
Dump a file attachment to disk, with optional filename and path
"""
if not filename:
filename = self.item(itemkey)["data"]["filename"]
if path:
pth = os.path.join(path, filename)
else:
... | def dump(self, itemkey, filename=None, path=None):
"""
Dump a file attachment to disk, with optional filename and path
"""
if not filename:
filename = self.item(itemkey)["data"]["filename"]
if path:
pth = os.path.join(path, filename)
else:
... | [
"Dump",
"a",
"file",
"attachment",
"to",
"disk",
"with",
"optional",
"filename",
"and",
"path"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L638-L653 | [
"def",
"dump",
"(",
"self",
",",
"itemkey",
",",
"filename",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"self",
".",
"item",
"(",
"itemkey",
")",
"[",
"\"data\"",
"]",
"[",
"\"filename\"",
"]",
"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.all_collections | Retrieve all collections and subcollections. Works for top-level collections
or for a specific collection. Works at all collection depths. | pyzotero/zotero.py | def all_collections(self, collid=None):
"""
Retrieve all collections and subcollections. Works for top-level collections
or for a specific collection. Works at all collection depths.
"""
all_collections = []
def subcoll(clct):
""" recursively add collections ... | def all_collections(self, collid=None):
"""
Retrieve all collections and subcollections. Works for top-level collections
or for a specific collection. Works at all collection depths.
"""
all_collections = []
def subcoll(clct):
""" recursively add collections ... | [
"Retrieve",
"all",
"collections",
"and",
"subcollections",
".",
"Works",
"for",
"top",
"-",
"level",
"collections",
"or",
"for",
"a",
"specific",
"collection",
".",
"Works",
"at",
"all",
"collection",
"depths",
"."
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L707-L732 | [
"def",
"all_collections",
"(",
"self",
",",
"collid",
"=",
"None",
")",
":",
"all_collections",
"=",
"[",
"]",
"def",
"subcoll",
"(",
"clct",
")",
":",
"\"\"\" recursively add collections to a flat master list \"\"\"",
"all_collections",
".",
"append",
"(",
"clct",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.collections_sub | Get subcollections for a specific collection | pyzotero/zotero.py | def collections_sub(self, collection, **kwargs):
""" Get subcollections for a specific collection
"""
query_string = "/{t}/{u}/collections/{c}/collections".format(
u=self.library_id, t=self.library_type, c=collection.upper()
)
return self._build_query(query_string) | def collections_sub(self, collection, **kwargs):
""" Get subcollections for a specific collection
"""
query_string = "/{t}/{u}/collections/{c}/collections".format(
u=self.library_id, t=self.library_type, c=collection.upper()
)
return self._build_query(query_string) | [
"Get",
"subcollections",
"for",
"a",
"specific",
"collection"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L742-L748 | [
"def",
"collections_sub",
"(",
"self",
",",
"collection",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"\"/{t}/{u}/collections/{c}/collections\"",
".",
"format",
"(",
"u",
"=",
"self",
".",
"library_id",
",",
"t",
"=",
"self",
".",
"library_type",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.tags | Get tags | pyzotero/zotero.py | def tags(self, **kwargs):
""" Get tags
"""
query_string = "/{t}/{u}/tags"
self.tag_data = True
return self._build_query(query_string) | def tags(self, **kwargs):
""" Get tags
"""
query_string = "/{t}/{u}/tags"
self.tag_data = True
return self._build_query(query_string) | [
"Get",
"tags"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L758-L763 | [
"def",
"tags",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"query_string",
"=",
"\"/{t}/{u}/tags\"",
"self",
".",
"tag_data",
"=",
"True",
"return",
"self",
".",
"_build_query",
"(",
"query_string",
")"
] | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.iterfollow | Generator for self.follow() | pyzotero/zotero.py | def iterfollow(self):
""" Generator for self.follow()
"""
# use same criterion as self.follow()
if self.links is None:
return
if self.links.get("next"):
yield self.follow()
else:
raise StopIteration | def iterfollow(self):
""" Generator for self.follow()
"""
# use same criterion as self.follow()
if self.links is None:
return
if self.links.get("next"):
yield self.follow()
else:
raise StopIteration | [
"Generator",
"for",
"self",
".",
"follow",
"()"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L789-L798 | [
"def",
"iterfollow",
"(",
"self",
")",
":",
"# use same criterion as self.follow()",
"if",
"self",
".",
"links",
"is",
"None",
":",
"return",
"if",
"self",
".",
"links",
".",
"get",
"(",
"\"next\"",
")",
":",
"yield",
"self",
".",
"follow",
"(",
")",
"el... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.everything | Retrieve all items in the library for a particular query
This method will override the 'limit' parameter if it's been set | pyzotero/zotero.py | def everything(self, query):
"""
Retrieve all items in the library for a particular query
This method will override the 'limit' parameter if it's been set
"""
try:
items = []
items.extend(query)
while self.links.get("next"):
ite... | def everything(self, query):
"""
Retrieve all items in the library for a particular query
This method will override the 'limit' parameter if it's been set
"""
try:
items = []
items.extend(query)
while self.links.get("next"):
ite... | [
"Retrieve",
"all",
"items",
"in",
"the",
"library",
"for",
"a",
"particular",
"query",
"This",
"method",
"will",
"override",
"the",
"limit",
"parameter",
"if",
"it",
"s",
"been",
"set"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L807-L822 | [
"def",
"everything",
"(",
"self",
",",
"query",
")",
":",
"try",
":",
"items",
"=",
"[",
"]",
"items",
".",
"extend",
"(",
"query",
")",
"while",
"self",
".",
"links",
".",
"get",
"(",
"\"next\"",
")",
":",
"items",
".",
"extend",
"(",
"self",
".... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.get_subset | Retrieve a subset of items
Accepts a single argument: a list of item IDs | pyzotero/zotero.py | def get_subset(self, subset):
"""
Retrieve a subset of items
Accepts a single argument: a list of item IDs
"""
if len(subset) > 50:
raise ze.TooManyItems("You may only retrieve 50 items per call")
# remember any url parameters that have been set
params... | def get_subset(self, subset):
"""
Retrieve a subset of items
Accepts a single argument: a list of item IDs
"""
if len(subset) > 50:
raise ze.TooManyItems("You may only retrieve 50 items per call")
# remember any url parameters that have been set
params... | [
"Retrieve",
"a",
"subset",
"of",
"items",
"Accepts",
"a",
"single",
"argument",
":",
"a",
"list",
"of",
"item",
"IDs"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L824-L839 | [
"def",
"get_subset",
"(",
"self",
",",
"subset",
")",
":",
"if",
"len",
"(",
"subset",
")",
">",
"50",
":",
"raise",
"ze",
".",
"TooManyItems",
"(",
"\"You may only retrieve 50 items per call\"",
")",
"# remember any url parameters that have been set",
"params",
"="... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._json_processor | Format and return data from API calls which return Items | pyzotero/zotero.py | def _json_processor(self, retrieved):
""" Format and return data from API calls which return Items
"""
json_kwargs = {}
if self.preserve_json_order:
json_kwargs["object_pairs_hook"] = OrderedDict
# send entries to _tags_data if there's no JSON
try:
... | def _json_processor(self, retrieved):
""" Format and return data from API calls which return Items
"""
json_kwargs = {}
if self.preserve_json_order:
json_kwargs["object_pairs_hook"] = OrderedDict
# send entries to _tags_data if there's no JSON
try:
... | [
"Format",
"and",
"return",
"data",
"from",
"API",
"calls",
"which",
"return",
"Items"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L842-L856 | [
"def",
"_json_processor",
"(",
"self",
",",
"retrieved",
")",
":",
"json_kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"preserve_json_order",
":",
"json_kwargs",
"[",
"\"object_pairs_hook\"",
"]",
"=",
"OrderedDict",
"# send entries to _tags_data if there's no JSON",
"tr... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._csljson_processor | Return a list of dicts which are dumped CSL JSON | pyzotero/zotero.py | def _csljson_processor(self, retrieved):
""" Return a list of dicts which are dumped CSL JSON
"""
items = []
json_kwargs = {}
if self.preserve_json_order:
json_kwargs["object_pairs_hook"] = OrderedDict
for csl in retrieved.entries:
items.append(jso... | def _csljson_processor(self, retrieved):
""" Return a list of dicts which are dumped CSL JSON
"""
items = []
json_kwargs = {}
if self.preserve_json_order:
json_kwargs["object_pairs_hook"] = OrderedDict
for csl in retrieved.entries:
items.append(jso... | [
"Return",
"a",
"list",
"of",
"dicts",
"which",
"are",
"dumped",
"CSL",
"JSON"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L858-L868 | [
"def",
"_csljson_processor",
"(",
"self",
",",
"retrieved",
")",
":",
"items",
"=",
"[",
"]",
"json_kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"preserve_json_order",
":",
"json_kwargs",
"[",
"\"object_pairs_hook\"",
"]",
"=",
"OrderedDict",
"for",
"csl",
"in... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._bib_processor | Return a list of strings formatted as HTML bibliography entries | pyzotero/zotero.py | def _bib_processor(self, retrieved):
""" Return a list of strings formatted as HTML bibliography entries
"""
items = []
for bib in retrieved.entries:
items.append(bib["content"][0]["value"])
self.url_params = None
return items | def _bib_processor(self, retrieved):
""" Return a list of strings formatted as HTML bibliography entries
"""
items = []
for bib in retrieved.entries:
items.append(bib["content"][0]["value"])
self.url_params = None
return items | [
"Return",
"a",
"list",
"of",
"strings",
"formatted",
"as",
"HTML",
"bibliography",
"entries"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L870-L877 | [
"def",
"_bib_processor",
"(",
"self",
",",
"retrieved",
")",
":",
"items",
"=",
"[",
"]",
"for",
"bib",
"in",
"retrieved",
".",
"entries",
":",
"items",
".",
"append",
"(",
"bib",
"[",
"\"content\"",
"]",
"[",
"0",
"]",
"[",
"\"value\"",
"]",
")",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._citation_processor | Return a list of strings formatted as HTML citation entries | pyzotero/zotero.py | def _citation_processor(self, retrieved):
""" Return a list of strings formatted as HTML citation entries
"""
items = []
for cit in retrieved.entries:
items.append(cit["content"][0]["value"])
self.url_params = None
return items | def _citation_processor(self, retrieved):
""" Return a list of strings formatted as HTML citation entries
"""
items = []
for cit in retrieved.entries:
items.append(cit["content"][0]["value"])
self.url_params = None
return items | [
"Return",
"a",
"list",
"of",
"strings",
"formatted",
"as",
"HTML",
"citation",
"entries"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L879-L886 | [
"def",
"_citation_processor",
"(",
"self",
",",
"retrieved",
")",
":",
"items",
"=",
"[",
"]",
"for",
"cit",
"in",
"retrieved",
".",
"entries",
":",
"items",
".",
"append",
"(",
"cit",
"[",
"\"content\"",
"]",
"[",
"0",
"]",
"[",
"\"value\"",
"]",
")... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.item_template | Get a template for a new item | pyzotero/zotero.py | def item_template(self, itemtype):
""" Get a template for a new item
"""
# if we have a template and it hasn't been updated since we stored it
template_name = "item_template_" + itemtype
query_string = "/items/new?itemType={i}".format(i=itemtype)
if self.templates.get(tem... | def item_template(self, itemtype):
""" Get a template for a new item
"""
# if we have a template and it hasn't been updated since we stored it
template_name = "item_template_" + itemtype
query_string = "/items/new?itemType={i}".format(i=itemtype)
if self.templates.get(tem... | [
"Get",
"a",
"template",
"for",
"a",
"new",
"item"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L895-L907 | [
"def",
"item_template",
"(",
"self",
",",
"itemtype",
")",
":",
"# if we have a template and it hasn't been updated since we stored it",
"template_name",
"=",
"\"item_template_\"",
"+",
"itemtype",
"query_string",
"=",
"\"/items/new?itemType={i}\"",
".",
"format",
"(",
"i",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero._attachment | Create attachments
accepts a list of one or more attachment template dicts
and an optional parent Item ID. If this is specified,
attachments are created under this ID | pyzotero/zotero.py | def _attachment(self, payload, parentid=None):
"""
Create attachments
accepts a list of one or more attachment template dicts
and an optional parent Item ID. If this is specified,
attachments are created under this ID
"""
attachment = Zupload(self, payload, parent... | def _attachment(self, payload, parentid=None):
"""
Create attachments
accepts a list of one or more attachment template dicts
and an optional parent Item ID. If this is specified,
attachments are created under this ID
"""
attachment = Zupload(self, payload, parent... | [
"Create",
"attachments",
"accepts",
"a",
"list",
"of",
"one",
"or",
"more",
"attachment",
"template",
"dicts",
"and",
"an",
"optional",
"parent",
"Item",
"ID",
".",
"If",
"this",
"is",
"specified",
"attachments",
"are",
"created",
"under",
"this",
"ID"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L919-L928 | [
"def",
"_attachment",
"(",
"self",
",",
"payload",
",",
"parentid",
"=",
"None",
")",
":",
"attachment",
"=",
"Zupload",
"(",
"self",
",",
"payload",
",",
"parentid",
")",
"res",
"=",
"attachment",
".",
"upload",
"(",
")",
"return",
"res"
] | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.show_condition_operators | Show available operators for a given saved search condition | pyzotero/zotero.py | def show_condition_operators(self, condition):
""" Show available operators for a given saved search condition """
# dict keys of allowed operators for the current condition
permitted_operators = self.savedsearch.conditions_operators.get(condition)
# transform these into values
p... | def show_condition_operators(self, condition):
""" Show available operators for a given saved search condition """
# dict keys of allowed operators for the current condition
permitted_operators = self.savedsearch.conditions_operators.get(condition)
# transform these into values
p... | [
"Show",
"available",
"operators",
"for",
"a",
"given",
"saved",
"search",
"condition"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L941-L949 | [
"def",
"show_condition_operators",
"(",
"self",
",",
"condition",
")",
":",
"# dict keys of allowed operators for the current condition",
"permitted_operators",
"=",
"self",
".",
"savedsearch",
".",
"conditions_operators",
".",
"get",
"(",
"condition",
")",
"# transform the... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.saved_search | Create a saved search. conditions is a list of dicts
containing search conditions, and must contain the following str keys:
condition, operator, value | pyzotero/zotero.py | def saved_search(self, name, conditions):
""" Create a saved search. conditions is a list of dicts
containing search conditions, and must contain the following str keys:
condition, operator, value
"""
self.savedsearch._validate(conditions)
payload = [{"name": name, "condi... | def saved_search(self, name, conditions):
""" Create a saved search. conditions is a list of dicts
containing search conditions, and must contain the following str keys:
condition, operator, value
"""
self.savedsearch._validate(conditions)
payload = [{"name": name, "condi... | [
"Create",
"a",
"saved",
"search",
".",
"conditions",
"is",
"a",
"list",
"of",
"dicts",
"containing",
"search",
"conditions",
"and",
"must",
"contain",
"the",
"following",
"str",
"keys",
":",
"condition",
"operator",
"value"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L952-L972 | [
"def",
"saved_search",
"(",
"self",
",",
"name",
",",
"conditions",
")",
":",
"self",
".",
"savedsearch",
".",
"_validate",
"(",
"conditions",
")",
"payload",
"=",
"[",
"{",
"\"name\"",
":",
"name",
",",
"\"conditions\"",
":",
"conditions",
"}",
"]",
"he... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.delete_saved_search | Delete one or more saved searches by passing a list of one or more
unique search keys | pyzotero/zotero.py | def delete_saved_search(self, keys):
""" Delete one or more saved searches by passing a list of one or more
unique search keys
"""
headers = {"Zotero-Write-Token": token()}
headers.update(self.default_headers())
req = requests.delete(
url=self.endpoint
... | def delete_saved_search(self, keys):
""" Delete one or more saved searches by passing a list of one or more
unique search keys
"""
headers = {"Zotero-Write-Token": token()}
headers.update(self.default_headers())
req = requests.delete(
url=self.endpoint
... | [
"Delete",
"one",
"or",
"more",
"saved",
"searches",
"by",
"passing",
"a",
"list",
"of",
"one",
"or",
"more",
"unique",
"search",
"keys"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L975-L992 | [
"def",
"delete_saved_search",
"(",
"self",
",",
"keys",
")",
":",
"headers",
"=",
"{",
"\"Zotero-Write-Token\"",
":",
"token",
"(",
")",
"}",
"headers",
".",
"update",
"(",
"self",
".",
"default_headers",
"(",
")",
")",
"req",
"=",
"requests",
".",
"dele... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.upload_attachments | Upload files to the already created (but never uploaded) attachments | pyzotero/zotero.py | def upload_attachments(self, attachments, parentid=None, basedir=None):
"""Upload files to the already created (but never uploaded) attachments"""
return Zupload(self, attachments, parentid, basedir=basedir).upload() | def upload_attachments(self, attachments, parentid=None, basedir=None):
"""Upload files to the already created (but never uploaded) attachments"""
return Zupload(self, attachments, parentid, basedir=basedir).upload() | [
"Upload",
"files",
"to",
"the",
"already",
"created",
"(",
"but",
"never",
"uploaded",
")",
"attachments"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L994-L996 | [
"def",
"upload_attachments",
"(",
"self",
",",
"attachments",
",",
"parentid",
"=",
"None",
",",
"basedir",
"=",
"None",
")",
":",
"return",
"Zupload",
"(",
"self",
",",
"attachments",
",",
"parentid",
",",
"basedir",
"=",
"basedir",
")",
".",
"upload",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.add_tags | Add one or more tags to a retrieved item,
then update it on the server
Accepts a dict, and one or more tags to add to it
Returns the updated item from the server | pyzotero/zotero.py | def add_tags(self, item, *tags):
"""
Add one or more tags to a retrieved item,
then update it on the server
Accepts a dict, and one or more tags to add to it
Returns the updated item from the server
"""
# Make sure there's a tags field, or add one
try:
... | def add_tags(self, item, *tags):
"""
Add one or more tags to a retrieved item,
then update it on the server
Accepts a dict, and one or more tags to add to it
Returns the updated item from the server
"""
# Make sure there's a tags field, or add one
try:
... | [
"Add",
"one",
"or",
"more",
"tags",
"to",
"a",
"retrieved",
"item",
"then",
"update",
"it",
"on",
"the",
"server",
"Accepts",
"a",
"dict",
"and",
"one",
"or",
"more",
"tags",
"to",
"add",
"to",
"it",
"Returns",
"the",
"updated",
"item",
"from",
"the",
... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L998-L1014 | [
"def",
"add_tags",
"(",
"self",
",",
"item",
",",
"*",
"tags",
")",
":",
"# Make sure there's a tags field, or add one",
"try",
":",
"assert",
"item",
"[",
"\"data\"",
"]",
"[",
"\"tags\"",
"]",
"except",
"AssertionError",
":",
"item",
"[",
"\"data\"",
"]",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.check_items | Check that items to be created contain no invalid dict keys
Accepts a single argument: a list of one or more dicts
The retrieved fields are cached and re-used until a 304 call fails | pyzotero/zotero.py | def check_items(self, items):
"""
Check that items to be created contain no invalid dict keys
Accepts a single argument: a list of one or more dicts
The retrieved fields are cached and re-used until a 304 call fails
"""
# check for a valid cached version
if self.t... | def check_items(self, items):
"""
Check that items to be created contain no invalid dict keys
Accepts a single argument: a list of one or more dicts
The retrieved fields are cached and re-used until a 304 call fails
"""
# check for a valid cached version
if self.t... | [
"Check",
"that",
"items",
"to",
"be",
"created",
"contain",
"no",
"invalid",
"dict",
"keys",
"Accepts",
"a",
"single",
"argument",
":",
"a",
"list",
"of",
"one",
"or",
"more",
"dicts",
"The",
"retrieved",
"fields",
"are",
"cached",
"and",
"re",
"-",
"use... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1016-L1066 | [
"def",
"check_items",
"(",
"self",
",",
"items",
")",
":",
"# check for a valid cached version",
"if",
"self",
".",
"templates",
".",
"get",
"(",
"\"item_fields\"",
")",
"and",
"not",
"self",
".",
"_updated",
"(",
"\"/itemFields\"",
",",
"self",
".",
"template... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.fields_types | Retrieve item fields or creator types | pyzotero/zotero.py | def fields_types(self, tname, qstring, itemtype):
""" Retrieve item fields or creator types
"""
# check for a valid cached version
template_name = tname + itemtype
query_string = qstring.format(i=itemtype)
if self.templates.get(template_name) and not self._updated(
... | def fields_types(self, tname, qstring, itemtype):
""" Retrieve item fields or creator types
"""
# check for a valid cached version
template_name = tname + itemtype
query_string = qstring.format(i=itemtype)
if self.templates.get(template_name) and not self._updated(
... | [
"Retrieve",
"item",
"fields",
"or",
"creator",
"types"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1094-L1106 | [
"def",
"fields_types",
"(",
"self",
",",
"tname",
",",
"qstring",
",",
"itemtype",
")",
":",
"# check for a valid cached version",
"template_name",
"=",
"tname",
"+",
"itemtype",
"query_string",
"=",
"qstring",
".",
"format",
"(",
"i",
"=",
"itemtype",
")",
"i... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.item_fields | Get all available item fields | pyzotero/zotero.py | def item_fields(self):
""" Get all available item fields
"""
# Check for a valid cached version
if self.templates.get("item_fields") and not self._updated(
"/itemFields", self.templates["item_fields"], "item_fields"
):
return self.templates["item_fields"][... | def item_fields(self):
""" Get all available item fields
"""
# Check for a valid cached version
if self.templates.get("item_fields") and not self._updated(
"/itemFields", self.templates["item_fields"], "item_fields"
):
return self.templates["item_fields"][... | [
"Get",
"all",
"available",
"item",
"fields"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1122-L1133 | [
"def",
"item_fields",
"(",
"self",
")",
":",
"# Check for a valid cached version",
"if",
"self",
".",
"templates",
".",
"get",
"(",
"\"item_fields\"",
")",
"and",
"not",
"self",
".",
"_updated",
"(",
"\"/itemFields\"",
",",
"self",
".",
"templates",
"[",
"\"it... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.create_items | Create new Zotero items
Accepts two arguments:
a list containing one or more item dicts
an optional parent item ID.
Note that this can also be used to update existing items | pyzotero/zotero.py | def create_items(self, payload, parentid=None, last_modified=None):
"""
Create new Zotero items
Accepts two arguments:
a list containing one or more item dicts
an optional parent item ID.
Note that this can also be used to update existing items
"""
... | def create_items(self, payload, parentid=None, last_modified=None):
"""
Create new Zotero items
Accepts two arguments:
a list containing one or more item dicts
an optional parent item ID.
Note that this can also be used to update existing items
"""
... | [
"Create",
"new",
"Zotero",
"items",
"Accepts",
"two",
"arguments",
":",
"a",
"list",
"containing",
"one",
"or",
"more",
"item",
"dicts",
"an",
"optional",
"parent",
"item",
"ID",
".",
"Note",
"that",
"this",
"can",
"also",
"be",
"used",
"to",
"update",
"... | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1135-L1186 | [
"def",
"create_items",
"(",
"self",
",",
"payload",
",",
"parentid",
"=",
"None",
",",
"last_modified",
"=",
"None",
")",
":",
"if",
"len",
"(",
"payload",
")",
">",
"50",
":",
"raise",
"ze",
".",
"TooManyItems",
"(",
"\"You may only create up to 50 items pe... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.create_collections | Create new Zotero collections
Accepts one argument, a list of dicts containing the following keys:
'name': the name of the collection
'parentCollection': OPTIONAL, the parent collection to which you wish to add this | pyzotero/zotero.py | def create_collections(self, payload, last_modified=None):
"""
Create new Zotero collections
Accepts one argument, a list of dicts containing the following keys:
'name': the name of the collection
'parentCollection': OPTIONAL, the parent collection to which you wish to add this
... | def create_collections(self, payload, last_modified=None):
"""
Create new Zotero collections
Accepts one argument, a list of dicts containing the following keys:
'name': the name of the collection
'parentCollection': OPTIONAL, the parent collection to which you wish to add this
... | [
"Create",
"new",
"Zotero",
"collections",
"Accepts",
"one",
"argument",
"a",
"list",
"of",
"dicts",
"containing",
"the",
"following",
"keys",
":"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1192-L1222 | [
"def",
"create_collections",
"(",
"self",
",",
"payload",
",",
"last_modified",
"=",
"None",
")",
":",
"# no point in proceeding if there's no 'name' key",
"for",
"item",
"in",
"payload",
":",
"if",
"\"name\"",
"not",
"in",
"item",
":",
"raise",
"ze",
".",
"Para... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.update_collection | Update a Zotero collection property such as 'name'
Accepts one argument, a dict containing collection data retrieved
using e.g. 'collections()' | pyzotero/zotero.py | def update_collection(self, payload, last_modified=None):
"""
Update a Zotero collection property such as 'name'
Accepts one argument, a dict containing collection data retrieved
using e.g. 'collections()'
"""
modified = payload["version"]
if last_modified is not ... | def update_collection(self, payload, last_modified=None):
"""
Update a Zotero collection property such as 'name'
Accepts one argument, a dict containing collection data retrieved
using e.g. 'collections()'
"""
modified = payload["version"]
if last_modified is not ... | [
"Update",
"a",
"Zotero",
"collection",
"property",
"such",
"as",
"name",
"Accepts",
"one",
"argument",
"a",
"dict",
"containing",
"collection",
"data",
"retrieved",
"using",
"e",
".",
"g",
".",
"collections",
"()"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1224-L1250 | [
"def",
"update_collection",
"(",
"self",
",",
"payload",
",",
"last_modified",
"=",
"None",
")",
":",
"modified",
"=",
"payload",
"[",
"\"version\"",
"]",
"if",
"last_modified",
"is",
"not",
"None",
":",
"modified",
"=",
"last_modified",
"key",
"=",
"payload... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.attachment_simple | Add attachments using filenames as title
Arguments:
One or more file paths to add as attachments:
An optional Item ID, which will create child attachments | pyzotero/zotero.py | def attachment_simple(self, files, parentid=None):
"""
Add attachments using filenames as title
Arguments:
One or more file paths to add as attachments:
An optional Item ID, which will create child attachments
"""
orig = self._attachment_template("imported_file")
... | def attachment_simple(self, files, parentid=None):
"""
Add attachments using filenames as title
Arguments:
One or more file paths to add as attachments:
An optional Item ID, which will create child attachments
"""
orig = self._attachment_template("imported_file")
... | [
"Add",
"attachments",
"using",
"filenames",
"as",
"title",
"Arguments",
":",
"One",
"or",
"more",
"file",
"paths",
"to",
"add",
"as",
"attachments",
":",
"An",
"optional",
"Item",
"ID",
"which",
"will",
"create",
"child",
"attachments"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1252-L1267 | [
"def",
"attachment_simple",
"(",
"self",
",",
"files",
",",
"parentid",
"=",
"None",
")",
":",
"orig",
"=",
"self",
".",
"_attachment_template",
"(",
"\"imported_file\"",
")",
"to_add",
"=",
"[",
"orig",
".",
"copy",
"(",
")",
"for",
"fls",
"in",
"files"... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.attachment_both | Add child attachments using title, filename
Arguments:
One or more lists or tuples containing title, file path
An optional Item ID, which will create child attachments | pyzotero/zotero.py | def attachment_both(self, files, parentid=None):
"""
Add child attachments using title, filename
Arguments:
One or more lists or tuples containing title, file path
An optional Item ID, which will create child attachments
"""
orig = self._attachment_template("impor... | def attachment_both(self, files, parentid=None):
"""
Add child attachments using title, filename
Arguments:
One or more lists or tuples containing title, file path
An optional Item ID, which will create child attachments
"""
orig = self._attachment_template("impor... | [
"Add",
"child",
"attachments",
"using",
"title",
"filename",
"Arguments",
":",
"One",
"or",
"more",
"lists",
"or",
"tuples",
"containing",
"title",
"file",
"path",
"An",
"optional",
"Item",
"ID",
"which",
"will",
"create",
"child",
"attachments"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1269-L1284 | [
"def",
"attachment_both",
"(",
"self",
",",
"files",
",",
"parentid",
"=",
"None",
")",
":",
"orig",
"=",
"self",
".",
"_attachment_template",
"(",
"\"imported_file\"",
")",
"to_add",
"=",
"[",
"orig",
".",
"copy",
"(",
")",
"for",
"f",
"in",
"files",
... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.update_item | Update an existing item
Accepts one argument, a dict containing Item data | pyzotero/zotero.py | def update_item(self, payload, last_modified=None):
"""
Update an existing item
Accepts one argument, a dict containing Item data
"""
to_send = self.check_items([payload])[0]
if last_modified is None:
modified = payload["version"]
else:
mod... | def update_item(self, payload, last_modified=None):
"""
Update an existing item
Accepts one argument, a dict containing Item data
"""
to_send = self.check_items([payload])[0]
if last_modified is None:
modified = payload["version"]
else:
mod... | [
"Update",
"an",
"existing",
"item",
"Accepts",
"one",
"argument",
"a",
"dict",
"containing",
"Item",
"data"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1286-L1312 | [
"def",
"update_item",
"(",
"self",
",",
"payload",
",",
"last_modified",
"=",
"None",
")",
":",
"to_send",
"=",
"self",
".",
"check_items",
"(",
"[",
"payload",
"]",
")",
"[",
"0",
"]",
"if",
"last_modified",
"is",
"None",
":",
"modified",
"=",
"payloa... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.update_items | Update existing items
Accepts one argument, a list of dicts containing Item data | pyzotero/zotero.py | def update_items(self, payload):
"""
Update existing items
Accepts one argument, a list of dicts containing Item data
"""
to_send = [self.check_items([p])[0] for p in payload]
headers = {}
headers.update(self.default_headers())
# the API only accepts 50 it... | def update_items(self, payload):
"""
Update existing items
Accepts one argument, a list of dicts containing Item data
"""
to_send = [self.check_items([p])[0] for p in payload]
headers = {}
headers.update(self.default_headers())
# the API only accepts 50 it... | [
"Update",
"existing",
"items",
"Accepts",
"one",
"argument",
"a",
"list",
"of",
"dicts",
"containing",
"Item",
"data"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1314-L1336 | [
"def",
"update_items",
"(",
"self",
",",
"payload",
")",
":",
"to_send",
"=",
"[",
"self",
".",
"check_items",
"(",
"[",
"p",
"]",
")",
"[",
"0",
"]",
"for",
"p",
"in",
"payload",
"]",
"headers",
"=",
"{",
"}",
"headers",
".",
"update",
"(",
"sel... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
valid | Zotero.addto_collection | Add one or more items to a collection
Accepts two arguments:
The collection ID, and an item dict | pyzotero/zotero.py | def addto_collection(self, collection, payload):
"""
Add one or more items to a collection
Accepts two arguments:
The collection ID, and an item dict
"""
ident = payload["key"]
modified = payload["version"]
# add the collection data from the item
m... | def addto_collection(self, collection, payload):
"""
Add one or more items to a collection
Accepts two arguments:
The collection ID, and an item dict
"""
ident = payload["key"]
modified = payload["version"]
# add the collection data from the item
m... | [
"Add",
"one",
"or",
"more",
"items",
"to",
"a",
"collection",
"Accepts",
"two",
"arguments",
":",
"The",
"collection",
"ID",
"and",
"an",
"item",
"dict"
] | urschrei/pyzotero | python | https://github.com/urschrei/pyzotero/blob/b378966b30146a952f7953c23202fb5a1ddf81d9/pyzotero/zotero.py#L1364-L1389 | [
"def",
"addto_collection",
"(",
"self",
",",
"collection",
",",
"payload",
")",
":",
"ident",
"=",
"payload",
"[",
"\"key\"",
"]",
"modified",
"=",
"payload",
"[",
"\"version\"",
"]",
"# add the collection data from the item",
"modified_collections",
"=",
"payload",... | b378966b30146a952f7953c23202fb5a1ddf81d9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.