fnp
/
texml.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bump version (incompatilibity: dropping old Pythons).
[texml.git]
/
Texml
/
texmlwr.py
diff --git
a/Texml/texmlwr.py
b/Texml/texmlwr.py
index
631517a
..
0cfa8cc
100644
(file)
--- a/
Texml/texmlwr.py
+++ b/
Texml/texmlwr.py
@@
-11,13
+11,18
@@
ASIS = 3
PDF = 4
WEAK_WS_IS_NEWLINE = 2
PDF = 4
WEAK_WS_IS_NEWLINE = 2
-import unimap
-import specmap
+
from Texml
import unimap
+
from Texml
import specmap
import codecs
import os
import sys
import string
import codecs
import os
import sys
import string
+if sys.version_info[0] >= 3:
+ byteord = lambda c: c
+else:
+ byteord = ord
+
#
# Writer&Co class
#
#
# Writer&Co class
#
@@
-69,7
+74,7
@@
class texmlwr:
if always_ascii:
encoding = 'ascii'
self.stream = stream_encoder(stream, encoding)
if always_ascii:
encoding = 'ascii'
self.stream = stream_encoder(stream, encoding)
- except Exception
,
e:
+ except Exception
as
e:
raise ValueError("Can't create encoder: '%s'" % e)
# Continue initialization
self.after_char0d = 1
raise ValueError("Can't create encoder: '%s'" % e)
# Continue initialization
self.after_char0d = 1
@@
-274,9
+279,9
@@
class texmlwr:
try:
bytes = ch.encode(self.encoding)
for by in bytes:
try:
bytes = ch.encode(self.encoding)
for by in bytes:
- self.write('^^%02x' % ord(by), 0)
+ self.write('^^%02x' %
byte
ord(by), 0)
return
return
- except Exception
,
e:
+ except Exception
as
e:
pass
#
# Symbol have to be rewritten. Let start with math mode.
pass
#
# Symbol have to be rewritten. Let start with math mode.
@@
-336,7
+341,7
@@
class texmlwr:
""" Write char in Acrobat utf16be encoding """
bytes = ch.encode('utf_16_be')
for by in bytes:
""" Write char in Acrobat utf16be encoding """
bytes = ch.encode('utf_16_be')
for by in bytes:
- self.write('\\%03o' % ord(by), 0)
+ self.write('\\%03o' %
byte
ord(by), 0)
#
# Wrapper over output stream to write is desired encoding
#
# Wrapper over output stream to write is desired encoding