diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index fe4c1ab7..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include LICENSE NEWS readme.md Requirements.txt -recursive-include patacrep/data * diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..7af8b663 --- /dev/null +++ b/README.rst @@ -0,0 +1,63 @@ +Patacrep, a songbook compilation chain +====================================== + +This package provides a compilation toolchain that produce LaTeX +songbook using the LaTeX songs package. A new LaTeX document class is +provided to allow specific customisation and new command like embedded +guitar tabs or lilypond sheets. + +Document are subject to the GNU GPLv2 except if another licence +is precised in the header. + +Python version +-------------- + +Patacrep is only compatible with Python > 3.3. + +Installation +------------ + +Using pip +^^^^^^^^^ + +As simple as:: + + pip3 install patacrep + +For developement +^^^^^^^^^^^^^^^^ + +Clone Patacrep repos:: + + git clone git://github.com/patacrep/patacrep.git + cd patacrep + pip3 install -r Requirements.txt + python3 setup.py install + +Quick and dirty Debian (and Ubuntu?) package +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This requires `stdeb `_ to be installed:: + + python setup.py --command-packages=stdeb.command bdist_deb + sudo dpkg -i deb_dist/python3-patacrep_4.0.0-1_all.deb + +Run +--- + +:: + + songbook + + +Look for existing songbook files in `patadata `_. + +More informations +----------------- + +The full documentation is hosted by readthedoc, here : http://patacrep.readthedocs.org/. + +Contact & Forums +---------------- + +* http://www.patacrep.com/forum diff --git a/patacrep/build.py b/patacrep/build.py index 31d54eeb..a575f9a4 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -219,8 +219,9 @@ class SongbookBuilder(object): stdin=PIPE, stdout=PIPE, stderr=PIPE, + env=os.environ, universal_newlines=True, - env=os.environ) + ) except Exception as error: LOGGER.debug(error) raise errors.LatexCompilationError(self.basename) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index a0cdb6b0..def0e643 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -57,7 +57,6 @@ def parse(keyword, argument, contentlist, config): if contentlist: break contentlist = files.recursive_find(songdir.fullpath, plugins.keys()) - for elem in contentlist: before = len(songlist) for songdir in config['_songdir']: @@ -65,16 +64,16 @@ def parse(keyword, argument, contentlist, config): continue with files.chdir(songdir.datadir): for filename in glob.iglob(os.path.join(songdir.subpath, elem)): - LOGGER.debug('Parsing file "{}"…'.format(filename)) extension = filename.split(".")[-1] if extension not in plugins: - LOGGER.warning(( - 'I do not know how to parse "{}". Ignored.' + LOGGER.warning( + 'File "{}" does not end with one of {}. Ignored.' ).format( os.path.join(songdir.datadir, filename), + ", ".join(["'.{}'".format(key) for key in plugins.keys()]), ) - ) continue + LOGGER.debug('Parsing file "{}"…'.format(filename)) renderer = SongRenderer(plugins[extension]( songdir.datadir, filename, diff --git a/patacrep/files.py b/patacrep/files.py index 86208746..a68146bf 100644 --- a/patacrep/files.py +++ b/patacrep/files.py @@ -1,6 +1,7 @@ """File system utilities.""" from contextlib import contextmanager +import fnmatch import importlib import logging import os @@ -10,13 +11,9 @@ import re LOGGER = logging.getLogger(__name__) def recursive_find(root_directory, extensions): - """Recursively find files with some extension, from a root_directory. + """Recursively find files with the given extensions, from a root_directory. - Return a list of files matching those conditions. - - Arguments: - - `extensions`: list of accepted extensions. - - `root_directory`: root directory of the search. + Return a list of files ending with one of the given extensions. """ if not os.path.isdir(root_directory): return [] diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index 747b6112..3bddb86e 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -96,10 +96,17 @@ class Song(Content): "_version", ] + # Default data + DEFAULT_DATA = { + '@titles': [], + '@languages': [], + } + def __init__(self, datadir, subpath, config): self.fullpath = os.path.join(datadir, subpath) self.datadir = datadir self.encoding = config["encoding"] + self.config = config if datadir: # Only songs in datadirs are cached diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index cd3f0d3b..5574c3dc 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -23,12 +23,10 @@ class ChordproSong(Song): self.cached = { 'song': song, } - #: Main language - self.language = song.get_directive('language', config['lang']) def tex(self, output): context = { - 'language': self.language, + 'language': self.cached['song'].get_directive('language', self.config['lang']), 'columns': self.cached['song'].get_directive('columns', 1), "path": files.relpath(self.fullpath, os.path.dirname(output)), "titles": r"\\".join(self.titles), diff --git a/readme.md b/readme.md deleted file mode 100644 index d293c596..00000000 --- a/readme.md +++ /dev/null @@ -1,61 +0,0 @@ -# Patacrep, a songbook compilation chain - -This package provides a compilation toolchain that produce LaTeX -songbook using the LaTeX songs package. A new LaTeX document class is -provided to allow specific customisation and new command like embedded -guitar tabs or lilypond sheets. - -Document are subject to the GNU GPLv2 except if another licence -is precised in the header. - -# Python version - -Patacrep is only compatible with Python > 3.3. - -# Installation - -## Using pip - -As simple as - -``` -pip3 install patacrep -``` - -## For developement - -Clone Patacrep repos: - -``` -git clone git://github.com/patacrep/patacrep.git -cd patacrep -pip3 install -r Requirements.txt -python3 setup.py install -``` - -## Quick and dirty Debian (and Ubuntu?) package - -This requires [stdeb](https://github.com/astraw/stdeb) to be installed. - -``` -python setup.py --command-packages=stdeb.command bdist_deb -sudo dpkg -i deb_dist/python3-patacrep_4.0.0-1_all.deb -``` - - -# Run - -``` -songbook - -``` - -Look for existing songbook files in [patadata](http://github.com/patacrep/patadata) - -# More informations - -The full documentation is hosted by readthedoc, here : http://patacrep.readthedocs.org/ - -# Contact & Forums - -* http://www.patacrep.com/forum diff --git a/setup.py b/setup.py index 8752fe73..5a315fbd 100755 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ setup( install_requires=[ "unidecode", "jinja2", "chardet", "ply", ], + setup_requires=["hgtools"], include_package_data=True, entry_points={ 'console_scripts': [ @@ -39,4 +40,5 @@ setup( ], platforms=["GNU/Linux", "Windows", "MacOsX"], test_suite="patacrep.test.suite", + long_description = open("README.rst", "r").read(), )