mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
add --try-harder for lyx2lyx
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10131 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ebe36adb3a
commit
9b4136de38
@ -1,3 +1,12 @@
|
||||
2005-07-05 José Matos <jamatos@lyx.org>
|
||||
|
||||
* LyX.py (LyX_Base):
|
||||
* LyX.py (File):
|
||||
* lyx2lyx (usage):
|
||||
* lyx2lyx (parse_options):
|
||||
* lyx2lyx (main): Add support for ignoring any errors during the
|
||||
file convertion.
|
||||
|
||||
2005-07-05 José Matos <jamatos@lyx.org>
|
||||
|
||||
* lyx_0_12.py (obsolete_latex_title): Obsolote old style.
|
||||
|
@ -78,7 +78,7 @@ def get_backend(textclass):
|
||||
#
|
||||
class LyX_Base:
|
||||
"""This class carries all the information of the LyX file."""
|
||||
def __init__(self, end_format = 0, input = "", output = "", error = "", debug = default_debug_level):
|
||||
def __init__(self, end_format = 0, input = "", output = "", error = "", debug = default_debug_level, try_hard = 0):
|
||||
"""Arguments:
|
||||
end_format: final format that the file should be converted. (integer)
|
||||
input: the name of the input source, if empty resort to standard input.
|
||||
@ -101,6 +101,7 @@ class LyX_Base:
|
||||
self.err = sys.stderr
|
||||
|
||||
self.debug = debug
|
||||
self.try_hard = try_hard
|
||||
|
||||
if end_format:
|
||||
self.end_format = self.lyxformat(end_format)
|
||||
@ -282,9 +283,16 @@ class LyX_Base:
|
||||
|
||||
for conv in table:
|
||||
init_t = time.time()
|
||||
conv(self)
|
||||
self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)),
|
||||
default_debug_level + 1)
|
||||
try:
|
||||
conv(self)
|
||||
except:
|
||||
self.warning("An error ocurred in %s, %s" % (version, str(conv)),
|
||||
default_debug_level)
|
||||
if not self.try_hard:
|
||||
raise
|
||||
else:
|
||||
self.warning("%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)),
|
||||
default_debug_level + 1)
|
||||
|
||||
self.format = version
|
||||
if self.end_format == self.format:
|
||||
@ -414,8 +422,8 @@ class LyX_Base:
|
||||
|
||||
class File(LyX_Base):
|
||||
" This class reads existing LyX files."
|
||||
def __init__(self, end_format = 0, input = "", output = "", error = "", debug = default_debug_level):
|
||||
LyX_Base.__init__(self, end_format, input, output, error, debug)
|
||||
def __init__(self, end_format = 0, input = "", output = "", error = "", debug = default_debug_level, try_hard = 0):
|
||||
LyX_Base.__init__(self, end_format, input, output, error, debug, try_hard)
|
||||
self.read()
|
||||
|
||||
|
||||
|
@ -35,18 +35,19 @@ Options:
|
||||
-f, --from version initial version (optional)
|
||||
-t, --to version final version (optional)
|
||||
-o, --output name name of the output file or else goes to stdout
|
||||
-n, --try-hard try hard (ignore any convertion errors)
|
||||
-q, --quiet same as --debug=0"""
|
||||
|
||||
|
||||
def parse_options(argv):
|
||||
_options = ["help", "version", "list", "debug=", "err=", "from=", "to=", "output=", "quiet"]
|
||||
_options = ["help", "version", "list", "debug=", "err=", "from=", "to=", "output=", "try-hard", "quiet"]
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "d:e:f:hlo:qt:v", _options)
|
||||
opts, args = getopt.getopt(argv[1:], "d:e:f:hlno:qt:v", _options)
|
||||
except getopt.error:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
end_format, input, output, error, debug = 0, "", "", "", LyX.default_debug_level
|
||||
end_format, input, output, error, debug, try_hard = 0, "", "", "", LyX.default_debug_level, 0
|
||||
for o, a in opts:
|
||||
if o in ("-h", "--help"):
|
||||
usage()
|
||||
@ -68,15 +69,17 @@ def parse_options(argv):
|
||||
end_format = a
|
||||
if o in ("-e","--err"):
|
||||
error = a
|
||||
if o in ("-n", "--try-hard"):
|
||||
try_hard = 1
|
||||
if args:
|
||||
input = args[0]
|
||||
|
||||
return end_format, input, output, error, debug
|
||||
return end_format, input, output, error, debug, try_hard
|
||||
|
||||
|
||||
def main(argv):
|
||||
end_format, input, output, error, debug = parse_options(argv)
|
||||
file = LyX.File(end_format, input, output, error, debug)
|
||||
end_format, input, output, error, debug, try_hard = parse_options(argv)
|
||||
file = LyX.File(end_format, input, output, error, debug, try_hard)
|
||||
|
||||
file.convert()
|
||||
file.write()
|
||||
|
Loading…
Reference in New Issue
Block a user