diff options
author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2019-01-27 02:46:25 +0100 |
---|---|---|
committer | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2019-01-27 02:46:25 +0100 |
commit | 8374ae53f1604f887255bd6214aae2b40b03c6f8 (patch) | |
tree | dd93486cf156bc6d91b1b650cfa4569af1ccb945 /ranger | |
parent | 981945a9afe4cca3b2e93ee0a57a22460b68f794 (diff) | |
download | ranger-8374ae53f1604f887255bd6214aae2b40b03c6f8.tar.gz |
Make it easier to test bookmarks by optionally disabling validation
The test bookmarks were intentionally bogus as we cannot reliably predict valid paths on the test system, so validation doesn't make any sense there.
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/bookmarks.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ranger/container/bookmarks.py b/ranger/container/bookmarks.py index 20809c10..25e81097 100644 --- a/ranger/container/bookmarks.py +++ b/ranger/container/bookmarks.py @@ -12,7 +12,7 @@ from ranger.core.shared import FileManagerAware ALLOWED_KEYS = string.ascii_letters + string.digits + "`'" -class Bookmarks(FileManagerAware): +class Bookmarks(FileManagerAware): # pylint: disable=too-many-instance-attributes """Bookmarks is a container which associates keys with bookmarks. A key is a string with: len(key) == 1 and key in ALLOWED_KEYS. @@ -29,7 +29,7 @@ class Bookmarks(FileManagerAware): load_pattern = re.compile(r"^[\d\w']:.") def __init__(self, bookmarkfile, bookmarktype=str, autosave=False, - nonpersistent_bookmarks=()): + validate=True, nonpersistent_bookmarks=()): """Initializes Bookmarks. <bookmarkfile> specifies the path to the file where @@ -41,6 +41,7 @@ class Bookmarks(FileManagerAware): self.path = bookmarkfile self.bookmarktype = bookmarktype self.nonpersistent_bookmarks = set(nonpersistent_bookmarks) + self.validate = validate def load(self): """Load the bookmarks from path/bookmarks""" @@ -89,7 +90,7 @@ class Bookmarks(FileManagerAware): key = "'" if key in self.dct: value = self.dct[key] - if os.path.isdir(value.path): + if not self.validate or os.path.isdir(str(value)): return value else: raise KeyError("Cannot open bookmark: `%s'!" % key) |