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.) # etc.)
_ROOT = os.path.abspath(resource_filename(__name__, 'data')) _ROOT = os.path.abspath(resource_filename(__name__, 'data'))
def pkg_datapath(path=''): def pkg_datapath(*path):
"""Return the package data path""" """Return the package data path"""
return os.path.join(_ROOT, path) return os.path.join(_ROOT, *path)
__DATADIR__ = os.path.abspath(pkg_datapath()) __DATADIR__ = os.path.abspath(pkg_datapath())

9
patacrep/build.py

@ -6,7 +6,7 @@ import glob
import logging import logging
import threading import threading
import os.path 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 import __DATADIR__, authors, content, errors, files
from patacrep.index import process_sxd from patacrep.index import process_sxd
@ -219,26 +219,25 @@ class SongbookBuilder(object):
compiler = "lualatex" compiler = "lualatex"
# test if the LaTeX compiler is accessible # Test if the LaTeX compiler is accessible
try: try:
process = Popen( check_call(
[compiler, "--version"], [compiler, "--version"],
stdin=PIPE, stdin=PIPE,
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
env=os.environ,
universal_newlines=True, universal_newlines=True,
) )
except Exception as error: except Exception as error:
raise errors.ExecutableNotFound(compiler) raise errors.ExecutableNotFound(compiler)
# Perform compilation
try: try:
process = Popen( process = Popen(
[compiler] + self._lualatex_options + [self.basename], [compiler] + self._lualatex_options + [self.basename],
stdin=PIPE, stdin=PIPE,
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
env=os.environ,
universal_newlines=True, universal_newlines=True,
) )
except Exception as error: 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)) self.get_datadirs(os.path.join("templates", self.output_language))
), ),
FileSystemLoader( 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 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@", "@DATA_FOLDER@",
path2posix( path2posix(
subprocess.check_output( 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, universal_newlines=True,
cwd=os.path.dirname(songbook), cwd=os.path.dirname(songbook),
).strip() ).strip()
@ -117,7 +117,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
command.extend(['--steps', steps]) command.extend(['--steps', steps])
try: try:
subprocess.check_output( subprocess.check_call(
command, command,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
universal_newlines=True, universal_newlines=True,

Loading…
Cancel
Save