Skip to main content

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.

Release files for smartcp 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartcp 0.2
File Size Uploaded
smartcp-0.2.tar.gz 6.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for smartcp 0.2
File Interpreter ABI Platform
smartcp-0.2.linux-x86_64.tar.gz Details
smartcp-0.2-py3.4.egg Legacy Egg format - - Details
smartcp-0.2-py2.7.egg Legacy Egg format - - Details

Total release size: 36.0 kB

Release files / smartcp-0.2.tar.gz

Download URL smartcp-0.2.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4c58d18c0dde89d934154cca0a65736632d351755e7085e72c889f4a8fa64228
BLAKE2b-256 checksum
How to use checksums
d6e4c6cf68e057e2d8585a72ec66d1ba73006de2d90800ef473bd9cfcc6e88fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / smartcp-0.2.linux-x86_64.tar.gz

Download URL smartcp-0.2.linux-x86_64.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0b14fa565828eb2609336dc2edeecf546d38f86fa3205475b51655373ef6d2d5
BLAKE2b-256 checksum
How to use checksums
a6f0538e19f661dd4311415f081dc12a87554b417edacc8748009bd2855f1d9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / smartcp-0.2-py3.4.egg

Download URL smartcp-0.2-py3.4.egg
Size 10.6 kB
Tags Egg
SHA-256 checksum
How to use checksums
0b63db8077c6e0762e6e1673e080ddc04189b0a2608a2a63d4b863a5830d62a4
BLAKE2b-256 checksum
How to use checksums
6609355302a7d6a513de9b27f1ec033d44e6a70be6999a00c33db580e018d8d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / smartcp-0.2-py2.7.egg

Download URL smartcp-0.2-py2.7.egg
Size 10.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
a71ff4ede284b2d02d1437e8c3fa7c7c1b2277da84806e172744c9d085ef0814
BLAKE2b-256 checksum
How to use checksums
2bec017a47dc8f33dc47901ab10317b874e0eb28024ecef3ad303721da9dc1f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

4 release files

0.1

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page