diff options
Diffstat (limited to 'modules/language/python/module')
-rw-r--r-- | modules/language/python/module/copy.scm | 9 | ||||
-rw-r--r-- | modules/language/python/module/gettext.py | 32 | ||||
-rw-r--r-- | modules/language/python/module/struct.scm | 3 |
3 files changed, 15 insertions, 29 deletions
diff --git a/modules/language/python/module/copy.scm b/modules/language/python/module/copy.scm index 2673e7e..795fff1 100644 --- a/modules/language/python/module/copy.scm +++ b/modules/language/python/module/copy.scm @@ -1,7 +1,12 @@ (define-module (language python module copy) + #:use-module (ice-9 match) #:export (Error copy deepcopy)) (define Error 'CopyError) -(define (copy x) ((@@ (logic guile-log persistance) copy) x)) -(define (deepcopy x) ((@@ (logic guile-log persistance) deep-copy) x)) +(define (s x) + (match x + ((#:obj x) x) + (x x))) +(define (copy x) (s ((@@ (logic guile-log persistance) copy) x))) +(define (deepcopy x) (S ((@@ (logic guile-log persistance) deep-copy) x))) diff --git a/modules/language/python/module/gettext.py b/modules/language/python/module/gettext.py index 80a9ebe..0ea54aa 100644 --- a/modules/language/python/module/gettext.py +++ b/modules/language/python/module/gettext.py @@ -335,26 +335,18 @@ class GNUTranslations(NullTranslations): def _parse(self, fp): """Override this method to support alternative .mo formats.""" - pk('_parse') - unpack = pk('unpack',struct.unpack) - pk(1) + unpack = struct.unpack filename = getattr(fp, 'name', '') - pk(2,filename) # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default - pk(3) buf = fp.read() buflen = len(buf) - pk(4,buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] - pk('magic') - pk('magic',magic,'LE',self.LE_MAGIC,'BE',self.BE_MAGIC) if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) - pk(version,msgcount,masteridx,transidx) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) @@ -363,7 +355,6 @@ class GNUTranslations(NullTranslations): raise OSError(0, 'Bad magic number', filename) major_version, minor_version = self._get_versions(version) - pk('version',major_version,self.VERSIONS) if major_version not in self.VERSIONS: raise OSError(0, 'Bad version number ' + str(major_version), filename) @@ -379,15 +370,13 @@ class GNUTranslations(NullTranslations): tmsg = buf[toff:tend] else: raise OSError(0, 'File is corrupt', filename) - pk('msg',mlen,tlen,msg,tmsg) + # See if we're looking at GNU .mo conventions for metadata if mlen == 0: # Catalog description lastk = None - for b_item in pk('split',tmsg.split(b'\n')): - pk('item',b_item) + for b_item in tmsg.split(b'\n'): item = b_item.decode().strip() - pk('decode',item) if not item: continue k = v = None @@ -395,20 +384,16 @@ class GNUTranslations(NullTranslations): k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() - pk('pair',k,v) self._info[k] = v lastk = k elif lastk: self._info[lastk] += '\n' + item - pk('lastk',lastk,self._info[lastk]) if k == 'content-type': self._charset = v.split('charset=')[1] - pk('charset',self._charset) elif k == 'plural-forms': v = v.split(';') plural = v[1].split('plural=')[1] self.plural = c2py(plural) - pk('plural',self.plural) # Note: we unconditionally convert both msgids and msgstrs to # Unicode using the character encoding specified in the charset # parameter of the Content-Type header. The gettext documentation @@ -548,19 +533,16 @@ def translation(domain, localedir=None, languages=None, # once. result = None for mofile in mofiles: - pk('mofile',mofile) - key = pk((class_, os.path.abspath(mofile))) - t = pk('tr',_translations.get(key)) + key = (class_, os.path.abspath(mofile)) + t = _translations.get(key) if t is None: with open(mofile, 'rb') as fp: - pk('process') - t = _translations.setdefault(key, pk('cl',class_(fp))) + t = _translations.setdefault(key, class_(fp)) # Copy the translation object to allow setting fallbacks and # output charset. All other instance data is shared with the # cached object. - pk('t1',t) t = copy.copy(t) - pk('t2',t) + if codeset: t.set_output_charset(codeset) if result is None: diff --git a/modules/language/python/module/struct.scm b/modules/language/python/module/struct.scm index 05b38f2..66496d3 100644 --- a/modules/language/python/module/struct.scm +++ b/modules/language/python/module/struct.scm @@ -102,7 +102,6 @@ (define c-i4 (lambda (k) (lambda (bv i) - (pk bv i) (cons (bytevector-s32-ref bv i end) (k bv (incr i 4)))))) @@ -252,7 +251,7 @@ (bv-scm bv) n)) (define (unpack format buffer) - (unpacker (pk (analyze format)) buffer 0)) + (unpacker (analyze format) buffer 0)) (define unpack_from (lam (format buffer (= offset 0)) |