Browse Source

Improve help. Add missing dependencies

pull/8/head
Luke Murphy 5 years ago
parent
commit
0e940df399
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 8
      README.md
  2. 14
      bin/etherpump
  3. 2
      etherpump/commands/appendmeta.py
  4. 2
      etherpump/commands/creatediffhtml.py
  5. 2
      etherpump/commands/deletepad.py
  6. 2
      etherpump/commands/dumpcsv.py
  7. 2
      etherpump/commands/gethtml.py
  8. 2
      etherpump/commands/gettext.py
  9. 12
      etherpump/commands/index.py
  10. 9
      etherpump/commands/init.py
  11. 2
      etherpump/commands/list.py
  12. 3
      etherpump/commands/listauthors.py
  13. 8
      etherpump/commands/publication.py
  14. 12
      etherpump/commands/pull.py
  15. 2
      etherpump/commands/revisionscount.py
  16. 3
      etherpump/commands/sethtml.py
  17. 6
      etherpump/commands/settext.py
  18. 4
      etherpump/commands/showmeta.py
  19. 11
      etherpump/commands/status.py
  20. 2
      setup.py

8
README.md

@ -27,9 +27,15 @@ After installing etherpump on the Varia server, we collectively decided to not w
Change log / notes
==================
**October 2019**
Improve `etherpump --help` handling to make it easier for new users.
Added the `python-dateutil` and `pypandoc` dependencies
**September 2019**
Forking *etherpump* into *etherpump*. (Work in progress!)
Forking *etherpump* into *etherpump*.
<https://git.vvvvvvaria.org/varia/etherpump>

14
bin/etherpump

@ -2,6 +2,7 @@
import os
import sys
from importlib import import_module
from pathlib import Path
from etherpump import __VERSION__
@ -9,14 +10,23 @@ from etherpump import __VERSION__
def subcommands():
"""List all sub-commands for the `--help` output."""
not_sub_commands = ['common.py', 'appendmeta.py', 'html5tidy.py', 'join.py']
subcommands = []
all_files = os.listdir(Path().absolute() / 'etherpump' / 'commands')
modules = filter(lambda file: not file.startswith('__'), all_files)
modules = filter(
lambda file: not file.startswith('__')
and not any(file == module for module in not_sub_commands),
all_files,
)
for module in modules:
name = module.split('.py')[0]
subcommands.append(f' {name}')
try:
doc = import_module(f'etherpump.commands.{name}').__doc__
except ModuleNotFoundError:
doc = ""
subcommands.append(f' {name}: {doc}')
subcommands.sort()

2
etherpump/commands/appendmeta.py

@ -1,8 +1,6 @@
#!/usr/bin/env python
import json
import os
from argparse import ArgumentParser

2
etherpump/commands/creatediffhtml.py

@ -1,3 +1,5 @@
"""Calls the createDiffHTML API function for the given padid"""
import json
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError

2
etherpump/commands/deletepad.py

@ -1,3 +1,5 @@
"""Calls the getText API function for the given padid"""
import json
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError

2
etherpump/commands/dumpcsv.py

@ -1,3 +1,5 @@
"""Dumps a CSV of all pads"""
import json
import re
import sys

2
etherpump/commands/gethtml.py

@ -1,3 +1,5 @@
"""Calls the getHTML API function for the given padid"""
import json
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError

2
etherpump/commands/gettext.py

@ -1,3 +1,5 @@
"""Calls the getText API function for the given padid"""
import json
import sys
from argparse import ArgumentParser

12
etherpump/commands/index.py

