mirror of https://github.com/patacrep/patacrep.git
Browse Source
Conflicts: patacrep/build.py patacrep/content/__init__.py patacrep/content/song.py patacrep/files.py patacrep/latex/__init__.py patacrep/latex/syntax.py patacrep/songs/__init__.pypull/70/head
Louis
10 years ago
29 changed files with 569 additions and 483 deletions
@ -0,0 +1,2 @@ |
|||
include LICENSE NEWS readme.md Requirements.txt |
|||
recursive-include patacrep/data * |
@ -1,68 +0,0 @@ |
|||
songbook 3.7.2 |
|||
|
|||
(Louis) Undocumented bug corrections and improvements. |
|||
|
|||
songbook 3.4.7 to 3.7.1 |
|||
|
|||
Mainly new songs in the data (which was included in songbook at this |
|||
time), and a few undocumented bug corrections and improvements. |
|||
|
|||
songbook (v0.8) |
|||
|
|||
Undocumented. |
|||
|
|||
songbook (v0.7) |
|||
|
|||
(lohrun) New songbook format (not compatible with older version). |
|||
Changes have been made to the compilation toolchain that prevent |
|||
compilation of old format songbook. |
|||
(lohrun) Use LaTeX Songs package v2.10. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sat, 17 Jul 2010 15:24:14 +0200 |
|||
|
|||
songbook (v0.6) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(lohrun) Use plain songs package v2.9 |
|||
(lohrun) Replace makeindex script with a new python version |
|||
(lohrun) Add script to produce the list of chords used in songs |
|||
(crep, lohrun) Correct chords and gtabs used in songs |
|||
(lohrun) Modification of the default geometry |
|||
(lohrun) Remove capos from the lyricbook |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Fri, 11 Dec 2009 15:35:03 +0100 |
|||
|
|||
songbook (0.5) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(lohrun) Add a proper volume mechanism |
|||
(lohrun) Add volume-1 source containing about 165 songs |
|||
(crep) Add naheulbeuk special edition |
|||
(lohrun) Upgraded songs.sty with bits from songs package v2.9 |
|||
(lohrun) Add tabs option |
|||
(crep,lohrun) Add lilypond option |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Tue, 18 Aug 2009 23:38:12 +0200 |
|||
|
|||
songbook (0.4) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(crep, lohrun) Add cover picture to each song |
|||
(lohrun) Update to the Songs Package v2.8 |
|||
(lohrun) Update makefile to be POSIX compilant |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sun, 31 May 2009 01:39:16 +0200 |
|||
|
|||
songbook (0.3) |
|||
|
|||
(crep) Corrections of a lot of mistakes. |
|||
(crep) Include image support. |
|||
(lohrun) Add make-html utility. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sun, 15 Feb 2009 18:34:59 +0100 |
|||
|
|||
songbook (0.2) |
|||
|
|||
Initial version. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sat, 11 Oct 2008 20:00:00 +0100 |
@ -0,0 +1,113 @@ |
|||
# patacrep 4.0.0 |
|||
|
|||
* Project gestion |
|||
* Name change [#39](http://github.com/patacrep/patacrep/issues/39) |
|||
* Renew of the developement team |
|||
* Separation engine/data |
|||
* The engine is the [current poject](http://github.com/patacrep/patacrep) |
|||
* Data have their [own project](http://github.com/patacrep/patadata) |
|||
* And so does [various tools](http://github.com/patacrep/pataextra) |
|||
|
|||
* Internal changes |
|||
* Complete migration to Python |
|||
* No more Makefiles |
|||
* Creation of a `songbook` command |
|||
* patacrep uses Python3 [#65](http://github.com/patacrep/patacrep/issues/65) |
|||
* Massive code refactoring and simplification |
|||
* [PEP8](http://legacy.python.org/dev/peps/pep-0008/) conformity |
|||
* Better LaTeX Packages |
|||
* Better langages handling |
|||
* Better errors handling |
|||
* Better code documentation (in comments) |
|||
* Caching song AST, which gave an improvement of 45s for the compilation of all patadata [#51](http://github.com/patacrep/patacrep/issues/51) |
|||
* Lot of small improvements |
|||
|
|||
* Installation |
|||
* All from PyPi ! You can now use pip to install/update/remove patacrep |
|||
|
|||
* Fonctionnalities |
|||
* Change the template engine [#9](http://github.com/patacrep/patacrep/issues/9) |
|||
* Ability to add user variables [#18](http://github.com/patacrep/patacrep/issues/18) |
|||
* Change the song inclusion syntaxe [#47](http://github.com/patacrep/patacrep/issues/47) |
|||
* It is now possible to include other things than songs |
|||
* You can write a plugins to include your own type of content |
|||
* Personalisaitons of the songbook is easier with patadata templates (font, paper, colors, column, ...) [#41](http://github.com/patacrep/patacrep/issues/41) |
|||
* You can change the number of columns [#41](http://github.com/patacrep/patacrep/issues/41) |
|||
* Lilypond |
|||
* On the fly lylipond files compilation |
|||
* Adapt partition size to the paper size [#19](http://github.com/patacrep/patacrep/issues/19) |
|||
* You can choos how to sort the songs [#36](http://github.com/patacrep/patacrep/issues/36) |
|||
* Easier song repertories management [#43](http://github.com/patacrep/patacrep/issues/43) and [#45](http://github.com/patacrep/patacrep/issues/45) |
|||
* You can have more than one data folder |
|||
* Better index customisation |
|||
* Better gestion of files encoding [#62](http://github.com/patacrep/patacrep/issues/62). |
|||
|
|||
|
|||
# songbook 3.7.2 |
|||
|
|||
(Louis) Undocumented bug corrections and improvements. |
|||
|
|||
# songbook 3.4.7 to 3.7.1 |
|||
|
|||
Mainly new songs in the data (which was included in songbook at this |
|||
time), and a few undocumented bug corrections and improvements. |
|||
|
|||
# songbook (v0.8) |
|||
|
|||
Undocumented. |
|||
|
|||
# songbook (v0.7) |
|||
|
|||
(lohrun) New songbook format (not compatible with older version). |
|||
Changes have been made to the compilation toolchain that prevent |
|||
compilation of old format songbook. |
|||
(lohrun) Use LaTeX Songs package v2.10. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sat, 17 Jul 2010 15:24:14 +0200 |
|||
|
|||
# songbook (v0.6) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(lohrun) Use plain songs package v2.9 |
|||
(lohrun) Replace makeindex script with a new python version |
|||
(lohrun) Add script to produce the list of chords used in songs |
|||
(crep, lohrun) Correct chords and gtabs used in songs |
|||
(lohrun) Modification of the default geometry |
|||
(lohrun) Remove capos from the lyricbook |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Fri, 11 Dec 2009 15:35:03 +0100 |
|||
|
|||
# songbook (0.5) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(lohrun) Add a proper volume mechanism |
|||
(lohrun) Add volume-1 source containing about 165 songs |
|||
(crep) Add naheulbeuk special edition |
|||
(lohrun) Upgraded songs.sty with bits from songs package v2.9 |
|||
(lohrun) Add tabs option |
|||
(crep,lohrun) Add lilypond option |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Tue, 18 Aug 2009 23:38:12 +0200 |
|||
|
|||
# songbook (0.4) |
|||
|
|||
(crep, lohrun) Corrections of mistakes and typos. |
|||
(crep, lohrun) Add cover picture to each song |
|||
(lohrun) Update to the Songs Package v2.8 |
|||
(lohrun) Update makefile to be POSIX compilant |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sun, 31 May 2009 01:39:16 +0200 |
|||
|
|||
# songbook (0.3) |
|||
|
|||
(crep) Corrections of a lot of mistakes. |
|||
(crep) Include image support. |
|||
(lohrun) Add make-html utility. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sun, 15 Feb 2009 18:34:59 +0100 |
|||
|
|||
# songbook (0.2) |
|||
|
|||
Initial version. |
|||
|
|||
-- Alexandre Dupas <alexandre.dupas@gmail.com> Sat, 11 Oct 2008 20:00:00 +0100 |
@ -1,21 +1,29 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
"""Dealing with encoding problems.""" |
|||
|
|||
import codecs |
|||
import chardet |
|||
import logging |
|||
import contextlib |
|||
|
|||
LOGGER = logging.getLogger(__name__) |
|||
|
|||
def open_read(filename, mode='r'): |
|||
|
|||
@contextlib.contextmanager |
|||
def open_read(filename, mode='r', encoding=None): |
|||
"""Open a file for reading, guessing the right encoding. |
|||
|
|||
Return a fileobject, reading unicode strings. |
|||
If `encoding` is set, use it as the encoding (do not guess). |
|||
""" |
|||
return codecs.open( |
|||
if encoding is None: |
|||
fileencoding = chardet.detect(open(filename, 'rb').read())['encoding'] |
|||
else: |
|||
fileencoding = encoding |
|||
|
|||
with codecs.open( |
|||
filename, |
|||
mode=mode, |
|||
encoding=chardet.detect(open(filename, 'rb').read())['encoding'], |
|||
encoding=fileencoding, |
|||
errors='replace', |
|||
) |
|||
) as fileobject: |
|||
yield fileobject |
|||
|
@ -1,3 +1,8 @@ |
|||
"""Dumb and very very incomplete LaTeX parser.""" |
|||
"""Dumb and very very incomplete LaTeX parser. |
|||
|
|||
This module uses an LALR parser to try to parse LaTeX code. LaTeX language |
|||
*cannot* be parsed by an LALR parser, so this is a very simple attemps, which |
|||
will work on simple cases, but not on complex ones. |
|||
""" |
|||
|
|||
from patacrep.latex.syntax import tex2plain, parse_song |
|||
|
@ -0,0 +1,154 @@ |
|||
"""Command line tool to compile songbooks using the songbook library.""" |
|||
|
|||
import argparse |
|||
import json |
|||
import locale |
|||
import logging |
|||
import os.path |
|||
import textwrap |
|||
import sys |
|||
|
|||
from patacrep.build import SongbookBuilder, DEFAULT_STEPS |
|||
from patacrep import __version__ |
|||
from patacrep import errors |
|||
import patacrep.encoding |
|||
|
|||
# Logging configuration |
|||
logging.basicConfig(level=logging.INFO) |
|||
LOGGER = logging.getLogger() |
|||
|
|||
# pylint: disable=too-few-public-methods |
|||
class ParseStepsAction(argparse.Action): |
|||
"""Argparse action to split a string into a list.""" |
|||
def __call__(self, __parser, namespace, values, __option_string=None): |
|||
if not getattr(namespace, self.dest): |
|||
setattr(namespace, self.dest, []) |
|||
setattr( |
|||
namespace, |
|||
self.dest, |
|||
( |
|||
getattr(namespace, self.dest) |
|||
+ [value.strip() for value in values[0].split(',')] |
|||
), |
|||
) |
|||
|
|||
class VerboseAction(argparse.Action): |
|||
"""Set verbosity level with option --verbose.""" |
|||
def __call__(self, *_args, **_kwargs): |
|||
LOGGER.setLevel(logging.DEBUG) |
|||
|
|||
def argument_parser(args): |
|||
"""Parse arguments""" |
|||
parser = argparse.ArgumentParser(description="A song book compiler") |
|||
|
|||
parser.add_argument('--version', help='Show version', action='version', |
|||
version='%(prog)s ' + __version__) |
|||
|
|||
parser.add_argument('book', nargs=1, help=textwrap.dedent("""\ |
|||
Book to compile. |
|||
""")) |
|||
|
|||
parser.add_argument('--datadir', '-d', nargs='+', type=str, action='append', |
|||
help=textwrap.dedent("""\ |
|||
Data location. Expected (not necessarily required) |
|||
subdirectories are 'songs', 'img', 'latex', 'templates'. |
|||
""")) |
|||
|
|||
parser.add_argument('--verbose', '-v', nargs=0, action=VerboseAction, |
|||
help=textwrap.dedent("""\ |
|||
Show details about the compilation process. |
|||
""")) |
|||
|
|||
parser.add_argument('--steps', '-s', nargs=1, type=str, |
|||
action=ParseStepsAction, |
|||
help=textwrap.dedent("""\ |
|||
Steps to run. Default is "{steps}". |
|||
Available steps are: |
|||
"tex" produce .tex file from templates; |
|||
"pdf" compile .tex file; |
|||
"sbx" compile index files; |
|||
"clean" remove temporary files; |
|||
any string beginning with '%%' (in this case, it will be run |
|||
in a shell). Several steps (excepted the custom shell |
|||
command) can be combinend in one --steps argument, as a |
|||
comma separated string. |
|||
""".format(steps=','.join(DEFAULT_STEPS))), |
|||
default=None, |
|||
) |
|||
|
|||
options = parser.parse_args(args) |
|||
|
|||
return options |
|||
|
|||
|
|||
def main(): |
|||
"""Main function:""" |
|||
|
|||
# set script locale to match user's |
|||
try: |
|||
locale.setlocale(locale.LC_ALL, '') |
|||
except locale.Error as error: |
|||
# Locale is not installed on user's system, or wrongly configured. |
|||
LOGGER.error("Locale error: {}\n".format(str(error))) |
|||
|
|||
options = argument_parser(sys.argv[1:]) |
|||
|
|||
songbook_path = options.book[0] |
|||
|
|||
basename = os.path.basename(songbook_path)[:-3] |
|||
|
|||
try: |
|||
with patacrep.encoding.open_read(songbook_path) as songbook_file: |
|||
songbook = json.load(songbook_file) |
|||
if 'encoding' in songbook: |
|||
with patacrep.encoding.open_read( |
|||
songbook_path, |
|||
encoding=songbook['encoding'] |
|||
) as songbook_file: |
|||
songbook = json.load(songbook_file) |
|||
except Exception as error: # pylint: disable=broad-except |
|||
LOGGER.error(error) |
|||
LOGGER.error("Error while loading file '{}'.".format(songbook_path)) |
|||
sys.exit(1) |
|||
|
|||
# Gathering datadirs |
|||
datadirs = [] |
|||
if options.datadir: |
|||
# Command line options |
|||
datadirs += [item[0] for item in options.datadir] |
|||
if 'datadir' in songbook: |
|||
# .sg file |
|||
if isinstance(songbook['datadir'], str): |
|||
songbook['datadir'] = [songbook['datadir']] |
|||
datadirs += [ |
|||
os.path.join( |
|||
os.path.dirname(os.path.abspath(songbook_path)), |
|||
path |
|||
) |
|||
for path in songbook['datadir'] |
|||
] |
|||
# Default value |
|||
datadirs.append(os.path.dirname(os.path.abspath(songbook_path))) |
|||
|
|||
songbook['datadir'] = datadirs |
|||
|
|||
try: |
|||
sb_builder = SongbookBuilder(songbook, basename) |
|||
sb_builder.unsafe = True |
|||
|
|||
sb_builder.build_steps(options.steps) |
|||
except errors.SongbookError as error: |
|||
LOGGER.error(error) |
|||
if LOGGER.level >= logging.INFO: |
|||
LOGGER.error( |
|||
"Running again with option '-v' may give more information." |
|||
) |
|||
sys.exit(1) |
|||
except KeyboardInterrupt: |
|||
LOGGER.warning("Aborted by user.") |
|||
sys.exit(1) |
|||
|
|||
sys.exit(0) |
|||
|
|||
if __name__ == '__main__': |
|||
main() |
@ -1,155 +1,9 @@ |
|||
#! /usr/bin/env python3 |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
"""Command line tool to compile songbooks using the songbook library.""" |
|||
|
|||
import argparse |
|||
import json |
|||
import locale |
|||
import logging |
|||
import os.path |
|||
import textwrap |
|||
import sys |
|||
|
|||
from patacrep.build import SongbookBuilder, DEFAULT_STEPS |
|||
from patacrep import __version__ |
|||
from patacrep import errors |
|||
from patacrep import encoding |
|||
|
|||
# Logging configuration |
|||
logging.basicConfig(level=logging.INFO) |
|||
LOGGER = logging.getLogger() |
|||
|
|||
# pylint: disable=too-few-public-methods |
|||
class ParseStepsAction(argparse.Action): |
|||
"""Argparse action to split a string into a list.""" |
|||
def __call__(self, __parser, namespace, values, __option_string=None): |
|||
if not getattr(namespace, self.dest): |
|||
setattr(namespace, self.dest, []) |
|||
setattr( |
|||
namespace, |
|||
self.dest, |
|||
( |
|||
getattr(namespace, self.dest) |
|||
+ [value.strip() for value in values[0].split(',')] |
|||
), |
|||
) |
|||
|
|||
class VerboseAction(argparse.Action): |
|||
"""Set verbosity level with option --verbose.""" |
|||
def __call__(self, *_args, **_kwargs): |
|||
LOGGER.setLevel(logging.DEBUG) |
|||
|
|||
def argument_parser(args): |
|||
"""Parse arguments""" |
|||
parser = argparse.ArgumentParser(description="A song book compiler") |
|||
|
|||
parser.add_argument('--version', help='Show version', action='version', |
|||
version='%(prog)s ' + __version__) |
|||
|
|||
parser.add_argument('book', nargs=1, help=textwrap.dedent("""\ |
|||
Book to compile. |
|||
""")) |
|||
|
|||
parser.add_argument('--datadir', '-d', nargs='+', type=str, action='append', |
|||
help=textwrap.dedent("""\ |
|||
Data location. Expected (not necessarily required) |
|||
subdirectories are 'songs', 'img', 'latex', 'templates'. |
|||
""")) |
|||
|
|||
parser.add_argument('--verbose', '-v', nargs=0, action=VerboseAction, |
|||
help=textwrap.dedent("""\ |
|||
Show details about the compilation process. |
|||
""")) |
|||
|
|||
parser.add_argument('--steps', '-s', nargs=1, type=str, |
|||
action=ParseStepsAction, |
|||
help=textwrap.dedent("""\ |
|||
Steps to run. Default is "{steps}". |
|||
Available steps are: |
|||
"tex" produce .tex file from templates; |
|||
"pdf" compile .tex file; |
|||
"sbx" compile index files; |
|||
"clean" remove temporary files; |
|||
any string beginning with '%%' (in this case, it will be run |
|||
in a shell). Several steps (excepted the custom shell |
|||
command) can be combinend in one --steps argument, as a |
|||
comma separated string. |
|||
""".format(steps=','.join(DEFAULT_STEPS))), |
|||
default=None, |
|||
) |
|||
|
|||
options = parser.parse_args(args) |
|||
# Do not edit this file. This file is just a helper file for development test. |
|||
# It is not part of the distributed software. |
|||
|
|||
return options |
|||
|
|||
|
|||
def main(): |
|||
"""Main function:""" |
|||
|
|||
# set script locale to match user's |
|||
try: |
|||
locale.setlocale(locale.LC_ALL, '') |
|||
except locale.Error as error: |
|||
# Locale is not installed on user's system, or wrongly configured. |
|||
LOGGER.error("Locale error: {}\n".format(str(error))) |
|||
|
|||
options = argument_parser(sys.argv[1:]) |
|||
|
|||
songbook_path = options.book[0] |
|||
|
|||
basename = os.path.basename(songbook_path)[:-3] |
|||
|
|||
songbook_file = None |
|||
try: |
|||
songbook_file = encoding.open_read(songbook_path) |
|||
songbook = json.load(songbook_file) |
|||
except Exception as error: # pylint: disable=broad-except |
|||
LOGGER.error(error) |
|||
LOGGER.error("Error while loading file '{}'.".format(songbook_path)) |
|||
sys.exit(1) |
|||
finally: |
|||
if songbook_file: |
|||
songbook_file.close() |
|||
|
|||
# Gathering datadirs |
|||
datadirs = [] |
|||
if options.datadir: |
|||
# Command line options |
|||
datadirs += [item[0] for item in options.datadir] |
|||
if 'datadir' in songbook: |
|||
# .sg file |
|||
if isinstance(songbook['datadir'], str): |
|||
songbook['datadir'] = [songbook['datadir']] |
|||
datadirs += [ |
|||
os.path.join( |
|||
os.path.dirname(os.path.abspath(songbook_path)), |
|||
path |
|||
) |
|||
for path in songbook['datadir'] |
|||
] |
|||
# Default value |
|||
datadirs.append(os.path.dirname(os.path.abspath(songbook_path))) |
|||
|
|||
songbook['datadir'] = datadirs |
|||
|
|||
try: |
|||
sb_builder = SongbookBuilder(songbook, basename) |
|||
sb_builder.unsafe = True |
|||
|
|||
sb_builder.build_steps(options.steps) |
|||
except errors.SongbookError as error: |
|||
LOGGER.error(error) |
|||
if LOGGER.level >= logging.INFO: |
|||
LOGGER.error( |
|||
"Running again with option '-v' may give more information." |
|||
) |
|||
sys.exit(1) |
|||
except KeyboardInterrupt: |
|||
LOGGER.warning("Aborted by user.") |
|||
sys.exit(1) |
|||
|
|||
sys.exit(0) |
|||
"""Command line tool to compile songbooks using the songbook library.""" |
|||
|
|||
if __name__ == '__main__': |
|||
main() |
|||
from patacrep.songbook import main |
|||
main() |
|||
|
@ -1,6 +1,6 @@ |
|||
[DEFAULT] |
|||
Depends: python3-jinja2, python3-pkg-resources, python3-chardet, python3-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended |
|||
Recommends: texlive-lang-english, texlive-lang-french, texlive-lang-portuguese, texlive-lang-spanish, texlive-fonts-extra |
|||
X-Python3-Version: |
|||
Debian-Version: 1 |
|||
Section: tex |
|||
|
|||
Depends3: texlive, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra |
|||
Recommends3: lilypond, texlive-lang-english, texlive-lang-french, texlive-lang-portuguese, texlive-lang-spanish, texlive-fonts-extra |
|||
Copyright-File: LICENSE |
|||
|
Loading…
Reference in new issue