Browse Source

Remove Python 2 cruft

pull/8/head
Luke Murphy 5 years ago
parent
commit
fc9c82c9e5
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 23
      etherpump/commands/common.py
  2. 11
      etherpump/commands/gettext.py
  3. 12
      etherpump/commands/index.py
  4. 13
      etherpump/commands/init.py
  5. 14
      etherpump/commands/list.py
  6. 12
      etherpump/commands/publication.py
  7. 11
      etherpump/commands/pull.py
  8. 11
      etherpump/commands/settext.py

23
etherpump/commands/common.py

@ -3,21 +3,9 @@ import re, os, json, sys
from math import ceil, floor
from time import sleep
try:
# python2
from urllib.parse import urlparse, urlunparse
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
from urllib.parse import quote_plus, unquote_plus
from html.entities import name2codepoint
input = raw_input
except ImportError:
# python3
from urllib.parse import urlparse, urlunparse, urlencode, quote_plus, unquote_plus
from urllib.request import urlopen, URLError, HTTPError
from html.entities import name2codepoint
from urllib.parse import urlparse, urlunparse, urlencode, quote_plus, unquote_plus
from urllib.request import urlopen, URLError, HTTPError
from html.entities import name2codepoint
groupnamepat = re.compile(r"^g\.(\w+)\$")
def splitpadname (padid):
@ -32,10 +20,6 @@ def padurl (padid, ):
def padpath (padid, pub_path="", group_path="", normalize=False):
g, p = splitpadname(padid)
# if type(g) == unicode:
# g = g.encode("utf-8")
# if type(p) == unicode:
# p = p.encode("utf-8")
p = quote_plus(p)
if normalize:
p = p.replace(" ", "_")
@ -128,4 +112,3 @@ def unescape(text):
pass
return text # leave as is
return re.sub("&#?\w+;", fixup, text)

11
etherpump/commands/gettext.py

@ -1,15 +1,8 @@
from argparse import ArgumentParser
import json, sys
try:
# python2
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
except ImportError:
# python3
from urllib.parse import urlencode
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen, URLError, HTTPError
def main(args):

12
etherpump/commands/index.py

@ -4,16 +4,8 @@ import sys, json, re, os, time
from datetime import datetime
import dateutil.parser
try:
# python2
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
from urllib.parse import urlparse, urlunparse
except ImportError:
# python3
from urllib.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from jinja2 import FileSystemLoader, Environment
from etherpump.commands.common import *

13
etherpump/commands/init.py

@ -1,17 +1,8 @@
from argparse import ArgumentParser
try:
# python2
from urllib.parse import urlparse, urlunparse
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
input = raw_input
except ImportError:
# python3
from urllib.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError
import json, os, sys

14
etherpump/commands/list.py

@ -3,17 +3,8 @@ from argparse import ArgumentParser
import json
import sys
from etherpump.commands.common import getjson
try:
# python2
from urllib.parse import urlparse, urlunparse
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
input = raw_input
except ImportError:
# python3
from urllib.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError
def main (args):
p = ArgumentParser("call listAllPads and print the results")
@ -38,4 +29,3 @@ def main (args):
else:
for r in results:
print (r)

12
etherpump/commands/publication.py

@ -5,16 +5,8 @@ from datetime import datetime
import dateutil.parser
import pypandoc
try:
# python2
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
from urllib.parse import urlparse, urlunparse
except ImportError:
# python3
from urllib.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from jinja2 import FileSystemLoader, Environment
from etherpump.commands.common import *

11
etherpump/commands/pull.py

@ -3,15 +3,8 @@ from argparse import ArgumentParser
import sys, json, re, os
from datetime import datetime
try:
# python2
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
except ImportError:
# python3
from urllib.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from etherpump.commands.common import *
from time import sleep

11
etherpump/commands/settext.py

@ -2,15 +2,8 @@
from argparse import ArgumentParser
import json, sys
try:
# python2
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
except ImportError:
# python3
from urllib.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
import requests

Loading…
Cancel
Save