diff options
Diffstat (limited to 'scripts/asciidoc2html.py')
-rwxr-xr-x | scripts/asciidoc2html.py | 51 |
1 files changed, 5 insertions, 46 deletions
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index 291d48d5f..560faa0cd 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -48,13 +48,7 @@ class AsciiDoc: 'install', 'stacktrace' ] - def __init__(self, - asciidoc: Optional[str], - asciidoc_python: Optional[str], - website: Optional[str]) -> None: - self._cmd: Optional[List[str]] = None - self._asciidoc = asciidoc - self._asciidoc_python = asciidoc_python + def __init__(self, website: Optional[str]) -> None: self._website = website self._homedir: Optional[pathlib.Path] = None self._themedir: Optional[pathlib.Path] = None @@ -63,7 +57,6 @@ class AsciiDoc: def prepare(self) -> None: """Get the asciidoc command and create the homedir to use.""" - self._cmd = self._get_asciidoc_cmd() self._homedir = pathlib.Path(tempfile.mkdtemp()) self._themedir = self._homedir / '.asciidoc' / 'themes' / 'qute' self._tempdir = self._homedir / 'tmp' @@ -224,31 +217,6 @@ class AsciiDoc: except FileExistsError: pass - def _get_asciidoc_cmd(self) -> List[str]: - """Try to find out what commandline to use to invoke asciidoc.""" - if self._asciidoc is not None: - python = (sys.executable if self._asciidoc_python is None - else self._asciidoc_python) - return [python, self._asciidoc] - - for executable in ['asciidoc', 'asciidoc.py']: - try: - subprocess.run([executable, '--version'], - capture_output=True, - text=True, - check=True) - except FileNotFoundError: - pass - except OSError as e: - utils.print_error(f"While running {executable}: {e}") - except subprocess.CalledProcessError as e: - utils.print_error( - f"While running {executable}: {e}\n{e.stdout}\n{e.stderr}") - else: - return [executable] - - raise FileNotFoundError - def call(self, src: pathlib.Path, dst: pathlib.Path, *args): """Call asciidoc for the given files. @@ -258,8 +226,7 @@ class AsciiDoc: *args: Additional arguments passed to asciidoc. """ print("Calling asciidoc for {}...".format(src.name)) - assert self._cmd is not None # for mypy - cmdline = self._cmd[:] + cmdline = [sys.executable, "-m", "asciidoc"] if dst is not None: cmdline += ['--out-file', str(dst)] cmdline += args @@ -286,12 +253,6 @@ def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument('--website', help="Build website into a given " "directory.") - parser.add_argument('--asciidoc', help="Full path to asciidoc.py. " - "If not given, it's searched in PATH.", - nargs='?') - parser.add_argument('--asciidoc-python', help="Python to use for asciidoc." - "If not given, the current Python interpreter is used.", - nargs='?') return parser.parse_args() @@ -303,9 +264,8 @@ def run(**kwargs) -> None: try: asciidoc.prepare() except FileNotFoundError: - utils.print_error("Could not find asciidoc! Please install it, or use " - "the --asciidoc argument to point this script to " - "the correct asciidoc.py location!") + utils.print_error("Could not find asciidoc! Please install it, e.g. via " + "pip install -r misc/requirements/requirements-docs.txt") sys.exit(1) try: @@ -319,8 +279,7 @@ def main(colors: bool = False) -> None: utils.change_cwd() utils.use_color = colors args = parse_args() - run(asciidoc=args.asciidoc, asciidoc_python=args.asciidoc_python, - website=args.website) + run(website=args.website) if __name__ == '__main__': |