Skip to content

Commit

Permalink
Merge pull request #3 from CSchulzeTLK/CSchulzeTLK-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ritchie authored Feb 12, 2022
2 parents 8a01d97 + 511bffe commit 588919d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion stubdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from argparse import ArgumentParser
from argparse import Namespace
import os
import importlib

from stubdoc import stubdoc

Expand Down Expand Up @@ -121,7 +122,7 @@ def _validate_module_path_arg(module_path_arg: Optional[str]) -> None:
if not os.path.isfile(module_path_arg):
raise ValueError(
f'Specified module not found: {module_path_arg}')
if not os.path.splitext(module_path_arg)[1] in ['.py', '.pyd']:
if not any(module_path_arg.endswith(ending) for ending in importlib.machinery.all_suffixes()):
raise ValueError(
f'A non-python module path specified: {module_path_arg}')

Expand Down
6 changes: 5 additions & 1 deletion stubdoc/stubdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ def _read_module(module_path: str) -> ModuleType:
file_name: str = os.path.basename(module_path)
dir_path: str = module_path.replace(file_name, '', 1)
sys.path.append(dir_path)
package_name: str = os.path.splitext(module_path)[0]
package_name: str = None
for ending in importlib.machinery.all_suffixes():
if module_path.endswith(ending):
package_name = module_path[:-len(ending)]
break
package_name = package_name.replace('/', '.')
package_name = package_name.replace('\\', '.')
while package_name.startswith('.'):
Expand Down

0 comments on commit 588919d

Please sign in to comment.