@ -1,3 +1,5 @@
"""Generate pages from etherpumps using a template"""
import json
import os
import re
@ -5,14 +7,12 @@ import sys
import time
from argparse import ArgumentParser
from datetime import datetime
from time import sleep
from urllib.parse import quote, urlencode, urlparse, urlunparse
from urllib.request import HTTPError, URLError, urlopen
from urllib.parse import urlparse, urlunparse
from jinja2 import Environment, FileSystemLoader
import dateutil.parser
from etherpump.commands.common import *
from etherpump.commands.common import * # noqa
"""
@ -39,10 +39,6 @@ def group(items, key=lambda x: x):
return ret
# def base (x):
# return re.sub(r"(\.raw\.html)|(\.diff\.html)|(\.meta\.json)|(\.raw\.txt)$", "", x)
def splitextlong(x):
""" split "long" extensions, i.e. foo.bar.baz => ('foo', '.bar.baz') """
m = re.search(r"^(.*?)(\..*)$", x)

9
etherpump/commands/init.py

@ -1,3 +1,5 @@
"""Initialize an etherpump folder"""
import json
import os
import sys
@ -11,7 +13,6 @@ def get_api(url, cmd=None, data=None, verbose=False):
useurl = url + cmd
if data:
useurl += "?" + urlencode(data)
# data['apikey'] = "7c8faa070c97f83d8f705c935a32d5141f89cbaa2158042fa92e8ddad5dbc5e1"
if verbose:
print("trying", useurl, file=sys.stderr)
resp = urlopen(useurl).read()
@ -29,10 +30,6 @@ def get_api(url, cmd=None, data=None, verbose=False):
if e.code == 401:
# Unauthorized is how the API responds to an incorrect API key
return {"code": 401, "message": e}
# resp = json.load(e)
# if "code" in resp and "message" in resp:
# # print ("returning", resp, file=sys.stderr)
# return resp
def tryapiurl(url, verbose=False):
@ -58,8 +55,6 @@ def tryapiurl(url, verbose=False):
apiurl = urlunparse((scheme, netloc, path, params, query, fragment))
if get_api(apiurl, "listAllPads", verbose=verbose):
return apiurl
# except ValueError as e:
# print ("ValueError", e, file=sys.stderr)
except URLError as e:
print("URLError", e, file=sys.stderr)

2
etherpump/commands/list.py

@ -1,3 +1,5 @@
"""Call listAllPads and print the results"""
import json
import sys
from argparse import ArgumentParser

3
etherpump/commands/listauthors.py

@ -1,6 +1,7 @@
"""Call listAuthorsOfPad for the padid"""
import json
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import urlopen

8
etherpump/commands/publication.py

@ -1,3 +1,5 @@
"""Generate a single document from etherpumps using a template"""
import json
import os
import re
@ -5,15 +7,13 @@ import sys
import time
from argparse import ArgumentParser
from datetime import datetime
from time import sleep
from urllib.parse import quote, urlencode, urlparse, urlunparse
from urllib.request import HTTPError, URLError, urlopen
from urllib.parse import urlparse, urlunparse
from jinja2 import Environment, FileSystemLoader
import dateutil.parser
import pypandoc
from etherpump.commands.common import *
from etherpump.commands.common import * # noqa
"""

12
etherpump/commands/pull.py

@ -1,3 +1,5 @@
"""Check for pads that have changed since last sync (according to .meta.json)"""
import json
import os
import re
@ -7,12 +9,12 @@ from datetime import datetime
from fnmatch import fnmatch
from time import sleep
from urllib.parse import quote, urlencode
from urllib.request import HTTPError, URLError, urlopen
from urllib.request import HTTPError
from xml.etree import ElementTree as ET
import html5lib
from etherpump.commands.common import *
from etherpump.commands.common import * # noqa
from etherpump.commands.html5tidy import html5tidy
@ -20,12 +22,8 @@ from etherpump.commands.html5tidy import html5tidy
pull(meta):
Update meta data files for those that have changed.
Check for changed pads by looking at revisions & comparing to existing
todo...
use/prefer public interfaces ? (export functions)
"""
@ -33,7 +31,7 @@ def try_deleting(files):
for f in files:
try:
os.remove(f)
except OSError as e:
except OSError:
pass

2
etherpump/commands/revisionscount.py

@ -1,3 +1,5 @@
"""Call getRevisionsCount for the given padid"""
import json
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError

3
etherpump/commands/sethtml.py

@ -1,7 +1,8 @@
"""Calls the setHTML API function for the given padid"""
import json
import sys
from argparse import ArgumentParser
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import urlopen

6
etherpump/commands/settext.py

@ -1,8 +1,10 @@
"""Calls the getText API function for the given padid"""
import json
import sys
from argparse import ArgumentParser
from urllib.parse import quote, urlencode
from urllib.request import HTTPError, URLError, urlopen
from urllib.parse import urlencode
from urllib.request import urlopen
import requests

4
etherpump/commands/showmeta.py

@ -1,9 +1,11 @@
"""Extract and output selected fields of metadata"""
import json
import re
import sys
from argparse import ArgumentParser
from .common import *
from .common import * # noqa
"""

11
etherpump/commands/status.py

@ -1,15 +1,10 @@
import json
"""Update meta data files for those that have changed"""
import os
import re
import sys
from argparse import ArgumentParser
from datetime import datetime
from math import ceil, floor
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import urlopen
from .common import *
from .common import * # noqa
"""

2
setup.py

@ -42,7 +42,7 @@ setup(
description='Etherpump: pumping text from etherpads into publications',
long_description=long_description,
long_description_content_type='text/markdown',
install_requires=["html5lib", "jinja2"],
install_requires=["html5lib", "jinja2", "python-dateutil", "pypandoc"],
classifiers=[
'Programming Language :: Python :: 3',
'Environment :: Console',

Loading…
Cancel
Save