diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..913363b9 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,50 @@ +environment: + matrix: + - PYTHON: "C:\\Python34" + PYTHON_VERSION: "3.4.x" # currently 3.4.3 + PYTHON_ARCH: "32" + +install: + # Download setup scripts and unzip + - ps: "wget https://github.com/cloudify-cosmo/appveyor-utils/archive/master.zip -OutFile ./master.zip" + - "7z e master.zip */appveyor/* -oappveyor" + + # Install Python (from the official .msi of http://python.org) and pip when + # not already installed. + - "powershell ./appveyor/install.ps1" + + # Prepend newly installed Python to the PATH of this build (this cannot be + # done from inside the powershell script as it would require to restart + # the parent CMD process). + - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + + # Check that we have the expected version and architecture for Python + - "python --version" + - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" + + # Download miktex portable (if not cached) + - ps: "If (!(Test-Path miktex-portable.exe)){wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe}" + + # Unzip miktex portable + - "7z x miktex-portable.exe * -aot -omiktex > nul" + + # Let the binaries be directly callable + - cmd: set PATH=%PATH%;C:\projects\patacrep\miktex\miktex\bin + + # Update fonts + - cmd: luaotfload-tool.exe --update + + # Manually install required texlive packages + - cmd: mpm.exe --install-some texlive_packages.txt + +build: false # Not a C# project, build stuff at the test step instead. + +before_test: + - "pip install tox" + +test_script: + - "tox" + +# Cache Miktex Portable file +cache: +- C:\projects\patacrep\miktex-portable.exe \ No newline at end of file diff --git a/README.rst b/README.rst index 97e5d54a..da4c1660 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,9 @@ Patacrep, a songbook compilation chain ====================================== -|sources| |build| |pypi| |documentation| |license| +|sources| |pypi| |documentation| |license| + +|build-travis| |build-appveyor| This package provides a compilation toolchain that produce LaTeX songbook using the LaTeX songs package. A new LaTeX document class is @@ -22,10 +24,14 @@ Installation Using pip ^^^^^^^^^ -As simple as:: +For the stable version, as simple as:: pip3 install patacrep +Or for the latest version:: + + pip3 install https://github.com/patacrep/patacrep/archive/master.zip + For developement ^^^^^^^^^^^^^^^^ @@ -34,7 +40,7 @@ Clone Patacrep repos:: git clone git://github.com/patacrep/patacrep.git cd patacrep pip3 install -r Requirements.txt - python3 setup.py install + python3 setup.py develop Quick and dirty Debian (and Ubuntu?) package ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,8 +60,8 @@ Run Look for existing songbook files in `patadata `_. -More informations ------------------ +Documentation +------------- The full documentation is hosted by readthedoc, here : http://patacrep.readthedocs.org/. @@ -72,5 +78,7 @@ Contact & Forums :target: http://www.gnu.org/licenses/gpl-2.0.html .. |sources| image:: https://img.shields.io/badge/sources-patacrep-brightgreen.svg :target: http://github.com/patacrep/patacrep -.. |build| image:: https://travis-ci.org/patacrep/patacrep.svg?branch=master - :target: https://travis-ci.org/patacrep/patacrep +.. |build-travis| image:: https://img.shields.io/travis-ci/patacrep/patacrep/master.svg?label=GNU/Linux + :target: https://travis-ci.org/patacrep/patacrep/branches +.. |build-appveyor| image:: https://img.shields.io/appveyor/ci/oliverpool/patacrep/master.svg?label=Windows + :target: https://ci.appveyor.com/project/oliverpool/patacrep/branch/master diff --git a/patacrep/__init__.py b/patacrep/__init__.py index e63b5123..60e4cd6a 100644 --- a/patacrep/__init__.py +++ b/patacrep/__init__.py @@ -17,3 +17,6 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__]) # etc.) __DATADIR__ = os.path.abspath(resource_filename(__name__, 'data')) +def pkg_datapath(*path): + """Return the package data path""" + return os.path.join(__DATADIR__, *path) diff --git a/patacrep/build.py b/patacrep/build.py index 00be667e..a720b9b1 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -6,7 +6,7 @@ import glob import logging import threading import os.path -from subprocess import Popen, PIPE, call +from subprocess import Popen, PIPE, call, check_call from patacrep import __DATADIR__, authors, content, errors, files from patacrep.index import process_sxd @@ -168,10 +168,6 @@ class SongbookBuilder(object): self._lualatex_options.append("--shell-escape") if not self.interactive: self._lualatex_options.append("-halt-on-error") - for datadir in self.songbook.config["datadir"]: - self._lualatex_options.append( - '--include-directory="{}"'.format(datadir) - ) def build_steps(self, steps=None): """Perform steps on the songbook by calling relevant self.build_*() @@ -217,13 +213,27 @@ class SongbookBuilder(object): LOGGER.info("Building '{}.pdf'…".format(self.basename)) self._run_once(self._set_latex) + compiler = "lualatex" + + # Test if the LaTeX compiler is accessible + try: + check_call( + [compiler, "--version"], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True, + ) + except Exception as error: + raise errors.ExecutableNotFound(compiler) + + # Perform compilation try: process = Popen( - ["lualatex"] + self._lualatex_options + [self.basename], + [compiler] + self._lualatex_options + [self.basename], stdin=PIPE, stdout=PIPE, stderr=PIPE, - env=os.environ, universal_newlines=True, ) except Exception as error: diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 71473aa8..4f9ab809 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -42,7 +42,7 @@ class SongRenderer(Content): {song} """).format( separator="%"*80, - path=self.song.subpath, + path=files.path2posix(self.song.subpath), song=self.song.render(output=context['filename']), ) diff --git a/patacrep/songs/chordpro/data/chordpro/content_chord b/patacrep/data/ast_templates/chordpro/chordpro/content_chord similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_chord rename to patacrep/data/ast_templates/chordpro/chordpro/content_chord diff --git a/patacrep/songs/chordpro/data/chordpro/content_chordlist b/patacrep/data/ast_templates/chordpro/chordpro/content_chordlist similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_chordlist rename to patacrep/data/ast_templates/chordpro/chordpro/content_chordlist diff --git a/patacrep/songs/chordpro/data/chordpro/content_comment b/patacrep/data/ast_templates/chordpro/chordpro/content_comment similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_comment rename to patacrep/data/ast_templates/chordpro/chordpro/content_comment diff --git a/patacrep/songs/chordpro/data/chordpro/content_define b/patacrep/data/ast_templates/chordpro/chordpro/content_define similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_define rename to patacrep/data/ast_templates/chordpro/chordpro/content_define diff --git a/patacrep/songs/chordpro/data/chordpro/content_endofline b/patacrep/data/ast_templates/chordpro/chordpro/content_endofline similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_endofline rename to patacrep/data/ast_templates/chordpro/chordpro/content_endofline diff --git a/patacrep/songs/chordpro/data/chordpro/content_error b/patacrep/data/ast_templates/chordpro/chordpro/content_error similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_error rename to patacrep/data/ast_templates/chordpro/chordpro/content_error diff --git a/patacrep/songs/chordpro/data/chordpro/content_guitar_comment b/patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_guitar_comment rename to patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment diff --git a/patacrep/songs/chordpro/data/chordpro/content_image b/patacrep/data/ast_templates/chordpro/chordpro/content_image similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_image rename to patacrep/data/ast_templates/chordpro/chordpro/content_image diff --git a/patacrep/songs/chordpro/data/chordpro/content_line b/patacrep/data/ast_templates/chordpro/chordpro/content_line similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_line rename to patacrep/data/ast_templates/chordpro/chordpro/content_line diff --git a/patacrep/songs/chordpro/data/chordpro/content_newline b/patacrep/data/ast_templates/chordpro/chordpro/content_newline similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_newline rename to patacrep/data/ast_templates/chordpro/chordpro/content_newline diff --git a/patacrep/songs/chordpro/data/chordpro/content_partition b/patacrep/data/ast_templates/chordpro/chordpro/content_partition similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_partition rename to patacrep/data/ast_templates/chordpro/chordpro/content_partition diff --git a/patacrep/songs/chordpro/data/chordpro/content_space b/patacrep/data/ast_templates/chordpro/chordpro/content_space similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_space rename to patacrep/data/ast_templates/chordpro/chordpro/content_space diff --git a/patacrep/songs/chordpro/data/chordpro/content_tablature b/patacrep/data/ast_templates/chordpro/chordpro/content_tablature similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_tablature rename to patacrep/data/ast_templates/chordpro/chordpro/content_tablature diff --git a/patacrep/songs/chordpro/data/chordpro/content_verse b/patacrep/data/ast_templates/chordpro/chordpro/content_verse similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_verse rename to patacrep/data/ast_templates/chordpro/chordpro/content_verse diff --git a/patacrep/songs/chordpro/data/chordpro/content_word b/patacrep/data/ast_templates/chordpro/chordpro/content_word similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/content_word rename to patacrep/data/ast_templates/chordpro/chordpro/content_word diff --git a/patacrep/songs/chordpro/data/chordpro/song b/patacrep/data/ast_templates/chordpro/chordpro/song similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/song rename to patacrep/data/ast_templates/chordpro/chordpro/song diff --git a/patacrep/songs/chordpro/data/chordpro/song_body b/patacrep/data/ast_templates/chordpro/chordpro/song_body similarity index 100% rename from patacrep/songs/chordpro/data/chordpro/song_body rename to patacrep/data/ast_templates/chordpro/chordpro/song_body diff --git a/patacrep/songs/chordpro/data/chordpro/song_header b/patacrep/data/ast_templates/chordpro/chordpro/song_header similarity index 81% rename from patacrep/songs/chordpro/data/chordpro/song_header rename to patacrep/data/ast_templates/chordpro/chordpro/song_header index cefca9de..56ad6a3a 100644 --- a/patacrep/songs/chordpro/data/chordpro/song_header +++ b/patacrep/data/ast_templates/chordpro/chordpro/song_header @@ -14,16 +14,20 @@ (*- for author in authors -*) {artist: (( author[1] )) (( author[0] ))} -(* endfor *) +(* endfor -*) -(*- for key in ['album', 'copyright', 'tag'] *) +(*- for key in ['album', 'copyright'] *) (* if key in metadata -*) {(( key )): (( metadata[key] ))} (* endif *) (* endfor *) (* if 'cover' in metadata -*) {(( 'cover' )): (( metadata['cover'].argument|search_image ))} -(* endif *) +(* endif -*) + +(* for tag in metadata.get("tag", [])|sortargs -*) + {tag: (( tag.argument ))} +(* endfor -*) (*- for key in metadata.morekeys -*) {key: (( key.keyword )): (( key.argument ))} diff --git a/patacrep/songs/chordpro/data/html/content_chord b/patacrep/data/ast_templates/chordpro/html/content_chord similarity index 100% rename from patacrep/songs/chordpro/data/html/content_chord rename to patacrep/data/ast_templates/chordpro/html/content_chord diff --git a/patacrep/songs/chordpro/data/html/content_chordlist b/patacrep/data/ast_templates/chordpro/html/content_chordlist similarity index 100% rename from patacrep/songs/chordpro/data/html/content_chordlist rename to patacrep/data/ast_templates/chordpro/html/content_chordlist diff --git a/patacrep/songs/chordpro/data/html/content_comment b/patacrep/data/ast_templates/chordpro/html/content_comment similarity index 100% rename from patacrep/songs/chordpro/data/html/content_comment rename to patacrep/data/ast_templates/chordpro/html/content_comment diff --git a/patacrep/songs/chordpro/data/html/content_define b/patacrep/data/ast_templates/chordpro/html/content_define similarity index 100% rename from patacrep/songs/chordpro/data/html/content_define rename to patacrep/data/ast_templates/chordpro/html/content_define diff --git a/patacrep/songs/chordpro/data/html/content_define_list b/patacrep/data/ast_templates/chordpro/html/content_define_list similarity index 100% rename from patacrep/songs/chordpro/data/html/content_define_list rename to patacrep/data/ast_templates/chordpro/html/content_define_list diff --git a/patacrep/songs/chordpro/data/html/content_endofline b/patacrep/data/ast_templates/chordpro/html/content_endofline similarity index 100% rename from patacrep/songs/chordpro/data/html/content_endofline rename to patacrep/data/ast_templates/chordpro/html/content_endofline diff --git a/patacrep/songs/chordpro/data/html/content_error b/patacrep/data/ast_templates/chordpro/html/content_error similarity index 100% rename from patacrep/songs/chordpro/data/html/content_error rename to patacrep/data/ast_templates/chordpro/html/content_error diff --git a/patacrep/songs/chordpro/data/html/content_guitar_comment b/patacrep/data/ast_templates/chordpro/html/content_guitar_comment similarity index 100% rename from patacrep/songs/chordpro/data/html/content_guitar_comment rename to patacrep/data/ast_templates/chordpro/html/content_guitar_comment diff --git a/patacrep/songs/chordpro/data/html/content_image b/patacrep/data/ast_templates/chordpro/html/content_image similarity index 100% rename from patacrep/songs/chordpro/data/html/content_image rename to patacrep/data/ast_templates/chordpro/html/content_image diff --git a/patacrep/songs/chordpro/data/html/content_line b/patacrep/data/ast_templates/chordpro/html/content_line similarity index 100% rename from patacrep/songs/chordpro/data/html/content_line rename to patacrep/data/ast_templates/chordpro/html/content_line diff --git a/patacrep/songs/chordpro/data/html/content_metadata_cover b/patacrep/data/ast_templates/chordpro/html/content_metadata_cover similarity index 100% rename from patacrep/songs/chordpro/data/html/content_metadata_cover rename to patacrep/data/ast_templates/chordpro/html/content_metadata_cover diff --git a/patacrep/songs/chordpro/data/html/content_newline b/patacrep/data/ast_templates/chordpro/html/content_newline similarity index 100% rename from patacrep/songs/chordpro/data/html/content_newline rename to patacrep/data/ast_templates/chordpro/html/content_newline diff --git a/patacrep/songs/chordpro/data/html/content_partition b/patacrep/data/ast_templates/chordpro/html/content_partition similarity index 100% rename from patacrep/songs/chordpro/data/html/content_partition rename to patacrep/data/ast_templates/chordpro/html/content_partition diff --git a/patacrep/songs/chordpro/data/html/content_space b/patacrep/data/ast_templates/chordpro/html/content_space similarity index 100% rename from patacrep/songs/chordpro/data/html/content_space rename to patacrep/data/ast_templates/chordpro/html/content_space diff --git a/patacrep/songs/chordpro/data/html/content_tablature b/patacrep/data/ast_templates/chordpro/html/content_tablature similarity index 100% rename from patacrep/songs/chordpro/data/html/content_tablature rename to patacrep/data/ast_templates/chordpro/html/content_tablature diff --git a/patacrep/songs/chordpro/data/html/content_verse b/patacrep/data/ast_templates/chordpro/html/content_verse similarity index 100% rename from patacrep/songs/chordpro/data/html/content_verse rename to patacrep/data/ast_templates/chordpro/html/content_verse diff --git a/patacrep/songs/chordpro/data/html/content_word b/patacrep/data/ast_templates/chordpro/html/content_word similarity index 100% rename from patacrep/songs/chordpro/data/html/content_word rename to patacrep/data/ast_templates/chordpro/html/content_word diff --git a/patacrep/songs/chordpro/data/html/song b/patacrep/data/ast_templates/chordpro/html/song similarity index 100% rename from patacrep/songs/chordpro/data/html/song rename to patacrep/data/ast_templates/chordpro/html/song diff --git a/patacrep/songs/chordpro/data/html/song_body b/patacrep/data/ast_templates/chordpro/html/song_body similarity index 100% rename from patacrep/songs/chordpro/data/html/song_body rename to patacrep/data/ast_templates/chordpro/html/song_body diff --git a/patacrep/songs/chordpro/data/html/song_header b/patacrep/data/ast_templates/chordpro/html/song_header similarity index 100% rename from patacrep/songs/chordpro/data/html/song_header rename to patacrep/data/ast_templates/chordpro/html/song_header diff --git a/patacrep/songs/chordpro/data/latex/content_chord b/patacrep/data/ast_templates/chordpro/latex/content_chord similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_chord rename to patacrep/data/ast_templates/chordpro/latex/content_chord diff --git a/patacrep/songs/chordpro/data/latex/content_chordlist b/patacrep/data/ast_templates/chordpro/latex/content_chordlist similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_chordlist rename to patacrep/data/ast_templates/chordpro/latex/content_chordlist diff --git a/patacrep/songs/chordpro/data/latex/content_comment b/patacrep/data/ast_templates/chordpro/latex/content_comment similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_comment rename to patacrep/data/ast_templates/chordpro/latex/content_comment diff --git a/patacrep/songs/chordpro/data/latex/content_define b/patacrep/data/ast_templates/chordpro/latex/content_define similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_define rename to patacrep/data/ast_templates/chordpro/latex/content_define diff --git a/patacrep/songs/chordpro/data/latex/content_endofline b/patacrep/data/ast_templates/chordpro/latex/content_endofline similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_endofline rename to patacrep/data/ast_templates/chordpro/latex/content_endofline diff --git a/patacrep/songs/chordpro/data/latex/content_error b/patacrep/data/ast_templates/chordpro/latex/content_error similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_error rename to patacrep/data/ast_templates/chordpro/latex/content_error diff --git a/patacrep/songs/chordpro/data/latex/content_guitar_comment b/patacrep/data/ast_templates/chordpro/latex/content_guitar_comment similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_guitar_comment rename to patacrep/data/ast_templates/chordpro/latex/content_guitar_comment diff --git a/patacrep/songs/chordpro/data/latex/content_image b/patacrep/data/ast_templates/chordpro/latex/content_image similarity index 58% rename from patacrep/songs/chordpro/data/latex/content_image rename to patacrep/data/ast_templates/chordpro/latex/content_image index ac97404b..a567730d 100644 --- a/patacrep/songs/chordpro/data/latex/content_image +++ b/patacrep/data/ast_templates/chordpro/latex/content_image @@ -1,5 +1,5 @@ (* block image *) -(* set image = content.argument|search_image *) +(* set image = content.argument|search_image|path2posix *) (* if image *) \image{(( image ))} (*- endif *) diff --git a/patacrep/songs/chordpro/data/latex/content_line b/patacrep/data/ast_templates/chordpro/latex/content_line similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_line rename to patacrep/data/ast_templates/chordpro/latex/content_line diff --git a/patacrep/songs/chordpro/data/latex/content_newline b/patacrep/data/ast_templates/chordpro/latex/content_newline similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_newline rename to patacrep/data/ast_templates/chordpro/latex/content_newline diff --git a/patacrep/data/ast_templates/chordpro/latex/content_partition b/patacrep/data/ast_templates/chordpro/latex/content_partition new file mode 100644 index 00000000..6942492a --- /dev/null +++ b/patacrep/data/ast_templates/chordpro/latex/content_partition @@ -0,0 +1,6 @@ +(* block partition *) +(* set partition = content.argument|search_partition|path2posix *) +(* if partition *) +\lilypond{ ((- partition -)) } +(*- endif -*) +(*- endblock -*) diff --git a/patacrep/songs/chordpro/data/latex/content_space b/patacrep/data/ast_templates/chordpro/latex/content_space similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_space rename to patacrep/data/ast_templates/chordpro/latex/content_space diff --git a/patacrep/songs/chordpro/data/latex/content_tablature b/patacrep/data/ast_templates/chordpro/latex/content_tablature similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_tablature rename to patacrep/data/ast_templates/chordpro/latex/content_tablature diff --git a/patacrep/songs/chordpro/data/latex/content_verse b/patacrep/data/ast_templates/chordpro/latex/content_verse similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_verse rename to patacrep/data/ast_templates/chordpro/latex/content_verse diff --git a/patacrep/songs/chordpro/data/latex/content_word b/patacrep/data/ast_templates/chordpro/latex/content_word similarity index 100% rename from patacrep/songs/chordpro/data/latex/content_word rename to patacrep/data/ast_templates/chordpro/latex/content_word diff --git a/patacrep/songs/chordpro/data/latex/song b/patacrep/data/ast_templates/chordpro/latex/song similarity index 89% rename from patacrep/songs/chordpro/data/latex/song rename to patacrep/data/ast_templates/chordpro/latex/song index 1e2ceaf8..e8016107 100644 --- a/patacrep/songs/chordpro/data/latex/song +++ b/patacrep/data/ast_templates/chordpro/latex/song @@ -22,14 +22,14 @@ (* endif *) (* endfor *) }, - (* for key in ['album', 'copyright', 'tag'] *) + (* for key in ['album', 'copyright'] *) (* if key in metadata *) (( key ))={(( metadata[key] ))}, (* endif *) (* endfor *) (* if 'cover' in metadata *) (* block cover *) - (* set cover = metadata["cover"].argument|search_image *) + (* set cover = metadata["cover"].argument|search_image|path2posix *) (* if cover *) cover={(( cover ))}, (* endif *) diff --git a/patacrep/songs/chordpro/data/latex/song_body b/patacrep/data/ast_templates/chordpro/latex/song_body similarity index 100% rename from patacrep/songs/chordpro/data/latex/song_body rename to patacrep/data/ast_templates/chordpro/latex/song_body diff --git a/patacrep/errors.py b/patacrep/errors.py index 5ec9fd9b..d1d3a74f 100644 --- a/patacrep/errors.py +++ b/patacrep/errors.py @@ -31,6 +31,16 @@ class TemplateError(SongbookError): else: return self.message +class ExecutableNotFound(SongbookError): + """Couldn't find a LaTeX executable.""" + + def __init__(self, executable): + super(ExecutableNotFound, self).__init__( + ( + """Could not find the following executable: {executable}""" + ).format(executable=executable) + ) + class StepError(SongbookError): """Error during execution of one compilation step.""" @@ -47,7 +57,7 @@ class LatexCompilationError(StepError): def __init__(self, basename): super(LatexCompilationError, self).__init__( ( - """Error while pdfLaTeX compilation of "{basename}.tex" """ + """Error while LaTeX compilation of "{basename}.tex" """ """(see {basename}.log for more information).""" ).format(basename=basename) ) diff --git a/patacrep/songbook/__init__.py b/patacrep/songbook/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 5095c4da..513977f6 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -3,17 +3,22 @@ from jinja2 import Environment, FileSystemLoader, contextfunction, ChoiceLoader import jinja2 import logging +import operator import os -from pkg_resources import resource_filename -from patacrep import encoding, files +from patacrep import encoding, files, pkg_datapath from patacrep.songs import Song from patacrep.songs.chordpro.syntax import parse_song from patacrep.templates import Renderer from patacrep.latex import lang2babel +from patacrep.files import path2posix LOGGER = logging.getLogger(__name__) +def sort_directive_argument(directives): + """Sort directives by their argument.""" + return sorted(directives, key=operator.attrgetter("argument")) + class ChordproSong(Song): """Chordpro song parser""" # pylint: disable=abstract-method @@ -48,12 +53,14 @@ class ChordproSong(Song): self.get_datadirs(os.path.join("templates", self.output_language)) ), FileSystemLoader( - os.path.join(resource_filename(__name__, 'data'), self.output_language) + pkg_datapath('ast_templates', 'chordpro', self.output_language) ), ])) jinjaenv.filters['search_image'] = self.search_image jinjaenv.filters['search_partition'] = self.search_partition jinjaenv.filters['lang2babel'] = lang2babel + jinjaenv.filters['sortargs'] = sort_directive_argument + jinjaenv.filters['path2posix'] = path2posix try: return Renderer( diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 0bfc4013..17afc0c9 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -215,6 +215,7 @@ class Song(AST): "artist": "add_author", "key": "add_key", "define": "add_cumulative", + "tag": "add_cumulative", } def __init__(self, filename): diff --git a/patacrep/songs/chordpro/data/latex/content_partition b/patacrep/songs/chordpro/data/latex/content_partition deleted file mode 100644 index a3c35a3e..00000000 --- a/patacrep/songs/chordpro/data/latex/content_partition +++ /dev/null @@ -1,6 +0,0 @@ -(* block partition *) -(* set partition = content.argument|search_partition *) -(* if partition *) -\lilypond{ ((- content.argument|search_partition -)) } -(*- endif -*) -(*- endblock -*) diff --git a/setup.py b/setup.py index 4cfaeda0..023201eb 100755 --- a/setup.py +++ b/setup.py @@ -21,7 +21,12 @@ setup( "unidecode", "jinja2", "chardet", "ply", ], setup_requires=["hgtools"], - include_package_data=True, + package_data={'patacrep': [ + 'data/ast_templates/*/*/*', + 'data/img/*', + 'data/latex/*', + 'data/templates/*', + ]}, entry_points={ 'console_scripts': [ "songbook = patacrep.songbook.__main__:main", diff --git a/test/test_chordpro/tags.sgc b/test/test_chordpro/tags.sgc new file mode 100644 index 00000000..555948c9 --- /dev/null +++ b/test/test_chordpro/tags.sgc @@ -0,0 +1,5 @@ +{lang: en} +{title: Tag test} +{tag: a third tag} +{tag: another} +{tag: one tag} diff --git a/test/test_chordpro/tags.source b/test/test_chordpro/tags.source new file mode 100644 index 00000000..5408dae0 --- /dev/null +++ b/test/test_chordpro/tags.source @@ -0,0 +1,4 @@ +{title: Tag test} +{tag: one tag} +{tag: another} +{tag: a third tag} diff --git a/test/test_chordpro/tags.tex b/test/test_chordpro/tags.tex new file mode 100644 index 00000000..e27a462a --- /dev/null +++ b/test/test_chordpro/tags.tex @@ -0,0 +1,10 @@ +\selectlanguage{english} + +\beginsong{Tag test}[ + by={ + }, +] + + + +\endsong diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 5b76e3e7..65d237c7 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -5,10 +5,12 @@ import glob import logging import os +import sys import subprocess import unittest from patacrep.encoding import open_read +from patacrep.files import path2posix from .. import dynamic # pylint: disable=unused-import @@ -67,16 +69,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): expected = expectfile.read().strip() expected = expected.replace( "@TEST_FOLDER@", - os.path.dirname(__file__), + path2posix(os.path.dirname(__file__)), ) expected = expected.replace( "@DATA_FOLDER@", - subprocess.check_output( - ["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long - universal_newlines=True, - cwd=os.path.dirname(songbook), - ).strip(), + path2posix( + subprocess.check_output( + [sys.executable, "-c", 'import patacrep; print(patacrep.__DATADIR__)'], # pylint: disable=line-too-long + universal_newlines=True, + cwd=os.path.dirname(songbook), + ).strip() + ), ) self.assertMultiLineEqual( @@ -108,12 +112,16 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @staticmethod def compile_songbook(songbook, steps=None): """Compile songbook, and return the command return code.""" - command = ['python', '-m', 'patacrep.songbook', '--cache=no', songbook, '-v'] + command = [sys.executable, '-m', 'patacrep.songbook', '--cache=no', songbook, '-v'] if steps: command.extend(['--steps', steps]) + # Continuous Integration will be verbose + if 'CI' in os.environ: + command.append('-v') + try: - subprocess.check_output( + subprocess.check_call( command, stderr=subprocess.STDOUT, universal_newlines=True, diff --git a/texlive_packages.txt b/texlive_packages.txt new file mode 100644 index 00000000..9320ca2e --- /dev/null +++ b/texlive_packages.txt @@ -0,0 +1,18 @@ +babel-english +babel-esperanto +babel-french +babel-german +babel-latin +babel-spanish +fancybox +framed +import +l3kernel +l3packages +mptopdf +ms +pgf +tipa +url +xcolor +xstring \ No newline at end of file diff --git a/tox.ini b/tox.ini index 1b6a3337..10fb9b9b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = py34, lint [testenv] commands = {envpython} setup.py test -passenv = TRAVIS +passenv = TRAVIS APPVEYOR CI deps = [testenv:lint]