git @ Cat's Eye Technologies yastasoti / 51880e5
Python 3 compatibility. Chris Pressey 1 year, 10 months ago
1 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 #!/usr/bin/env python
0 #!/usr/bin/env python3
11
22 from argparse import ArgumentParser
33 import hashlib
66 from subprocess import check_call, CalledProcessError
77 import sys
88 from time import sleep, localtime, strftime
9 import urllib
9 try:
10 from urllib import unquote, quote_plus
11 except ImportError:
12 from urllib.parse import unquote, quote_plus
13 assert unquote and quote_plus
1014
1115 import requests
1216 try:
1923 parts = url.split(u'/')
2024 parts = parts[2:]
2125 domain_name = parts[0]
22 domain_name = urllib.quote_plus(domain_name)
26 domain_name = quote_plus(domain_name)
2327 parts = parts[1:]
2428 filename = u'/'.join(parts)
25 filename = urllib.quote_plus(filename.encode('utf-8'))
29 filename = quote_plus(filename.encode('utf-8'))
2630 if not filename:
2731 filename = 'index.html'
2832 return (domain_name, filename)
9599 filename = url.split('#')[0]
96100 else:
97101 filename = url
98 filename = urllib.unquote(filename)
102 filename = unquote(filename)
99103 filename = os.path.join(self.article_root, filename)
100104 if not os.path.exists(filename):
101105 raise ValueError('Local file "{}" does not exist'.format(filename))