Пример #1
0
def main():
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], "hp:cy",
                                       ["help", "path=", "coffee"])
    except getopt.GetoptError as err:
        print(str(err) + "\n")
        usage()
        sys.exit(2)

    path = None
    coffee = False

    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit(0)
        elif o in ("-p", "--path"):
            path = a
        elif o in ("-c", "--coffee"):
            coffee = True
        else:
            print("\nUnknown argument: " + o + ". Unable to continue.\n\n")
            usage()
            sys.exit(2)

    currentDirectory = os.path.abspath(os.curdir)
    if path is None:
        name, path = queryFromList('Select the path you want compressed?', [
            'Current Directory: [%s]' % currentDirectory,
            'Other [enter custom value]'
        ], [currentDirectory, None])
        if path is None:
            path = queryGeneralValue('Specify the path you want compressed?',
                                     currentDirectory)

    inc = IncludeCompressor(coffee)
    inc.compress(path)

    print("Operation complete.")
Пример #2
0
def main():
    try:
        opts, args = getopt.gnu_getopt(sys.argv[1:], "hp:cy", ["help", "path=", "coffee"])
    except getopt.GetoptError as err:
        print(str(err) + "\n")
        usage()
        sys.exit(2)

    path   = None
    coffee = False

    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit(0)
        elif o in ("-p", "--path"):
            path = a
        elif o in ("-c", "--coffee"):
            coffee = True
        else:
            print("\nUnknown argument: " + o + ". Unable to continue.\n\n")
            usage()
            sys.exit(2)

    currentDirectory = os.path.abspath(os.curdir)
    if path is None:
        name, path = queryFromList(
            'Select the path you want compressed?', [
                'Current Directory: [%s]' % currentDirectory,
                'Other [enter custom value]' ],
            [currentDirectory, None ])
        if path is None:
            path = queryGeneralValue('Specify the path you want compressed?', currentDirectory)

    inc = IncludeCompressor(coffee)
    inc.compress(path)

    print("Operation complete.")
Пример #3
0
    def executeConversion(source =None, srcType =None, targetType =None, target =None, recursive =False):
        types = ['xml', 'json']

        if source is None:
            source = queryGeneralValue('Enter the source file (or path) to convert:')

        if srcType is None and os.path.isfile(source):
            fileType = source.split('.')[-1].lower()
            if fileType in types:
                srcType = fileType

        if srcType is None:
            srcType = queryFromList('Specify source file(s) type:', types)

        if targetType is None:
            targetType = queryFromList('Specify target file(s) type:', types)

        d = DataFormatConverter()
        if os.path.isfile(source):
            d.load(source, srcType)
            d.writeToFile(targetType, target)
        else:
            d.convertDirectory(source, srcType, targetType, recursive)
Пример #4
0
    def executeConversion(source =None, srcType =None, targetType =None, target =None, recursive =False):
        types = ['xml', 'json']

        if source is None:
            source = queryGeneralValue('Enter the source file (or path) to convert:')

        if srcType is None and os.path.isfile(source):
            fileType = source.split('.')[-1].lower()
            if fileType in types:
                srcType = fileType

        if srcType is None:
            srcType = queryFromList('Specify source file(s) type:', types)

        if targetType is None:
            targetType = queryFromList('Specify target file(s) type:', types)

        d = DataFormatConverter()
        if os.path.isfile(source):
            d.load(source, srcType)
            d.writeToFile(targetType, target)
        else:
            d.convertDirectory(source, srcType, targetType, recursive)
Пример #5
0
        elif o in ("-p", "--path"):
            path = a
        elif o in ("-c", "--coffee"):
            coffee = True
        else:
            print "\nUnknown argument: " + o + ". Unable to continue.\n\n"
            usage()
            sys.exit(2)

    currentDirectory = os.path.abspath(os.curdir)
    if path is None:
        name, path = queryFromList(
            'Select the path you want compressed?', [
                'Current Directory: [%s]' % currentDirectory,
                'Other [enter custom value]' ],
            [currentDirectory, None ])
        if path is None:
            path = queryGeneralValue('Specify the path you want compressed?', currentDirectory)

    inc = IncludeCompressor(coffee)
    inc.compress(path)

    print "Operation complete."

####################################################################################################
####################################################################################################

if __name__ == '__main__':
    main()