sync
Low-level functionality for synchronizing across different machines
abspath_from_uri(uri)
Extract and unquote the path component of a URI to turn it into an
unambiguous absolute pathlib.Path
h/t https://stackoverflow.com/a/61922504
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri |
ParseResult
|
The parsed URI to extract the path from |
required |
Returns:
Type | Description |
---|---|
Path
|
The path part of the URI as a Path |
Source code in enderchest/sync/utils.py
get_default_netloc()
Compile a netloc from environment variables, etc.
Returns:
Type | Description |
---|---|
str
|
The default netloc, which is {user}@{hostname} |
pull(remote_uri, local_path, exclude=None, dry_run=False, **kwargs)
Pull all upstream changes from a remote into the specified location
Parameters:
Name | Type | Description | Default |
---|---|---|---|
remote_uri |
ParseResult
|
The URI for the remote resource to pull |
required |
local_path |
Path
|
The local destination |
required |
exclude |
list of str
|
Any patterns that should be excluded from the sync |
None
|
dry_run |
bool
|
Whether to only simulate this sync (report the operations to be performed but not actually perform them). Default is False. |
False
|
**kwargs |
Any additional options to pass into the sync command |
{}
|
Source code in enderchest/sync/__init__.py
push(local_path, remote_uri, exclude=None, dry_run=False, **kwargs)
Push all local changes in the specified directory into the specified remote
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_path |
Path
|
The local path to push |
required |
remote_uri |
ParseResult
|
The URI for the remote destination |
required |
exclude |
list of str
|
Any patterns that should be excluded from the sync |
None
|
dry_run |
bool
|
Whether to only simulate this sync (report the operations to be performed but not actually perform them). Default is False. |
False
|
**kwargs |
Any additional options to pass into the sync command |
{}
|
Source code in enderchest/sync/__init__.py
remote_file(uri)
Grab a file from a remote filesystem by its URI and read its contents
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri |
parsed URI
|
The URI of the file to read |
required |
Yields:
Type | Description |
---|---|
Path
|
A path to a local (temp) copy of the file |
Source code in enderchest/sync/__init__.py
render_remote(alias, uri)
Render a remote to a descriptive string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alias |
str
|
The name of the remote |
required |
uri |
ParseResult
|
The parsed URI for the remote |
required |
Returns:
Type | Description |
---|---|
str
|
|
Source code in enderchest/sync/utils.py
uri_to_ssh(uri)
Convert a URI to an SSH address
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uri |
ParseResult
|
The URI to convert |
required |
Returns:
Type | Description |
---|---|
str
|
The SSH-format address |