1
0
Fork
You've already forked verfix
0
A python script to fix strings like version strings that must be identical and literal but are distributed over several source files.
Python 100%
2024年11月19日 09:39:10 +01:00
examples Initial version 2024年11月19日 09:39:10 +01:00
src/verfix Initial version 2024年11月19日 09:39:10 +01:00
Development.md Initial version 2024年11月19日 09:39:10 +01:00
LICENCE Initial version 2024年11月19日 09:39:10 +01:00
LICENCE.verfix Initial version 2024年11月19日 09:39:10 +01:00
pyproject.toml Initial version 2024年11月19日 09:39:10 +01:00
pyproject.verfix.toml Initial version 2024年11月19日 09:39:10 +01:00
README.md Initial version 2024年11月19日 09:39:10 +01:00
requirements.txt Initial version 2024年11月19日 09:39:10 +01:00
verfix.py Initial version 2024年11月19日 09:39:10 +01:00
verfix.yaml Initial version 2024年11月19日 09:39:10 +01:00

Verfix - Version String Management Tool

Verfix is a lightweight Python tool that manages version strings and other variables across your project files using template files. Each file that needs versioning has a corresponding .verfix template, making it clear which files contain version strings while keeping the templates under version control.

Features

  • 🔍 Clear identification of files with version strings via .verfix templates
  • 📝 Templates stay under version control
  • 🔗 Variable interpolation using ${var} syntax in YAML
  • 🎯 Explicit file listing
  • 🛡️ Editor-friendly template naming (maintains syntax highlighting)
  • Simple, direct processing of templates to files

Installation

There are several ways to install verfix:

pip install verfix

From Source

# Clone the repository
git clone https://codeberg.org/threadpanic/verfix.git
cd verfix
# Install in development mode
pip install -e .
# Or install directly from repo
pip install git+https://codeberg.org/threadpanic/verfix.git

Dependencies Only (run from source)

pip install -r requirements.txt
./src/verfix/main.py

Usage

As Command Line Tool

After installation with pip:

# Using default verfix.yaml
verfix
# Using custom config file
verfix custom-config.yaml

When running from source:

./src/verfix/main.py
# or
python -m verfix.main

As a Python Library

from verfix import VersionFixer
# Using default verfix.yaml
fixer = VersionFixer()
fixer.run()
# Using custom config
fixer = VersionFixer("custom-config.yaml")
fixer.run()
# Access variables after loading
fixer.load_config()
print(fixer.variables["version"])
# Process single file
fixer.process_file("path/to/file.txt")

Configuration

Create a verfix.yaml configuration file:

variables:version:0.1.2fullversion:${version}-betafiles:- Cargo.toml- src/main.rs

Template Files

Create .verfix template files (note: .verfix goes before the extension):

# Cargo.verfix.toml
[package]
name = "myapp"
version = "^(version)^"
edition = "2021"
// src/main.verfix.rs
fn main(){println!("MyApp version ^(version)^ starting up...");}

Project Structure Example

myproject/
├── verfix.yaml
├── Cargo.toml # Generated from template
├── Cargo.verfix.toml # Template with ^(version)^
├── src/
│ ├── main.rs # Generated from template
│ ├── main.verfix.rs # Template with ^(version)^
│ └── lib.rs # No versioning needed

Template Naming Convention

To maintain proper syntax highlighting in editors:

  • main.rsmain.verfix.rs
  • Cargo.tomlCargo.verfix.toml
  • version.pyversion.verfix.py
  • README.mdREADME.verfix.md

For files without extensions:

  • READMEREADME.verfix
  • VERSIONVERSION.verfix

Variable Interpolation

Templates use ^(variable)^ syntax:

constVERSION: &str ="^(version)^";constFULL_VERSION: &str ="^(fullversion)^";

YAML config supports variable references:

variables:major:2minor:0patch:5version:${major}.${minor}.${patch}fullversion:${version}-beta

Common Use Cases

  1. Rust Projects
variables:version:0.1.2files:- Cargo.toml- src/main.rs
  1. Python Packages
variables:version:1.0.0files:- setup.py- src/myapp/__init__.py
  1. Node.js Projects
variables:version:2.1.0files:- package.json- src/version.ts

Development

Want to contribute? Here's how to set up for development:

# Clone the repository
git clone https://codeberg.org/threadpanic/verfix.git
cd verfix
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .

Notes

  • Run verfix from the directory containing your verfix.yaml file
  • Each file listed in verfix.yaml must have a corresponding .verfix template
  • Original files are overwritten with processed content
  • Templates stay under version control showing where version strings appear
  • Template files now use .verfix before the extension for better IDE support
  • Missing templates will cause an error

License

MIT No Attribution License (MIT-0)


For more information or to contribute, please visit verfix on Codeberg.