from tempfile import mkstemp
fd, tmpfname = mkstemp(suffix='.ltx')
if os.name == 'nt':
- from locale import getdefaultlocale
- language, encoding = getdefaultlocale()
- if encoding == None:
- encoding = 'latin1'
+ encoding = sys.getfilesystemencoding()
if sys.version_info[0] < 3:
inpname = shortPath(unicode(tmpfname, encoding)).replace('\\', '/')
else:
- inpname = shortPath(str(tmpfname, encoding)).replace('\\', '/')
+ inpname = shortPath(tmpfname).replace('\\', '/')
else:
inpname = cmdOutput('cygpath -m ' + tmpfname)
logname = os.path.basename(re.sub("(?i).ltx", ".log", inpname))
inpname = inpname.replace('~', '\\string~')
- os.write(fd, r'\relax')
+ os.write(fd, b'\\relax')
os.close(fd)
latex_out = cmdOutput(r'latex "\nonstopmode\input{%s}\makeatletter\@@end"'
% inpname)
# Construct the list of classes to test for.
# build the list of available layout files and convert it to commands
# for chkconfig.ltx
- declare = re.compile(r'^\s*#\s*\\Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}\s*$')
- category = re.compile(r'^\s*#\s*\\DeclareCategory{(.*)}\s*$')
- empty = re.compile(r'^\s*$')
+ declare = re.compile(b'^\\s*#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
+ category = re.compile(b'^\\s*#\\s*\\\\DeclareCategory{(.*)}\\s*$')
+ empty = re.compile(b'^\\s*$')
testclasses = list()
for file in (glob.glob( os.path.join('layouts', '*.layout') )
+ glob.glob( os.path.join(srcdir, 'layouts', '*.layout' ) ) ):
if not os.path.isfile(file):
continue
classname = file.split(os.sep)[-1].split('.')[0]
- decline = ""
- catline = ""
- for line in open(file).readlines():
- if not empty.match(line) and line[0] != '#':
- if decline == "":
+ decline = b""
+ catline = b""
+ for line in open(file, 'rb').readlines():
+ if not empty.match(line) and line[0] != b'#'[0]:
+ if decline == b"":
logger.warning("Failed to find valid \Declare line "
"for layout file `%s'.\n\t=> Skipping this file!" % file)
nodeclaration = True
# A class, but no category declaration. Just break.
break
if declare.search(line) != None:
- decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip())
+ decline = b"\\TestDocClass{%s}{%s}" \
+ % (classname.encode('ascii'), line[1:].strip())
testclasses.append(decline)
elif category.search(line) != None:
- catline = ("\\DeclareCategory{%s}{%s}"
- % (classname, category.search(line).groups()[0]))
+ catline = (b"\\DeclareCategory{%s}{%s}"
+ % (classname.encode('ascii'),
+ category.search(line).groups()[0]))
testclasses.append(catline)
- if catline == "" or decline == "":
+ if catline == b"" or decline == b"":
continue
break
if nodeclaration:
continue
testclasses.sort()
- cl = open('chklayouts.tex', 'w')
+ cl = open('chklayouts.tex', 'wb')
for line in testclasses:
- cl.write(line + '\n')
+ cl.write(line + b'\n')
cl.close()
#
# we have chklayouts.tex, then process it