X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy%2Fdata.py;h=e9a10799d8fe793c0b6ecf44f13216bba7d1deda;hp=d7de13addc111a43ea5dbd07da5de5b04376a448;hb=11ae0d6e7e05cffb744f7b40f37309f07696d34a;hpb=5210334c47e97988ea55543d60a6b24985ebd140 diff --git a/mudpy/data.py b/mudpy/data.py index d7de13a..e9a1079 100644 --- a/mudpy/data.py +++ b/mudpy/data.py @@ -1,6 +1,6 @@ """Data interface functions for the mudpy engine.""" -# Copyright (c) 2004-2016 Jeremy Stanley . Permission +# Copyright (c) 2004-2017 Jeremy Stanley . Permission # to use, copy, modify, and distribute this software is granted under # terms provided in the LICENSE file distributed with this software. @@ -134,15 +134,17 @@ class DataFile: if "__control__" in self.data and "backup_count" in self.data[ "__control__"]: max_count = self.data["__control__"]["backup_count"] - else: + elif "mudpy.limit" in self.universe.contents: max_count = self.universe.contents["mudpy.limit"].get( - "backups") + "backups", 0) + else: + max_count = 0 if os.path.exists(self.filename) and max_count: backups = [] for candidate in os.listdir(os.path.dirname(self.filename)): if re.match( os.path.basename(self.filename) + - """\.\d+$""", candidate + r"""\.\d+$""", candidate ): backups.append(int(candidate.split(".")[-1])) backups.sort() @@ -191,18 +193,14 @@ class DataFile: def find_file( file_name=None, - root_path=None, - search_path=None, - default_dir=None, + prefix=None, relative=None, + search=None, + stash=None, universe=None ): """Return an absolute file path based on configuration.""" - # make sure to get rid of any surrounding quotes first thing - if file_name: - file_name = file_name.strip("\"'") - # this is all unnecessary if it's already absolute if file_name and os.path.isabs(file_name): return os.path.realpath(file_name) @@ -211,16 +209,14 @@ def find_file( if universe: if hasattr( - universe, - "contents" - ) and "internal:storage" in universe.contents: - storage = universe.categories["internal"]["storage"] - if not root_path: - root_path = storage.get("root_path").strip("\"'") - if not search_path: - search_path = storage.get("search_path") - if not default_dir: - default_dir = storage.get("default_dir").strip("\"'") + universe, "contents") and "mudpy.filing" in universe.contents: + filing = universe.contents["mudpy.filing"] + if not prefix: + prefix = filing.get("prefix") + if not search: + search = filing.get("search") + if not stash: + stash = filing.get("stash") # if there's only one file loaded, try to work around a chicken