perky 02/04/26 00:29:43
Modified: korean/python hangul.py qwerty2bul.py
Log:
- Emulate Nested scope and iter() for old versions under 2.2
- Import korean.aliases before unit test
Tested on: Python 2.0.1, 2.1.3
Revision Changes Path
1.7 +30 -2 KoreanCodecs/korean/python/hangul.py
Index: hangul.py
===================================================================
RCS file: /cvsroot/koco/KoreanCodecs/korean/python/hangul.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- hangul.py 25 Apr 2002 21:13:44 -0000 1.6
+++ hangul.py 26 Apr 2002 07:29:43 -0000 1.7
@@ -15,7 +15,7 @@
# Conjoining Jamo Behavior:
# http://www.unicode.org/unicode/uni2book/ch03.pdf (section 3.11)
#
-# $Id: hangul.py,v 1.6 2002/04/25 21:13:44 perky Exp $
+# $Id: hangul.py,v 1.7 2002/04/26 07:29:43 perky Exp $
#
class UnicodeHangulError(Exception):
@@ -210,9 +210,37 @@
else:
return 0, c in u'013678.bklmnptMN'
+# Iterator Emulator for ancient versions before 2.1
+try:
+ iter
+except:
+ class iter:
+ def __init__(self, obj):
+ self.obj = obj
+ self.ptr = 0
+ def next(self):
+ try:
+ return self.obj[self.ptr]
+ finally:
+ self.ptr += 1
+
+# Nested scope lambda emulation for versions before 2.2
+import sys
+if sys.hexversion < '0x2020000':
+ class plambda:
+ def __init__(self, obj):
+ self.obj = obj
+ def __call__(self):
+ return self.obj
+else:
+ plambda = None
+del sys
+
def format(fmtstr, *args, **kwargs):
if kwargs:
- argget = lambda:kwargs
+ argget = lambda:kwargs
+ if plambda:
+ argget = plambda(kwargs)
else:
argget = iter(args).next
1.5 +2 -2 KoreanCodecs/korean/python/qwerty2bul.py
Index: qwerty2bul.py
===================================================================
RCS file: /cvsroot/koco/KoreanCodecs/korean/python/qwerty2bul.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- qwerty2bul.py 11 Apr 2002 22:04:23 -0000 1.4
+++ qwerty2bul.py 26 Apr 2002 07:29:43 -0000 1.5
@@ -1,5 +1,5 @@
# Hye-Shik Chang <16 Feb 2002>
-# $Id: qwerty2bul.py,v 1.4 2002/04/11 22:04:23 perky Exp $
+# $Id: qwerty2bul.py,v 1.5 2002/04/26 07:29:43 perky Exp $
import codecs
from korean.hangul import Moeum, Jaeum, Chosung, Jungsung, Jongsung
@@ -165,7 +165,7 @@
if errors not in supported_errors:
raise UnicodeError, "unknown error handling"
- s = unicode(data, self.BASECODEC, errors=errors)
+ s = unicode(data, self.BASECODEC, errors)
am = Automata_Hangul2()
r = am.convert(s)
return (r, len(r))
|