Browse Source

Merge pull request #178 from patacrep/default_config

Move the DEFAULT_CONFIG into the songs package
filepath_with_space
Louis 9 years ago
parent
commit
a4321d63a8
  1. 10
      patacrep/build.py
  2. 14
      patacrep/songs/__init__.py
  3. 2
      patacrep/songs/convert/__main__.py
  4. 2
      test/test_chordpro/test_parser.py

10
patacrep/build.py

@ -11,7 +11,7 @@ from subprocess import Popen, PIPE, call, check_call
from patacrep import authors, content, errors, files
from patacrep.index import process_sxd
from patacrep.templates import TexBookRenderer
from patacrep.songs import DataSubpath
from patacrep.songs import DataSubpath, DEFAULT_CONFIG
LOGGER = logging.getLogger(__name__)
EOL = "\n"
@ -27,14 +27,6 @@ GENERATED_EXTENSIONS = [
"_title.sbx",
"_title.sxd",
]
DEFAULT_CONFIG = {
'template': "default.tex",
'lang': 'en',
'content': [],
'titleprefixwords': [],
'encoding': None,
'datadir': [],
}

14
patacrep/songs/__init__.py

@ -12,6 +12,15 @@ from patacrep.authors import process_listauthors
LOGGER = logging.getLogger(__name__)
DEFAULT_CONFIG = {
'template': "default.tex",
'lang': 'en',
'content': [],
'titleprefixwords': [],
'encoding': None,
'datadir': [],
}
def cached_name(datadir, filename):
"""Return the filename of the cache version of the file."""
fullpath = os.path.abspath(os.path.join(datadir, '.cache', filename))
@ -93,7 +102,10 @@ class Song:
"_version",
]
def __init__(self, subpath, config, *, datadir=None):
def __init__(self, subpath, config=None, *, datadir=None):
if config is None:
config = DEFAULT_CONFIG.copy()
if datadir is None:
self.datadir = ""
# Only songs in datadirs may be cached

2
patacrep/songs/convert/__main__.py

@ -8,7 +8,7 @@ import logging
import sys
from patacrep import files
from patacrep.build import DEFAULT_CONFIG
from patacrep.songs import DEFAULT_CONFIG
from patacrep.utils import yesno
LOGGER = logging.getLogger(__name__)

2
test/test_chordpro/test_parser.py

@ -9,7 +9,7 @@ import unittest
from pkg_resources import resource_filename
from patacrep import files
from patacrep.build import DEFAULT_CONFIG
from patacrep.songs import DEFAULT_CONFIG
from patacrep.encoding import open_read
from .. import disable_logging

Loading…
Cancel
Save