Introduction
The codec safename is meant to rename files to safe filenames. These safe filenames have the following properties:
The safe filenames are valid on most filesystems.
The safe filenames can be restored to the original filenames.
The safe filenames are more or less readable.
Examples:
Input |
Output |
|---|---|
spam |
spam |
Spam |
{s}pam |
SPAM |
{spam} |
spam eggs |
spam_eggs |
spam eggs |
spam___eggs |
spàm |
sp(e0)m |
The script safename will rename a list of files, by applying the codec safename to the current filenames.
Installation
Install the distribution from source:
$ python setup.py install
Or install with easy_install:
$ easy_install fnord.safename
Codec
Import the package fnord.safename to register the codec safename:
>>> import fnord.safename
Now you can encode and decode strings:
>>> "Spam".encode("safename")
'{s}pam'
>>> "{s}pam".decode("safename")
'Spam'
Script
safename [-d|--decode] [-t|--test] [-v|--verbose] [FILE ...] safename [-e|--encode] [-t|--test] [-v|--verbose] [FILE ...]
- --decode, -d
decode from safe filenames for the given files
- --encode, -e
encode to safe filenames for the given files
- --recursive, -r
decode or encode filenames recursively
- --test, -t
don’t rename the files
- --verbose, -v
print out every renaming operation
Remarks
Based on the module safefilename from Torsten Bronger’s Bobcat project. The implementation is my own.
Contributors
Bert Vanderbauwhede <batlock666@gmail.com>, Author
Changelog
0.5 (2013-08-17)
Refactor code to use class re.Scanner [Bert Vanderbauwhede]
0.4 (2013-08-11)
Refactor code to use package fnord.easycodec [Bert Vanderbauwhede]
0.3 (2013-08-10)
Add option --recursive to the script [Bert Vanderbauwhede]
Synchronize documentation for options [Bert Vanderbauwhede]
Change error-messages [Bert Vanderbauwhede]
0.2 (2013-07-28)
Fix handling of exceptions [Bert Vanderbauwhede]
Clean up and expand readme [Bert Vanderbauwhede]
Change license to LGPL [Bert Vanderbauwhede]
Add tests [Bert Vanderbauwhede]
Add buildout [Bert Vanderbauwhede]
0.1 (2013-07-14)
Package created using templer [Bert Vanderbauwhede]
First implementation [Bert Vanderbauwhede]
Metadata
Release files for fnord.safename 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fnord.safename-0.5.tar.gz | 7.9 kB | Without provenance | Details for fnord.safename-0.5.tar.gz |
Release files / fnord.safename-0.5.tar.gz
| Download URL | fnord.safename-0.5.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af56c10f1080ee68461450ebb6f55642a7353363e2ba63df97aa224a099e8ada
|
|
BLAKE2b-256 checksum How to use checksums |
b8b1d32a2d699717c88380e65a1e6b2c8674eefaf05c67509a50f835bc4d474c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for fnord.safename 0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.