Browse Source

Rename internal attributes to reflect actual usage for output

pull/203/head
Oliverpool 9 years ago
parent
commit
4e63d38899
  1. 2
      patacrep/build.py
  2. 2
      patacrep/content/cwd.py
  3. 4
      patacrep/data/templates/songbook_model.yml
  4. 7
      patacrep/songbook/__init__.py
  5. 2
      test/test_content/test_content.py

2
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)

2
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)] +

4
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

7
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)

2
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]

Loading…
Cancel
Save