Skip to main content

A Python wrapper for the ffeditc_unicode.exe utility.

Project description

pyFFEDITC

GitHub release (latest by date) Python 3.6+ License GNU GPL v3

This Python module wraps the ffeditc_unicode.exe utility. The module allows you to compress and decompress MSTS files such as shape and world files on Windows.

[!IMPORTANT] This module requires ffeditc_unicode.exe from Microsoft Train Simulator (MSTS). It is not included with this Python module. You must provide the executable from your own MSTS installation.

See also:

  • pytkutils - handles compression and decompression of MSTS files such as shape and world file through the TK.MSTS.Tokens.dll library by Okrasa Ghia.

Prerequisites

This Python module requires Windows, and in addition you must supply the ffeditc_unicode.exe utility found in MSTS installations yourself.

Installation

Install from PyPI

pip install --upgrade pyffeditc

Install from wheel

If you have downloaded a .whl file from the Releases page, install it with:

pip install path/to/pyffeditc-<version>‑py3‑none‑any.whl

Replace <version> with the actual version number in the filename.

Install from source

git clone https://github.com/pgroenbaek/pyffeditc.git
pip install --upgrade ./pyffeditc

Usage

Check if a file on disk is compressed

To check whether a file on disk is compressed, you can use the is_compressed function. This function returns True if the file is compressed and False if it is not. If the file is empty or its state cannot be determined, the function will return None.

import pyffeditc

compressed = pyffeditc.is_compressed("./path/to/example.s")

if compressed is True:
    print("Compressed")
elif compressed is False:
    print("Uncompressed")
else:
    print("Could not determine (possibly empty file)")

Compress or decompress files

The compression and decompression functions in this module use the ffeditc_unicode.exe utility found in MSTS installations. This utility is not included with the Python module.

Alternatively, you can use pytkutils on both Windows, Linux and macOS. But note that only compression appears to work properly using the TK.MSTS.Tokens.dll library by Okrasa Ghia.

You can also compress/decompress manually using ffeditc_unicode.exe through the Shape File Manager or use the FFEDIT_Sub v1.2 utility by Ged Saunders.

import pyffeditc

ffeditc_path = "./path/to/ffeditc_unicode.exe"

# Compress and decompress in-place.
pyffeditc.compress(ffeditc_path, "./path/to/example.s")
pyffeditc.decompress(ffeditc_path, "./path/to/example.s")

# Compress and decompress to an output file.
pyffeditc.compress(ffeditc_path, "./path/to/example.s", "./path/to/output.s")
pyffeditc.decompress(ffeditc_path, "./path/to/example.s", "./path/to/output.s")

Running Tests

You can run tests manually or use tox to test across multiple Python versions.

Run Tests Manually

First, install the required dependencies:

pip install pytest pytest-dependency

Then, run tests with:

pytest

Run Tests with tox

tox allows you to test across multiple Python environments.

1. Install tox

pip install tox

2. Run Tests

tox

This will execute tests in all specified Python versions.

3. tox.ini Configuration

The tox.ini file should be in your project root:

[tox]
envlist = py36, py37, py38, py39, py310

[testenv]
deps = pytest
commands = pytest

Modify envlist to match the Python versions you want to support.

Contributing

Contributions of all kinds are welcome. These could be suggestions, issues, bug fixes, documentation improvements, or new features.

For more details see the contribution guidelines.

License

This Python module was created by Peter Grønbæk Andersen and is licensed under GNU GPL v3.

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

pyffeditc-0.1.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

pyffeditc-0.1.1-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file pyffeditc-0.1.1.tar.gz.

File metadata

  • Download URL: pyffeditc-0.1.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyffeditc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8070b5c4e48ff71c521ffecb5a1078043d0544862d33a2065dc97b9d4d622e6a
MD5 b8b373b1c4fc49f53aef1ebc9ea3b1bd
BLAKE2b-256 434e4fa4978a4af01421bc9171089c8238aca6b5a8bb1894846f4703b881027a

See more details on using hashes here.

File details

Details for the file pyffeditc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyffeditc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyffeditc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f06458be12d33112618875364daa2c96cfd44737c8cbe6badbe27da2d58fedb
MD5 50a978bbb66643c03a51018f6ea9ef53
BLAKE2b-256 a3033da4bf46f0ff166cba5d689c3041d544f8f208837e021e4139c7e1f15721

See more details on using hashes here.

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