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:
@@ -74,7 +74,7 @@ def write_cache_db(conf, versions_to_include,
|
|||||||
stream = open(outfilename, 'w')
|
stream = open(outfilename, 'w')
|
||||||
close_stream = True
|
close_stream = True
|
||||||
else:
|
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)):
|
if not os.path.exists(os.path.dirname(outfilename)):
|
||||||
os.makedirs(os.path.dirname(outfilename))
|
os.makedirs(os.path.dirname(outfilename))
|
||||||
stream = open(outfilename, 'w')
|
stream = open(outfilename, 'w')
|
||||||
|
|||||||
@@ -259,7 +259,13 @@ class Config(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def notespath(self):
|
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)
|
return os.path.join(self.relnotesdir, self.notesdir)
|
||||||
|
|
||||||
# def parse_config_into(parsed_arguments):
|
# def parse_config_into(parsed_arguments):
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ from reno import scanner
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_cache_filename(reporoot, notesdir):
|
def get_cache_filename(conf):
|
||||||
return os.path.join(reporoot, notesdir, 'reno.cache')
|
return os.path.normpath(os.path.join(
|
||||||
|
conf.reporoot, conf.notespath, 'reno.cache'))
|
||||||
|
|
||||||
|
|
||||||
class Loader(object):
|
class Loader(object):
|
||||||
@@ -54,8 +55,7 @@ class Loader(object):
|
|||||||
self._cache = None
|
self._cache = None
|
||||||
self._scanner = None
|
self._scanner = None
|
||||||
self._scanner_output = None
|
self._scanner_output = None
|
||||||
self._cache_filename = get_cache_filename(self._reporoot,
|
self._cache_filename = get_cache_filename(conf)
|
||||||
self._notespath)
|
|
||||||
|
|
||||||
self._load_data()
|
self._load_data()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user