示例#1
0
文件: cvs_add.py 项目: chyser/bin
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)
示例#2
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)
示例#3
0
def getType(opt, archive, args=None):
#-------------------------------------------------------------------------------
    """ determines the type of archive
    """

    ext = oss.splitext(archive)

    if opt.zip or ext == '.zip':
        archtype = 'zip'
    elif opt.tgz or ext == '.tgz' or archive.endswith('.tar.gz'):
        archtype = 'tgz'
    elif archive.endswith('.tar.bz2'):
        archtype = 'tbz'
    else:
        if args and (len(args) > 1 or oss.IsDir(args[0])):
            if opt.gzip or ext == '.gz':
                archtype = 'tgz'
            elif opt.bzip or ext == '.bz2':
                archtype = 'tbz'
            else:
                return
        else:
            if opt.gzip or ext == '.gz':
                archtype = 'gz'
            elif opt.bzip or ext == '.bz2':
                archtype = 'bz'
            else:
                return

    return archtype
示例#4
0
文件: mycvs.py 项目: chyser/bin
    def add(self, args, opts):
    #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        """ adds the specified files or directories to CVS archive (possible
            offline)

            @type  args: sequence
            @param args: sequence of files or directories to add
        """

        for fn in args:
            if opts.noIgnore is None:
                if self.ignoreFile(oss.basename(fn)):
                    continue

            ext = oss.splitext(fn).lower()
            if opts.binary:
                cvsopts = ' -kb '
            else:
                cvsopts = ' -kb ' if ext in self.BinExts else ''
            self._issueCmd(' add ' + cvsopts + fn)
示例#5
0
文件: beautify.py 项目: chyser/bin
def main(argv):
    #-------------------------------------------------------------------------------
    """ usage: beautify.py [options] <file_name> [<file_name> ...]

        options:
            -f | --force   : force overwrite of the backup file

        beautifies python and eventually c/cpp code
    """
    args, opts = oss.gopt(argv[1:], [('f', 'force')], [], main.__doc__)

    for f in args:
        ext = oss.splitext(f)
        if ext == '.py':
            DoPython(f, opts.force)

        elif ext in set(['.c', '.cpp', '.h', '.cxx', '.hxx', '.java']):
            d = CppDoer()
            d.run(f, opts.force)

    oss.exit(0)
示例#6
0
文件: beautify.py 项目: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: beautify.py [options] <file_name> [<file_name> ...]

        options:
            -f | --force   : force overwrite of the backup file

        beautifies python and eventually c/cpp code
    """
    args, opts = oss.gopt(argv[1:], [('f', 'force')], [], main.__doc__)

    for f in args:
        ext = oss.splitext(f)
        if ext == '.py':
            DoPython(f, opts.force)

        elif ext in set(['.c', '.cpp', '.h', '.cxx', '.hxx', '.java']):
            d = CppDoer()
            d.run(f, opts.force)

    oss.exit(0)
示例#7
0
def checkFile(f, exts):
#-------------------------------------------------------------------------------
    if not exts:
        return True
    return oss.splitext(f) in exts
示例#8
0
文件: copyit.py 项目: chyser/bin
def main(argv):
#-------------------------------------------------------------------------------
    """ usage: copyit <options>

        options
            -o | --once  : run through loop once and then halt
            -d | --dest  : specify detination directory
            -s | --src   : specifly source directory
    """
    args, opts = oss.gopt(argv[1:], [('o', 'once')], [('d', 'dest'), ('s', 'src')], main.__doc__)

    if opts.dest is None:
        opts.dest = getDir(DEST_DIRS)

    if opts.src is None:
        opts.src = getDir(SRC_DIRS)

    if not oss.exists(opts.dest):
        opts.usage(1, "Destination dir '%s' doesn't exist" % opts.dest)

    if not oss.exists(opts.src):
        opts.usage(1, "Source dir '%s' doesn't exist" % opts.src)

    print("Destination:", opts.dest)
    print("Source:", opts.src)
    oss.cd(opts.src)

    destDirName = opts.dest + ''.join(map(lambda s: "%02d" % s, time.localtime()[:6]))
    print("Making", destDirName)
    oss.mkdir(destDirName)

    xfrc = XferFileClass()

    id = fileCount = idx = 0
    doneMsg = False
    while 1:
        done = True

        files = oss.ls()
        if not files:
            if not doneMsg:
                print('\n--- All files Done ---')
            doneMsg = True
        else:
            doneMsg = False

        for ef in files:
            if oss.isDir(ef):
                continue

            ext = oss.splitext(ef)

            ## mozzilla
            if ext in IGNORE_EXTENSIONS:
                continue

            fn = destDirName + '/%08d' % (id) + ext
            fs = xfrc.xferFile(ef,  fn)

            if fs:
                print('  xfer: %s <-- %s, %d' % (fn, ef, fs))
                fileCount += 1
            else:
                done = False

            id += 1

        if done and opts.once:
            break


        ch = util.delayKey(DELAY_TIME)
        if ch in ['q', 'Q']:
            break

        elif ch == 'x':
            pprint.pprint(xfrc.xfers)

        elif ch == 'p':
            print('pausing')
            while util.delayKey(1000) == None:
                pass
            print('\npausing stopped')

        idx += 1

        if idx > 30:
            idx = 0
            xfrc.bad = set()

    if fileCount == 0:
        print("Removing unused directory '%s'" % destDirName)
        oss.rmdir(destDirName)
    else:
        print("Copied %d files" % fileCount)

    print('Bad Files:', xfrc.bad)