Example #1
0
File: misc.py Project: jjbenham/gub
def forall (generator):
    v = True
    try:
        while v:
            v = v and next (generator)
    except StopIteration:
        pass
    return v
Example #2
0
File: misc.py Project: jjbenham/gub
def map_command_dir (os_commands, dir, command, predicate):
    if not os.path.isdir (dir):
        raise Exception ('warning: no such dir: %(dir)s' % locals ())
    (root, dirs, files) = next (os.walk (dir))
    for file in files:
        if predicate (os.path.join (root, file)):
            os_commands.system ('%(command)s %(root)s/%(file)s' % locals (),
                                ignore_errors=True)
Example #3
0
File: misc.py Project: marnen/gub
def map_command_dir(os_commands, dir, command, predicate):
    if not os.path.isdir(dir):
        raise Exception('warning: no such dir: %(dir)s' % locals())
    (root, dirs, files) = next(os.walk(dir))
    for file in files:
        if predicate(os.path.join(root, file)):
            os_commands.system('%(command)s %(root)s/%(file)s' % locals(),
                               ignore_errors=True)
Example #4
0
File: misc.py Project: marnen/gub
def forall(generator):
    v = True
    try:
        while v:
            v = v and next(generator)
    except StopIteration:
        pass
    return v
Example #5
0
 def rewire_binary_dir(self, dir):
     if not os.path.isdir(dir):
         raise Exception('not a directory: %(dir)' % locals())
     (root, dirs, files) = next(os.walk(dir))
     files = [os.path.join(root, f) for f in files]
     for f in files:
         must_skip = [s for s in self.skip if s in f]
         if not must_skip and os.path.isfile(f):
             self.rewire_mach_o_object_executable_path(f)
Example #6
0
File: darwin.py Project: cneira/gub
 def rewire_binary_dir (self, dir):
     if not os.path.isdir (dir):
         raise Exception ('not a directory: %(dir)' % locals ())
     (root, dirs, files) = next (os.walk (dir))
     files = [os.path.join (root, f) for f in files]
     for f in files:
         must_skip = [s for s in self.skip if s in f]
         if not must_skip and os.path.isfile (f):
             self.rewire_mach_o_object_executable_path (f)
Example #7
0
File: misc.py Project: jjbenham/gub
def shadow (src, target, soft=False):
    '''Symlink files from SRC in TARGET recursively.

    If SOFT, do not overwrite any existing files in target.'''
    target = os.path.abspath (target)
    src = os.path.abspath (src)
    if not soft or not os.path.exists (target):
        os.makedirs (target)
    (root, dirs, files) = next (os.walk (src))
    for f in files:
        t = os.path.join (target, f)
        if not soft or not os.path.exists (t):
            os.symlink (os.path.join (root, f), t)
    for d in dirs:
        shadow (os.path.join (root, d), os.path.join (target, d), soft)
Example #8
0
File: misc.py Project: marnen/gub
def shadow(src, target, soft=False):
    '''Symlink files from SRC in TARGET recursively.

    If SOFT, do not overwrite any existing files in target.'''
    target = os.path.abspath(target)
    src = os.path.abspath(src)
    if not soft or not os.path.exists(target):
        os.makedirs(target)
    (root, dirs, files) = next(os.walk(src))
    for f in files:
        t = os.path.join(target, f)
        if not soft or not os.path.exists(t):
            os.symlink(os.path.join(root, f), t)
    for d in dirs:
        shadow(os.path.join(root, d), os.path.join(target, d), soft)
Example #9
0
File: misc.py Project: jjbenham/gub
def map_dir (func, dir):
    if not os.path.isdir (dir):
        raise Exception ('warning: no such dir: %(dir)s' % locals ())
    (root, dirs, files) = next (os.walk (dir))
    for file in files:
        func (root, file)
Example #10
0
File: misc.py Project: marnen/gub
def map_dir(func, dir):
    if not os.path.isdir(dir):
        raise Exception('warning: no such dir: %(dir)s' % locals())
    (root, dirs, files) = next(os.walk(dir))
    for file in files:
        func(root, file)