zipline package
zipline.client module
- class zipline.Client(server_url, token)[source]
Bases:
objectA Zipline client.
- async with x:
Returns the client itself. Used to gracefully close the client on exit.
async with zipline.Client(server_url, token) as client: ...
- async get_version()[source]
This function is a coroutine.
Gets the Zipline server version information.
- Returns:
The version information for the server.
- Return type:
- async get_user_stats()[source]
This function is a coroutine.
Retrieve stats about the current user.
- Returns:
Stats for the current user.
- Return type:
- async create_user(*, username, password, role=UserRole.user, avatar=None)[source]
This function is a coroutine.
Creates a user.
- Parameters:
username (
str) – The username of the user to create.password (
str) – The password of the user to create.role (
UserRole) – The permissions level of the created User. Only available if used by a Super Admin.avatar (Optional[
Avatar]) –If given, an object containing the avatar to be assigned to the created user.
Example
with open('avatar.png', 'rb') as fp: avatar_bytes = fp.read() avatar_mime = 'image/png' avatar = zipline.Avatar(avatar_mime, avatar_bytes) user = await create_user( username='Example', password='s0m3th!ngs3cur3', avatar=avatar, )
- Returns:
The created user.
- Return type:
- Raises:
BadRequest – Missing required fields.
Forbidden – You do not have permission to use this endpoint.
- async edit_current_user(username=None, password=None, avatar=..., view_settings=None)[source]
This function is a coroutine.
Edit the currently authenticated user.
Note
Only provided parameters will be updated. At least one parameter must be specified.
Added in version 0.28.0.
- Parameters:
username (Optional[
str]) – The new username for the user.password (Optional[
str]) – The new password for the user.avatar (Optional[
Avatar]) – The new avatar for the user.view_settings (Optional[
UserViewSettings]) – The new view settings for the user.
- Returns:
The newly edited user model.
- Return type:
- Raises:
ValueError – No parameters were specified.
BadRequest –
usernameis already taken or any provided argument is invalid.
- async delete_user(id, /, *, remove_data=True)[source]
This function is a coroutine.
Delete a user with given id.
- async get_all_invites()[source]
This function is a coroutine.
Retrieves all invites.
Warning
This method may retrieve invites for all users, not just the user the token belongs to.
- Returns:
The invites on the server.
- Return type:
List[
Invite]
- async create_invite(*, max_uses=1, expires_at=None)[source]
This function is a coroutine.
Creates an invite.
Changed in version 0.21.0: Removed the count parameter as it’s no longer supported. Return type is now a complete Invite object as opposed to a partial model.
- Parameters:
max_uses (Optional[
int]) –The number of times the created invite can be used, by default 1. If None is passed the invite will have unlimited uses.
Added in version 0.21.0.
expires_at (Optional[Union[
datetime.datetime,datetime.timedelta]]) –When the created invite(s) should expire.
Changed in version 0.21.0: Default expiration removed. This parameter will now accept a timedelta. If None is passed, the invite will never expire.
- Returns:
The created invite.
- Return type:
- Raises:
ValueError – An invalid argument was passed.
BadRequest – Provided arguments are invalid.
- async get_all_folders(*, with_files=True)[source]
This function is a coroutine.
Returns all folders.
- async create_folder(name, /, files=None, public=False)[source]
This function is a coroutine.
Creates a folder.
- Parameters:
- Returns:
The created folder.
- Return type:
- Raises:
BadRequest – Folder name is missing or invalid. Invalid file(s) or id(s) provided.
- async get_all_urls()[source]
This function is a coroutine.
Retrieves all shortened urls for your user.
- Returns:
The requested shortened urls.
- Return type:
List[
URL]
- async shorten_url(original_url, *, vanity=None, max_views=None, password=None, enabled=True, override_domain=None, text_only=False)[source]
This function is a coroutine.
Shortens a url.
- Parameters:
original_url (
str) – The url to shorten.vanity (Optional[
str]) – A vanity name to use. None to receive a randomly assigned name.max_views (Optional[
int]) – The number of times the url can be used before being deleted. None for unlimited uses, by default None.password (Optional[
str]) –The password required to use the URL, if given.
Added in version 0.21.0.
enabled (
bool) –Whether the url should be enabled for use, by default True.
Added in version 0.21.0.
override_domain (Optional[Union[
str, List[str]]]) –The domain to return a url for. Must still be connected to the Zipline instance or it will not work. If a list of domains is passed, a random one will be chosen.
Added in version 0.28.0.
text_only (
bool) –If True, return a plain text response including only the created url, by default False.
Added in version 0.28.0.
- Returns:
If text_only is False, a full
URLinstance. Otherwise a plain string with the resulting url.- Return type:
- Raises:
ValueError – Invalid value for max views passed.
BadRequest – Vanity url already taken, max view invalid, destination is missing.
Forbidden – Creating the URL would exceed your assigned quota.
- async get_all_tags()[source]
This function is a coroutine.
Get all tags belonging to the current user.
- Returns:
The requested tags.
- Return type:
List[
Tag]
- async create_tag(name, *, color=None)[source]
This function is a coroutine.
Create a tag with a given name and color.
Added in version 0.28.0.
- Parameters:
- Returns:
The newly created tag.
- Return type:
- Raises:
BadRequest – A tag with this name already exists.
- async get_files(*, page=1, per_page=100, filter=RecentFilesFilter.all, favorite=None, sort_by=FileSearchSort.created_at, order=Order.asc, search_field=FileSearchField.file_name, search_query=None)[source]
This function is a coroutine.
Get files belonging to your user.
- Parameters:
page (
int) – The page of files to get.per_page (
int) – How many files should be returned per page.filter (
RecentFilesFilter) – A filter to apply to the files retrieved.favorite (Optional[
bool]) – Whether to search for only favorited or unfavorited files. None for all files.sort_by (
FileSearchSort) – How the results should be sorted. Defaults to creation datetime.order (
Order) – How the results should be ordered. Defaults to ascending.search_field (
FileSearchField) – What file attribute to search by. Defaults to file name.search_query (Optional[
str]) – The query to use in the search.
- Returns:
The requested search results.
- Return type:
- Raises:
BadRequest –
pageorper_pageare missing or invalid.sort_by,orderorsearch_field/search_querywere invalid.
- async iter_files(*, per_page=100, filter=RecentFilesFilter.all, favorite=None, sort_by=FileSearchSort.created_at, order=Order.asc, search_field=FileSearchField.file_name, search_query=None)[source]
Retrieves an asynchronous generator of the files owned by the current user that meet the defined criteria.
This method behaves in a similar fashion to
get_files().Added in version 0.25.0.
Example
async for file in client.iter_files(): if file.deletes_at: print(f"{file.full_url} will be removed at: {file.deletes_at:%Y-%m-%d %H:%M:%S})
- Parameters:
per_page (
int) – The number of results returned by each iteration, by default 100.filter (
RecentFilesFilter) – A filter to apply to the files retrieved.favorite (Optional[
bool]) – Whether to search for only favorited or unfavorited files. None for all files.sort_by (
FileSearchSort) – How the results should be sorted. Defaults to creation datetime.order (
Order) – How the results should be ordered. Defaults to ascending.search_field (
FileSearchField) – What file attribute to search by. Defaults to file name.search_query (Optional[
str]) – The query to use in the search.
- Yields:
File– Files that meet the search criteria.
- async get_recent_files(*, amount=10, filter=RecentFilesFilter.all)[source]
This function is a coroutine.
Gets recent files uploaded by the current user.
- Parameters:
amount (Optional[
int]) – The number of results to return, by default 10.filter (
RecentFilesFilter) –What files to get.
Changed in version 0.21.0: This is now controlled by an enum.
- Returns:
The requested Files.
- Return type:
List[
File]- Raises:
ValueError – An invalid amount was passed.
BadRequest – An invalid amount was passed.
- async delete_files(*files, delete_datasource=False)[source]
This function is a coroutine.
Delete many files from Zipline.
Added in version 0.28.0.
- Parameters:
files (Union[
zipline.models.File,str]) – The files to be removed. May either beFileobjects or a file ids.delete_datasource (
bool) – Whether to delete the files from the underlying datasource as well. Defaults to False.
- Returns:
The number of deleted files.
- Return type:
- Raises:
BadRequest – Invalid file(s) or id(s) provided.
- async bulk_file_favorite(*files, favorite)[source]
This function is a coroutine.
Update the favorite status for many files.
Note
For bulk additions to folders, see
add_files().Added in version 0.28.0.
- Parameters:
- Returns:
The number of updated files.
- Return type:
- Raises:
BadRequest – Invalid file(s) or id(s) provided.
NotFound – Specified files do not exist.
- async upload_file(*payload, format=None, compression_percent=0, expiry=None, password=None, max_views=None, override_name=None, original_name=None, folder=None, override_extension=None, override_domain=None, text_only=False)[source]
This function is a coroutine.
Upload a file to Zipline.
- Parameters:
Data regarding the file to upload.
Changed in version 0.28.0: It is now possible to pass multiple
FileDataobjects.format (Optional[
NameFormat]) –The format of the name to assign to the uploaded file, uses Zipline’s configured name formatting by default.
Changed in version 0.27.0: This parameter’s default is now
None. Previously, it wasuuid.compression_percent (Optional[
int]) – How compressed should the uploaded file be, by default 0.expiry (Optional[Union[
datetime.datetime,datetime.timedelta]]) –When the uploaded file should expire, by default None.
Changed in version 0.25.0: This parameter now accepts timedeltas as well as concrete datetimes.
password (Optional[
str]) – The password required to view the uploaded file, by default None.max_views (Optional[
int]) – The number of times the uploaded file can be viewed before it is deleted, by default None.override_name (Optional[
str]) – A name to give the uploaded file. If provided this will override the server generated name, by default None.original_name (Optional[
bool]) – Whether to preserve the original name of the file when downloaded.folder (Optional[Union[
Folder,str]]) –The folder (or it’s ID) to place this upload into automatically upon completion.
Added in version 0.15.0.
override_extension (Optional[
str]) –The extension to use for this file instead of the original.
Added in version 0.21.0.
override_domain (Optional[Union[
str, List[str]]]) –The domain to return a url for. Must still be connected to the Zipline instance or it will not work. If a list of domains is passed, a random one will be chosen.
Added in version 0.25.0.
Changed in version 0.27.0: It is now possible to pass a list of domains to select one at random from the list given.
text_only (
bool) –If True this method returns a simple string containing the url of the uploaded file, by default False.
Added in version 0.25.0.
- Returns:
Information about the file uploaded.
Changed in version 0.25.0: This now returns a
strif text_only is True.- Return type:
Union[
UploadResponse,str]- Raises:
ValueError –
compression_percentwas not in0 <= compression_percent <= 100.max_viewswas less than 0. Type offolderis invalid.BadRequest – Provided folder does not exist.
Forbidden – Folder upload not allowed for anonymous user.
PayloadTooLarge – Processing this upload would exceed the quota assigned to the currently authenticated user.
ServerError – An unexpected error occurred while processing the upload.
zipline.models module
- class zipline.models.File(_http, id, created_at, updated_at, deletes_at, favorite, original_name, name, size, type, views, max_views, password, folder_id, thumbnail, tags, url)[source]
Bases:
objectRepresents a file stored on Zipline.
- str(x)
Returns the full url of the file.
- created_at
When the file was created.
- Type:
- updated_at
When the file was last updated.
- Type:
- deletes_at
The scheduled deletion time of the file, if applicable.
- Type:
Optional[
datetime.datetime]
- max_views
The maximum number of times the file can be viewed before being removed, if applicable.
- Type:
Optional[
int]
- property thumbnail_url
returns: The full url for the thumbnail image, if available. :rtype: Optional[
str]
- async download_password_protected(password)[source]
This function is a coroutine.
Download this file if password protected.
- async edit(*, favorite=None, tags=None, max_views=None, original_name=None, password=None, type=None)[source]
This function is a coroutine.
Update this file.
- Parameters:
favorite (Optional[
bool]) – The new favorite status of the file, if given.tags (Optional[Sequence[
Tag]]) – Tag to apply to this file, if given.max_views (Optional[
int]) – The new maximum views of the file, if given.original_name (Optional[
str]) – The new original name of the file, if given.password (Optional[
str]) – The new password for the file, if given.type (Optional[
str]) –The new MIME type for the file, if given.
Warning
Misuse of this parameter can cause files to display incorrectly or fail outright.
- Returns:
The updated file.
- Return type:
- Raises:
BadRequest – Required fields missing or invalid, numeric fields are invalid, or tags provided are invalid or no longer exist.
NotFound – This file no longer exists.
- async add_favorite()[source]
This function is a coroutine.
Favorite this file.
- Returns:
A new instance with the latest information about this file.
- Return type:
- Raises:
ValueError – The file is already favorited.
NotFound – This file no longer exists.
- async add_tag(tag, /)[source]
This function is a coroutine.
Add a tag to this file.
Added in version 0.28.0.
Note
This method should not be used for bulk updates. Please use
edit()instead.Equivalent to:
tag = ... current_tags = file.tags or [] current_tags.append(tag) await file.edit(tags=current_tags)
- Parameters:
tag (
Tag) – The tag to be added to this file.- Returns:
A new instance with the latest information about this file.
- Return type:
- Raises:
ValueError – The tag is already applied to this file.
NotFound – This file no longer exists or the provided tag could not be found.
- async remove_tag(tag, /)[source]
This function is a coroutine.
Remove a tag from this file.
Added in version 0.28.0.
tag = ... current_tags = file.tags or [] current_tags.remove(tag) await file.edit(tags=current_tags)
- Parameters:
tag (
Tag) – The tag to be removed from this file.- Returns:
A new instance with the latest information about this file.
- Return type:
- Raises:
ValueError – The file does not have the given tag.
NotFound – This file no longer exists or the tag provided does not exist.
- async remove_favorite()[source]
This function is a coroutine.
Unfavorite this file.
- Returns:
A new instance with the latest information about this file.
- Return type:
- Raises:
ValueError – The file is already not favorited.
- class zipline.models.Folder(_http, id, created_at, updated_at, name, public, files, user, user_id)[source]
Bases:
objectRepresents a folder on Zipline.
- str(x)
Returns the full url of the folder.
- created_at
When the folder was created.
- Type:
- updated_at
When the folder was last updated.
- Type:
- async edit(*, name=None, public=None, allow_uploads=None)[source]
This function is a coroutine.
Edit this folder.
- Parameters:
name (Optional[
str]) –The new name of this folder, if given.
Changed in version 0.28.0: This field is no longer required.
public (Optional[
bool]) –Whether this folder should be public.
Added in version 0.28.0.
allow_uploads (Optional[
bool]) –Whether this folder should allow unauthenticated uploads.
Added in version 0.28.0.
- Returns:
The updated folder.
- Return type:
- Raises:
BadRequest – At least one field must be provided.
NotFound – This folder no longer exists.
- async remove_file(file, /)[source]
This function is a coroutine.
Remove a file from this folder.
- Parameters:
file (Union[
File,str]) – The file or file id to remove from this folder.- Returns:
A new instance with the latest information about this folder.
- Return type:
- Raises:
BadRequest – Provided file not in folder.
NotFound – This folder no longer exists or the provided file no longer exists.
Forbidden – The authenticated user does not own the provided file or does not own this folder.
- async add_files(files, /)[source]
This function is a coroutine.
Add multiple files to this folder.
- Parameters:
files (Sequence[Union[
File,str]]) – The files or file ids to add to this folder.- Returns:
A new instance with the latest information about this folder.
- Return type:
- Raises:
BadRequest – Invalid file(s) or id(s) provided.
NotFound – Any of the specified files do not exist, this folder no longer exists, or this folder is not owned by the authenticated user.
- class zipline.models.User(_http, id, username, created_at, updated_at, role, view, sessions, oauth_providers, totp_secret, passkeys, quota, avatar, password, token)[source]
Bases:
objectRepresents a Zipline user.
- str(x)
Returns the username of this user.
- created_at
When this user was created or registered.
- Type:
- updated_at
The last time this user was updated.
- Type:
- view
Custom view info for this user.
- Type:
- oauth_providers
OAuth providers registered for this user.
- Type:
List[
OAuthProvider]
- passkeys
Passkeys registered for this user.
- Type:
List[
UserPasskey]
- async refresh()[source]
This function is a coroutine.
Retrieve the latest information about this user.
- async edit(*, username=None, password=None, avatar=None, role=None, quota=None)[source]
This function is a coroutine.
Edit this user.
- Parameters:
username (Optional[
str]) – The new username for this user, if given.password (Optional[
str]) – The new password for this user, if given.avatar (Optional[
Avatar]) – The new avatar for this user, if given.role (Optional[
UserRole]) – The new role for this user, if given.quota (Optional[Union[
UserQuota,PartialQuota]]) – The new quota for this user, if given.
- Returns:
The updated user.
- Return type:
- Raises:
BadRequest – Invalid fields, missing required quota properties, invalid role.
NotFound – If the user with this ID no longer exists.
- async get_files(*, page=1, per_page=10, filter=RecentFilesFilter.all, favorite=None, sort_by=FileSearchSort.created_at, order=Order.asc, search_field=FileSearchField.file_name, search_query=None)[source]
This function is a coroutine.
Get files belonging to this user.
Note
This route requires that you have an account with the Super Admin type.
- Parameters:
page (
int) – The page of files to get.per_page (
int) – How many files should be returned per page.filter (
RecentFilesFilter) – A filter to apply to the files retrieved.favorite (Optional[
bool]) – Whether to search for only favorited or unfavorited files. None for all files.sort_by (
FileSearchSort) – How the results should be sorted. Defaults to creation datetime.order (
Order) – How the results should be ordered. Defaults to ascending.search_field (
FileSearchField) – What file attribute to search by. Defaults to file name.search_query (Optional[
str]) – The query to use in the search.
- Returns:
The requested search results.
- Return type:
- class zipline.models.InviteUser(_http, username, id, role)[source]
Bases:
objectUser information provided with an
Invite.- str(x)
Returns the full url of the file.
- class zipline.models.Invite(_http, id, created_at, updated_at, expires_at, code, uses, max_uses, inviter, inviter_id)[source]
Bases:
objectRepresents an invite to a Zipline instance.
- str(x)
Returns the url of the invite.
- created_at
When this invite was created.
- Type:
- updated_at
When this invite was last updated.
- Type:
- expires_at
When this invite expires, if applicable.
- Type:
Optional[
datetime.datetime]
- max_uses
The number of times this invite can be used before it’s no longer valid, if applicable.
- Type:
Optional[
int]
- inviter
The user that is attributed to the creation of this invite.
- Type:
- class zipline.models.Tag(_http, id, created_at, updated_at, name, color, files)[source]
Bases:
objectRepresents a tag on Zipline.
- str(x)
Returns the name of this tag.
- created_at
When this tag was created.
- Type:
- updated_at
When this tag was last updated.
- Type:
- async edit(color=None, name=None)[source]
This function is a coroutine.
Edit this tag.
- Parameters:
- Returns:
The updated tag.
- Return type:
- Raises:
BadRequest – New name provided is already taken.
NotFound – This tag no longer exists.
- class zipline.models.URL(_http, id, created_at, updated_at, code, vanity, destination, views, max_views, password, enabled, user, user_id)[source]
Bases:
objectRepresents a shortened url on Zipline.
- str(x)
Returns the link to use the URL.
- created_at
When this url was created.
- Type:
- updated_at
When this url was last updated.
- Type:
- async edit(max_views=None, vanity=None, destination=None, enabled=None, password=None)[source]
This function is a coroutine.
Edit this url.
- Parameters:
max_views (Optional[
int]) – The new maximum views, if given.vanity (Optional[
str]) – The new vanity code this url should have, if given.destination (Optional[
str]) – The new destination, if given.enabled (Optional[
bool]) – Whether this url should be usable, if given.password (Optional[
str]) – The new password required to use this url, if given.
- Returns:
The updated url.
- Return type:
- Raises:
BadRequest –
vanityis already taken,max_viewsis invalid, ordestinationis invalid.NotFound – This URL no longer exists.
- class zipline.models.UploadFile(_http, id, type, url)[source]
Bases:
objectFile data given by the API when a file is uploaded.
- str(x)
Returns the full url of the uploaded file.
- class zipline.models.UploadResponse(_http, files, deletes_at)[source]
Bases:
objectResponse given by the API when a file or multiple files are uploaded.
- files
A list of information about the files uploaded.
- Type:
List[
UploadFile]
- class zipline.models.FileData(data, filename=None, *, mimetype=None)[source]
Bases:
objectUsed to upload a File to Zipline.
- data
The file or file like object to open.
- Type:
Union[
str,bytes,os.PathLike,io.BufferedIOBase]
- class zipline.models.PartialQuota(type, value=None, max_urls=...)[source]
Bases:
objectA partial quota useful for creating a new quota for a
User.
- class zipline.models.UserQuota(_http, id, created_at, updated_at, files_quota, max_bytes, max_files, max_urls, user, user_id)[source]
Bases:
objectRepresents a quota assigned to a
Userin Zipline.Note
While this class may be used to update a user’s quota this class is not intended to be created manually and should not be used for this purpose.
Usage of
PartialQuotais recommended this purpose instead.- created_at
When this quota was created.
- Type:
- updated_at
When this quota was last updated.
- Type:
- class zipline.models.OAuthProvider(id, created_at, updated_at, user_id, provider, username, access_token, refresh_token, oauth_id)[source]
Bases:
objectRepresents an OAuth provider being used by a
Useron Zipline.- created_at
When this entry was created.
- Type:
- updated_at
When this entry was updated.
- Type:
- provider
The service this entry is for.
- Type:
- class zipline.models.UserViewSettings(enabled, align, show_mimetype, show_tags, show_folder, content, embed, embed_title, embed_description, embed_color, embed_site_name)[source]
Bases:
objectRepresents view settings for a Zipline
User.- align
How the content should be aligned on the page.
- Type:
Optional[Literal[‘left’, ‘center’, ‘right’]]
- show_folder
Whether to show the folder this file is in.
Added in version 0.28.0.
- Type:
Optional[
bool]
- embed_description
The description of the embed the content will generate, if applicable.
- Type:
Optional[
str]
- class zipline.models.ServerVersionInfo(latest_tag, latest_url, latest_commit, is_upstream, is_release, is_latest, version_tag, version_sha, version_url, details_version, details_sha, cached)[source]
Bases:
objectVersion information for a Zipline instance.
Changed in version 0.28.0: This now only supports the latest versioning scheme in use by Zipline as of
4.1.0.- latest_commit
Information about the latest commit. Only available if the server is running an upstream version. Available keys are:
sha,url,pull.
- property version
Returns the Zipline version currently in use.
- class zipline.models.UserStats(files_uploaded, favorite_files, views, avg_views, storage_used, avg_storage_used, urls_created, url_views, sort_type_count)[source]
Bases:
objectStats for a Zipline
User.
- class zipline.models.UserFilesResponse(page, search, total, pages)[source]
Bases:
objectRepresents a response to a file search on Zipline.
- class zipline.models.Avatar(data, mime=None)[source]
Bases:
objectWraps the representation of avatars in Zipline.
- str(x)
Returns the encoded data for this Avatar.
- mime
The MIME type of the data. If not given the library will attempt to guess the type.
- Type:
Optional[
str]
- classmethod from_coded_string(coded_str)[source]
Transforms a coded string.
- Parameters:
coded_str (
str) – The string to transform
- to_payload_str()[source]
Returns the base64 encoded string for use in Zipline requests.
- Returns:
The string for use in requests.
- Return type:
- Raises:
ZiplineError – MIME type is None.
zipline.enums module
- class zipline.enums.QuotaType(value)[source]
-
The different types of quotas that can be applied to a user.
zipline.color module
- class zipline.color.Color(value)[source]
Bases:
objectRepresents a color for use on Zipline.
An alias named Colour is also supplied.
- str(x)
Returns the hex format of the color.
- int(x)
Returns the raw value of the color.
- classmethod from_str(value)[source]
Construct a Color from a given string.
Supported formats:
RGB:
`rgb(rrr, ggg, bbb)`HSV:
hsv(hh, 0.s, 0.v)Hex:
#rrggbbor#rgb
- Parameters:
value (
str) – The correctly formatted input string.- Returns:
The resulting Color.
- Return type:
- Raises:
ValueError – Input string does not match supported formats.
zipline.utils module
- zipline.utils.get(iterable, /, **attrs)[source]
A helper that returns the first element in the iterable that meets all the traits passed in
attrs.When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by
x.y) then pass inx__yas the keyword argument.If nothing is found that matches the attributes passed, then
Noneis returned.- Parameters:
iterable (Union[
collections.abc.Iterable,collections.abc.AsyncIterable]) – The iterable to search through. Using acollections.abc.AsyncIterable, makes this function return a coroutine.**attrs – Keyword arguments that denote attributes to search with.
- zipline.utils.utcnow()[source]
Returns an aware UTC datetime representing the current time.
- Returns:
The current time in UTC as an aware datetime.
- Return type:
- zipline.utils.as_chunks(iterable, n)[source]
Batches an iterable into chunks of up to size n.
- Parameters:
iterable (
collections.abc.Iterable) – The iterable to batchn (
int) – The number of elements per generated tuple.
- Raises:
ValueError – At least one result must be returned per group.
- zipline.utils.slotted_dataclass_to_dict(inst)[source]
Recursively transforms a slotted dataclass instance into a json-like Python object.
- Parameters:
inst (Any) – The class instance to convert.
- Returns:
A json-like structure representing the given instance.
- Return type:
JSON
- Raises:
TypeError – An invalid value was given for
inst.
zipline.errors module
- class zipline.errors.HTTPError(message, code)[source]
Bases:
ZiplineErrorBase class for HTTP related exceptions. All children implement the attributes of this class.
- message
The message returned by the API.
- Type:
Any
- class zipline.errors.UnhandledError(message, code)[source]
Bases:
HTTPErrorRaised by the library if the server returns a status code not handled by the lib.
- class zipline.errors.BadRequest(message, code)[source]
Bases:
HTTPErrorServer returned a 400 response.
- class zipline.errors.Forbidden(message, code)[source]
Bases:
HTTPErrorServer returned a 401 or 403 response.
- class zipline.errors.NotFound(message, code)[source]
Bases:
HTTPErrorServer returned a 404 response.
- class zipline.errors.PayloadTooLarge(message, code)[source]
Bases:
HTTPErrorServer returned a 413 response.
Added in version 0.28.0.
- class zipline.errors.RateLimited(message, code)[source]
Bases:
HTTPErrorServer returned a 429 response.