# Full author contact details are available in file CREDITS.
from __future__ import print_function
-import glob, logging, os, re, shutil, subprocess, sys, stat
+import glob, logging, os, re, shutil, subprocess, sys, stat, io
# set up logging
logging.basicConfig(level = logging.DEBUG,
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)
\Format tiff tif TIFF "" "%s" "%s" "" "image/tiff"
\Format xbm xbm XBM "" "%s" "%s" "" "image/x-xbitmap"
\Format xpm xpm XPM "" "%s" "%s" "" "image/x-xpixmap"'''
- path, iv = checkViewerNoRC('a raster image viewer', ['xv', 'kview', 'gimp-remote', 'gimp'], rc_entry = [imageformats])
- path, ie = checkEditorNoRC('a raster image editor', ['gimp-remote', 'gimp'], rc_entry = [imageformats])
- addToRC(imageformats %
- (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie) )
- #
- checkViewerEditor('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate',
- 'nedit', 'gedit', 'notepad', 'geany', 'leafpad', 'mousepad'],
+ path, iv = checkViewerNoRC('a raster image viewer',
+ ['xv', 'gwenview', 'kview',
+ 'eog', 'xviewer', 'ristretto', 'gpicview', 'lximage-qt',
+ 'xdg-open', 'gimp-remote', 'gimp'],
+ rc_entry = [imageformats])
+ path, ie = checkEditorNoRC('a raster image editor',
+ ['gimp-remote', 'gimp'], rc_entry = [imageformats])
+ addToRC(imageformats % ((iv, ie)*10))
+ #
+ checkViewerEditor('a text editor',
+ ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate',
+ 'nedit', 'gedit', 'geany', 'leafpad', 'mousepad', 'xed', 'notepad'],
rc_entry = [r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" ""
\Format docbook sgml DocBook B "" "%%" "document,menu=export" ""
\Format docbook-xml xml "DocBook (XML)" "" "" "%%" "document,menu=export" "application/docbook+xml"
#
#checkProg('a Postscript interpreter', ['gs'],
# rc_entry = [ r'\ps_command "%%"' ])
- checkViewer('a Postscript previewer', ['kghostview', 'okular', 'qpdfview --unique',
- 'evince', 'gv', 'ghostview -swap',
- 'gsview64', 'gsview32'],
+ checkViewer('a Postscript previewer',
+ ['kghostview', 'okular', 'qpdfview --unique',
+ 'evince', 'xreader',
+ 'gv', 'ghostview -swap', 'gsview64', 'gsview32'],
rc_entry = [r'''\Format eps eps EPS "" "%%" "" "vector" "image/x-eps"
\Format eps2 eps "EPS (uncropped)" "" "%%" "" "vector" ""
\Format eps3 eps "EPS (cropped)" "" "%%" "" "document" ""
\Format ps ps Postscript t "%%" "" "document,vector,menu=export" "application/postscript"'''])
# for xdg-open issues look here: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg151818.html
+ # maybe use "bestApplication()" from https://github.com/jleclanche/python-mime
# the MIME type is set for pdf6, because that one needs to be autodetectable by libmime
- checkViewer('a PDF previewer', ['pdfview', 'kpdf', 'okular', 'qpdfview --unique',
- 'evince', 'kghostview', 'xpdf', 'SumatraPDF',
- 'acrobat', 'acroread', 'mupdf', 'gv',
- 'ghostview', 'AcroRd32', 'gsview64', 'gsview32'],
+ checkViewer('a PDF previewer',
+ ['pdfview', 'kpdf', 'okular', 'qpdfview --unique',
+ 'evince', 'xreader', 'kghostview', 'xpdf', 'SumatraPDF',
+ 'acrobat', 'acroread', 'mupdf',
+ 'gv', 'ghostview', 'AcroRd32', 'gsview64', 'gsview32'],
rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document,vector,menu=export" ""
\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document,vector,menu=export" ""
\Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document,vector,menu=export" ""
\Format pdf7 pdf "PDF (cropped)" "" "%%" "" "document,vector" ""
\Format pdf8 pdf "PDF (lower resolution)" "" "%%" "" "document,vector" ""'''])
#
- checkViewer('a DVI previewer', ['xdvi', 'kdvi', 'okular', 'yap', 'dviout -Set=!m'],
+ checkViewer('a DVI previewer', ['xdvi', 'kdvi', 'okular',
+ 'evince', 'xreader',
+ 'yap', 'dviout -Set=!m'],
rc_entry = [r'''\Format dvi dvi DVI D "%%" "" "document,vector,menu=export" "application/x-dvi"
\Format dvi3 dvi "DVI (LuaTeX)" V "%%" "" "document,vector,menu=export" ""'''])
if dtl_tools:
rc_entry = [ r'\chktex_command "%%"' ])
checkProgAlternatives('BibTeX or alternative programs',
['bibtex', 'bibtex8', 'biber'],
- rc_entry = [ r'\bibtex_command "%%"' ],
+ rc_entry = [ r'\bibtex_command "automatic"' ],
alt_rc_entry = [ r'\bibtex_alternatives "%%"' ])
- checkProg('a specific Japanese BibTeX variant',
- ['pbibtex', 'jbibtex', 'bibtex'],
- rc_entry = [ r'\jbibtex_command "%%"' ])
+ checkProgAlternatives('a specific Japanese BibTeX variant',
+ ['pbibtex', 'upbibtex', 'jbibtex', 'bibtex', 'biber'],
+ rc_entry = [ r'\jbibtex_command "automatic"' ],
+ alt_rc_entry = [ r'\jbibtex_alternatives "%%"' ])
checkProgAlternatives('available index processors',
['texindy', 'makeindex -c -q', 'xindy'],
rc_entry = [ r'\index_command "%%"' ],
classname = file.split(os.sep)[-1].split('.')[0]
decline = ""
catline = ""
- for line in open(file).readlines():
+ if os.name == 'nt':
+ enco = sys.getfilesystemencoding()
+ else:
+ enco="utf8"
+ for line in io.open(file, encoding=enco).readlines():
if not empty.match(line) and line[0] != '#':
if decline == "":
logger.warning("Failed to find valid \Declare line "
return '"%s" "%s" "%s" "%s" "%s" "%s" "%s"\n' % (modname, filename, cet, cfm, db, desc, pkgs)
+def checkXTemplates():
+ removeFiles(['xtemplates.lst'])
+
+ logger.info('+checking list of external templates... ')
+ tx = open('xtemplates.lst', 'w')
+ tx.write('''## This file lists external templates.
+## It has been automatically generated by configure
+## Use "Options/Reconfigure" if you need to update it after a
+## configuration change.
+''')
+
+ # build the list of available templates
+ seen = []
+ # note that this searches the local directory first, then the
+ # system directory. that way, we pick up the user's version first.
+ for file in glob.glob( os.path.join('xtemplates', '*.xtemplate') ) + \
+ glob.glob( os.path.join(srcdir, 'xtemplates', '*.xtemplate' ) ) :
+ # valid file?
+ logger.info(file)
+ if not os.path.isfile(file):
+ continue
+
+ filename = file.split(os.sep)[-1]
+ if seen.count(filename):
+ continue
+
+ seen.append(filename)
+ if filename != "":
+ tx.write(filename + "\n")
+ tx.close()
+ logger.info('\tdone')
+
+
def checkTeXAllowSpaces():
''' Let's check whether spaces are allowed in TeX file names '''
tex_allows_spaces = 'false'
lyx_check_config = True
lyx_kpsewhich = True
outfile = 'lyxrc.defaults'
- lyxrc_fileformat = 20
+ lyxrc_fileformat = 21
rc_entries = ''
lyx_keep_temps = False
version_suffix = ''
rescanTeXFiles()
checkModulesConfig()
checkCiteEnginesConfig()
+ checkXTemplates()
# --without-latex-config can disable lyx_check_config
ret = checkLatexConfig(lyx_check_config and LATEX != '', bool_docbook)
removeTempFiles()