diff piecrust/publishing/rsync.py @ 622:5d8e0c8cdb5f

publish: Add the `rsync` publisher.
author Ludovic Chabant <ludovic@chabant.com>
date Mon, 08 Feb 2016 20:44:38 -0800
parents
children b45fb2137a07
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/publishing/rsync.py	Mon Feb 08 20:44:38 2016 -0800
@@ -0,0 +1,23 @@
+from piecrust.publishing.base import ShellCommandPublisherBase
+
+
+class RsyncPublisher(ShellCommandPublisherBase):
+    PUBLISHER_NAME = 'rsync'
+    PUBLISHER_SCHEME = 'rsync'
+
+    def _getCommandArgs(self, ctx):
+        if self.has_url_config:
+            dest = self.parsed_url.netloc + self.parsed_url.path
+        else:
+            dest = self.getConfigValue('destination')
+
+        rsync_options = None
+        if not self.has_url_config:
+            rsync_options = self.getConfigValue('options')
+        if rsync_options is None:
+            rsync_options = ['-avc', '--delete']
+
+        args = ['rsync'] + rsync_options
+        args += [ctx.bake_out_dir, dest]
+        return args
+