https://github.com/tkf/uniquify
https://github.com/tkf/uniquify
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tkf/uniquify
- Owner: tkf
- Created: 2011-12-08T16:27:46.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T10:23:01.000Z (almost 3 years ago)
- Last Synced: 2025-03-28T18:09:14.728Z (10 months ago)
- Language: Python
- Homepage:
- Size: 113 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Uniquify - get unique, short and easy-to-read names and paths
=============================================================
Examples
--------
Shorten names/paths by extracting non-common parts:
>>> from uniquify import shortname, shortpath
>>> shortname(['__common_part___abc___common_part__',
... '__common_part___xbc___common_part__',
... '__common_part___xyz___common_part__'])
['abc', 'xbc', 'xyz']
>>> shortpath(['some/long/path/___/alpha/___/___/',
... 'some/long/path/___/beta/___/___/',
... 'some/long/path/___/gamma/___/___/'])
['alpha', 'beta', 'gamma']
Convert common parts into skip marks:
>>> from uniquify import skipcommonname, skipcommonpath
>>> skipcommonname(['ab__common_part___c',
... 'ij__common_part___k',
... 'xy__common_part___z'])
['ab...c', 'ij...k', 'xy...z']
>>> skipcommonpath(['alpha/common/path/beta',
... 'epsilon/common/path/delta',
... 'phi/common/path/psi'])
['alpha/.../beta', 'epsilon/.../delta', 'phi/.../psi']
Install
-------
Install it from pypi_
::
pip install uniquify
# easy_install uniquify
.. _pypi: http://pypi.python.org/pypi/uniquify/