Fix imports + subparsers in python3
This commit is contained in:
parent
ce9d13eafa
commit
35541a43e6
3
bmc.py
3
bmc.py
@ -433,7 +433,8 @@ def update(entry):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description="A bibliography " +
|
parser = argparse.ArgumentParser(description="A bibliography " +
|
||||||
"management tool.")
|
"management tool.")
|
||||||
subparsers = parser.add_subparsers(help="sub-command help")
|
subparsers = parser.add_subparsers(help="sub-command help", dest='parser')
|
||||||
|
subparsers.required = True # Fix for Python 3.3.5
|
||||||
|
|
||||||
parser_download = subparsers.add_parser('download', help="download help")
|
parser_download = subparsers.add_parser('download', help="download help")
|
||||||
parser_download.add_argument('-t', '--type', default=None,
|
parser_download.add_argument('-t', '--type', default=None,
|
||||||
|
@ -24,12 +24,13 @@ except ImportError:
|
|||||||
# Fall back to Python 2's urllib2
|
# Fall back to Python 2's urllib2
|
||||||
from urllib2 import urlopen, URLError
|
from urllib2 import urlopen, URLError
|
||||||
import arxiv2bib as arxiv_metadata
|
import arxiv2bib as arxiv_metadata
|
||||||
import tools
|
import libbmc.tools
|
||||||
from bibtexparser.bparser import BibTexParser
|
from bibtexparser.bparser import BibTexParser
|
||||||
from config import Config
|
from libbmc.config import Config
|
||||||
|
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
default_socket = socket.socket
|
||||||
|
|
||||||
|
|
||||||
def download(url):
|
def download(url):
|
||||||
@ -51,7 +52,10 @@ def download(url):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
port = None
|
port = None
|
||||||
socks.set_default_proxy(proxy_type, proxy, port)
|
socks.set_default_proxy(proxy_type, proxy, port)
|
||||||
else: # TODO : Reset if proxy is empty
|
socket.socket = socks.socksocket
|
||||||
|
elif proxy == '':
|
||||||
|
socket.socket = default_socket
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
proxy, port = proxy.split(':')
|
proxy, port = proxy.split(':')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user