Skip to main content

xsyncfar

Project description

xsyncfar

Tool for one-directional sync across pre-mapped directory paths with find-and-replace rules applied to file content.

The sync direction is determined automatically by the directory you run the tool from — no flags needed.


Features

  • Bidirectional mapping: run from either side of a mapping to sync in that direction
  • Case-insensitive literal find-and-replace applied to file content during sync
  • Only writes files whose content has actually changed (diff before write)
  • Recursively processes all subdirectories
  • Pre-flight summary with confirmation prompt before any changes are made
  • Automatically creates missing destination directories and files
  • Configurable file extension filter (with sensible defaults)
  • Git-style config discovery (walks up the directory tree)
  • Works on Windows and Linux/macOS
  • Python 3.6+, no dependencies beyond PyYAML

Installation

pip install xsyncfar

Or install from source:

git clone <repo-url>
cd xsyncfar
pip install -e .

Configuration

Create a .xsyncfar.yml file in your project root (or any parent directory). The tool will walk up the directory tree to find it.

syncmap:
  # Path prefix prepended to all lab/prod paths in mappings
  prefix: "/home/user/projects/"

  # Optional: override the default file extensions to sync
  # Defaults: .py .yml .yaml .json .txt .md
  # extensions:
  #   - .yml
  #   - .tf
  #   - .py

  # Optional: copy files with non-matching extensions as-is (binary copy, no replacements)
  # Useful for images, binaries, shell scripts, etc.
  # copy_other_files: true

  # Literal find-and-replace rules applied to file content (case-insensitive)
  replacements:
    - lab: "mylab"       # string to find in source
      prod: "mycompany"  # string to replace with in destination
    - lab: "dev-cluster"
      prod: "prod-cluster"

  # Directory path pairs (relative to prefix)
  mappings:
    - lab: "my-lab-project/helm-charts/my-chart"
      prod: "my-prod-project/helm-charts/my-chart"
    - lab: "my-lab-project/configs"
      prod: "my-prod-project/configs"

How direction is determined

The tool compares your current working directory against all lab and prod paths in the config:

  • If your CWD is inside a lab path → syncs lab → prod (applying lab patterns, replacing with prod values)
  • If your CWD is inside a prod path → syncs prod → lab (reversing all replacements)

Usage

Navigate into any directory that matches a mapping (or a subdirectory of one), then run:

xsyncfar
# or
python -m xsyncfar

The tool will:

  1. Find the nearest .xsyncfar.yml walking up from your CWD
  2. Detect the sync direction from your CWD
  3. Show a pre-flight summary of what it will do
  4. Ask you to confirm before making any changes
  5. Sync all eligible files, applying find/replace rules
  6. Report all files that were written

Example session

============================================================
  xsyncfar — pre-flight summary
============================================================
  Direction : lab → prod
  Source    : /home/user/projects/my-lab-project/helm-charts/my-chart
  Dest      : /home/user/projects/my-prod-project/helm-charts/my-chart
  Files     : 8 eligible file(s) found

  Replacements to apply:
    'mylab'       →  'mycompany'
    'dev-cluster' →  'prod-cluster'
============================================================

Proceed with sync? [y/N]: y

Sync complete — 3 file(s) written:
  values.yaml
  templates/deployment.yaml
  templates/configmap.yaml

Supported file extensions (default)

.py, .yml, .yaml, .json, .txt, .md

Override by adding an extensions list to your .xsyncfar.yml.

To also copy files with other extensions unchanged (binary copy, no replacements — useful for images, scripts, binaries), set copy_other_files: true in your syncmap.


Running tests

python -m unittest discover -s tests -v

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

xsyncfar-0.2.0.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xsyncfar-0.2.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file xsyncfar-0.2.0.tar.gz.

File metadata

  • Download URL: xsyncfar-0.2.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xsyncfar-0.2.0.tar.gz
Algorithm Hash digest
SHA256 29eb18815ef6306a049087262dbe5e8032138ad60d2a5de01ff513a677184a3b
MD5 3f5be557d710d306fd83f36ef1222e4a
BLAKE2b-256 b8f51a8595daeb66932822c554eeddcd333ba4482c98d344fbbb52507cfce393

See more details on using hashes here.

Provenance

The following attestation bundles were made for xsyncfar-0.2.0.tar.gz:

Publisher: publish.yml on tkdpython/xsyncfar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xsyncfar-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: xsyncfar-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xsyncfar-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfefb62fae9f4344dacf435ec1bfb2ec41775cff0d320a2871c984c1fb057472
MD5 0ed9b3d0bf3d443cdd6571778fc723a2
BLAKE2b-256 2337dd43b9bc9fce24324656254dc46b682194c652c3cc160e337af84180f560

See more details on using hashes here.

Provenance

The following attestation bundles were made for xsyncfar-0.2.0-py3-none-any.whl:

Publisher: publish.yml on tkdpython/xsyncfar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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