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 math import ceil, floor
from time import sleep from time import sleep
try: from urllib.parse import urlparse, urlunparse, urlencode, quote_plus, unquote_plus
# python2 from urllib.request import urlopen, URLError, HTTPError
from urllib.parse import urlparse, urlunparse from html.entities import name2codepoint
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
groupnamepat = re.compile(r"^g\.(\w+)\$") groupnamepat = re.compile(r"^g\.(\w+)\$")
def splitpadname (padid): def splitpadname (padid):
@ -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)

11
etherpump/commands/gettext.py

@ -1,15 +1,8 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import json, sys import json, sys
try: from urllib.parse import urlencode
# python2 from urllib.request import urlopen, URLError, HTTPError
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
def main(args): def main(args):

12
etherpump/commands/index.py

@ -4,16 +4,8 @@ import sys, json, re, os, time
from datetime import datetime from datetime import datetime
import dateutil.parser import dateutil.parser
try: from urllib.parse import urlparse, urlunparse, urlencode, quote
# python2 from urllib.request import urlopen, URLError, HTTPError
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 jinja2 import FileSystemLoader, Environment from jinja2 import FileSystemLoader, Environment
from etherpump.commands.common import * from etherpump.commands.common import *

13
etherpump/commands/init.py

@ -1,17 +1,8 @@
from argparse import ArgumentParser from argparse import ArgumentParser
try: from urllib.parse import urlparse, urlunparse, urlencode
# python2 from urllib.request import urlopen, URLError, HTTPError
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
import json, os, sys import json, os, sys

14
etherpump/commands/list.py

@ -3,17 +3,8 @@ 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: from urllib.parse import urlparse, urlunparse, urlencode
# python2 from urllib.request import urlopen, URLError, HTTPError
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
def main (args): def main (args):
p = ArgumentParser("call listAllPads and print the results") p = ArgumentParser("call listAllPads and print the results")
@ -38,4 +29,3 @@ def main (args):
else: else:
for r in results: for r in results:
print (r) print (r)

12
etherpump/commands/publication.py

@ -5,16 +5,8 @@ from datetime import datetime
import dateutil.parser import dateutil.parser
import pypandoc import pypandoc
try: from urllib.parse import urlparse, urlunparse, urlencode, quote
# python2 from urllib.request import urlopen, URLError, HTTPError
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 jinja2 import FileSystemLoader, Environment from jinja2 import FileSystemLoader, Environment
from etherpump.commands.common import * from etherpump.commands.common import *

11
etherpump/commands/pull.py

@ -3,15 +3,8 @@ from argparse import ArgumentParser
import sys, json, re, os import sys, json, re, os
from datetime import datetime from datetime import datetime
try: from urllib.parse import urlencode, quote
# python2 from urllib.request import urlopen, URLError, HTTPError
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 etherpump.commands.common import * from etherpump.commands.common import *
from time import sleep from time import sleep

11
etherpump/commands/settext.py

@ -2,15 +2,8 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import json, sys import json, sys
try: from urllib.parse import urlencode, quote
# python2 from urllib.request import urlopen, URLError, HTTPError
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
import requests import requests

Loading…
Cancel
Save