Skip to main content

Smart Copy Utility

Project description

This is an useful utility for automating copy from source and destination that can be customised by arguments that may vary. A good example of usage is available with this repo.

Install

You can install it from source by cloning this repo

git clone https://github.com/blegat/smartcp.git

and running

sudo python setup.py install

You can also install the latest released version through pip

sudo pip install smartcp

or easy_install

sudo easy_install smartcp

Requirements

It is officially only compatible with Python 3 and Python 2 but has some issues with accents for Python 2 (Python 3 has a better unicode approach than Python 2).

You will also need PyYAML.

Usage

You can get help by running

smartcp -h

Config file

To specify which files to copy where, you need to specify a config file. It should use the YAML syntax. It contains a base path for the source, a base path for the destination and clients. For each client, you can specify some arguments (if no argument is given, there will be one copy but there can’t be any node arg) and how to generate the source and destination from these arguments. To specify them you need to nest three types of nodes.

  • A path_format which can contain placeholders {n} and then parameters to replace them. The parameters can be one of the three nodes.

  • A mapping which contain a hash and a key which is a node.

  • An arg which is one of the arguments.

Here is an example which copies files from version/subversion/file to file-version.subversion while renaming file to b if it is a. It also copies 1/1/x to ../x-1.1.

input_base: .
output_base: .
clients:
  - name: Official
    arguments:
      subversion: [1, 2, 3]
      version: [1, 2, 3, 4, 5]
      file: [a, A, x, X]
    input:
      path_format: "{0}/{1}/{2}"
      parameters:
        - arg: subversion
        - arg: version
        - arg: file
    output:
      path_format: "{0}-{1}.{2}"
      parameters:
        - mapping:
            a: b
          key:
            arg: file
        - arg: version
        - arg: subversion
  - name: Simple copy
    input:
      path_format: 1/1/x
    output:
      path_format: ../x-1.1

Note the " for the path format because without it YAML won’t understand that it is just a string.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartcp-0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distributions

smartcp-0.2.linux-x86_64.tar.gz (8.9 kB view details)

Uploaded Source

smartcp-0.2-py3.4.egg (10.6 kB view details)

Uploaded Source

smartcp-0.2-py2.7.egg (10.5 kB view details)

Uploaded Source

File details

Details for the file smartcp-0.2.tar.gz.

File metadata

  • Download URL: smartcp-0.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartcp-0.2.tar.gz
Algorithm Hash digest
SHA256 4c58d18c0dde89d934154cca0a65736632d351755e7085e72c889f4a8fa64228
MD5 46c06af9f14953f94a5fa85e835f3a1e
BLAKE2b-256 d6e4c6cf68e057e2d8585a72ec66d1ba73006de2d90800ef473bd9cfcc6e88fd

See more details on using hashes here.

File details

Details for the file smartcp-0.2.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for smartcp-0.2.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 0b14fa565828eb2609336dc2edeecf546d38f86fa3205475b51655373ef6d2d5
MD5 7f18cfab22e9f8c075f7919545d7641e
BLAKE2b-256 a6f0538e19f661dd4311415f081dc12a87554b417edacc8748009bd2855f1d9f

See more details on using hashes here.

File details

Details for the file smartcp-0.2-py3.4.egg.

File metadata

  • Download URL: smartcp-0.2-py3.4.egg
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartcp-0.2-py3.4.egg
Algorithm Hash digest
SHA256 0b63db8077c6e0762e6e1673e080ddc04189b0a2608a2a63d4b863a5830d62a4
MD5 b3164d2f66ed756b54e14071cd572e4e
BLAKE2b-256 6609355302a7d6a513de9b27f1ec033d44e6a70be6999a00c33db580e018d8d7

See more details on using hashes here.

File details

Details for the file smartcp-0.2-py2.7.egg.

File metadata

  • Download URL: smartcp-0.2-py2.7.egg
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smartcp-0.2-py2.7.egg
Algorithm Hash digest
SHA256 a71ff4ede284b2d02d1437e8c3fa7c7c1b2277da84806e172744c9d085ef0814
MD5 893c362f911b6f894e8e68c97caaf222
BLAKE2b-256 2bec017a47dc8f33dc47901ab10317b874e0eb28024ecef3ad303721da9dc1f6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page