Browse Source

Change sb to yaml extension

pull/198/head
Oliverpool 9 years ago
parent
commit
0912eaf0d2
  1. 2
      README.rst
  2. 0
      examples/example-all.yaml
  3. 0
      examples/example-all.yaml.yaml
  4. 0
      examples/example-crepbook.yaml
  5. 0
      examples/example-layout.yaml
  6. 0
      examples/example-songs.yaml
  7. 0
      examples/example-test.yaml
  8. 0
      examples/example.yaml
  9. 0
      examples/example_encoding.yaml
  10. 8
      patacrep/build.py
  11. 6
      patacrep/content/__init__.py
  12. 2
      patacrep/content/cwd.py
  13. 4
      patacrep/songbook/__main__.py
  14. 2
      test/test_content/test_content.py
  15. 2
      test/test_songbook/content.yaml
  16. 0
      test/test_songbook/datadir.yaml
  17. 0
      test/test_songbook/languages.yaml
  18. 0
      test/test_songbook/syntax.yaml
  19. 10
      test/test_songbook/test_compilation.py
  20. 0
      test/test_songbook/unicode.yaml

2
README.rst

@ -55,7 +55,7 @@ Run
:: ::
songbook <songbook_file.sb> songbook <songbook_file.yaml>
<pdfreader> <songbook_file.pdf> <pdfreader> <songbook_file.pdf>
Look for existing songbook files in `patadata <http://github.com/patacrep/patadata>`_. Look for existing songbook files in `patadata <http://github.com/patacrep/patadata>`_.

0
examples/example-all.sb → examples/example-all.yaml

0
examples/example-all.yaml.sb → examples/example-all.yaml.yaml

0
examples/example-crepbook.sb → examples/example-crepbook.yaml

0
examples/example-layout.sb → examples/example-layout.yaml

0
examples/example-songs.sb → examples/example-songs.yaml

0
examples/example-test.sb → examples/example-test.yaml

0
examples/example.sb → examples/example.yaml

0
examples/example_encoding.sb → examples/example_encoding.yaml

8
patacrep/build.py

