lilypond-1.3.16
[lilypond.git] / bin / lily-python.py
blob6f85149b50de132c71bbcd9c2a876a74a6b69478
1 #!@PYTHON@
3 #
4 # lily-python.py -- implement general LilyPond-wide python stuff
5 #
6 # source file of the GNU LilyPond music typesetter
7 #
8 # (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #
11 import posix
12 import pwd
13 import regex
14 import regsub
15 import string
16 import sys
17 import os
18 import getopt
24 make_assign_re = regex.compile('^\([A-Z_]*\) *= *\(.*\)$')
26 def version_str_tuple(file):
27 lines = file.readlines()
29 mi = pa = mp = mj = ''
31 for l in lines:
32 if make_assign_re.search(l) <> -1:
33 nm = make_assign_re.group(1)
34 val = make_assign_re.group(2)
35 if nm == 'TOPLEVEL_MAJOR_VERSION':
36 mj = val
37 elif nm == 'TOPLEVEL_MINOR_VERSION':
38 mi = val
39 elif nm == 'TOPLEVEL_PATCH_LEVEL':
40 pa = val
41 elif nm == 'TOPLEVEL_MY_PATCH_LEVEL':
42 mp = val
43 return (mj,mi,pa,mp)
45 class Lilydirs:
46 def __init__(self):
47 try:
48 self.topdir = os.environ['LILYPOND_SOURCEDIR'] + '/'
49 except IndexError:
50 self.topdir = os.environ['HOME'] + 'musix/current'
52 self.release_dir = self.topdir + '../releases/'
53 self.patch_dir = self.topdir + '../patches/'
55 def version_str_tuple(self):
56 f = open (self.topdir + 'VERSION')
57 v = version_str_tuple(f)
58 f.close ()
59 return v
61 lilydirs = Lilydirs()
63 print lilydirs.version_str_tuple()