Browse Source

Fix command listing to work on pip package installs

pull/8/head
Luke Murphy 5 years ago
parent
commit
d9988a932c
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 48
      bin/etherpump
  2. 1
      setup.py

48
bin/etherpump

@ -1,36 +1,46 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os
import sys import sys
from importlib import import_module
from pathlib import Path
from etherpump import __VERSION__ from etherpump import __VERSION__
def subcommands(): def subcommands():
"""List all sub-commands for the `--help` output.""" """List all sub-commands for the `--help` output."""
not_sub_commands = ['common.py', 'appendmeta.py', 'html5tidy.py', 'join.py'] output = []
subcommands = []
subcommands = [
all_files = os.listdir(Path().absolute() / 'etherpump' / 'commands') 'creatediffhtml',
modules = filter( 'deletepad',
lambda file: not file.startswith('__') 'dumpcsv',
and not any(file == module for module in not_sub_commands), 'gethtml',
all_files, 'gettext',
) 'index',
'init',
for module in modules: 'list',
name = module.split('.py')[0] 'listauthors',
'publication',
'pull',
'revisionscount',
'sethtml',
'settext',
'showmeta',
]
for subcommand in subcommands:
try: try:
doc = import_module(f'etherpump.commands.{name}').__doc__ # http://stackoverflow.com/questions/301134/dynamic-module-import-in-python
doc = __import__(
"etherpump.commands.%s" % subcommand,
fromlist=["etherdump.commands"],
).__doc__
except ModuleNotFoundError: except ModuleNotFoundError:
doc = "" doc = ""
subcommands.append(f' {name}: {doc}') output.append(f' {subcommand}: {doc}')
subcommands.sort() output.sort()
return '\n'.join(subcommands) return '\n'.join(output)
usage = """ usage = """

1
setup.py

@ -48,6 +48,7 @@ setup(
"python-dateutil", "python-dateutil",
"pypandoc", "pypandoc",
"tqdm", "tqdm",
"requests",
], ],
classifiers=[ classifiers=[
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',

Loading…
Cancel
Save