def addAlternatives(rcs, alt_type):
+ '''
+ Returns a \\prog_alternatives string to be used as an alternative
+ rc entry. alt_type can be a string or a list of strings.
+ '''
r = re.compile(r'\\Format (\S+).*$')
m = None
alt = ''
- alt_token = '\\%s_alternatives ' % alt_type
+ alt_token = '\\%s_alternatives '
+ if isinstance(alt_type, str):
+ alt_tokens = [alt_token % alt_type]
+ else:
+ alt_tokens = map(lambda s: alt_token % s, alt_type)
for idxx in range(len(rcs)):
if len(rcs) == 1:
m = r.match(rcs[0])
if m:
- alt = alt_token + m.group(1) + " %%"
+ alt = '\n'.join([s + m.group(1) + " %%" for s in alt_tokens])
elif len(rcs) > 1:
m = r.match(rcs[idxx])
if m:
if idxx > 0:
alt += '\n'
- alt += alt_token + m.group(1) + " %%"
+ alt += '\n'.join([s + m.group(1) + " %%" for s in alt_tokens])
return alt
-def checkViewer(description, progs, rc_entry = [], path = []):
- ''' The same as checkProgAlternatives, but for viewers '''
+def listAlternatives(progs, alt_type, rc_entry = []):
+ '''
+ Returns a list of \\prog_alternatives strings to be used as alternative
+ rc entries. alt_type can be a string or a list of strings.
+ '''
if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1:
logger.error("rc entry should have one item or item for each prog and not_found.")
sys.exit(2)
for idx in range(len(progs)):
if len(rc_entry) == 1:
rcs = rc_entry[0].split('\n')
- alt = addAlternatives(rcs, 'viewer')
+ alt = addAlternatives(rcs, alt_type)
alt_rc_entry.insert(0, alt)
elif len(rc_entry) > 1:
rcs = rc_entry[idx].split('\n')
- alt = addAlternatives(rcs, 'viewer')
+ alt = addAlternatives(rcs, alt_type)
alt_rc_entry.insert(idx, alt)
+ return alt_rc_entry
+
+
+def checkViewer(description, progs, rc_entry = [], path = []):
+ ''' The same as checkProgAlternatives, but for viewers '''
+ alt_rc_entry = listAlternatives(progs, 'viewer', rc_entry)
return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto')
def checkEditor(description, progs, rc_entry = [], path = []):
''' The same as checkProgAlternatives, but for editors '''
- if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1:
- logger.error("rc entry should have one item or item for each prog and not_found.")
- sys.exit(2)
- alt_rc_entry = []
- for idx in range(len(progs)):
- if len(rc_entry) == 1:
- rcs = rc_entry[0].split('\n')
- alt = addAlternatives(rcs, 'editor')
- alt_rc_entry.insert(0, alt)
- elif len(rc_entry) > 1:
- rcs = rc_entry[idx].split('\n')
- alt = addAlternatives(rcs, 'editor')
- alt_rc_entry.insert(idx, alt)
+ alt_rc_entry = listAlternatives(progs, 'editor', rc_entry)
return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto')
def checkViewerNoRC(description, progs, rc_entry = [], path = []):
''' The same as checkViewer, but do not add rc entry '''
- if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1:
- logger.error("rc entry should have one item or item for each prog and not_found.")
- sys.exit(2)
- alt_rc_entry = []
- for idx in range(len(progs)):
- if len(rc_entry) == 1:
- rcs = rc_entry[0].split('\n')
- alt = addAlternatives(rcs, 'viewer')
- alt_rc_entry.insert(0, alt)
- elif len(rc_entry) > 1:
- rcs = rc_entry[idx].split('\n')
- alt = addAlternatives(rcs, 'viewer')
- alt_rc_entry.insert(idx, alt)
+ alt_rc_entry = listAlternatives(progs, 'viewer', rc_entry)
rc_entry = []
return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto')
def checkEditorNoRC(description, progs, rc_entry = [], path = []):
''' The same as checkViewer, but do not add rc entry '''
- if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1:
- logger.error("rc entry should have one item or item for each prog and not_found.")
- sys.exit(2)
- alt_rc_entry = []
- for idx in range(len(progs)):
- if len(rc_entry) == 1:
- rcs = rc_entry[0].split('\n')
- alt = addAlternatives(rcs, 'editor')
- alt_rc_entry.insert(0, alt)
- elif len(rc_entry) > 1:
- rcs = rc_entry[idx].split('\n')
- alt = addAlternatives(rcs, 'editor')
- alt_rc_entry.insert(idx, alt)
+ alt_rc_entry = listAlternatives(progs, 'editor', rc_entry)
rc_entry = []
return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto')
def checkViewerEditor(description, progs, rc_entry = [], path = []):
''' The same as checkProgAlternatives, but for viewers and editors '''
- checkEditorNoRC(description, progs, rc_entry, path)
- return checkViewer(description, progs, rc_entry, path)
+ alt_rc_entry = listAlternatives(progs, ['editor', 'viewer'], rc_entry)
+ return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto')
def checkDTLtools():
# rc_entry = [ r'\ps_command "%%"' ])
checkViewer('a Postscript previewer', ['kghostview', 'okular', 'evince', 'gv', 'ghostview -swap'],
rc_entry = [r'''\Format eps eps EPS "" "%%" "" "vector"
-\Format ps ps Postscript t "%%" "" "document,vector"'''])
+\Format ps ps Postscript t "%%" "" "document,vector,menu=export"'''])
# for xdg-open issues look here: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg151818.html
checkViewer('a PDF previewer', ['kpdf', 'okular', 'evince', 'kghostview', 'xpdf', 'acrobat', 'acroread', \
'gv', 'ghostview'],
\Format lyx14x 14.lyx "LyX 1.4.x" "" "" "" "document"
\Format lyx15x 15.lyx "LyX 1.5.x" "" "" "" "document"
\Format lyx16x 16.lyx "LyX 1.6.x" "" "" "" "document,menu=export"
+\Format lyx20x 20.lyx "LyX 2.0.x" "" "" "" "document,menu=export"
\Format clyx cjklyx "CJK LyX 1.4.x (big5)" "" "" "" "document"
\Format jlyx cjklyx "CJK LyX 1.4.x (euc-jp)" "" "" "" "document"
\Format klyx cjklyx "CJK LyX 1.4.x (euc-kr)" "" "" "" "document"
\converter lyx lyx14x "python -tt $$s/lyx2lyx/lyx2lyx -t 245 $$i > $$o" ""
\converter lyx lyx15x "python -tt $$s/lyx2lyx/lyx2lyx -t 276 $$i > $$o" ""
\converter lyx lyx16x "python -tt $$s/lyx2lyx/lyx2lyx -t 345 $$i > $$o" ""
+\converter lyx lyx20x "python -tt $$s/lyx2lyx/lyx2lyx -t 413 $$i > $$o" ""
\converter lyx clyx "python -tt $$s/lyx2lyx/lyx2lyx -c big5 -t 245 $$i > $$o" ""
\converter lyx jlyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_jp -t 245 $$i > $$o" ""
\converter lyx klyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr -t 245 $$i > $$o" ""