From ec72c5e1d4e0478879e7b679a0ea082ffc644456 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Thu, 22 Sep 2011 21:47:03 +0200
Subject: ukrepl: moved to crypto

---
 crypto/bin/ukrepl | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100755 crypto/bin/ukrepl

(limited to 'crypto/bin/ukrepl')

diff --git a/crypto/bin/ukrepl b/crypto/bin/ukrepl
new file mode 100755
index 00000000..21aa4d84
--- /dev/null
+++ b/crypto/bin/ukrepl
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import sys
+wont_change = { ' '  : ' ' , 
+           '\n' : '\n'
+           }
+fixed_active = False
+def fixed_width_replace(char):
+    if char in wont_change: print char,
+    else: 
+      try:
+        print unichr(0xFF00 + ord(char)-32),
+      except:
+        print char,
+
+cyr_active = False
+cyrillic_dict = {
+    'A' : u'А', 'a' : 'а','Ä' : u'Ӓ', 'ä' : u'ӓ',
+    'B' : u'В',
+    'c' : u'с',
+    'E' : u'Е',
+    'e' : u'е',
+    'H' : u'Н',
+    'I' : u'І', 'i' : u'і',
+    'j' : u'ј','J' : u'Ј',
+    'K' : u'К',
+    'M' : u'М',
+    'O' : u'О', 'o' : u'о', 'Ö' : u'Ӧ', 'ö' : u'ӧ',
+    'P' : u'Р', 'p' : u'р',
+    'S' : u'Ѕ',
+    'T' : u'г'
+    }
+
+def cyrillic_replace(char):
+  print cyrillic_dict.get(char,char),
+
+def helpme():
+  print "usage %s [modes]" % sys.argv[0]
+  print "modes:"
+  print "  c -- cyrillic replace"
+  print "  f -- fixed width"
+  print "  h -- this message"
+  sys.exit(0)
+
+#parsing happens inside the nested loop
+modes = ''.join(sys.argv[1:])
+# sane defaults if no mode given
+if not modes : modes = "f"
+
+if 'h' in modes: helpme()
+
+for mode in modes:
+  for line in sys.stdin:
+    for char in line:
+      if mode is 'c':
+        cyrillic_replace(char)
+      elif mode is 'f':
+        fixed_width_replace(char)
+      else:
+        print "unknown mode %c" % mode
+        helpme()
+
-- 
cgit v1.2.3