Search is not available for this dataset
text stringlengths 75 104k |
|---|
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 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 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 _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_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 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 _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 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_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_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 _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 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 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 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 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 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 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 _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 _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 _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 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_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_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 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 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 _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 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 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 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_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_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 _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 _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 _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 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 _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_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 _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 _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 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_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 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(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 _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 _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 _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 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 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 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 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 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 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 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 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 _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 _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 _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 _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 _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 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 _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 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 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_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 _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 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 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 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 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 last_modified_version(self, **kwargs):
""" Get the last modified version
"""
self.items(**kwargs)
return int(self.request.headers.get("last-modified-version", 0)) |
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 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 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 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 tags(self, **kwargs):
""" Get tags
"""
query_string = "/{t}/{u}/tags"
self.tag_data = True
return self._build_query(query_string) |
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 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 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 _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 _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 _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 _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 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 _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 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 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 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 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 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 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 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 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 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_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 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 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_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 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_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 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.