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.
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.dlllibrary by Okrasa Ghia.
To use this Python module you must supply the ffeditc_unicode.exe utility found in MSTS installations. It is not included with the module.
On Linux you need Wine installed.
To install Wine on Debian-based distros:
dpkg --add-architecture i386
apt update
apt install wine64 wine32Then create the Wine directory:
export WINEPREFIX="$HOME/.wine"
export WINEARCH=win64
wineboot -uNow ffeditc_unicode.exe can be run via Wine:
wine path/to/ffeditc_unicode.exeThe Python module will automatically attempt to use Wine on Linux.
pip install --upgrade pyffeditcIf you have downloaded a .whl file from the Releases page, install it with:
pip install path/to/pyffeditc-<version>‑py3‑none‑any.whlReplace <version> with the actual version number in the filename.
git clone https://github.com/pgroenbaek/pyffeditc.git
pip install --upgrade ./pyffeditcTo 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)")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. 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")You can run tests manually or use tox to test across multiple Python versions.
First, install the required dependencies:
pip install pytest pytest-dependencyThen, run tests with:
pytestFirst, install the required dependencies:
pip install tox pytest pytest-dependencyThen, run tests with:
toxThis will execute tests for all Python versions specified in tox.ini.
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.
This Python module was created by Peter Grønbæk Andersen and is licensed under GNU GPL v3.