Browse Source

Minor improvements

pull/149/head
Louis 9 years ago
committed by Oliverpool
parent
commit
92b7185a7f
  1. 4
      patacrep/__init__.py
  2. 9
      patacrep/build.py
  3. 2
      patacrep/songs/chordpro/__init__.py
  4. 4
      test/test_compilation/test_compilation.py

4
patacrep/__init__.py

@ -17,8 +17,8 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__])
# etc.)
_ROOT = os.path.abspath(resource_filename(__name__, 'data'))
def pkg_datapath(path=''):
def pkg_datapath(*path):
"""Return the package data path"""
return os.path.join(_ROOT, path)
return os.path.join(_ROOT, *path)
__DATADIR__ = os.path.abspath(pkg_datapath())

9
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
@ -219,26 +219,25 @@ class SongbookBuilder(object):
compiler = "lualatex"
# test if the LaTeX compiler is accessible
# Test if the LaTeX compiler is accessible
try:
process = Popen(
check_call(
[compiler, "--version"],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
env=os.environ,
universal_newlines=True,
)
except Exception as error:
raise errors.ExecutableNotFound(compiler)
# Perform compilation
try:
process = Popen(
[compiler] + self._lualatex_options + [self.basename],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
env=os.environ,
universal_newlines=True,
)
except Exception as error:

2
patacrep/songs/chordpro/__init__.py

@ -53,7 +53,7 @@ class ChordproSong(Song):
self.get_datadirs(os.path.join("templates", self.output_language))
),
FileSystemLoader(
os.path.join(pkg_datapath('ast_templates'), 'chordpro', self.output_language)
pkg_datapath('ast_templates', 'chordpro', self.output_language)
),
]))
jinjaenv.filters['search_image'] = self.search_image

4
test/test_compilation/test_compilation.py

@ -76,7 +76,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
"@DATA_FOLDER@",
path2posix(
subprocess.check_output(
[sys.executable, "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long
[sys.executable, "-c", 'import patacrep; print(patacrep.__DATADIR__)'], # pylint: disable=line-too-long
universal_newlines=True,
cwd=os.path.dirname(songbook),
).strip()
@ -117,7 +117,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
command.extend(['--steps', steps])
try:
subprocess.check_output(
subprocess.check_call(
command,
stderr=subprocess.STDOUT,
universal_newlines=True,

Loading…
Cancel
Save