Improve help. Add missing dependencies
This commit is contained in:
parent
fa9acea169
commit
0e940df399
@ -27,9 +27,15 @@ After installing etherpump on the Varia server, we collectively decided to not w
|
|||||||
Change log / notes
|
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**
|
**September 2019**
|
||||||
|
|
||||||
Forking *etherpump* into *etherpump*. (Work in progress!)
|
Forking *etherpump* into *etherpump*.
|
||||||
|
|
||||||
<https://git.vvvvvvaria.org/varia/etherpump>
|
<https://git.vvvvvvaria.org/varia/etherpump>
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from importlib import import_module
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from etherpump import __VERSION__
|
from etherpump import __VERSION__
|
||||||
@ -9,14 +10,23 @@ 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']
|
||||||
subcommands = []
|
subcommands = []
|
||||||
|
|
||||||
all_files = os.listdir(Path().absolute() / 'etherpump' / 'commands')
|
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:
|
for module in modules:
|
||||||
name = module.split('.py')[0]
|
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()
|
subcommands.sort()
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Calls the createDiffHTML API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Calls the getText API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Dumps a CSV of all pads"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Calls the getHTML API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Calls the getText API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Generate pages from etherpumps using a template"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -5,14 +7,12 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import sleep
|
from urllib.parse import urlparse, urlunparse
|
||||||
from urllib.parse import quote, urlencode, urlparse, urlunparse
|
|
||||||
from urllib.request import HTTPError, URLError, urlopen
|
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import dateutil.parser
|
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
|
return ret
|
||||||
|
|
||||||
|
|
||||||
# def base (x):
|
|
||||||
# return re.sub(r"(\.raw\.html)|(\.diff\.html)|(\.meta\.json)|(\.raw\.txt)$", "", x)
|
|
||||||
|
|
||||||
|
|
||||||
def splitextlong(x):
|
def splitextlong(x):
|
||||||
""" split "long" extensions, i.e. foo.bar.baz => ('foo', '.bar.baz') """
|
""" split "long" extensions, i.e. foo.bar.baz => ('foo', '.bar.baz') """
|
||||||
m = re.search(r"^(.*?)(\..*)$", x)
|
m = re.search(r"^(.*?)(\..*)$", x)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Initialize an etherpump folder"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -11,7 +13,6 @@ def get_api(url, cmd=None, data=None, verbose=False):
|
|||||||
useurl = url + cmd
|
useurl = url + cmd
|
||||||
if data:
|
if data:
|
||||||
useurl += "?" + urlencode(data)
|
useurl += "?" + urlencode(data)
|
||||||
# data['apikey'] = "7c8faa070c97f83d8f705c935a32d5141f89cbaa2158042fa92e8ddad5dbc5e1"
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print("trying", useurl, file=sys.stderr)
|
print("trying", useurl, file=sys.stderr)
|
||||||
resp = urlopen(useurl).read()
|
resp = urlopen(useurl).read()
|
||||||
@ -29,10 +30,6 @@ def get_api(url, cmd=None, data=None, verbose=False):
|
|||||||
if e.code == 401:
|
if e.code == 401:
|
||||||
# Unauthorized is how the API responds to an incorrect API key
|
# Unauthorized is how the API responds to an incorrect API key
|
||||||
return {"code": 401, "message": e}
|
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):
|
def tryapiurl(url, verbose=False):
|
||||||
@ -58,8 +55,6 @@ def tryapiurl(url, verbose=False):
|
|||||||
apiurl = urlunparse((scheme, netloc, path, params, query, fragment))
|
apiurl = urlunparse((scheme, netloc, path, params, query, fragment))
|
||||||
if get_api(apiurl, "listAllPads", verbose=verbose):
|
if get_api(apiurl, "listAllPads", verbose=verbose):
|
||||||
return apiurl
|
return apiurl
|
||||||
# except ValueError as e:
|
|
||||||
# print ("ValueError", e, file=sys.stderr)
|
|
||||||
except URLError as e:
|
except URLError as e:
|
||||||
print("URLError", e, file=sys.stderr)
|
print("URLError", e, file=sys.stderr)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Call listAllPads and print the results"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
"""Call listAuthorsOfPad for the padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Generate a single document from etherpumps using a template"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -5,15 +7,13 @@ import sys
|
|||||||
import time
|
import time
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import sleep
|
from urllib.parse import urlparse, urlunparse
|
||||||
from urllib.parse import quote, urlencode, urlparse, urlunparse
|
|
||||||
from urllib.request import HTTPError, URLError, urlopen
|
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import pypandoc
|
import pypandoc
|
||||||
from etherpump.commands.common import *
|
from etherpump.commands.common import * # noqa
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Check for pads that have changed since last sync (according to .meta.json)"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -7,12 +9,12 @@ from datetime import datetime
|
|||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from urllib.parse import quote, urlencode
|
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
|
from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
import html5lib
|
import html5lib
|
||||||
|
|
||||||
from etherpump.commands.common import *
|
from etherpump.commands.common import * # noqa
|
||||||
from etherpump.commands.html5tidy import html5tidy
|
from etherpump.commands.html5tidy import html5tidy
|
||||||
|
|
||||||
|
|
||||||
@ -20,12 +22,8 @@ from etherpump.commands.html5tidy import html5tidy
|
|||||||
pull(meta):
|
pull(meta):
|
||||||
Update meta data files for those that have changed.
|
Update meta data files for those that have changed.
|
||||||
Check for changed pads by looking at revisions & comparing to existing
|
Check for changed pads by looking at revisions & comparing to existing
|
||||||
|
|
||||||
|
|
||||||
todo...
|
todo...
|
||||||
use/prefer public interfaces ? (export functions)
|
use/prefer public interfaces ? (export functions)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ def try_deleting(files):
|
|||||||
for f in files:
|
for f in files:
|
||||||
try:
|
try:
|
||||||
os.remove(f)
|
os.remove(f)
|
||||||
except OSError as e:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Call getRevisionsCount for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
"""Calls the setHTML API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.error import HTTPError, URLError
|
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
"""Calls the getText API function for the given padid"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from urllib.parse import quote, urlencode
|
from urllib.parse import urlencode
|
||||||
from urllib.request import HTTPError, URLError, urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
"""Extract and output selected fields of metadata"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from .common import *
|
from .common import * # noqa
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -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 *
|
import os
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
|
from .common import * # noqa
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -22,7 +17,7 @@ design decisions...
|
|||||||
ok based on the fact that only the txt file is pushable (via setText)
|
ok based on the fact that only the txt file is pushable (via setText)
|
||||||
it makes sense to give this file "primacy" ... ie to put the other forms
|
it makes sense to give this file "primacy" ... ie to put the other forms
|
||||||
(html, diff.html) in a special place (if created at all). Otherwise this
|
(html, diff.html) in a special place (if created at all). Otherwise this
|
||||||
complicates the "syncing" idea....
|
complicates the "syncing" idea....
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -42,7 +42,7 @@ setup(
|
|||||||
description='Etherpump: pumping text from etherpads into publications',
|
description='Etherpump: pumping text from etherpads into publications',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
install_requires=["html5lib", "jinja2"],
|
install_requires=["html5lib", "jinja2", "python-dateutil", "pypandoc"],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Environment :: Console',
|
'Environment :: Console',
|
||||||
|
Loading…
Reference in New Issue
Block a user