Changeset 5018


Ignore:
Timestamp:
Feb 11, 2008, 4:45:53 PM (16 years ago)
Author:
ole
Message:

Made an ANUGA specific wrapper for data_audit and added some more comments.
Data audit is still disabled from test_all.py until we decide how to invoke it.
However, create_distribution.py is using it.

Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/data_audit.py

    r5014 r5018  
    1 """Track IP of data files included in this distribution.
     1"""Track IP of data files in an entire directory tree.
     2See docstring for the public function IP_verified()
     3for details.
    24"""
    35
     
    79from anuga.utilities.xml_tools import xml2object, XML_element
    810from anuga.utilities.system_tools import compute_checksum
    9 
    10 from data_audit_config import extensions_to_ignore, directories_to_ignore, files_to_ignore
    11 
    1211
    1312
     
    2524                    WrongTags)
    2625
    27 def IP_verified(directory, verbose=False):
     26
     27def IP_verified(directory,
     28                extensions_to_ignore=None,
     29                directories_to_ignore=None,
     30                files_to_ignore=None,
     31                verbose=False):
    2832    """Find and audit potential data files that might violate IP
    2933
     
    4145    If verbose is False, only diagnostics about failed audits will appear.
    4246    All files that check OK will pass silently.
    43    
    44 
     47
     48    Optional arguments extensions_to_ignore, directories_to_ignore, and
     49    files_to_ignore are lists of things to skip.
     50
     51    Examples are:
     52    extensions_to_ignore = ['.py','.c','.h', '.f'] # Ignore source code
     53    files_to_ignore = ['README.txt']
     54    directories_to_ignore = ['.svn', 'misc']
     55
     56    None is also OK for these parameters.
     57   
    4558    """
    4659
     
    5164    first_time = True
    5265    all_files_accounted_for = True
    53     for dirpath, datafile in identify_datafiles(directory):
     66    for dirpath, datafile in identify_datafiles(directory,
     67                                                extensions_to_ignore,
     68                                                directories_to_ignore,
     69                                                files_to_ignore):
    5470       
    5571        filename = join(dirpath, datafile)
     
    99115
    100116
    101 def identify_datafiles(root):
     117
     118#------------------
     119# Private functions
     120#------------------
     121def identify_datafiles(root,
     122                       extensions_to_ignore=None,
     123                       directories_to_ignore=None,
     124                       files_to_ignore=None):
    102125    """ Identify files that might contain data
     126
     127    See function IP_verified() for details about optinoal parmeters
    103128    """
    104129
     
    109134                dirnames.remove(ignore)  # don't visit ignored directories
    110135
    111         #print 'Searching dir', dirpath
    112        
    113136
    114137        for filename in filenames:
     
    129152
    130153def license_file_is_valid(fid, dirpath='.', verbose=False):
    131     """Check that XML license file is valid
     154    """Check that XML license file is valid.
     155
     156    Check for each datafile listed that
     157
     158    * Datafile tags are there
     159    * Fields are non empty
     160    * Datafile exists
     161    * Checksum is correct
     162    * Datafile is flagged as publishable
     163
     164    If anything is violated an appropriate exception is raised.
     165    If everything is honky dory the function will return True.
    132166    """
    133167
     
    149183
    150184    # Validate elements: metadata, datafile, datafile, ...
     185    # FIXME (Ole): I'd like this to verified by the parser
     186    # using a proper DTD template one day....
     187    # For not, let's check the main ones.
    151188    elements = doc['ga_license_file']
    152189    if not elements.has_key('metadata'):
     
    174211    author = metadata['author']
    175212    if verbose: print 'Author:   ', author
     213    if author == '':
     214        msg = 'Missing author'
     215        raise Exception, msg               
    176216   
    177217    #svn_keywords = metadata['svn_keywords']
  • anuga_core/test_all.py

    r5017 r5018  
    1 from anuga.utilities.data_audit import IP_verified
     1from anuga.utilities.data_audit_wrapper import IP_verified
    22from tempfile import mktemp
    33
     
    1414
    1515
     16print
     17print '************************** NOTE *************************************'
     18print 'If all unit tests passed you should run the suite of validation tests'
     19print 'Go to the directory anuga_validation/automated_validation_tests'
     20print 'and run'
     21print '    python validate_all.py'
     22print
     23print 'These tests will take a few hours and will verify that ANUGA'
     24print 'produces the physical results expected.'
     25print '*********************************************************************'
     26
     27
     28
    1629# Temporary bail out
    1730import sys; sys.exit()
     
    2336
    2437# Create temporary area for svn to export source files
     38# FIXME (Ole): It would be good to make sure these files
     39# are exactly the same as those walked over by the
     40# release script: create_distribution.
     41#
     42# Come to think of it - this is probably not the best
     43# place for this check. It may have to move up one level.
     44# What do you all think?
     45
     46
     47
    2548temp_dir = mktemp()
    2649
    2750print 'Temp dir', temp_dir
    2851os.mkdir(temp_dir)
    29 
    3052
    3153# Get the ANUGA core source files
     
    4264
    4365
    44 print
    45 print '************************** NOTE *************************************'
    46 print 'If all unit tests passed you should run the suite of validation tests'
    47 print 'Go to the directory anuga_validation/automated_validation_tests'
    48 print 'and run'
    49 print '    python validate_all.py'
    50 print
    51 print 'These tests will take a few hours and will verify that ANUGA'
    52 print 'produces the physical results expected.'
    53 print '*********************************************************************'
     66
    5467
    5568   
  • create_distribution.py

    r5016 r5018  
    1818   it depends on still work for that revision.
    1919
    20    This script works only on Linux
     20   This script works only on Linux!
    2121"""
    2222
     
    3030from anuga.config import major_revision
    3131
    32 from anuga.utilities.data_audit import IP_verified
     32from anuga.utilities.data_audit_wrapper import IP_verified
    3333
    3434if platform == 'win32':
Note: See TracChangeset for help on using the changeset viewer.