asynchronous generic cloud drive library
Project description
wcpan.drive
Asynchronous generic cloud drive library.
This package needs a driver to actually work with a cloud drive.
Example Usage
from wcpan.drive.core.drive import (
DriveFactory, download_to_local, upload_from_local,
)
async def simple_demo():
# Load config and data from default locations.
factory = DriveFactory()
factory.load_config()
async with factory() as drive:
# Check for authorization.
if not await drive.is_authorized():
# Start OAuth 2.0 process
url = await drive.get_oauth_url()
# ... The user visits the url ...
# Get tokens from the user.
token = ...
# Finish OAuth 2.0 process.
await drive.set_oauth_token(token)
# It is important to keep cache in sync.
async for change in drive.sync():
print(change)
# Get the root node.
root_node = await drive.get_root_node()
# Get a node.
node = await drive.get_node_by_path('/path/to/drive/file')
# List children.
children = await drive.get_children(root_node)
# Make a folder.
new_folder = await drive.create_folder(root_node, 'folder_name')
# Download file.
await download_to_local(drive, node, '/tmp')
# Upload file.
new_file = await upload_from_local(drive, root_node, '/path/to/local/file')
# Traverse drive.
async for root, folders, files in drive.walk(root_node):
print(root, folders, files)
async def config_demo():
factory = DriveFactory()
# Read config files from here.
# The default is $HOME/.config/wcpan.drive.
# These files are what you want to keep and backup.
factory.config_path = '/tmp/config'
# Put generated files here.
# The default is $HOME/.local/share/wcpan.drive.
# These files should be safely deleted.
factory.data_path = '/tmp/data'
# Setup cache database, will write to data folder.
factory.database = 'nodes.sqlite'
# Setup driver class.
factory.driver = 'some.random.driver.RandomDriver'
# load config file from config folder
# this will not overwrite the above given values
factory.load_config()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wcpan_drive_core-3.2.0.tar.gz
(18.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wcpan_drive_core-3.2.0.tar.gz.
File metadata
- Download URL: wcpan_drive_core-3.2.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d11756e1f702ba5f35f84095bf0cf0dc3b65d5c76171495f6a38bcc376cf2f9
|
|
| MD5 |
185043d4d3f64880cb8be0c2404b333e
|
|
| BLAKE2b-256 |
2c2188fec85221274ec16bca6240500557df94ed17dcfaf23efe0cdb1396d01d
|
File details
Details for the file wcpan_drive_core-3.2.0-py3-none-any.whl.
File metadata
- Download URL: wcpan_drive_core-3.2.0-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.9.2 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f8d24c2fa63850498b400c9f014c282ab5cee0f60ab9541910a2390eee4cd9a
|
|
| MD5 |
b026e0ded95864ccf261431915eaba2e
|
|
| BLAKE2b-256 |
1596c120070bbbe769eded1b945a2cf5eb9c94be2dd2a3f0dcc143219020a5ca
|