def test_04_SearchByExtension(self): """4:Test searching by file extension.""" res = find.find(start="_test", ext="py") self.failUnless(map(filename, res) == ['file2.py'], "did not find file2.py") res = find.find(start="_test", ext='text') self.failUnless(map(filename, res) == ["file1.txt"], "did not find file1.txt")
def test_02_SearchFileName(self): """2:Test searching for specific file by regexp.""" res = find.find(r"file", start="_test") self.failUnless(map(filename, res) == ['file1.txt', 'file2.py'], 'wrong results') res = find.find(r"py$", start="_test") self.failUnless(map(filename, res) == ['file2.py'], 'Python file search incorrect')
def test_03_SearchByContent(self): """3:Test searching by content.""" res = find.find(start="_test", content="first") self.failUnless(map(filename, res) == ['file1.txt'], 'did not find file1.txt') res = find.find(where="py$", start="_test", content="line") self.failUnless(len(res) == 0, "found something that did not exist")
def makeStuffDataAndPack(): # pkg step print '--publish server luascript--' updateAllScript() pkg_cmd = pkg_maker + ' -p ' + work_data_path + ' ' + work_data_path + ' ' + (game_data_path + 'stuff.dat') + ' ' + pkgexclude_file os.system( pkg_cmd ) copys(work_data_path + 'script/res/*.lua', game_data_path + 'script/res/') print '--publish proxy server --' copys(work_proxy_path + '*.py', game_proxy_path) copys(work_proxy_path + 'qqsdk/*.py', game_proxy_path+'qqsdk/') print '--publish server dll exe--' #copys(work_bin_path + '*.dll', game_bin_path ) copys(work_bin_path + '*.so', game_bin_path ) #copys(work_bin_path + '*.xml', game_bin_path ) copys(work_bin_path + '*.exe', game_bin_path ) print '--tar pack.tar--' tar = tarfile.open(tmp_base_path + "pack.tar", "w") tar.add(game_data_path + 'stuff.dat') for name in find.find('*.*', game_bin_path): tar.add(name) for name in find.find('*.*', game_proxy_path): tar.add(name) for name in find.find('*.*', game_data_path + 'script/res/'): tar.add(name) tar.close()
def main(): """Get user input to either add movie to collection, view entire collection, find movie from collection, or enter 'Q' to quit program. object: dict1 is the dictionary the movie collection is stored in. :return: """ user_command = (input("Enter 'A' to add a movie to collection\n" "Enter 'V' to view entire collection\n" "Enter 'F' to find a movie from collection\n" "Enter 'Q' to quit\n")).lower() # Continue looping through until user quits program while user_command in {'v', 'a', 'f'}: # if user input is 'a' call add function from add module and pass in dict1 if user_command == 'a': add(dict1) # if user input is 'v' call view function from view module and pass in dict1 elif user_command == 'v': view(dict1) # if user input is 'f' call find function from find module and pass in dict1 elif user_command == 'f': find(dict1) user_command = (input("Enter 'A' to add a movie to collection\n" "Enter 'V' to view entire collection\n" "Enter 'F' to find a movie from collection\n" "Enter 'Q' to quit\n")).lower()
def testSearchByContent(self): '''test searching by content''' res = find.find(start='_test', content='first') self.assertEqual(map(filename, res), ['file1.txt']) res = find.find(where='py$', start='_test', content='line') self.assertEqual(map(filename, res), ['file2.py']) res = find.find(where='py$', start='_test', content='second') self.assertEqual(len(res), 0)
def test_03_SearchByContent(self): """ 3: Test searching by content. """ res = find.find(start="_test", content="first") self.failUnless(map(filename, res) == ["file1.txt"], "didn't find file1.txt") res = find.find(where="py$", start="_test", content="line") self.failUnless(map(filename, res) == ["file2.py"], "didn't find file2.py") res = find.find(where="py$", start="_test", content="second") self.failUnless(len(res) == 0, "found something that didn't exist")
def count(string, l): word = string c = 0 index = find(word, l) while index >= 0: index = find(word, l, index+1) c += 1 print(c)
def test_04_SearchByExtension(self): '''4:Test searching by for extension.''' res = find.find(start="_test", ext='py') self.failUnless( map(filename, res) == ['file2.py'], "didn't find file2.py") res = find.find(start="_test", ext='txt') self.failUnless( map(filename, res) == ['file1.txt'], "didn't find file1.txt")
def test_04_SearchByExtension(self): """ 4: Poszukiwanie z u¿yciem rozszerzenia pliku. """ res = find.find(start="_test", ext='py') self.failUnless( map(filename, res) == ['plik2.py'], "nie znaleziono plik2.py") res = find.find(start="_test", ext='txt') self.failUnless( map(filename, res) == ['plik1.txt'], "nie znaleziono plik1.txt")
def test_03_SearchByContent(self): '''3:Test searching by content.''' res = find.find(start='_test', content="first") self.failUnless( map(filename, res) == ['file1.txt'], "didn't find file1.txt") res = find.find(where="py$", start='_test', content='line') self.failUnless( map(filename, res) == ['file2.py'], "didn't find file2.py") res = find.find(where="py$", start='_test', content='second') self.failUnless(len(res) == 0, "found something that didn't exist")
def test_03_SearchByContent(self): """ 3: Poszukiwanie wed³ug zawartoœci. """ res = find.find(start="_test", content="pierwszy") self.failUnless( map(filename, res) == ['plik1.txt'], "nie znaleziono plik1.txt") res = find.find(where="py$", start="_test", content="wiersz") self.failUnless( map(filename, res) == ['plik2.py'], "nie znaleziono plik2.py") res = find.find(where="py$", start="_test", content="drugi") self.failUnless(len(res) == 0, "znaleziono coœ, co nie istnieje")
def test_02_SearchFileName(self): """ 2: Poszukiwanie pliku z u¿yciem wyra¿eñ regularnych. """ res = find.find(r"file", start="_test") self.failUnless( map(filename, res) == ['plik1.txt', 'plik2.py'], 'niepoprawne wyniki') res = find.find(r"py$", start="_test") self.failUnless( map(filename, res) == ['plik2.py'], 'nieudane poszukiwanie pliku Pythona')
def test_find_iterative(self): assert find("bob", "bob") == True assert find("BOB", "bob") == True assert find("bobcat", "bob") == True assert find("boBcat", "bob") == True assert find("catbob", "bob") == True assert find("catbob", "BoB") == True assert find("bocatboocatbobcatbo", "bob") == True assert find("akjdajbadabbokajdkabobobkajdn", "bob") == True assert find("ajdjadajaxjuenjxad", "ajax") == True
def main(argv): _parseargs(argv) def want_h5(b, d, i): return b == 'Data.h5' subdir = '.DATA' extent, path, antibody = [getattr(PARAM, a) for a in 'extent path antibody' .split()] # if extent == 'plate': # ncrmode = bool(int(argv[3])) if nargs > 3 else False # else: # ncrmode = _scrape_ncrmode(path, antibody) param = PARAM if extent == 'plate': def mode(path, wells, antibody): modes = map(partial(_scrape_ncrmode, antibody=antibody), [op.join(path, w) for w in wells]) if all(modes): return True else: assert all(map(notop, modes)) return False q = [(sum([list(find(op.join(path, w), want_h5)) for w in c], []), _dimspec(mode(path, z, antibody), **param.__dict__), op.join(path, subdir, antibody, ','.join(c))) for c, z in getcontrols(path)] else: ncrmode = _scrape_ncrmode(path, antibody) assert extent == 'well' q = [(find(path, want_h5), _dimspec(ncrmode, **param.__dict__), op.join(path, subdir, antibody))] for paths, param, basedir in q: data, warnings = extractdata(paths, param) processed, rawheaders = process(data, param) preamble = makepreamble(rawheaders, warnings) dir_ = op.join(basedir, param.readout) mkdirp(dir_) dump(dir_, transpose_map(dict(data=processed, preamble=preamble))) return 0
def parse_line(sen,count): totranslate=[] k=[] k2={} dic={} for word in ' '.join(sen.split('\n')).split(' '): if find(words,clean(word))==0: k+=[clean(word)] if len(k)==0: return [sen,[]] else: par=detect(sen) for key in par: k2[clean(key)]=par[key] for key in k: if key in k2: dic[key]='{'+str(count)+'}' totranslate+=[(key,k2[key])] count+=1 l=sen.split('\n') sen=' '.join(l) l=sen.split(' ') for i in range(len(l)): word=clean(l[i]) if word in dic: l[i]+='<font color="#ff0000">'+dic[word]+'</font>' sen=' '.join(l) return [sen,totranslate]
def create_makefiles(here): Makefile = """ # Makefile automatically generated. SCONS := $(shell which scons) SCONSOPTS := -Q%s all: @$(SCONS) $(SCONSOPTS) clean: @$(SCONS) $(SCONSOPTS) -c distclean: -rm -rf build .scon* -find . -name Makefile -exec rm -f '{}' \; """ from find import find for f in find(here): try: if f.endswith('SConscript'): makefile = os.path.join( os.path.dirname(f), 'Makefile') print "creating %s"%makefile fp = open(makefile, 'w') fp.write(Makefile%(' -u')) if f.endswith('SConstruct'): makefile = os.path.join( os.path.dirname(f), 'Makefile') print "creating %s"%makefile fp = open(makefile, 'w') fp.write(Makefile%('')) except Exception, e: print 'Error:'+str(e) sys.exit(2)
def find_samplesheet(run_dir): """ Finds the samplesheet in the run dir """ matches = find.find(search_dir=run_dir, inclusion_patterns=['SampleSheet.csv'], search_type="file") return (matches)
def find_samples_fastqs(sample_IDs, fastq_dir, search_level=None): """ Matches the supplied sample IDs to .fastq.gz files in the directory Parameters ---------- sample_IDs: list a list of the ``str`` sample IDs to search for fastq_dir: str path to the directory to search for sample fastq.gz files search_level: int number of directories deep to search, or ``None`` Returns ------- list a list of dicts with information on the samples and their fastq files Notes ----- Omits any supplied samples that did not have fastq files """ samples_fastqs = [] for sample_ID in sample_IDs: sample_pattern = '{0}*'.format(sample_ID) all_sample_fastqs = sorted( find.find(search_dir=fastq_dir, inclusion_patterns=[sample_pattern, '*.fastq.gz'], search_type='file', level_limit=search_level, match_mode="all")) # dont return entries without fastq files if len(all_sample_fastqs) < 1: continue R1_fastqs = [ x for x in find.multi_filter(names=all_sample_fastqs, patterns=["*_R1_*.fastq.gz"], match_mode="all") ] R2_fastqs = [ x for x in find.multi_filter(names=all_sample_fastqs, patterns=["*_R2_*.fastq.gz"], match_mode="all") ] sample_dict = { 'sample': sample_ID, 'fastq-all': all_sample_fastqs, # ','.join(all_sample_fastqs), 'fastq-R1': R1_fastqs, #','.join(R1_fastqs), 'fastq-R2': R2_fastqs #','.join(R2_fastqs) } samples_fastqs.append(sample_dict) validate_samples_fastqs(samples_fastqs=samples_fastqs)
def clean(): """Remove all compiled opcode cache files (*.pyc).""" count = 0 for pycfile in find("./", r"^[a-zA-Z0-9_]+\.(?:pyc|pyo)$"): print("Removing %s" % pycfile) remove(pycfile) count += 1 print("-" * 78) print("%d files has been removed." % count)
def lintdir(directory_name): """lint all files recursively in directory""" from find import find print "\n\nrecursively linting %s\n\n" % directory_name (pyg, context) = setup() python_files = find("*.py", directory_name) for x in python_files: print "\n\n [ %s ]\n\n" % x lint(open(x).read(), pyg, context) print "\014"
def lintdir(directory_name): """lint all files recursively in directory""" from find import find print "\n\nrecursively linting %s\n\n" % directory_name (pyg, context) = setup() python_files = find("*.py", directory_name) for x in python_files: print "\n\n [ %s ]\n\n" % x lint( open(x).read(), pyg, context ) print "\014"
def find_RunParametersxml(run_dir): """ """ matches = find.find(search_dir=run_dir, inclusion_patterns=['RunParameters.xml'], search_type="file", num_limit=1, level_limit=1, match_mode="all") return (matches)
def search(path, file_pattern, content_pattern): """Start to find""" files = find(path, file_pattern, True) for file in files: i = 0 opened_file = open(file) for line in opened_file.readlines(): i = i + 1 if re.search(content_pattern, line): print(file, "line", i)
def id_handler(bot: Bot, update: Update, user_data: dict): if find.find(update.message.text): user_data[ID] = update.message.text update.message.reply_text( "Please choose your academic level", reply_markup=get_academic_level() ) return LEVEL else: return ID
def prejoin(): f=find(r'\.xlsx',os.path.abspath(os.curdir))[0] for i in f: print('='*5) print('bookName:',i.split(os.sep)[-1]) shtli=ox.load_workbook(i).sheetnames print('sheets:',shtli) for j in shtli: print('\t','sheetName:',j) print('\t'*2,'sheetCols:',pd.read_excel(i,sheet_name=j).columns) print('-'*5)
def test_rand(self): def findSOLVEIT(n): result = 0 for i in range(3,n+1): if i%3==0 or i%5==0: result += i return result for cwtests in range(0,96): num = randint(1,100000) result = findSOLVEIT(num) self.assertEqual(find(num), result)
def pep8(): """Check the project's coding style according to PEP 8.""" modules = " ".join(find(".", r"^[a-zA-Z0-9_]+\.py$")) print("\n", "-" * 78, sep="") with popen("pep8 --statistics --count %s" % modules) as sh: result = sh.read() if not result: print("The project through the PEP8 check.") else: print(result, file=stderr) print("-" * 78)
def handler(): if len(sys.argv) > 1: # myDict init if sys.argv[1] == 'init': init.initialize() # myDict add elif sys.argv[1] == 'add' or sys.argv[1] == '-a': add.add() elif sys.argv[1] == 'show' or sys.argv[1] == '-s': # myDict show if len(sys.argv) == 2: show.showAllCategories() elif len(sys.argv) == 3: # myDict show all if sys.argv[2] == 'all': show.showAll() # myDict show <category> else: show.showItemsInCategory(sys.argv[2]) # myDict show <category> <name> elif len(sys.argv) == 4: show.showItem(sys.argv[2], sys.argv[3]) # myDicy help elif sys.argv[1] == 'help' or sys.argv[1] == '-h': help.help() # myDict find <item> elif sys.argv[1] == 'find' or sys.argv[1] == '-f': find.find(sys.argv[2]) # myDict export elif sys.argv[1] == 'export' or sys.argv[1] == '-e': if len(sys.argv) == 2: # myDict export all if sys.argv[2] == 'all': export.exportAll() # myDict export <category> else: export.exportSelectedItem()
def do_find(self, command): """Find papers from the paperdir iota> find query:"test" sortfield:year reverse:True maxnum:50 """ c = parse_command(command) try: sexps = find(self.database, **c) except TypeError as e: raise e else: self.print_sexp(sexps)
def search_image_for_unit(haystack, unit: api.Unit) -> List[LocationBox]: """ Loading (reading) the image takes ~0.004 seconds (20x less after caching). Simplifying an image takes ~0.0001 seconds. """ # unit_icon_path = f"icons-simple-24/{unit.name.replace(' ', '')}_simple.png" if not os.path.isfile(unit.iconPath): logging.warning(f"Can't open file {unit.iconPath}.") return unit_image = simplify_image(cv2.imread(unit.iconPath)) return find(unit_image, haystack)
def test_find_iterative_with_pattern_not_in_string(self): assert find("bo", "bob") == False assert find("bocat", "bob") == False assert find("catob", "bob") == False assert find("bocatboocatbocatbo", "bob") == False assert find("akjdajbadabbokajdkaboobkajdn", "bob") == False assert find("ajdjadajajuenjxad", "ajax") == False
def get_runs(seq_dir): """ Gets the available runs from the parent sequencer data output directory """ run_dirs = find.find(search_dir=seq_dir, exclusion_patterns=[ 'to_be_demultiplexed', 'automatic_demultiplexing_logs', 'run_index', '*_test*', '*_run_before_sequencing_done' ], search_type='dir', level_limit=0) return (run_dirs)
def search(btn): term = app.getEntry('search') exact = app.getCheckBox("exact") listin = [] files = [f for f in listdir(mypath) if isfile(join(mypath, f))] if(exact): print(term) for f in files: if(find(mypath+"/"+f,term)): if f not in listin: listin.append(f) else: terms = term.split() print(terms) for t in terms: for f in files: if(find(mypath+"/"+f,t)): if f not in listin: listin.append(f) app.updateListItems("list_in", listin)
def copyAllScriptsAndPack(): print '--publish server all luascript files--' updateAllScript() copys(work_data_path + 'script/*.lua', game_data_path + 'script/') safeMakeDir(game_data_path + 'script/res/') safeMakeDir(game_data_path + 'script/com/') safeMakeDir(game_data_path + 'script/npctalks/') copys(work_data_path + 'script/res/*.lua', game_data_path + 'script/res/') copys(work_data_path + 'script/com/*.lua', game_data_path + 'script/com/') copys(work_data_path + 'script/npctalks/*.lua', game_data_path + 'script/npctalks/') os.chdir( game_data_path ) os.system('rm ' + game_data_path + 'stuff.dat') os.system('rm ' + tmp_base_path + 'pack.tar') tar = tarfile.open(tmp_base_path + "pack.tar", "w") tar.add(game_data_path + 'stuff.dat') for name in find.find('*.*', game_bin_path): tar.add(name) for name in find.find('*.*', game_proxy_path): tar.add(name) for name in find.find('*.*', game_data_path + 'script/'): tar.add(name) tar.close()
def get_files(): allfiles = find.find('*.java') files=[] for file in allfiles: if string.find(string.lower(file),'test') >= 0: continue fh = open(file) # check first two lines for copyright found=0 line = string.lower(string.strip(fh.readline())) if string.find(line,'copyright')>=0: found=1 line = string.lower(string.strip(fh.readline())) if string.find(line,'copyright')>=0: found=1 if not found: files.append(file) fh.close() return files
def get_files(): allfiles = find.find('*.java') files = [] for file in allfiles: if string.find(string.lower(file), 'test') >= 0: continue fh = open(file) # check first two lines for copyright found = 0 line = string.lower(string.strip(fh.readline())) if string.find(line, 'copyright') >= 0: found = 1 line = string.lower(string.strip(fh.readline())) if string.find(line, 'copyright') >= 0: found = 1 if not found: files.append(file) fh.close() return files
def find_path(self): filt = find("t") st, _, _ = depth_first_search(self.graph, "s", filter=filt) if "t" not in st: return None else: path = [] sink = "t" # build up path from spanning tree returned from dfs while sink != "s": src = st[sink] new_edge = (src, sink, self.graph.edge_weight((src, sink))) path.insert(0, new_edge) sink = src return path
def grepThreadProducer(self, filenamepatt, dirname, grepkey, encoding, myqueue): from find import find matches = [] try: for filepath in find(pattern=filenamepatt, startdir=dirname): try: textfile = open(filepath, encoding=encoding) for (linenum, linestr) in enumerate(textfile): if grepkey in linestr: msg = '%s@%d [%s]' % (filepath, linenum+1, linestr) matches.append(msg) except UnicodeError as X: print('Unicode Error in: ', filepath, X) except IOError as X: print('IE Error in: ', filepath, X) finally: myqueue.put(matches)
def find_path(graph, source): filt = find("t") st, po, _ = depth_first_search(graph, source, filter=filt) # no path from s -> source -> t exists if "t" not in st or not graph.has_edge(("s", source)): return None else: # construct path from st (spanning tree) path = [] sink = "t" while sink != source: src = st[sink] new_edge = (src, sink, graph.edge_weight((src, sink))) path.insert(0, new_edge) sink = src source_edge = ("s", source, graph.edge_weight(("s", source))) path.insert(0, source_edge) return path
def test_05_SearchByLogic(self): """ 5: Test searching using a logical combination callback. """ res = find.find(start="_test", logic=lambda x: (x["size"] < 50)) self.failUnless(map(filename, res) == ["file1.txt"], "failed to find by size")
#!/usr/bin/python # Using the standard find method to look for GIF files. import sys, find if len(sys.argv) > 1: dirs = sys.argv[1:] else: dirs = [ '.' ] # Go for it. for dir in dirs: files = find.find('*.gif', dir) if files: print "For", dir + ':' for fn in files: print " ", fn else: print "For", dir + ': None'
def test_04_SearchByExtension(self): """ 4: Test searching by file extension. """ res = find.find(start="_test", ext="py") self.failUnless(map(filename, res) == ["file2.py"], "didn't find file2.py") res = find.find(start="_test", ext="txt") self.failUnless(map(filename, res) == ["file1.txt"], "didn't find file1.txt")
def test_01_SearchAll(self): """ 1: Test searching for all files. """ res = find.find(r".*", start="_test") self.failUnless(map(filename, res) == ["file1.txt", "file2.py"], "wrong results")
def test_02_SearchFileName(self): """ 2: Test searching for specific file by regexp. """ res = find.find(r"file", start="_test") self.failUnless(map(filename, res) == ["file1.txt", "file2.py"], "wrong results") res = find.find(r"py$", start="_test") self.failUnless(map(filename, res) == ["file2.py"], "Python file search incorrect")
def _path_iter(path, test): def wanted(basename, dirname, isdir): return isdir and test(basename) return find(path, wanted)
########################################################### # find and delete all "*.pyc" bytecode files at and below # the directory where this script is run; this uses a # Python find call, and so is portable to most machines; # run this to delete .pyc's from an old Python release; # cd to the directory you want to clean before running; ########################################################### import os, sys, find # here, gets PyTools find count = 0 for file in find.find("*.pyc"): # for all file names count = count + 1 print file os.remove(file) print 'Removed %d .pyc files' % count
def test_find_py(self): # expected 652 matches find("/home/synd/Books-solutions/Python-For-Everyone-Horstmann", "pyc")
def test_find_txt(self): # expected 1 match find("/home/synd/Books-solutions/Python-For-Everyone-Horstmann", "txt")
logger = logging.getLogger("app") logger.setLevel(logging.DEBUG) def set_logging(debug): ch = logging.StreamHandler() if debug: ch.setLevel(logging.DEBUG) else: ch.setLevel(logging.INFO) ch.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")) logger.addHandler(ch) def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--value", type=int, required=True, metavar="n", help="hash value of solution string") parser.add_argument("-l", "--length", type=int, required=True, metavar="n", help="length of solution string") parser.add_argument("-d", "--debug", action="store_true", help="set logging level to debug") args = parser.parse_args() return args if __name__ == "__main__": args = parse_args() set_logging(args.debug) logger.info("starting") s = find(args.value, args.length) print("\n\nSoultion: '{}'\n\n".format(s)) logger.info("done")
# with "from PP2E.PyTools import find" (or add PP2E\PyTools # to your path setting and just "import find"); this script # takes 4 seconds total time on my 650mhz Win98 notebook to # run 10 finds over a directory tree of roughly 1500 names; ############################################################ import sys, os, string for dir in sys.path: if string.find(os.path.abspath(dir), 'PyTools') != -1: print 'removing', repr(dir) sys.path.remove(dir) # else may import both finds from PyTools, '.'! import find # get deprecated builtin (for now) import PP2E.PyTools.find # later use: from PP2E.PyTools import find print find print PP2E.PyTools.find assert find.find != PP2E.PyTools.find.find # really different? assert string.find(str(find), 'Lib') != -1 # should be after path remove assert string.find(str(PP2E.PyTools.find), 'PyTools') != -1 startdir = r'C:\PP2ndEd\examples\PP2E' for pattern in ('*.py', '*.html', '*.c', '*.cgi', '*'): print pattern, '=>' list1 = find.find(pattern, startdir) list2 = PP2E.PyTools.find.find(pattern, startdir) print len(list1), list1[-1] print len(list2), list2[-1] print list1 == list2,; list1.sort(); print list1 == list2
import find # find all JPEG files in or beneath the current directory for file in find.find("*.jpg", "."): print file ## .\samples\sample.jpg
# -*- coding: utf-8 -*- """ Created on Sat Jun 25 21:00:45 2016 @author: wei """ import os,sys,find count= 0 for filename in find.find('*.pyc',sys.argv[1]): count+=1 print(filename) os.remove(filename) print('Remove %d .pyc files '% count)
def run(*options): """Runs nose tests in isolation, and aggregates the coverage reports :param directory: directory in which to run the nose tests """ options = list(options) directory = DEFAULT_DIRECTORY xunit_file_dir = DEFAULT_XUNIT_FILE_DIR for option in copy(options): if option.startswith('--xunit-file-dir='): options.remove(option) xunit_file_dir = option[option.index('=') + 1:] elif option.startswith('--directory='): options.remove(option) directory = option[option.index('=') + 1:] if not os.path.exists(xunit_file_dir): sys.stderr.write('Xunit file directory "%s" does not exist!\n') sys.stderr.flush() sys.exit(1) current_working_directory = os.getcwd() found_tests = [test for test in find(directory)] succeeded = 0 if found_tests: print 'Found %d tests' % len(found_tests) for number, test in enumerate(found_tests): test_number = number + 1 sys.stdout.write('Running test #%d "%s"...' % (test_number, test)) sys.stdout.flush() xunit_filename = os.path.join(xunit_file_dir, XUNIT_FILE_NAME_FORMAT % {'number': test_number}) process = subprocess.Popen(['nosetests', test, COVER_OPTION, XUNIT_OPTION, '--xunit-file=%s' % xunit_filename] + options, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if process.wait(): sys.stdout.write(FAIL_MESSAGE) sys.stdout.flush() else: sys.stdout.write(OK_MESSAGE) sys.stdout.flush() if os.path.exists(COVERAGE_FILE): os.rename(COVERAGE_FILE, '.coverage.%d' % test_number) succeeded += 1 else: sys.stdout.write(ERROR_MESSAGE) sys.stdout.flush() sys.stderr.write('Cannot find coverage file\n') sys.stderr.flush() sys.stdout.write('%d of %d tests passed\n' % (succeeded, len(found_tests))) sys.stdout.write('Combining coverage data...') sys.stdout.flush() process = subprocess.Popen(['coverage', 'combine'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if process.wait(): sys.stdout.write(ERROR_MESSAGE) sys.stdout.flush() sys.stderr.write(process.stderr.read()) sys.stderr.flush() sys.exit(1) else: sys.stdout.write(OK_MESSAGE) sys.stdout.flush() else: print 'Did not find any tests to run'
def main(): global use_final, dryrun, pathoption, thisProg, verbose optlist, makefiles = getopt.getopt(sys.argv[1:], 'vhp:n', [ 'version', 'verbose', 'path=', 'help', 'no-final']) for option, param in optlist: if option == '--version': print "\n" print thisProg + "$Revision: 1.1.1.1 $" print "This is really free software, unencumbered by the GPL." print "You can do anything you like with it except sueing me." print "Copyright 1998 Kalle Dalheimer <kalle\@kde.org>" print "Concept, design and unnecessary questions about perl" print " by Matthias Ettrich <ettrich\@kde.org>" print "" print "Making it useful by Stephan Kulow <coolo\@kde.org> and" print "Harri Porten <porten\@kde.org>" print "Updated (Feb-1999), John Birch <jb.nz\@writeme.com>" print "Current Maintainer Stephan Kulow" sys.exit(0) if option == '--verbose' or option == '-v': verbose = 1 if option == '-p' or option == '--path': thisProg = param + "/" + thisProg if (not posixpath.exists(thisProg)): sys.stderr.write(thisProg + " doesn't exist\n") pathoption=1 if option == '--help' or option == '-h': print "Usage " + thisProg + " [OPTION] ... [dir/Makefile.in]..." print "Patches dir/Makefile.in generated from automake" print "(where dir can be a full or relative directory name)" print " -v, --verbose verbosely list files processed" print " -h, --help print this help, then exit" print " --version print version number, then exit" print " -p, --path= use the path to am_edit if the path" print " --no-final don't patch for --enable-final" print " called from is not the one to be used" sys.exit(0) if option == '--no-final': use_final = 0 if option == '-n': dryrun = 1 if not use_final: thisProg = thisProg + " --no-final" if thisProg[0] == '/' and not pathoption: sys.stderr.write( "Illegal full pathname call performed...\n" "The call to \"" + thisProg + "\"\n" "would be inserted in some Makefile.in.\n" "Please use option --path.\n") sys.exit(1) if len(makefiles) == 0: import find makefiles = find.find('Makefile.in') for index in range(len(makefiles)): if not makefiles[index][0] == '/': makefiles[index] = os.path.normcase(os.path.abspath(makefiles[index])) makefiles.sort() for file in makefiles: makefile = Makefile(file) try: makefile.initialize() makefile.tag_automake() makefile.finalTouch() makefile.writeback() except Makefile.NoMakefileAmFound, param: if verbose: print Makefile.NoMakefileAmFound + ' in ' + param
sub_dir = ctree.root sub_name = sub_dir.value.split('/') sub_name = sub_name[-1] deltas = stack() while(True): command = raw_input("\n/"+sub_name+" Command: ") command = command.split() if(command == []): continue if(command[0] == "f"): if(len(command) < 2): print("Give Search Parameter") else: print(find(command[1], ctree)) elif(command[0] == "fa"): if(len(command) < 2): print("Give Search Parameter") else: temp = find_dir(command[1], ctree.root) if(temp == None): print("Not Found") else: print(temp) elif(command[0] == "fd"): if(len(command) < 2): print("Give Searh Parameter") else: temp = find_dir(command[1], sub_dir) if(temp == None): print("Not Found")