<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

__version__ = "1.0"
__revision__ = '1.2.1'
__author__ = "Tzeng, Yi-Feng"
__authorcontact__ = "<EMAIL>"
__website__ = "http://antbsd.twbbs.org/"

import sys
import zipfile
import os
import getopt
import shutil

DEFAULT_ENCODING = 'cp936'

def usage():
    print """usage: unzip.py [-l] <zipfile> [[-e <encoding>] -p <password>]
    <zipfile> is the source zipfile to extract
    <encoding> is the encoding of zipfile
    <password> is the password of zipfile

    -h: help
    -l: list files only
    long options also work:
    --verbose
    --encoding
    --password
    --list 
    """

def get_filename(fileinfo, encoding):
    """
    Return Values:
    	return filename on success or None otherwise
    """
    if encoding == None:
        return fileinfo.filename
    try:
        filename = unicode(fileinfo.filename, encoding)
    except TypeError:
        filename = fileinfo.filename
    except:
        #print "ERROR: unknown encoding (" + encoding + ")"
        filename = None
    return filename
    
def get_zipinfo_unicode(fileinfo, encoding=None):
    assert fileinfo != None
    filename = get_filename(fileinfo, encoding)
    file_size = fileinfo.file_size
    compress_size = fileinfo.compress_size
    crc_value = fileinfo.CRC
    date_time = fileinfo.date_time
    fileinfo_dict = {"filename": filename, "file_size": file_size, "compress_size": compress_size, "datetime": date_time}
    return fileinfo_dict
    pass

def pretty_datetime(datetime):
    return str(datetime[0]).zfill(2) + "-" + str(datetime[1]).zfill(2) + "-" + str(datetime[2]).zfill(2) + " " + str(datetime[3]).zfill(2) + ":" + str(datetime[4]).zfill(2) + ":" + str(datetime[5]).zfill(2)
    
ZIPINFO_DESC = "{:>10}  {:>10}   {:>10}  FILE_NAME".format("压缩后", "解压后", "时间")
    
def zipinfo_prettify(fileinfo, encoding=None):
    infos = get_zipinfo_unicode(fileinfo, encoding)
    keys = ['filename', 'compress_size', 'file_size', 'datetime']
    info_str = ''
    for key in keys[1:]:
        if key == 'datetime':
            s = pretty_datetime(infos[key])
        else:
            s = str(infos[key])
        info_str += "{:>10}  ".format(s)
    info_unicode = info_str
    info_unicode = unicode(info_str, "ascii") + unicode("\t", "ascii") + infos['filename']
    return info_unicode

def main():
    shortargs = 'hel:p:'
    longargs = ['help', 'encoding=', 'password=', 'list']

    if len(sys.argv) < 2:
        usage()
        sys.exit(0)

    try:<commit_msg>clean some obselete infomation and change `list` option in English<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import zipfile
import os
import getopt
import shutil

DEFAULT_ENCODING = 'cp936'

def usage():
    print """usage: unzip.py [-l] <zipfile> [[-e <encoding>] -p <password>]
    <zipfile> is the source zipfile to extract
    <encoding> is the encoding of zipfile
    <password> is the password of <PASSWORD>

    -h: help
    -l: list files only
    long options also work:
    --verbose
    --encoding
    --password
    --list 
    """

def get_filename(fileinfo, encoding):
    """
    Return Values:
    	return filename on success or None otherwise
    """
    if encoding == None:
        return fileinfo.filename
    try:
        filename = unicode(fileinfo.filename, encoding)
    except TypeError:
        filename = fileinfo.filename
    except:
        #print "ERROR: unknown encoding (" + encoding + ")"
        filename = None
    return filename
    
def get_zipinfo_unicode(fileinfo, encoding=None):
    assert fileinfo != None
    filename = get_filename(fileinfo, encoding)
    file_size = fileinfo.file_size
    compress_size = fileinfo.compress_size
    crc_value = fileinfo.CRC
    date_time = fileinfo.date_time
    fileinfo_dict = {"filename": filename, "file_size": file_size, "compress_size": compress_size, "datetime": date_time}
    return fileinfo_dict
    pass

def pretty_datetime(datetime):
    return str(datetime[0]).zfill(2) + "-" + str(datetime[1]).zfill(2) + "-" + str(datetime[2]).zfill(2) + " " + str(datetime[3]).zfill(2) + ":" + str(datetime[4]).zfill(2) + ":" + str(datetime[5]).zfill(2)
    
ZIPINFO_DESC = "{:>10}  {:>10}  {:>10}  FILE_NAME".format("Compressed", "Real", "Datetime")
    
def zipinfo_prettify(fileinfo, encoding=None):
    infos = get_zipinfo_unicode(fileinfo, encoding)
    keys = ['filename', 'compress_size', 'file_size', 'datetime']
    info_str = ''
    for key in keys[1:]:
        if key == 'datetime':
            s = pretty_datetime(infos[key])
        else:
            s = str(infos[key])
        info_str += "{:>10}  ".format(s)
    info_unicode = info_str
    info_unicode = unicode(info_str, "ascii") + unicode("\t", "ascii") + infos['filename']
    return info_unicode

def main():
    shortargs = 'hel:p:'
    longargs = ['help', 'encoding=', 'password=', 'list']

    if len(sys.argv) < 2:
        usage()
        sys.exit(0)

    try:
{'fraction_non_alphanumeric': 0.14579138139347564, 'fraction_numerical': 0.011880789367700362, 'mean_word_length': 3.0880658436213992, 'pattern_counts': {'":': 12, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '579621', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1638, 'n_words': 403}