]> git.donarmstrong.com Git - lilypond.git/blobdiff - stepmake/bin/packagepython.py
* Documentation/user/music-glossary.tely: add @omf tags
[lilypond.git] / stepmake / bin / packagepython.py
index a1b8bab54649316c9c5def950cd5e53beb9c4a40..86fc71969c547f3a2e1308808342a3e2e26dcdea 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/python
 
+
+#ugh. junkme.
+
 # packagepython.py --  implement general StepMake-wide python stuff
 # 
 # source file of the GNU LilyPond music typesetter
 # (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
 #                Jan Nieuwenhuizen <janneke@gnu.org>
 
-import regex
-import regsub
-from string import *
-# from flower import *
+import re
+import string
+
 import sys
 import os
 import getopt
 
-make_assign_re = regex.compile('^\([A-Z_]*\)=\(.*\)$')
+make_assign_re = re.compile ('^([A-Z_]*)=(.*)$')
 
 def read_makefile (fn):
        file = open (fn)
@@ -26,9 +28,10 @@ def read_makefile (fn):
 
        make_dict = {}
        for l in lines:
-               if make_assign_re.search(l) <> -1:
-                       nm = make_assign_re.group(1)
-                       val = make_assign_re.group(2)
+               m = make_assign_re.search (l)
+               if m:
+                       nm = m.group (1)
+                       val = m.group (2)
                        make_dict[nm] = val
        return make_dict
 
@@ -36,8 +39,8 @@ class Package:
        def __init__ (self, dirname):
                dict = read_makefile (dirname + '/VERSION')
                version_list = []
-               for x in [ 'MAJOR_VERSION', 'MINOR_VERSION',   'PATCH_LEVEL']:
-                       version_list.append (atoi (dict[x]))
+               for x in [ 'MAJOR_VERSION', 'MINOR_VERSION', 'PATCH_LEVEL']:
+                       version_list.append (string.atoi (dict[x]))
                version_list.append (dict['MY_PATCH_LEVEL'])
                self.topdir = dirname
                self.groupdir = self.topdir + '/..'
@@ -46,12 +49,12 @@ class Package:
                self.test_dir = self.groupdir + '/test/'
                self.version =  tuple(version_list)
                self.Name = dict['PACKAGE_NAME']
-               self.name = lower (self.Name)
+               self.name = string.lower (self.Name)
                if self.name == 'lilypond':
                        self.nickname = 'lelie'
                else:
                        self.nickname = self.name
-               self.NAME = upper (self.Name)
+               self.NAME = string.upper (self.Name)
 
 
 class Packager:
@@ -77,10 +80,9 @@ def full_version_tup(tup):
                  break
        return tuple(t)
 
-def split_my_patchlevel(str):
-       return (regsub.sub('[0-9]*$', '', str),
-               atoi(regsub.sub('[^0-9]*', '', str)))
-       
+def split_my_patchlevel (str):
+       m = re.match ('(.*?)([0-9]*)$', str)
+       return (m.group (1), string.atoi (m.group (2)))
 
 def next_version(tup):
        l = list(full_version_tup (tup))
@@ -100,7 +102,7 @@ def prev_version(tup):
        l = list(full_version_tup (tup))
        t3name=t3num=''
        if l[3]:
-               (t3name,t3num)= split_my_patchlevel (l[3])
+               (t3name, t3num) = split_my_patchlevel (l[3])
                if t3num and t3num - 1 > 0:
                        t3num = '%d' %(t3num - 1)
                else:
@@ -120,31 +122,27 @@ def version_tuple_to_str(tup):
        return ('%d.%d.%d' % tup[0:3]) + my
 
 def version_str_to_tuple(str):
-       t = split(str, '.')
-       try:
-               mypatch = t[3]
-       except IndexError:
-               mypatch = ''
-       return (atoi(t[0]), atoi(t[1]), atoi(t[2]), mypatch)
-
-def version_compare (tupl, tupr):
-       tupl = full_version_tup (tupl)
-       tupr = full_version_tup (tupr)
+       t = string.split(str, '.')
+       mypatch = ''
+       if len (t) >= 4:
+               mypatch = string.join (t[3:], '.')
+       return (string.atoi(t[0]), string.atoi(t[1]), string.atoi(t[2]), mypatch)
+
+def version_compare (ltup, rtup):
+       rtup = full_version_tup (ltup)
+       rtup = full_version_tup (rtup)
        for i in (0,1,2):
-               if tupl[i] - tupr[i]: return tupl[i] - tupr[i]
-       if tupl[3] and tupr[3]:
-               lname = regsub.sub('[0-9]*$', '', tupl[3])
-               lnum = atoi(regsub.sub('[^0-9]*', '', tupl[3]))
-               rname = regsub.sub('[0-9]*$', '', tupr[3])
-               rnum = atoi(regsub.sub('[^0-9]*', '', tupr[3]))
+               if ltup[i] - rtup[i]: return ltup[i] - rtup[i]
+       if ltup[3] and rtup[3]:
+               (lname, lnum) = split_my_patchlevel (ltup[i])
+               (rname, rnum) = split_my_patchlevel (rtup[3])
                if lname != rname:
                        raise 'ambiguous'
                return sign (lnum - rnum)
-       if tupl[3]:
+       if ltup[3]:
                return 1
        else:
                return -1
-
        
 if __name__ == '__main__':
        p = Package ('.')
@@ -161,18 +159,3 @@ def dump_file(f, s):
        i.write(s)
        i.close ()
 
-def gulp_file(f):
-       try:
-               i = open(f)
-               i.seek (0, 2)
-               n = i.tell ()
-               i.seek (0,0)
-       except:
-               sys.stderr.write( 'can\'t open file %s\n ' % f)
-               return ''
-       s = i.read (n)
-       if len (s) <= 0:
-               sys.stderr.write( 'gulped empty file: %s\n'% f)
-       return s
-
-