diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-04 07:24:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-04 07:24:05 +0000 |
commit | 621555af37594a213d91ea113d5fc7739af84d40 (patch) | |
tree | 5aaa3b586692062accffc21cfaaa5a3917ee77b3 /pdoc/cli.py | |
parent | Adding upstream version 10.2.9. (diff) | |
download | sqlglot-621555af37594a213d91ea113d5fc7739af84d40.tar.xz sqlglot-621555af37594a213d91ea113d5fc7739af84d40.zip |
Adding upstream version 10.4.2.upstream/10.4.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pdoc/cli.py')
-rwxr-xr-x | pdoc/cli.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/pdoc/cli.py b/pdoc/cli.py new file mode 100755 index 0000000..72a986d --- /dev/null +++ b/pdoc/cli.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +from importlib import import_module +from pathlib import Path +from unittest import mock + +from pdoc.__main__ import cli, parser + +# Need this import or else import_module doesn't work +import sqlglot + + +def mocked_import(*args, **kwargs): + """Return a MagicMock if import fails for any reason""" + try: + return import_module(*args, **kwargs) + except Exception: + mocked_module = mock.MagicMock() + mocked_module.__name__ = args[0] + return mocked_module + + +if __name__ == "__main__": + # Mock uninstalled dependencies so pdoc can still work + with mock.patch("importlib.import_module", side_effect=mocked_import): + opts = parser.parse_args() + opts.docformat = "google" + opts.modules = ["sqlglot"] + opts.footer_text = "Copyright (c) 2022 Toby Mao" + opts.template_directory = Path(__file__).parent.joinpath("templates").absolute() + opts.edit_url = ["sqlglot=https://github.com/tobymao/sqlglot/"] + + with mock.patch("pdoc.__main__.parser", **{"parse_args.return_value": opts}): + cli() |