mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Port os.getcwdu to python 3
This commit is contained in:
parent
5234e43f0e
commit
cc9a11fba0
@ -23,6 +23,8 @@ sys.path.insert(0, SRC)
|
||||
sys.resources_location = os.path.join(os.path.dirname(SRC), 'resources')
|
||||
sys.extensions_location = os.path.abspath(os.environ.get('CALIBRE_SETUP_EXTENSIONS_PATH', os.path.join(SRC, 'calibre', 'plugins')))
|
||||
sys.running_from_setup = True
|
||||
if not hasattr(os, 'getcwdu'):
|
||||
os.getcwdu = os.getcwd
|
||||
|
||||
__version__ = __appname__ = modules = functions = basenames = scripts = None
|
||||
|
||||
|
@ -12,6 +12,12 @@ if 'CALIBRE_SHOW_DEPRECATION_WARNINGS' not in os.environ:
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
try:
|
||||
os.getcwdu()
|
||||
except AttributeError:
|
||||
os.getcwdu = os.getcwd
|
||||
try:
|
||||
os.getcwd()
|
||||
except EnvironmentError:
|
||||
os.chdir(os.path.expanduser('~'))
|
||||
except EnvironmentError:
|
||||
os.chdir(os.path.expanduser('~'))
|
||||
|
||||
@ -342,9 +348,9 @@ def get_parsed_proxy(typ='http', debug=True):
|
||||
if proxy:
|
||||
pattern = re.compile((
|
||||
'(?:ptype://)?'
|
||||
'(?:(?P<user>\w+):(?P<pass>.*)@)?'
|
||||
'(?P<host>[\w\-\.]+)'
|
||||
'(?::(?P<port>\d+))?').replace('ptype', typ)
|
||||
'(?:(?P<user>\\w+):(?P<pass>.*)@)?'
|
||||
'(?P<host>[\\w\\-\\.]+)'
|
||||
'(?::(?P<port>\\d+))?').replace('ptype', typ)
|
||||
)
|
||||
|
||||
match = pattern.match(proxies[typ])
|
||||
|
Loading…
x
Reference in New Issue
Block a user