PATCH:bksys - fix some win32 related path delimiter problems

Ralf Habacker ralf.habacker at freenet.de
Mon Oct 3 17:00:48 BST 2005


Am Donnerstag, 29. September 2005 01:56 schrieb Ralf Habacker:
> Am Donnerstag, 29. September 2005 01:19 schrieb tnagyemail-ml at yahoo.fr:
> > While we are at it, lstrip(param) does not work for
> > python =< 2.2 (Redhat 9).
>
> any replacement for this available ?
I've added a replacement for lstrip. The related patch was verified on linux 
and windows (cygwin)

Regards 
Ralf 

$ svn diff  generic.py
Index: generic.py
===================================================================
--- generic.py  (revision 466875)
+++ generic.py  (working copy)
@@ -189,7 +189,7 @@
                def reldir(dir):
                        ndir    = 
SCons.Node.FS.default_fs.Dir(dir).srcnode().abspath
                        rootdir = SCons.Node.FS.default_fs.Dir('#').abspath
-                       return ndir.replace(rootdir, '').lstrip(os.sep)
+                       return striproot(ndir.replace(rootdir, ''))

                dir=self.dirprefix
                if not len(dir)>2: dir=reldir('.')
@@ -358,15 +358,24 @@
        else:
                return val

-## HELPER
+## HELPER - strip root '/' from path
+def striproot(s):
+       a = string.lstrip(s)
+       # TODO add win32 support
+       if a[0] == os.sep:
+               return a[1:]
+       else:
+               return a
+
+## HELPER - join pathes
 def join(lenv, s1, s2, s3=None, s4=None):
        if s4 and s3: return lenv.join(s1, s2, lenv.join(s3, s4))
        if s3 and s2: return lenv.join(s1, lenv.join(s2, s3))
        elif not s2:  return s1
        # having s1, s2
-       #print "path1 is "+s1+" path2 is "+s2+" 
"+os.path.join(s1,string.lstrip(s2,os.sep))
+       #print "path1 is "+s1+" path2 is "+s2+" 
"+os.path.join(s1,striproot(s2))
        if not s1: s1=os.sep
-       return os.path.join(s1,string.lstrip(s2,os.sep))
+       return os.path.join(s1,striproot(s2))

 ## HELPER export the data to xml
 bks_dump='<?xml version="1.0" encoding="UTF-8"?>\n<bksys version="1">\n'
@@ -383,7 +392,7 @@
 def getreldir(lenv):
        cwd=os.getcwd()
        root=SCons.Node.FS.default_fs.Dir('#').abspath
-       return cwd.replace(root,'').lstrip(os.sep)
+       return striproot(cwd.replace(root,''))

 ## HELPER - find programs and headers
 def find_path(lenv, file, path_list):




More information about the kde-core-devel mailing list