Back to index

enigmail  1.4.3
Functions | Variables
pymake.globrelative Namespace Reference

Functions

def hasglob
def glob
def globpattern

Variables

tuple _globcheck = re.compile('[[*?]')

Detailed Description

Filename globbing like the python glob module with minor differences:

* glob relative to an arbitrary directory
* include . and ..
* check that link targets exist, not just links

Function Documentation

def pymake.globrelative.glob (   fsdir,
  path 
)
Yield paths matching the path glob. Sorts as a bonus. Excludes '.' and '..'

Definition at line 17 of file globrelative.py.

00017 
00018 def glob(fsdir, path):
00019     """
00020     Yield paths matching the path glob. Sorts as a bonus. Excludes '.' and '..'
00021     """
00022 
00023     dir, leaf = os.path.split(path)
00024     if dir == '':
00025         return globpattern(fsdir, leaf)
00026 
00027     if hasglob(dir):
00028         dirsfound = glob(fsdir, dir)
00029     else:
00030         dirsfound = [dir]
00031 
00032     r = []
00033 
00034     for dir in dirsfound:
00035         fspath = util.normaljoin(fsdir, dir)
00036         if not os.path.isdir(fspath):
00037             continue
00038 
00039         r.extend((util.normaljoin(dir, found) for found in globpattern(fspath, leaf)))
00040 
00041     return r

Here is the call graph for this function:

Here is the caller graph for this function:

def pymake.globrelative.globpattern (   dir,
  pattern 
)
Return leaf names in the specified directory which match the pattern.

Definition at line 42 of file globrelative.py.

00042 
00043 def globpattern(dir, pattern):
00044     """
00045     Return leaf names in the specified directory which match the pattern.
00046     """
00047 
00048     if not hasglob(pattern):
00049         if pattern == '':
00050             if os.path.isdir(dir):
00051                 return ['']
00052             return []
00053 
00054         if os.path.exists(util.normaljoin(dir, pattern)):
00055             return [pattern]
00056         return []
00057 
00058     leaves = os.listdir(dir) + ['.', '..']
00059 
00060     # "hidden" filenames are a bit special
00061     if not pattern.startswith('.'):
00062         leaves = [leaf for leaf in leaves
00063                   if not leaf.startswith('.')]
00064 
00065     leaves = fnmatch.filter(leaves, pattern)
00066     leaves = filter(lambda l: os.path.exists(util.normaljoin(dir, l)), leaves)
00067 
00068     leaves.sort()
00069     return leaves

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 14 of file globrelative.py.

00014 
00015 def hasglob(p):
00016     return _globcheck.search(p) is not None

Here is the caller graph for this function:


Variable Documentation

tuple pymake.globrelative._globcheck = re.compile('[[*?]')

Definition at line 12 of file globrelative.py.