[LyX/master] ePub: share a bit of code for parsing arguments.
Thibaut Cuvelier
tcuvelier at lyx.org
Sun Feb 7 22:16:13 UTC 2021
commit 7622292027f6bc851a47103164a58b8989916e4f
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Sun Feb 7 23:18:54 2021 +0100
ePub: share a bit of code for parsing arguments.
---
lib/scripts/docbook2epub.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/scripts/docbook2epub.py b/lib/scripts/docbook2epub.py
index b35296a..1d39962 100644
--- a/lib/scripts/docbook2epub.py
+++ b/lib/scripts/docbook2epub.py
@@ -21,6 +21,10 @@ import tempfile
import zipfile
+def _parse_nullable_argument(arg):
+ return arg if arg != '' and arg != 'none' else None
+
+
class DocBookToEpub:
def __init__(self, args=None):
if args is None:
@@ -31,10 +35,10 @@ class DocBookToEpub:
sys.exit(1)
self.own_path = sys.argv[0]
- self.java_path = sys.argv[1] if sys.argv[1] != '' and sys.argv[1] != 'none' else None
- self.saxon_path = sys.argv[2] if sys.argv[2] != '' and sys.argv[2] != 'none' else None
- self.xsltproc_path = sys.argv[3] if sys.argv[3] != '' and sys.argv[3] != 'none' else None
- self.xslt_path = sys.argv[4] if sys.argv[4] != '' and sys.argv[4] != 'none' else None
+ self.java_path = _parse_nullable_argument(sys.argv[1])
+ self.saxon_path = _parse_nullable_argument(sys.argv[2])
+ self.xsltproc_path = _parse_nullable_argument(sys.argv[3])
+ self.xslt_path = _parse_nullable_argument(sys.argv[4])
self.input = sys.argv[5]
self.output = sys.argv[6]
self.script_folder = os.path.dirname(self.own_path) + '/../'
More information about the lyx-cvs
mailing list