def checkPath(path): #------------------------------------------------------------------------------- oss.cd(path) libs = [] covered = set() for i in oss.paths(oss.ls('*.pth')): libs.append(i.name) for line in oss.readf(i): if line.strip().startswith('#'): continue covered.add(line) for i in oss.paths(oss.ls()): if i in covered: continue if i.ext == '.py': libs.append(i.name) if oss.IsDir(i): if oss.exists(i + '/__init__.py'): libs.append(i.name) return libs
def main(argv): #------------------------------------------------------------------------------- # # handle options # args, opts = oss.gopt(argv[1:], [('u', 'unittest'), ('m', 'main')], [('t', 'target'), ('f', 'file')], usage) if opts.main: if opts.file is None: opts.file = "makefile" mf = file(opts.file, "w") print >> mf, TOP mf.close() oss.exit(0) if opts.target is None: MAIN = MSMAIN EXE = MSEXE if opts.file is None: opts.file = "mak.inc" # # create the file # mf = file(opts.file, "w") print >> mf, MAIN t_objs = [] if opts.unittest: for f in oss.paths(args): hdrs, objs = GetObjectObjs(f) t_objs.extend(objs) else: t_objs = args print t_objs for f in oss.paths(t_objs): print "f:", f hdrs, objs = GetObjectObjs(f) objs.remove(f) oo = [] for o in oss.paths(objs): oo.append("%s.obj" % o.drive_path_name) ff = f.drive_path_name print >> mf, "#\n# %s\n#" % (ff) print >> mf, EXE % (ff, f, ' '.join(hdrs), f, ff, ' '.join(oo), ff, ff, ff, f, " ".join(hdrs), ff, f, ff) mf.close() oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- """ usage: compilexrc [options] <xrc_file> options: -d | --dialog : generate dialog code (default) -a | --app : generate application code -f | --frame : generate frame code -w | --wizard : generate wizard code -p | --panel : generate panel code -m | --mixin : import mixin file, name = <xrc_file>_mixin.py """ args, opts = oss.gopt(argv[1:], [('a', 'app'), ('w', 'wizard'), ('d', 'dialog'), ('m', 'mixin'), ('p', 'panel'), ('f', 'frame')], [], __doc__ + main.__doc__) if not args: oss._usage(1, "must supply xrc file(s)") if opts.app: tflag = 'APP' elif opts.wizard: tflag = 'WIZ' elif opts.dialog: tflag = 'DLG' elif opts.panel: tflag = 'PNL' elif opts.frame: tflag = 'APP' else: tflag = None for infn in oss.paths(args): fn = infn.name xrc = XRCParser(infn, fn) xrc.compileXrc(tflag, opts.mixin) oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- """ usage: tester <files to test> run an automated test against the specified python files. The files must have one or more functions with '__test__' embedded somewhere in the function name. """ args, opts = oss.gopt(argv[1:], [('v', 'verbose')], [('p', 'package')], main.__doc__) pkg = '' if opts.package is None else opts.package + '.' tried = failed = 0 for a in oss.paths(args): try: print("%-20s" % a, end='') t = test_it(pkg + a.name, opts.verbose) print(" %d tests" % t) tried += t except TesterException: print("failed") failed += 1 print("\nRan %d tests. %d Failed\n" % (tried, failed), file=oss.stderr) if failed: oss.exit(1) oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- """ usage: cvtimage -t <type> file [file ...] converts one or more image files to the specified image file type types include: jpg : jpeg bmp : bitmaps png : gif : (input only) """ args, opts = oss.gopt(argv[1:], [], [('t', 'type')], main.__doc__) if opts.type is None: opts.usage(1, "must specify type") args = oss.paths(args) for a in args: otfn = a.drive_path_name + '.' + opts.type if otfn != a: try: print "Converting", a, "to", otfn Image.open(a).save(otfn) except IOError: print >> oss.stderr, "Cannot convert", a, "to", otfn oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- args, opts = oss.gopt(argv[1:], [], [], usage) cvsdwn = not CvsRootCheck() for f in oss.paths(args): ext = oss.splitext(f).lower() opts = '-kb' if ext in BinExts else '' if cvsdwn: otf = file('CVS/offline', 'a') print >> otf, 'add ' + opts + ' ' + f otf.close() else: if oss.exists('CVS/offline'): inf = file('CVS/offline') for cmd in inf: oss.r('cvs.exe ' + cmd) inf.close() oss.rm('CVS/offline') oss.r('cvs.exe add ' + opts + ' ' + f) oss.exit(0)
def pull(db, args): #------------------------------------------------------------------------------- for a in oss.paths(args): nm = a.name_ext pth = db.get(nm) fpath = pth + '/' + nm print('pulling "%s" -> "%s' % (a, fpath)) src = DIR + nm if not oss.exists(src): print("%s does not exist" % src) continue if oss.exists(fpath): ch = raw_input('overwrite "%s": (Y/n): ' % fpath) if ch == 'n': continue else: print('overwritten') db.rm(nm) oss.cp(src, fpath)
def main(argv): #------------------------------------------------------------------------------- """ usage: diskusage [options] [path] calculates the bytes used by the sub directories of the specified path. defaults to the current directory options: -d | --dir_only : show directories only -p | --progress : show progress -x | --exclude : specifiy path to be excluded (can be issued multiple times) """ args, opts = oss.gopt(argv[1:], [('p', 'progress'), ('d', 'dir_only')], [], [], [('x', 'exclude')], main.__doc__) if not args: args = ['.'] if opts.exclude: global gExcludes gExcludes = [oss.canonicalPath('./' + x) for x in opts.exclude] print('Excludes:', gExcludes) for pth in oss.paths(args): for ss in sizeDir(pth, opts.dir_only, opts.progress): print("%8s" % util.CvtGigMegKBytes(ss.size, "1.1"), ss.pth) oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- """ usage: """ args, opts = oss.gopt(argv[1:], [], [], main.__doc__) for a in oss.paths(args): if not oss.exists(a): continue pth = a.fpath nm = a.name print(pth, nm) oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- global gFileName, gOutFile, gOpts args, opts = oss.gopt(argv[1:], [('g', 'go')], [], usage) args = oss.paths(args) gOpts = opts for a in args: if a.ext == '': gFileName = a + '.myc' else: gFileName = a gOutFile = file(a.name + '.mcpp', 'wU') yacc.parse(file(gFileName).read(), debug=1) print "\n" print 'types:', types print 'comments:', gComments gOutFile.close() oss.exit(0)
def push(db, args): #------------------------------------------------------------------------------- for a in oss.paths(args): print('pushing "%s"' % a) pth = a.fpath nm = a.name_ext if not oss.exists(a): print('"%s" does not exist' % a) continue dest = DIR + nm if oss.exists(dest): print("warning: saved %s exists" % nm) ch = raw_input("overwrite: (Y/n): ") if ch == 'n': continue else: print('overwritten') print(nm, pth) db.put(nm, pth) oss.cp(a, DIR)
def clean(db, args): #------------------------------------------------------------------------------- for k in oss.paths(args): print('cleaning "%s"' % k) db.rm(k.name_ext)
def main(argv): #------------------------------------------------------------------------------- """ usage: mycvs [cmd] [...] wrapper around cvs to make it work better to include some offline support cmd: online only: create [directory] - create a new archive from directory or current directory co <archive name> - checkout the specified archive ci [dir_file [dir_file ...]] - checkin file or directories or current dir up [dir_file [dir_file ...]] - update file or directories or current dir cfd <file_name> - compare file to top of truck showing diffs cf [dir_file [dir_file ...]] - check for actions needed for file or directory sync - sync the archive to the directory (cleanup deleted files etc) online or offline: add <file_name or directory name> - adds the file or directory to archive certain extensions are treated as binary rm <file_name> - removes the file both from the archive and directory cff [dir [dir ...] - recursively checks directories for files that aren't part of the archive decvs - remove the CVS directories """ args, opts = oss.gopt(argv[1:], [('F', 'force'), ('p', 'inPlace'), ('N', 'noIgnore'), ('b', 'binary')], [('d', 'dir'), ('m', 'msg')], main.__doc__) cmd = args[0] args = oss.paths(args[1:]) cvs = CVS(opts.dir) cvs.Connect() if cmd == 'create': cvs.create(args, opts) elif cmd == 'check' or cmd == 'cf': cvs.check(args, opts) elif cmd == 'ci': cvs.ci(args, opts) elif cmd == 'up': cvs.update(args, opts) elif cmd == 'rm': cvs.rm(args, opts) elif cmd == 'add': cvs.add(args, opts) elif cmd == 'co': cvs.co(args, opts) elif cmd == 'cff': cvs.cff(args, opts) elif cmd == "cfd": cvs.fdiff(args, opts) elif cmd == 'decvs': cvs.decvs(args, opts) elif cmd == 'sync': cvs.sync(args, opts) oss.exit(0)
def main(argv): #------------------------------------------------------------------------------- """ usage: crlf [options] <file> [<file> ...] options: -i | --identify : identify line ending in file (default) -w | --win : convert line endings to windows -u | --unix : convert line ending to unix -m | --mac : convert line endings to mac converts line endings in a file to the specifed type """ args, opts = oss.gopt(argv[1:], [('w', 'win'), ('u', 'unix'), ('m', 'mac'), ('i', 'identify')], [], main.__doc__) if not args: opts.usage(1, "must specify files") src = r"\r|\n|\r\n" if opts.identify: mode = "id" elif opts.mac: mode = "mac" dest = "\r" elif opts.unix: mode = "unix" src = r"\r?\n" dest = "\n" elif opts.win: mode = "win" dest = "\r\n" else: mode = "id" for fName in oss.paths(args): if oss.IsDir(fName): print(fName, "Directory!") continue oss.cp(fName, BUFILE) with open(fName, "rb") as inf: data = inf.read() if '\0' in data: print(fName, "Binary!") continue if mode == "id": if re.search(r"[^\r]\n", data): res = 'unix' elif re.search(r"\r\n", data): res = 'win' elif re.search(r"\r[^\n]", data): res = 'mac' else: res = 'unkn' print('{0} -> {1}'.format(fName, res)) else: newdata = re.sub(src, dest, data) if newdata != data: with open(TMPFILE, 'wb') as f: f.write(newdata) oss.cp(TMPFILE, fName) print(fName) oss.exit(0)