Added command line interface with charset option, regexp optionnal, help.
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 27 May 2009 17:57:03 +0000 (17:57 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 27 May 2009 17:57:03 +0000 (17:57 +0000)
Added a link in /usr/bin
Added a man

debian/links
debian/rules
decoratedstr.1 [new file with mode: 0644]
decoratedstr.py

index 871fcc3a6ebc8307e128174f2bde937517cb1f55..e43a9e903846c29f46721bac41b620b0d2e214c2 100644 (file)
@@ -1 +1 @@
-#/decoratedstr.py /usr/bin/decoratedstr
+/usr/share/python-support/python-decoratedstr/decoratedstr.py /usr/bin/decoratedstr
index b5566a362377649af3d4f01921b9b8649c6647fd..0a216e9f5baae3f86f09c3fd349aaa0e8624e38b 100755 (executable)
@@ -56,7 +56,7 @@ binary-indep: build install
 #      dh_installmime
 #      dh_installinit
 #      dh_installcron
-#      dh_installman man/*
+       dh_installman *.1
        dh_installinfo
        dh_installchangelogs
        dh_link
diff --git a/decoratedstr.1 b/decoratedstr.1
new file mode 100644 (file)
index 0000000..c46cd7f
--- /dev/null
@@ -0,0 +1,29 @@
+.TH decoratedstr "May 27, 2009" "" "User Commands"
+.SH NAME
+decoratedstr \- decorated characters tools
+.SH SYNOPSIS
+.B decoratedstr [\-h|\-\-help] [\-\-charset] [\-r|\-\-regexp]
+.I string
+.SH DESCRIPTION
+.PP
+Remove decorations - such as accents and rings - from characters, expand
+ligatures.
+Optionnaly prints a matching regular expression.
+.SH EXAMPLE
+.BI "decoratedstr \(OEuf à la poëlle"
+.PP
+Oeuf a la poelle
+.PP
+.BI "decoratedstr \-r oeuf"
+.PP
+(\(oe|\(OE|[oòóôöøōŏőOÒÓÔÖØŌŎŐ][eèéêëēĕėęěEÈÉÊËĒĔĖĘĚ])[uùúûüũūŭůűųUÙÚÛÜŨŪŬŮŰŲ][fF]
+.SH NOTES
+.PP
+No note available.
+.SH BUGS
+Python doesn't detect the LANG charset in the environement. You will need to use \-\-charset option
+if you don't use UTF\-8.
+.SH "AUTHOR"
+Jean-Michel Vourg\(`ere
+.mso www.tmac
+.URL "http://www.nirgal.com/"
index 50aff673004e6642a9ad68eec898c80cb9463411..1dc8737028190caf7a99f3a9ac66320ddc7e78fc 100755 (executable)
@@ -112,10 +112,20 @@ def decorated_match(txt, casesensitive=False):
 
 if __name__ == '__main__':
     import sys
-    if len(sys.argv)<2:
+    from optparse import OptionParser
+    parser = OptionParser(usage='%prog [options] string')
+    parser.add_option('--charset', help="set charset. default=%default", action='store', dest='charset', default='utf-8')
+    parser.add_option('-r', '--regexp', help="generate regular expression.", action='store_true', dest='regexp')
+    (options, args) = parser.parse_args()
+
+    if not args:
         print >> sys.stderr, u'Missing required parameter. Try "Œuf"'
         sys.exit(1)
-    input = unicode(' '.join(sys.argv[1:]), 'utf-8')
-    print "input:", input                            # Œuf
-    print "undecorated:", remove_decoration(input)   # Oeuf
-    print "regex:", decorated_match(input)           # (œ|Œ|[oòóôöøōŏőOÒÓÔÖØŌŎŐ][eèéêëēĕėęěEÈÉÊËĒĔĖĘĚ])[uùúûüũūŭůűųUÙÚÛÜŨŪŬŮŰŲ][fF]
+    input = unicode(' '.join(args), options.charset)
+    #print "input:", input                            # Œuf
+    #print "undecorated:", remove_decoration(input)   # Oeuf
+    #print "regex:", decorated_match(input)           # (œ|Œ|[oòóôöøōŏőOÒÓÔÖØŌŎŐ][eèéêëēĕėęěEÈÉÊËĒĔĖĘĚ])[uùúûüũūŭůűųUÙÚÛÜŨŪŬŮŰŲ][fF]
+    if options.regexp:
+        print decorated_match(input).encode(options.charset)
+    else:
+        print remove_decoration(input).encode(options.charset)