Added os.path.expanduser() before open() calls with user supplied paths
This commit is contained in:
parent
05db6e32c7
commit
a2da9b6c02
|
@ -518,6 +518,7 @@ def save(opts, path, defaults=False):
|
|||
|
||||
Raises OptionsError if the existing data is corrupt.
|
||||
"""
|
||||
path = os.path.expanduser(path)
|
||||
if os.path.exists(path) and os.path.isfile(path):
|
||||
with open(path, "rt", encoding="utf8") as f:
|
||||
try:
|
||||
|
|
|
@ -75,7 +75,7 @@ class RandomGenerator:
|
|||
|
||||
class FileGenerator:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.path = os.path.expanduser(path)
|
||||
|
||||
def __len__(self):
|
||||
return os.path.getsize(self.path)
|
||||
|
|
|
@ -208,6 +208,7 @@ def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr):
|
|||
|
||||
reqs = []
|
||||
for r in args.requests:
|
||||
r = os.path.expanduser(r)
|
||||
if os.path.isfile(r):
|
||||
with open(r) as f:
|
||||
r = f.read()
|
||||
|
|
|
@ -215,6 +215,7 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr):
|
|||
|
||||
anchors = []
|
||||
for patt, spec in args.anchors:
|
||||
spec = os.path.expanduser(spec)
|
||||
if os.path.isfile(spec):
|
||||
with open(spec) as f:
|
||||
data = f.read()
|
||||
|
|
Loading…
Reference in New Issue