def master_range_finder(self, quiet=False): #Find all db files in the rfiles directory and compile ranges into best_ranges self.safe_print("master_range_finder() combining ranges", quiet) #Only needs run once - compiles best ranges from the passed rfiles list if self.master_ranges_found: return DT_list = [] #Get the rfiles from the repository with dR.cd("%s/%s" % (self.rfile_path, self.rfile_directory)): #Set up dctTools for ranges in provided rfiles for db in self.rfiles: DT_temp = dR.dctTools({}) DT_temp.range_reader(str(db), append=False) DT_list.append(DT_temp) master_DT = dR.dctTools({}) self.master_ranges = master_DT.get_best_ranges(*DT_list) self.master_ranges_found = True
def range_organizer(self, index, quiet=False): #Read and write ranges to the fileTools inst according to user setup current_DT = dR.dctTools(self.master_tree_dct[index]) sister_db = self.master_file_dct[index].sister_db #Read in range files to populate master_tree_dct with dR.cd("%s/%s" % (self.rfile_path, self.rfile_directory)): self.master_tree_dct[index] = current_DT.range_reader(sister_db, append=True) self.safe_print("file_organizer(%i) reading range file %s" % (index, sister_db), quiet )
htemp.SetTitle(n_s) integral = htemp.Integral() htemp.Write() self.safe_print("File %s:TTree %s: Subleaf %s[%i] was written" % \ (index, i_tree, br_name, i), quiet) #DEBUG if self.debug and i > 20: break self.hout.Close() # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - parse_class = BM_TxtParser(Options) input_dct = parse_class.read_in_dct(options.input) dR.dctTools(input_dct).printer() #------------------------------------------------------------------------------------ #Instatiate OptionsClass try: shutil.rmtree("test_output") except: pass my_options = Options(input_dct, batch_path, rfile_path, rootfile_path) #Comparator(my_options, debug=True).execute()
dct[current_cmd] = [line[1]] else: dct[current_cmd].append(line[1]) return dct # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Script Region if __name__ == "__main__": parser = OptionParser() parser.add_option("-i", "--input", dest="input", help="Batch request file, .txt", type="string") (options, args) = parser.parse_args() mydct = TxtParser(ExeLines).read_in_dct(options.input) print "Your input batch options:" dR.dctTools(mydct).printer() ExeLines(mydct, batch_path, rfile_path, rootfile_path) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import unittest import shutil class TestBatchMake(unittest.TestCase): """Barrage of tests for output management in the user's environment""" def __init__(self): # Determine that all files are here before testing test_files = ["batch_test.txt", "BatchMake.py"]