def set_location(_option, _opt_str, value, parser):
"""Sets the location variable in the parser to the filename in question"""
if not os.path.exists(os.path.abspath(value)):
debug.error("The requested file doesn't exist")
if parser.values.location == None:
slashes = "//"
# Windows pathname2url decides to convert C:\blah to ///C:/blah
# So to keep the URLs correct, we only add file: rather than file://
if sys.platform.startswith('win'):
slashes = ""
parser.values.location = "file:" + slashes + urllib.pathname2url(os.path.abspath(value))
评论列表
文章目录