Browse Source

Merge branch 'bug_imagecache' of git://git.spalax.fr.eu.org/songbook

Conflicts:
	songbook-makeindex.py
	songbook.py
	templates/ancient.tmpl
	templates/minimal.tmpl
	templates/patacrep.tmpl
	utils/songbook-gtab.py
remotes/origin/HEAD
Romain Goffe 12 years ago
parent
commit
f6d9616cc1
  1. 2
      makefile
  2. 25
      songbook.py
  3. 2
      templates/ancient.tmpl
  4. 2
      templates/minimal.tmpl
  5. 2
      templates/patacrep.tmpl
  6. 3
      tex/crepbook.cls
  7. 3
      utils/songbook-gtab.py

2
makefile

@ -62,7 +62,6 @@ clean:
$(TARGETS:%=%.nav) $(TARGETS:%=%.snm) $(TARGETS:%=%.nav) $(TARGETS:%=%.snm)
@rm -f *.sbx *.sxd *.sxc @rm -f *.sbx *.sxd *.sxc
@rm -f *.pyc @rm -f *.pyc
@rm -rf covers/
cleanall: clean cleanall: clean
@rm -f $(PDF) @rm -f $(PDF)
@ -99,7 +98,6 @@ archive: cleanall
--exclude=$(BOOKS_DIR)/default.sb \ --exclude=$(BOOKS_DIR)/default.sb \
--exclude=perso/* --exclude=perso \ --exclude=perso/* --exclude=perso \
--exclude=build/* --exclude=build \ --exclude=build/* --exclude=build \
--exclude=covers/* --exclude=covers \
--exclude=data/* --exclude=data \ --exclude=data/* --exclude=data \
--exclude=*tar.gz \ --exclude=*tar.gz \
--transform 's/songbook/songbook-$(DATE)/1' \ --transform 's/songbook/songbook-$(DATE)/1' \

25
songbook.py

@ -26,27 +26,6 @@ class Song:
def __repr__(self): def __repr__(self):
return repr((self.title, self.artist, self.album, self.path)) return repr((self.title, self.artist, self.album, self.path))
if platform.system() == "Linux":
from xdg.BaseDirectory import *
cachePath = os.path.join(xdg_cache_home, 'songbook')
else:
cachePath = os.path.join('cache', 'songbook')
def makeCoverCache(library):
'''
Copy all pictures found in the libraries into a unique cache
folder.
'''
# create the cache directory if it does not exist
if not os.path.exists(cachePath):
os.makedirs(cachePath)
# copy pictures file into the cache directory
covers = recursiveFind(os.path.join(library, 'songs'), '*.jpg')
for cover in covers:
coverPath = os.path.join(cachePath, os.path.basename(cover))
shutil.copy(cover, coverPath)
def matchRegexp(reg, iterable): def matchRegexp(reg, iterable):
return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ] return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ]
@ -177,9 +156,6 @@ def makeTexFile(sb, library, output):
content = [ line for line in f if not commentPattern.match(line) ] content = [ line for line in f if not commentPattern.match(line) ]
for index, line in enumerate(content): for index, line in enumerate(content):
if re.compile("getCacheDirectory").search(line):
line = line.replace("\\getCacheDirectory", cachePath.replace("\\","/") + "/")
content[index] = line
if re.compile("getLibraryImgDirectory").search(line): if re.compile("getLibraryImgDirectory").search(line):
line = line.replace("\\getLibraryImgDirectory", library + "img/") line = line.replace("\\getLibraryImgDirectory", library + "img/")
content[index] = line content[index] = line
@ -267,7 +243,6 @@ def main():
else: else:
assert False, "unhandled option" assert False, "unhandled option"
makeCoverCache(library)
if songbook and output: if songbook and output:
f = open(songbook) f = open(songbook)
sb = json.load(f) sb = json.load(f)

2
templates/ancient.tmpl

@ -68,7 +68,7 @@
\newindex{titleidx}{\getname_title} \newindex{titleidx}{\getname_title}
\newauthorindex{authidx}{\getname_auth} \newauthorindex{authidx}{\getname_auth}
\graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory}, {\getCacheDirectory} } \graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory} }
\renewcommand{\lilypond}[1]{% \renewcommand{\lilypond}[1]{%
\iflilypond% \iflilypond%

2
templates/minimal.tmpl

@ -42,7 +42,7 @@
\usepackage[italian,portuguese,spanish,english,french]{babel} \usepackage[italian,portuguese,spanish,english,french]{babel}
\lang{\getlang} \lang{\getlang}
\graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory}, {\getCacheDirectory} } \graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory} }
\renewcommand{\lilypond}[1]{% \renewcommand{\lilypond}[1]{%
\iflilypond% \iflilypond%

2
templates/patacrep.tmpl

@ -69,7 +69,7 @@
\newindex{titleidx}{\getname_title} \newindex{titleidx}{\getname_title}
\newauthorindex{authidx}{\getname_auth} \newauthorindex{authidx}{\getname_auth}
\graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory}, {\getCacheDirectory} } \graphicspath{ {img/}, {\getLibraryImgDirectory}, {\getLibraryLilypondDirectory} }
\renewcommand{\lilypond}[1]{% \renewcommand{\lilypond}[1]{%
\iflilypond% \iflilypond%

3
tex/crepbook.cls

@ -73,6 +73,7 @@
\RequirePackage{xstring} \RequirePackage{xstring}
\RequirePackage{ifthen} \RequirePackage{ifthen}
\RequirePackage{framed} \RequirePackage{framed}
\RequirePackage{currfile}
\iflyric% \iflyric%
\tabsfalse% \tabsfalse%
@ -202,7 +203,7 @@
\setlength{\coverspace}{0.1cm} \setlength{\coverspace}{0.1cm}
\newcommand{\songcover}{} \newcommand{\songcover}{}
\newcommand{\songalbum}{} \newcommand{\songalbum}{}
\newsongkey{cov}{\let\songcover\@empty}{\def\songcover{#1}} \newsongkey{cov}{\let\songcover\@empty}{\def\songcover{\currfiledir#1}}
\newsongkey{album}{\let\songalbum\@empty}{\def\songalbum{#1}} \newsongkey{album}{\let\songalbum\@empty}{\def\songalbum{#1}}
\newsongkey{url}{\let\songurl\@empty}{\def\songurl{#1}} \newsongkey{url}{\let\songurl\@empty}{\def\songurl{#1}}
\newsongkey{original}{\let\songoriginal\@empty}{\def\songoriginal{#1}} \newsongkey{original}{\let\songoriginal\@empty}{\def\songoriginal{#1}}

3
utils/songbook-gtab.py

@ -6,6 +6,8 @@ import re
from optparse import OptionParser from optparse import OptionParser
from utils.utils import recursiveFind from utils.utils import recursiveFind
from utils.utils import recursiveFind
# Pattern set to ignore latex command in title prefix # Pattern set to ignore latex command in title prefix
gtabPattern = re.compile(r"\\gtab\{(.*)\}\{(.*)\}"); gtabPattern = re.compile(r"\\gtab\{(.*)\}\{(.*)\}");
@ -27,6 +29,7 @@ def main():
positions = dict() positions = dict()
songfiles = recursiveFind(os.path.join(library, 'songs'), '*.sg') songfiles = recursiveFind(os.path.join(library, 'songs'), '*.sg')
for file in songfiles: for file in songfiles:
for line in open(file): for line in open(file):
result = gtabPattern.match(line) result = gtabPattern.match(line)

Loading…
Cancel
Save