Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
glob Namespace Reference

Functions

def glob
 
def glob1
 
def has_magic
 

Variables

list __all__ = ["glob"]
 
tuple magic_check = re.compile('[*?[]')
 

Detailed Description

Filename globbing utility.

Function Documentation

def glob.glob (   pathname)
Return a list of paths matching a pathname pattern.

The pattern may contain simple shell-style wildcards a la fnmatch.

Definition at line 9 of file glob.py.

References glob1(), and has_magic().

9 
10 def glob(pathname):
11  """Return a list of paths matching a pathname pattern.
12 
13  The pattern may contain simple shell-style wildcards a la fnmatch.
14 
15  """
16  if not has_magic(pathname):
17  if os.path.exists(pathname):
18  return [pathname]
19  else:
20  return []
21  dirname, basename = os.path.split(pathname)
22  if not dirname:
23  return glob1(os.curdir, basename)
24  elif has_magic(dirname):
25  list = glob(dirname)
26  else:
27  list = [dirname]
28  if not has_magic(basename):
29  result = []
30  for dirname in list:
31  if basename or os.path.isdir(dirname):
32  name = os.path.join(dirname, basename)
33  if os.path.exists(name):
34  result.append(name)
35  else:
36  result = []
37  for dirname in list:
38  sublist = glob1(dirname, basename)
39  for name in sublist:
40  result.append(os.path.join(dirname, name))
41  return result
def glob.glob1 (   dirname,
  pattern 
)

Definition at line 42 of file glob.py.

References fnmatch.filter().

42 
43 def glob1(dirname, pattern):
44  if not dirname: dirname = os.curdir
45  try:
46  names = os.listdir(dirname)
47  except os.error:
48  return []
49  if pattern[0]!='.':
50  names=filter(lambda x: x[0]!='.',names)
51  return fnmatch.filter(names,pattern)
52 
def glob.has_magic (   s)

Definition at line 55 of file glob.py.

55 
56 def has_magic(s):
57  return magic_check.search(s) is not None

Variable Documentation

list __all__ = ["glob"]

Definition at line 7 of file glob.py.

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

Definition at line 53 of file glob.py.