https://github.com/znerol/py-idlk
idlk lock filename generator
https://github.com/znerol/py-idlk
Last synced: about 1 year ago
JSON representation
idlk lock filename generator
- Host: GitHub
- URL: https://github.com/znerol/py-idlk
- Owner: znerol
- License: mit
- Created: 2015-06-09T18:10:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T08:46:26.000Z (over 10 years ago)
- Last Synced: 2025-02-27T08:01:31.525Z (over 1 year ago)
- Language: Python
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Python idlk
[](https://travis-ci.org/znerol/py-idlk)
[](https://coveralls.io/github/znerol/py-idlk?branch=master)
This is a proof-of-concept implementation of a lock filename generator for idlk
files used by a well known desktop publishing suite.
## Usage
```
from idlk import idlk
lockname = idlk(u'My Layout File.INDD')
# lockname == u'~my layout file~q7e)nv.idlk'
lockname = idlk(u'My Text.icml')
# lockname == u'~my text~7h5m7u.idlk'
```
## Technical details
The names of the lockfiles are derived from a given file name with the
following steps:
1. Apply NFC unicode normalization.
2. Convert the complete filename to lower case.
3. Switch to Mac Roman encoding.
4. Generate a 32bit hash value over the whole file name and encode it using a
custom base41 encoding scheme.
5. Remove extension from the prepared file name, shorten it further to 18
characters if necessary.
6. Generate the idlk file name using the following pattern:
~shortened-lowercase-basename[1..18]~hash[6].idlk
Note: Even though the hash-function is rather primitive, there is no way of
directly deriving the original document name for a given idlk name.
### Hash function
The hash function is a very simple shift-add function. The only tricky/weird
thing is a final modulo with the magic number `0xFFFEECED`.
### Base41 encoding
Base41 produces a case insensitive string containing digits `0-9`, characters
`a-z` and the 5 additional characters `-`, `_`, `(`, `)` and `$`.
## Caveats
The algorithm has been deduced after observing the behavior of the original
software. It currently only works with file names which are completely mappable
to the Mac Roman encoding.
## License
All code and documentation is released under the MIT license.