loader: Extract cache filename from config object

The only places that this is called, we already have a
reno.config.Config instance available. Simply use that instead.

We also include a note of the 'conf.notespath' property, because the odd
behavior of this caught me out for a bit, and call 'os.path.normpath',
because the default path included redundant up-level references.

Change-Id: I58948cd8fad55d29bd30c65653630bd466259cdc
This commit is contained in:
Stephen Finucane 2017-06-19 15:32:13 +01:00
parent b6832f7a81
commit b2aadef726
3 changed files with 12 additions and 6 deletions

View File

@ -74,7 +74,7 @@ def write_cache_db(conf, versions_to_include,
stream = open(outfilename, 'w')
close_stream = True
else:
outfilename = loader.get_cache_filename(conf.reporoot, conf.notespath)
outfilename = loader.get_cache_filename(conf)
if not os.path.exists(os.path.dirname(outfilename)):
os.makedirs(os.path.dirname(outfilename))
stream = open(outfilename, 'w')

View File

@ -259,7 +259,13 @@ class Config(object):
@property
def notespath(self):
"The path in the repo where notes are kept."
"""The path in the repo where notes are kept.
.. important::
This does not take ``reporoot`` into account. You need to add this
manually if required.
"""
return os.path.join(self.relnotesdir, self.notesdir)
# def parse_config_into(parsed_arguments):

View File

@ -21,8 +21,9 @@ from reno import scanner
LOG = logging.getLogger(__name__)
def get_cache_filename(reporoot, notesdir):
return os.path.join(reporoot, notesdir, 'reno.cache')
def get_cache_filename(conf):
return os.path.normpath(os.path.join(
conf.reporoot, conf.notespath, 'reno.cache'))
class Loader(object):
@ -54,8 +55,7 @@ class Loader(object):
self._cache = None
self._scanner = None
self._scanner_output = None
self._cache_filename = get_cache_filename(self._reporoot,
self._notespath)
self._cache_filename = get_cache_filename(conf)
self._load_data()