From 4e63d38899a03955bcb6e512a01a7494765aef38 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 11 Feb 2016 15:37:24 +0100 Subject: [PATCH] Rename internal attributes to reflect actual usage for output --- patacrep/build.py | 2 +- patacrep/content/cwd.py | 2 +- patacrep/data/templates/songbook_model.yml | 4 ++-- patacrep/songbook/__init__.py | 7 +++---- test/test_content/test_content.py | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index c3ac9461..60bb62e3 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -169,7 +169,7 @@ class SongbookBuilder: def __init__(self, raw_songbook): # Basename of the songbook to be built. - self.basename = raw_songbook['_basename'] + self.basename = raw_songbook['_outputname'] # Representation of the .yaml songbook configuration file. self.songbook = Songbook(raw_songbook, self.basename) diff --git a/patacrep/content/cwd.py b/patacrep/content/cwd.py index 2c43af39..15c84fb8 100755 --- a/patacrep/content/cwd.py +++ b/patacrep/content/cwd.py @@ -34,7 +34,7 @@ def parse(keyword, config, argument): """ subpath = argument['path'] old_songdir = config['_songdir'] - sbdir = os.path.dirname(config['_filepath']) + sbdir = config['_outputdir'] config['_songdir'] = ( [DataSubpath(sbdir, subpath)] + diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index 19fb66fb..35cf639b 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -5,8 +5,8 @@ schema: template: //any required: _cache: //bool - _filepath: //str - _basename: //str + _outputdir: //str + _outputname: //str _error: //str _datadir: type: //arr diff --git a/patacrep/songbook/__init__.py b/patacrep/songbook/__init__.py index 0c602d4e..c6d26cdd 100644 --- a/patacrep/songbook/__init__.py +++ b/patacrep/songbook/__init__.py @@ -36,8 +36,8 @@ def open_songbook(filename): except Exception as error: # pylint: disable=broad-except raise patacrep.errors.SongbookError(str(error)) - user_songbook['_filepath'] = filename - user_songbook['_basename'] = os.path.splitext(os.path.basename(filename))[0] + user_songbook['_outputdir'] = os.path.dirname(os.path.abspath(filename)) + user_songbook['_outputname'] = os.path.splitext(os.path.basename(filename))[0] return prepare_songbook(user_songbook) @@ -95,13 +95,12 @@ def _iter_absolute_datadirs(raw_songbook): Appends the songfile dir at the end """ datadir = raw_songbook.get('book', {}).get('datadir') - filepath = raw_songbook['_filepath'] + basedir = raw_songbook['_outputdir'] if datadir is None: datadir = [] elif isinstance(datadir, str): datadir = [datadir] - basedir = os.path.dirname(os.path.abspath(filepath)) for path in datadir: abspath = os.path.join(basedir, path) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index d4fae378..c12aa644 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -56,7 +56,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): sbcontent = yaml.load(sourcefile) config = cls.config.copy() - config['_filepath'] = base + config['_outputdir'] = os.path.dirname(base) with logging_reduced('patacrep.content.song'): expandedlist = content.process_content(sbcontent, config) sourcelist = [cls._clean_path(elem) for elem in expandedlist]