Package pysys :: Package utils :: Module filegrep
[frames] | no frames]

Module filegrep

source code

Functions
list
getmatches(file, regexpr)
Look for matches on a regular expression in an input file, return a sequence of the matches.
source code
integer
filegrep(file, expr)
Search for matches to a regular expression in an input file, returning true if a match occurs.
source code
integer
lastgrep(file, expr, ignore=[], include=[])
Search for matches to a regular expression in the last line of an input file, returning true if a match occurs.
source code
integer
orderedgrep(file, exprList)
Seach for ordered matches to a set of regular expressions in an input file, returning true if the matches occur in the correct order.
source code
 
logContents(message, list)
Log a list of strings, prepending the line number to each line in the log output.
source code
Variables
  BACKGROUND = 10
  BLOCKED = 26
  DEFAULT_DESCRIPTOR = ['pysystest.xml', '.pysystest', 'descript...
  DEFAULT_FORMAT_RUNLOG = '%(asctime)s %(levelname)-5s %(message)s'
  DEFAULT_FORMAT_STDOUT = '%(asctime)s %(levelname)-5s %(message)s'
  DEFAULT_GROUP = ''
  DEFAULT_INPUT = 'Input'
  DEFAULT_MAKER = ['ConsoleMakeTestHelper', 'pysys.launcher.cons...
  DEFAULT_MODULE = 'run'
  DEFAULT_OUTPUT = 'Output'
  DEFAULT_PROJECTFILE = ['pysysproject.xml', '.pysysproject']
  DEFAULT_REFERENCE = 'Reference'
  DEFAULT_RUNNER = ['BaseRunner', 'pysys.baserunner']
  DEFAULT_STYLESHEET = '/System/Library/Frameworks/Python.framew...
  DEFAULT_TESTCLASS = 'PySysTest'
  DEFAULT_TIMEOUT = 600
  DEFAULT_WRITER = ['XMLResultsWriter', 'pysys.writer', 'testsum...
  DEVNULL = '/dev/null'
  DUMPEDCORE = 25
  DYLD_LIBRARY_PATH = '/usr/lib:/usr/local/lib'
  ENVSEPERATOR = ':'
  FAILED = 23
  FAILS = [26, 25, 24, 23]
  FALSE = False
  FOREGROUND = 11
  HOSTNAME = '10070'
  INSPECT = 21
  LD_LIBRARY_PATH = ''
  LOOKUP = {False: 'FALSE', True: 'TRUE', 20: 'PASSED', 21: 'REQ...
  NOTVERIFIED = 22
  OSFAMILY = 'unix'
  OSWALK_IGNORES = ['Input', 'Output', 'Reference', 'CVS', '.svn']
  PASSED = 20
  PATH = '/bin:/usr/bin:/usr/sbin:/usr/local/bin'
  PLATFORM = 'darwin'
  PRECEDENT = [27, 26, 25, 24, 23, 22, 21, 20]
  PROJECT = None
  SITE_PACKAGES_DIR = '/System/Library/Frameworks/Python.framewo...
  SKIPPED = 27
  TIMEDOUT = 24
  TIMEOUTS = {'ManualTester': 1800, 'WaitForFile': 30, 'WaitForP...
  TRUE = True
  __package__ = 'pysys.utils'
  stdoutHandler = ThreadedStreamHandler(sys.stdout)
Function Details

getmatches(file, regexpr)

source code 

Look for matches on a regular expression in an input file, return a sequence of the matches.

Parameters:
  • file - The full path to the input file
  • regexpr - The regular expression used to search for matches
Returns: list
A list of the match objects
Raises:

filegrep(file, expr)

source code 

Search for matches to a regular expression in an input file, returning true if a match occurs.

Parameters:
  • file - The full path to the input file
  • expr - The regular expression (uncompiled) to search for in the input file
Returns: integer
success (True / False)
Raises:

lastgrep(file, expr, ignore=[], include=[])

source code 

Search for matches to a regular expression in the last line of an input file, returning true if a match occurs.

Parameters:
  • file - The full path to the input file
  • expr - The regular expression (uncompiled) to search for in the last line of the input file
  • ignore - A list of regular expressions which remove entries in the input file contents before making the grep
  • include - A list of regular expressions used to select lines from the input file contents to use in the grep
Returns: integer
success (True / False)
Raises:

orderedgrep(file, exprList)

source code 

Seach for ordered matches to a set of regular expressions in an input file, returning true if the matches occur in the correct order.

The ordered grep method will only return true if matches to the set of regular expression in the expression list occur in the input file in the order they appear in the expression list. Matches to the regular expressions do not have to be across sequential lines in the input file, only in the correct order. For example, for a file with contents :

   A is for apple 
   B is for book
   C is for cat
   D is for dog

an expression list of ["^A.*$", "^C.*$", "^D.*$"] will return true, whilst an expression list of ["^A.*$", "^C.$", "^B.$"] will return false.

Parameters:
  • file - The full path to the input file
  • exprList - A list of regular expressions (uncompiled) to search for in the input file
Returns: integer
success (True / False)
Raises:

logContents(message, list)

source code 

Log a list of strings, prepending the line number to each line in the log output.

Parameters:
  • list - The list of strings to log

Variables Details

DEFAULT_DESCRIPTOR

Value:
['pysystest.xml', '.pysystest', 'descriptor.xml']

DEFAULT_MAKER

Value:
['ConsoleMakeTestHelper', 'pysys.launcher.console']

DEFAULT_STYLESHEET

Value:
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.\
7/site-packages/pysys-log.xsl'

DEFAULT_WRITER

Value:
['XMLResultsWriter',
 'pysys.writer',
 'testsummary_%Y%m%d%H%M%S.xml',
 {}]

LOOKUP

Value:
{False: 'FALSE',
 True: 'TRUE',
 20: 'PASSED',
 21: 'REQUIRES INSPECTION',
 22: 'NOT VERIFIED',
 23: 'FAILED',
 24: 'TIMED OUT',
 25: 'DUMPED CORE',
...

SITE_PACKAGES_DIR

Value:
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.\
7/site-packages'

TIMEOUTS

Value:
{'ManualTester': 1800,
 'WaitForFile': 30,
 'WaitForProcessStop': 10,
 'WaitForSignal': 60,
 'WaitForSocket': 60}