def main4(sfd,func_pool,arg,file_path='.dat'): """ This function write data produced by servise function in its own file. TODO: describe all tests as documentation for further displaying.For example This func: 1 ....do something............... 2 ....do something............... ................... sfd -- dictionary of sorted files for reading """ for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file(sfd):#read data from files for fun in func_pool: try: # Create file's object from function's attribute that stores path to writing file func_file = open(fun.my_file,'a') func_file.write(fun(**arg)+'') func_file.close() except: # Create file, write head string and first line f_test1 = open(fun.__name__ + '.dat','w') f_test1.write('This is head of %s\n\n'%fun.__name__) f_test1.write(fun(**arg)+'') f_test1.close() # Attach file's name as function attribute fun.__setattr__('my_file' ,fun.__name__ + file_path) print 'File name is %s'%fun.my_file
def main4(sfd, func_pool, arg, file_path='.dat'): """ This function write data produced by servise function in its own file. TODO: describe all tests as documentation for further displaying.For example This func: 1 ....do something............... 2 ....do something............... ................... sfd -- dictionary of sorted files for reading """ for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file( sfd): #read data from files for fun in func_pool: try: # Create file's object from function's attribute that stores path to writing file func_file = open(fun.my_file, 'a') func_file.write(fun(**arg) + '') func_file.close() except: # Create file, write head string and first line f_test1 = open(fun.__name__ + '.dat', 'w') f_test1.write('This is head of %s\n\n' % fun.__name__) f_test1.write(fun(**arg) + '') f_test1.close() # Attach file's name as function attribute fun.__setattr__('my_file', fun.__name__ + file_path) print 'File name is %s' % fun.my_file
def main3(func_pool,arg): """ This function extract data from list of files, number of files and number of lines in file and pass theirs as arguments to pool of function. """ # Get dictionary of binary files sfd = sort_file_dict(test_path['main_fun']) for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file(sfd):#read data from files for fun in func_pool: print 'I am %s'%fun.__name__ print fun(**arg),'\n'
def main3(func_pool, arg): """ This function extract data from list of files, number of files and number of lines in file and pass theirs as arguments to pool of function. """ # Get dictionary of binary files sfd = sort_file_dict(test_path['main_fun']) for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file( sfd): #read data from files for fun in func_pool: print 'I am %s' % fun.__name__ print fun(**arg), '\n'
def main2(): """ This is the second part of main function which separate tupels of arguments for functions according fuctions. vargs -- list of tuples with arguments """ # Get dictionary of binary files sfd = sort_file_dict(test_path['main_fun']) for f, r, l in line_from_file(sfd):#read data from files func_args = {'test1':(f,),'test2':(f,r),'test3':(f,r,l)} for fun, arg in zip(func_pool,func_args): print 'I am %s'%fun.__name__ print fun(*func_args[fun.__name__]),'\n'
def main2(): """ This is the second part of main function which separate tupels of arguments for functions according fuctions. vargs -- list of tuples with arguments """ # Get dictionary of binary files sfd = sort_file_dict(test_path['main_fun']) for f, r, l in line_from_file(sfd): #read data from files func_args = {'test1': (f, ), 'test2': (f, r), 'test3': (f, r, l)} for fun, arg in zip(func_pool, func_args): print 'I am %s' % fun.__name__ print fun(*func_args[fun.__name__]), '\n'
def main(): """ """ for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file(sfd):#read data from files for fun in func_pool: try: # Create file's object from function's attribute that stores path to writing file func_file = open(fun.my_file,'a') func_file.write(fun(**arg)+'') func_file.close() except: # Create file, write head string and first line f_test1 = open(fun.__name__ + '.dat','w') f_test1.write('This is head of %s\n\n'%fun.__name__) f_test1.write(fun(**arg)+'') f_test1.close() # Attach file's name as function attribute fun.__setattr__('my_file' ,fun.__name__ + file_path) print 'File name is %s'%fun.my_file
def main(): """ """ for arg['arg1'], arg['arg2'], arg['arg3'] in line_from_file( sfd): #read data from files for fun in func_pool: try: # Create file's object from function's attribute that stores path to writing file func_file = open(fun.my_file, 'a') func_file.write(fun(**arg) + '') func_file.close() except: # Create file, write head string and first line f_test1 = open(fun.__name__ + '.dat', 'w') f_test1.write('This is head of %s\n\n' % fun.__name__) f_test1.write(fun(**arg) + '') f_test1.close() # Attach file's name as function attribute fun.__setattr__('my_file', fun.__name__ + file_path) print 'File name is %s' % fun.my_file