@ -1,4 +1,4 @@
"""Build a songbook, according to parameters found in a .sb file.""" """Build a songbook, according to parameters found in a .yaml file."""
import codecs import codecs
import copy import copy
@ -34,10 +34,10 @@ GENERATED_EXTENSIONS = [
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
class Songbook: class Songbook:
"""Represent a songbook (.sb) file. """Represent a songbook (.yaml) file.
- Low level: provide a Python representation of the values stored in the - Low level: provide a Python representation of the values stored in the
'.sb' file. '.yaml' file.
- High level: provide some utility functions to manipulate these data. - High level: provide some utility functions to manipulate these data.
""" """
@ -183,7 +183,7 @@ class SongbookBuilder:
_called_functions = {} _called_functions = {}
def __init__(self, raw_songbook, basename): def __init__(self, raw_songbook, basename):
# Representation of the .sb songbook configuration file. # Representation of the .yaml songbook configuration file.
self.songbook = Songbook(raw_songbook, basename) self.songbook = Songbook(raw_songbook, basename)
# Basename of the songbook to be built. # Basename of the songbook to be built.
self.basename = basename self.basename = basename

6
patacrep/content/__init__.py

@ -1,7 +1,7 @@
"""Content plugin management. """Content plugin management.
Content that can be included in a songbook is controlled by plugins. From the Content that can be included in a songbook is controlled by plugins. From the
user (or .sb file) point of view, each piece of content is introduced by a user (or .yaml file) point of view, each piece of content is introduced by a
keyword. This keywold is associated with a plugin (a submodule of this very keyword. This keywold is associated with a plugin (a submodule of this very
module), which parses the content, and return a ContentList object, which is module), which parses the content, and return a ContentList object, which is
little more than a list of instances of the ContentItem class. little more than a list of instances of the ContentItem class.
@ -14,7 +14,7 @@ dictionary where:
- keys are keywords, - keys are keywords,
- values are parsers (see below). - values are parsers (see below).
When analysing the content field of the .sb file, when those keywords are When analysing the content field of the .yaml file, when those keywords are
met, the corresponding parser is called. met, the corresponding parser is called.
# Keyword examples # Keyword examples
@ -252,7 +252,7 @@ def process_content(content, config=None):
"""Process content, and return a list of ContentItem() objects. """Process content, and return a list of ContentItem() objects.
Arguments are: Arguments are:
- content: the content field of the .sb file, which should be a nested list - content: the content field of the .yaml file, which should be a nested list
and describe what is to be included in the songbook; and describe what is to be included in the songbook;
- config: the configuration dictionary of the current songbook. - config: the configuration dictionary of the current songbook.

2
patacrep/content/cwd.py

@ -28,7 +28,7 @@ def parse(keyword, config, argument):
for, and then processes the content. for, and then processes the content.
The 'path' is added: The 'path' is added:
- first as a relative path to the *.sb file directory; - first as a relative path to the *.yaml file directory;
- then as a relative path to every path already present in - then as a relative path to every path already present in
config['songdir']. config['songdir'].
""" """

4
patacrep/songbook/__main__.py

@ -128,8 +128,8 @@ def main():
options = argument_parser(sys.argv[1:]) options = argument_parser(sys.argv[1:])
songbook_path = options.book[-1] songbook_path = options.book[-1]
if os.path.exists(songbook_path + ".sb") and not os.path.exists(songbook_path): if os.path.exists(songbook_path + ".yaml") and not os.path.exists(songbook_path):
songbook_path += ".sb" songbook_path += ".yaml"
basename = os.path.basename(songbook_path)[:-3] basename = os.path.basename(songbook_path)[:-3]

2
test/test_content/test_content.py

@ -21,7 +21,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"""Test of the content plugins. """Test of the content plugins.
For any given `foo.source`, it parses the content as a yaml "content" For any given `foo.source`, it parses the content as a yaml "content"
argument of a .sb file. argument of a .yaml file.
It controls that the generated file list is equal to the one in `foo.control`. It controls that the generated file list is equal to the one in `foo.control`.
""" """

2
test/test_songbook/content.sb → test/test_songbook/content.yaml

@ -12,7 +12,7 @@ content:
- sort: - sort:
- songsection: Test of song section - songsection: Test of song section
- cwd: - cwd:
# relative to sb file # relative to yaml songfile
path: content_datadir/content path: content_datadir/content
content: content:
- "song.csg" - "song.csg"

0
test/test_songbook/datadir.sb → test/test_songbook/datadir.yaml

0
test/test_songbook/languages.sb → test/test_songbook/languages.yaml

0
test/test_songbook/syntax.sb → test/test_songbook/syntax.yaml

10
test/test_songbook/test_compilation.py

@ -18,7 +18,7 @@ LOGGER = logging.getLogger(__name__)
class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"""Test of songbook compilation. """Test of songbook compilation.
For any given `foo.sb`, it performs several checks: For any given `foo.yaml`, it performs several checks:
- the corresponding tex file is generated; - the corresponding tex file is generated;
- the generated tex file matches the `foo.tex.control` control file; - the generated tex file matches the `foo.tex.control` control file;
- the compilation (tex, pdf, indexes) works without errors. - the compilation (tex, pdf, indexes) works without errors.
@ -34,9 +34,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"""Iterate over dynamically generated test methods.""" """Iterate over dynamically generated test methods."""
for songbook in sorted(glob.glob(os.path.join( for songbook in sorted(glob.glob(os.path.join(
os.path.dirname(__file__), os.path.dirname(__file__),
'*.sb', '*.yaml',
))): ))):
base = songbook[:-len(".sb")] base = songbook[:-len(".yaml")]
yield ( yield (
"test_latex_generation_{}".format(os.path.basename(base)), "test_latex_generation_{}".format(os.path.basename(base)),
cls._create_generation_test(base), cls._create_generation_test(base),
@ -52,7 +52,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
def test_generation(self): def test_generation(self):
"""Test that `base.tex` is correctly generated.""" """Test that `base.tex` is correctly generated."""
songbook = "{}.sb".format(base) songbook = "{}.yaml".format(base)
# Check tex generation # Check tex generation
self.assertEqual(0, self.compile_songbook(songbook, "tex")) self.assertEqual(0, self.compile_songbook(songbook, "tex"))
@ -100,7 +100,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
def test_compilation(self): def test_compilation(self):
"""Test that `base` is rendered to pdf.""" """Test that `base` is rendered to pdf."""
# Check compilation # Check compilation
songbook = "{}.sb".format(base) songbook = "{}.yaml".format(base)
self.assertEqual(0, self.compile_songbook(songbook)) self.assertEqual(0, self.compile_songbook(songbook))
test_compilation.__doc__ = ( test_compilation.__doc__ = (

0
test/test_songbook/unicode.sb → test/test_songbook/unicode.yaml

Loading…
Cancel
Save