Métamorphose logo

Métamorphose : A File -n- Folder Renamer

Programmer's Corner

Here are some python scripts, modules, and code snippets which could be of interest to fellow python programmers.
These are all used within Métamorphose, but can be used in other programs or in shell scripts.
Check each file for licensing info.

accentStrip.py

Removes accents and splits linked letters (ligatures) from the full set of Unicode Latin characters for ASCII compatability.

Usage:
import accentStrip
test = u"¡ŦĦË Ɋṻîčḵ Ƀṝọẁñ Ḟøẍ Ɉṻḿṗş Ṏṽḝŗ Ŧĥệ Ⱡåẕÿ Ğṑð! ¿Cette œuvre là? Große. ॐ"

# automatically choose best method
print accentStrip.autoConvert(test)

# full conversion, slow for large strings
print accentStrip.fullConvert(test)

# no squashing but much faster for large strings such as files
print accentStrip.fastConvert(test)
Input is Unicode, the output is Unicode which will map directly to ASCII.
Up to you to convert to/from your encoding.

View    Download



greek_numb.py

Convert whole numbers to Greek numerals. In the case of a negative integer, its absolute value will be used.
Input can be an integer or a string, output will be in unicode.
Based on Greek.pm

Example usage in python:
import greek_numb as greek
greek_number = greek.int2greek(1984, arch_qoppa=True)

Variables (default values shown):

Usage from command line:
greek_numb.py --help

Testing in bash:
for ((i=0; i<=100; i=i+1)); do ./greek_numb.py $i; done;

View    Download

SourceForge.net Logo