Functions | |
def | omitLine |
def | printOut |
def | runRules |
def | splitPaths |
Variables | |
string | __author__ = "Aurelija" |
string | __date__ = "$2010-07-14 16.48.55$" |
list | arg = sys.argv[i] |
tuple | argvLen = len(sys.argv) |
checkPath = checkPath | |
configuration = Configuration | |
createPickle = False | |
createTxt = False | |
tuple | cwd = os.getcwd() |
goodParameters = True | |
help = False | |
html = False | |
int | i = 1 |
picklePath = picklePath | |
printResult = False | |
tuple | result = runRules(ruleNumbers, checkPath) |
ruleNumbers = RULES | |
RULES = rulesNames | |
rules = False | |
txtPath = txtPath |
def cmsCodeRulesChecker::omitLine | ( | lines, | |
line, | |||
regEx = None |
|||
) |
Definition at line 104 of file cmsCodeRulesChecker.py.
00105 : 00106 fileLines = lines 00107 if re.match('^\d+$',line): 00108 xline = int(line)-1 00109 try: 00110 if (not regEx) or (re.search(regEx,fileLines[xline].strip())): 00111 fileLines[xline] = '' 00112 except IndexError: 00113 pass 00114 else: 00115 for i,lineData in enumerate(fileLines): 00116 if re.match(line,str(i)): 00117 lineData = lineData.strip() 00118 if (not regEx) or (re.search(regEx,lineData)): 00119 fileLines[i] = '' 00120 return fileLines
def cmsCodeRulesChecker::printOut | ( | listOfResult, | |
filePath = None |
|||
) |
Definition at line 121 of file cmsCodeRulesChecker.py.
00122 : 00123 file = None 00124 try: 00125 for rule, result in listOfResult: 00126 if filePath: 00127 file = open('%s/cmsCodeRule%s.txt'%(filePath, rule), 'w') 00128 for path, lineNumbers in result: 00129 file.write('%s\n'%path) 00130 file.write('%s\n'%str(lineNumbers)) 00131 file.close() 00132 else: 00133 if not result or result == -1: 00134 print 'No results for rule %s'%rule 00135 else: 00136 print 'Rule %s:' %rule 00137 for path, lineNumbers in result: 00138 print path 00139 print lineNumbers 00140 except TypeError: 00141 print "Error: wrong type of parameter in function printOut"
def cmsCodeRulesChecker::runRules | ( | ruleNumberList, | |
directory | |||
) |
Definition at line 32 of file cmsCodeRulesChecker.py.
00033 : 00034 00035 result = [] 00036 osWalk = [] 00037 00038 for rule in ruleNumberList: 00039 if str(rule) not in RULES: 00040 print 'Error: wrong rule parameter. There is no such rule: "'+rule+'"\n\n' + rulesDescription 00041 print '\nWrite -h for help' 00042 return -1 00043 00044 for rule in configuration.keys(): 00045 configuration[rule]['filter'] = re.compile(configuration[rule]['filter']) 00046 00047 osWalk.extend(os.walk(directory)) 00048 00049 exceptPathsForEachRule = [] 00050 for path in exceptPaths: 00051 exceptPathsForEachRule.append(join(checkPath, path)) 00052 00053 for ruleNr in ruleNumberList: 00054 files = [] 00055 rule = str(ruleNr) 00056 rule = configuration[ruleNr] 00057 00058 filesToMatch = rule['filesToMatch'] 00059 exceptRuleLines = [] 00060 exceptRulePaths = [] 00061 for path in rule['exceptPaths']: 00062 try: 00063 file, line = path.split(":",1) 00064 xline = line 00065 xdata = None 00066 try: 00067 xline, xdata = line.split(":",1) 00068 if not xline: xline = '.*' 00069 except ValueError: 00070 pass 00071 exceptRuleLines.append((pathToRegEx(file), xline,xdata)) 00072 except ValueError: 00073 exceptRulePaths.append(pathToRegEx(path)) 00074 for fileType in filesToMatch: 00075 fileList = getFilePathsFromWalk(osWalk, fileType, exceptPathsForEachRule) 00076 # ------------------------------------------------------------------------------ 00077 for path in exceptRulePaths: 00078 xFileList = [] 00079 for file in fileList: 00080 xFile = file.replace(join(checkPath, ""), "") 00081 if not re.match(path, xFile): 00082 xFileList.append(file) 00083 fileList = xFileList 00084 # ------------------------------------------------------------------------------ 00085 filesLinesList = fileList 00086 if rule['skip']: 00087 for skipper in rule['skip']: 00088 filesLinesList = skipper(filesLinesList) 00089 else: 00090 for i,xFile in enumerate(filesLinesList): 00091 filesLinesList[i]=((xFile,open(xFile).readlines())) 00092 # ------------------------------------------------------------------------------ 00093 for Nr, fileLine in enumerate(exceptRuleLines): 00094 regEx, line, lineEx = fileLine 00095 for index, file in enumerate(fileList): 00096 xFile = file.replace(join(checkPath, ""), "") 00097 if re.match(regEx, xFile): 00098 filesLinesList[index] = (filesLinesList[index][0], omitLine(filesLinesList[index][1], line,lineEx)) 00099 files.extend(filesLinesList) 00100 # ------------------------------------------------------------------------------ 00101 listRule = finds(files, rule['filter'], rule['exceptFilter']) 00102 result.append((ruleNr, splitPaths(listRule, checkPath))) 00103 return result
def cmsCodeRulesChecker::splitPaths | ( | listRule, | |
pathHead | |||
) |
Definition at line 23 of file cmsCodeRulesChecker.py.
string cmsCodeRulesChecker::__author__ = "Aurelija" |
Definition at line 3 of file cmsCodeRulesChecker.py.
string cmsCodeRulesChecker::__date__ = "$2010-07-14 16.48.55$" |
Definition at line 4 of file cmsCodeRulesChecker.py.
list cmsCodeRulesChecker::arg = sys.argv[i] |
Definition at line 159 of file cmsCodeRulesChecker.py.
Referenced by MonitorElementsDb::analyze(), PhysicsTools::AtomicId::build(), Gauss(), HDQMUtil::Gauss(), ConversionFastHelix::helixStateAtVertex(), fit::RootMinuitCommands< Function >::init(), LocalFileSystem::initFSInfo(), mygauss(), funct::NUM(), DQMNet::onPeerConnect(), EMECALShowerParametrization::p(), Args::parse(), optutl::CommandLineParser::parseArguments(), funct::PROD_S(), module::pushswitch(), DQMNet::run(), funct::TEMPL(), and PhysicsTools::MVATrainer::trainFileName().
tuple cmsCodeRulesChecker::argvLen = len(sys.argv) |
Definition at line 153 of file cmsCodeRulesChecker.py.
Definition at line 19 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::configuration = Configuration |
Definition at line 17 of file cmsCodeRulesChecker.py.
Definition at line 146 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::createTxt = False |
Definition at line 147 of file cmsCodeRulesChecker.py.
tuple cmsCodeRulesChecker::cwd = os.getcwd() |
Definition at line 144 of file cmsCodeRulesChecker.py.
Referenced by DQMProvInfo::getShowTags().
Definition at line 152 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::help = False |
Definition at line 149 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::html = False |
Definition at line 148 of file cmsCodeRulesChecker.py.
int cmsCodeRulesChecker::i = 1 |
Definition at line 157 of file cmsCodeRulesChecker.py.
Definition at line 20 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::printResult = False |
Definition at line 154 of file cmsCodeRulesChecker.py.
tuple cmsCodeRulesChecker::result = runRules(ruleNumbers, checkPath) |
Definition at line 218 of file cmsCodeRulesChecker.py.
Definition at line 155 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::RULES = rulesNames |
Definition at line 18 of file cmsCodeRulesChecker.py.
cmsCodeRulesChecker::rules = False |
Definition at line 150 of file cmsCodeRulesChecker.py.
Referenced by L1TdeCSCTF::analyze(), edm::FileLocator::applyRules(), edm::RootInputFileSequence::dropUnwantedBranches_(), and edm::FileLocator::init().
Definition at line 21 of file cmsCodeRulesChecker.py.