示例#1
0
def uncompress_data(compressed_dir):
    import uncompress

    parser = uncompress.get_parser()
    args, _ = parser.parse_known_args()
    args.ipdir = compressed_dir
    args.opdir = os.path.dirname(compressed_dir) + "_uncompressed"
    uncompress.main(args)
    return args.opdir
示例#2
0
except ValueError:
    pass

try:
    options, args = getopt.getopt(argv, 'hf:m:', ['help', 'file=', 'method='])
except getopt.GetoptError:
    usage()

for name, value in options:
    if name in ('-h', '--help'):
        usage()
    if name in ('-f', '--file'):
        file = value
    if name in ('-m', '--method'):
        method = value
        if method not in methods:
            usage()

if 'x' in command or 'u' in command:
    from uncompress import main
    fin = '/dev/stdin' if archive is None else archive
    fout = '/dev/stdout' if file is None else file
elif 'c' in command or 'm' in command:
    from compress import main
    fin = '/dev/stdin' if file is None else file
    fout = '/dev/stdout' if archive is None else archive
else:
    usage()
fin, fout = open(fin, 'rb'), open(fout, 'wb')
main(fin, fout, method)