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. 17
      etherpump/commands/common.py
  2. 7
      etherpump/commands/gettext.py
  3. 8
      etherpump/commands/index.py
  4. 9
      etherpump/commands/init.py
  5. 10
      etherpump/commands/list.py
  6. 8
      etherpump/commands/publication.py
  7. 7
      etherpump/commands/pull.py
  8. 7
      etherpump/commands/settext.py

17
etherpump/commands/common.py

@ -3,18 +3,6 @@ import re, os, json, sys
from math import ceil, floor from math import ceil, floor
from time import sleep 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.parse import urlparse, urlunparse, urlencode, quote_plus, unquote_plus
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError
from html.entities import name2codepoint from html.entities import name2codepoint
@ -32,10 +20,6 @@ def padurl (padid, ):
def padpath (padid, pub_path="", group_path="", normalize=False): def padpath (padid, pub_path="", group_path="", normalize=False):
g, p = splitpadname(padid) 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) p = quote_plus(p)
if normalize: if normalize:
p = p.replace(" ", "_") p = p.replace(" ", "_")
@ -128,4 +112,3 @@ def unescape(text):
pass pass
return text # leave as is return text # leave as is
return re.sub("&#?\w+;", fixup, text) return re.sub("&#?\w+;", fixup, text)

7
etherpump/commands/gettext.py

@ -1,13 +1,6 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import json, sys 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.parse import urlencode
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

8
etherpump/commands/index.py

@ -4,14 +4,6 @@ import sys, json, re, os, time
from datetime import datetime from datetime import datetime
import dateutil.parser 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.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

9
etherpump/commands/init.py

@ -1,15 +1,6 @@
from argparse import ArgumentParser 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.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

10
etherpump/commands/list.py

@ -3,15 +3,6 @@ from argparse import ArgumentParser
import json import json
import sys import sys
from etherpump.commands.common import getjson 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.parse import urlparse, urlunparse, urlencode
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError
@ -38,4 +29,3 @@ def main (args):
else: else:
for r in results: for r in results:
print (r) print (r)

8
etherpump/commands/publication.py

@ -5,14 +5,6 @@ from datetime import datetime
import dateutil.parser import dateutil.parser
import pypandoc 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.parse import urlparse, urlunparse, urlencode, quote
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

7
etherpump/commands/pull.py

@ -3,13 +3,6 @@ from argparse import ArgumentParser
import sys, json, re, os import sys, json, re, os
from datetime import datetime 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.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

7
etherpump/commands/settext.py

@ -2,13 +2,6 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import json, sys 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.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError from urllib.request import urlopen, URLError, HTTPError

Loading…
Cancel
Save