publish#

import userdir_publish.publish

Validate a built website and copy it to the web directory with rsync.

exception PublishError[source]#

Bases: RuntimeError

Raised when the website cannot be published safely.

validate_build(settings: Settings) → None[source]#

Check that the build can be published.

The build must contain an index.html. If htaccess_source is set, every .htaccess file under it must appear unchanged at the same relative path in the build. Hidden directories, the build itself, and files ignored by Git are not searched.

Raises:

PublishError – If a check fails.

use_ssh(settings: Settings) → bool[source]#

Decide whether to publish over SSH.

With transport = "auto", SSH is used when a host is set and the target directory does not exist on this machine.

rsync_command(settings: Settings, *, ssh: bool, dry_run: bool = False, progress: bool = False) → list[str][source]#

Build the rsync command that mirrors the build to the target.

The command passes --delete, so files in the target that are not in the build are removed, except those matched by keep. Unless dry_run is set, a local target directory is created, and over SSH the remote target is created by the command itself. With progress, rsync reports the overall transfer progress.

publish(settings: Settings, *, dry_run: bool = False, progress: bool = False) → list[str][source]#

Copy the build to the target and return the rsync command that was run.

A dry run still validates the build and refuses a symlinked target, but copies nothing and creates no directories.

Raises:
is_openrsync() → bool[source]#

Check whether the rsync in PATH is openrsync, the default rsync of macOS.

openrsync accepts --chmod but silently leaves the permissions unchanged.