OpenQuizz
Une application de gestion des contenus pédagogiques
FileList Class Reference

Public Member Functions

def __init__ (self, warn=None, debug_print=None)
 
def set_allfiles (self, allfiles)
 
def findall (self, dir=os.curdir)
 
def debug_print (self, msg)
 
def append (self, item)
 
def extend (self, items)
 
def sort (self)
 
def remove_duplicates (self)
 
def process_template_line (self, line)
 
def include_pattern (self, pattern, anchor=1, prefix=None, is_regex=0)
 
def exclude_pattern (self, pattern, anchor=1, prefix=None, is_regex=0)
 

Data Fields

 allfiles
 
 files
 

Detailed Description

A list of files built by on exploring the filesystem and filtered by
applying various patterns to what we find there.

Instance attributes:
  dir
    directory from which files will be taken -- only used if
    'allfiles' not supplied to constructor
  files
    list of filenames currently being built/filtered/manipulated
  allfiles
    complete list of files under consideration (ie. without any
    filtering applied)

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  warn = None,
  debug_print = None 
)

Member Function Documentation

◆ append()

def append (   self,
  item 
)

◆ debug_print()

def debug_print (   self,
  msg 
)
Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.

◆ exclude_pattern()

def exclude_pattern (   self,
  pattern,
  anchor = 1,
  prefix = None,
  is_regex = 0 
)
Remove strings (presumably filenames) from 'files' that match
'pattern'.  Other parameters are the same as for
'include_pattern()', above.
The list 'self.files' is modified in place.
Return True if files are found, False otherwise.

◆ extend()

def extend (   self,
  items 
)

◆ findall()

def findall (   self,
  dir = os.curdir 
)

◆ include_pattern()

def include_pattern (   self,
  pattern,
  anchor = 1,
  prefix = None,
  is_regex = 0 
)
Select strings (presumably filenames) from 'self.files' that
match 'pattern', a Unix-style wildcard (glob) pattern.  Patterns
are not quite the same as implemented by the 'fnmatch' module: '*'
and '?'  match non-special characters, where "special" is platform-
dependent: slash on Unix; colon, slash, and backslash on
DOS/Windows; and colon on Mac OS.

If 'anchor' is true (the default), then the pattern match is more
stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
'anchor' is false, both of these will match.

If 'prefix' is supplied, then only filenames starting with 'prefix'
(itself a pattern) and ending with 'pattern', with anything in between
them, will match.  'anchor' is ignored in this case.

If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
'pattern' is assumed to be either a string containing a regex or a
regex object -- no translation is done, the regex is just compiled
and used as-is.

Selected strings will be added to self.files.

Return True if files are found, False otherwise.

◆ process_template_line()

def process_template_line (   self,
  line 
)

◆ remove_duplicates()

def remove_duplicates (   self)

◆ set_allfiles()

def set_allfiles (   self,
  allfiles 
)

◆ sort()

def sort (   self)

Field Documentation

◆ allfiles

allfiles

◆ files

files

The documentation for this class was generated from the following file: