module cli.pyq_sync_cli

Short summary

module pyquickhelper.cli.pyq_sync_cli

Wrapper function synchronize_folder() into a command line.

source on GitHub

Functions

function

truncated documentation

pyq_sync

Synchronizes a folder using function synchronize_folder().

Documentation

Wrapper function synchronize_folder into a command line.

source on GitHub

pyquickhelper.cli.pyq_sync_cli.pyq_sync(fLOG=<built-in function print>, args=None)[source]

Synchronizes a folder using function synchronize_folder.

Parameters:
  • fLOG – logging function

  • args – to overwrite sys.args

Synchronize two folders

Synchronizes two folders from the command line.

pyq_sync –help

usage: synchronize_folder [-h] [--p1 P1] [--p2 P2] [-ha HASH_SIZE] [-r REPO1]
                          [-re REPO2] [-s SIZE_DIFFERENT] [-n NO_DELETION]
                          [-f FILTER] [-fi FILTER_COPY] [-a AVOID_COPY]
                          [-fil FILE_DATE] [-c COPY_1TO2] [-cr CREATE_DEST]

Synchronizes two folders (or copy if the second is empty), it only copies more
recent files. It can walk through a `git` repository or SVN.

optional arguments:
  -h, --help            show this help message and exit
  --p1 P1               (str) first path (default: None)
  --p2 P2               (str) second path (default: None)
  -ha HASH_SIZE, --hash_size HASH_SIZE
                        (bool) to check whether or not two files are different
                        (default: 1048576)
  -r REPO1, --repo1 REPO1
                        (bool) assuming the first folder is under SVN or GIT,
                        it uses pysvn to get the list of files (avoiding any
                        extra files) (default: False)
  -re REPO2, --repo2 REPO2
                        (bool) assuming the second folder is under SVN or GIT,
                        it uses pysvn to get the list of files (avoiding any
                        extra files) (default: False)
  -s SIZE_DIFFERENT, --size_different SIZE_DIFFERENT
                        (bool) if True, a file will be copied only if size are
                        different, otherwise, it will be copied if the first
                        file is more recent (default: True)
  -n NO_DELETION, --no_deletion NO_DELETION
                        (bool) if a file is found in the second folder and not
                        in the first one, if will be removed unless
                        no_deletion is True (default: False)
  -f FILTER, --filter FILTER
                        (str) None to accept every file, a string if it is a
                        regular expression, a function for something more
                        complex: function ``(fullname) --> True`` (every file
                        is considered in lower case), (use `*py.re.search`)
                        (default: None)
  -fi FILTER_COPY, --filter_copy FILTER_COPY
                        (str) None to accept every file, a string if it is a
                        regular expression, a function for something more
                        complex: function (fullname) --> True (default: None)
  -a AVOID_COPY, --avoid_copy AVOID_COPY
                        (bool) if True, just return the list of files which
                        should be copied but does not do the copy (default:
                        False)
  -fil FILE_DATE, --file_date FILE_DATE
                        (str) filename which contains information about when
                        the last sync was done (default: None)
  -c COPY_1TO2, --copy_1to2 COPY_1TO2
                        (bool) only copy files from *p1* to *p2* (default:
                        False)
  -cr CREATE_DEST, --create_dest CREATE_DEST
                        (bool) create destination directory if not exist
                        (default: False)

source on GitHub