#! python: #w#VIC idtests - dictionary of internal tests ID might run - user definable # # Copyright 2003 by Timothy Rue <3seas@threeseas.net> # # VIC idtests dictionary: version 0.5.1.python # idtests.py is used by the ID command # # EXCEPT FOR SPECIFICALLY NOTED user defined test(s), and ONLY for such # noted user defined test(s)... # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation version 2 # of the License. http://www.gnu.org/copyleft/gpl.html # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Or access http://www.gnu.org/copyleft/gpl.html # ############################################################################## # August 25, 2003 split this section away from the id.py code so to better # isolate the id.py code away from user editing of test distionary, as well as # allow for any differing licensing of any individual test(s) # ############################################################################## # TO ADD a test function simply define the test function and add it to the # "internal_tests dictionary" with the name you want to give it, as to be used # in .id files, followed by the defined test function name. Also add any # modules you need to the import statement, if not aklready there. Also # optionally comment the beginning of each test with a line that begins with # "#s#-- " so to maintain IQ parseability of this file. Thanks, T.Rue ############################################################################## #w#import system modules used in tests import os, os.path, sys #w#Internal test functions ################################################### #s#-- Test whether a file exists ----------------------------------------------# def test_exists(filename): return os.path.exists(filename) #s#-- Test whether a file is an LHA archive -----------------------------------# def test_is_lha(filename): result = 0 file = open(filename, 'r') data = file.read(7) if len(data) == 7: # LHA header: ??-lh?- if data[2:5] == '-lh' and data[6] == '-': result = 1 file.close() return result #s#dictionary of internal test functions internal_tests = { 'exists' : test_exists, 'is_lha' : test_is_lha }