小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

oday 壓縮文件解壓工具------python版 - 獨木的日志 - 網(wǎng)易博客

 weicat 2011-03-29

oday 壓縮文件解壓工具------python版

python 2007-04-04 14:03:39 閱讀76 評論0   字號: 訂閱

原來使用batch來調(diào)用WinRAR,解壓oday 壓縮文件,總是有些問題。后來學(xué)習(xí)python,就將程序改了一下,修正一些bug。

#!/usr/bin/python
# -*- coding: UTF-8 -*-

#  demo of the usage of python
#
#
#

"""Test code

Suggested usage: import MyUnrar
"""
__decription__ = "Batch Unrar Kit"
__version__ = "0.1"
__date__ = " Mar.28th.2007"
__author__ = "hu <huys03@gmail.com> "
__license__ = "Licensed under the GPLv2, see the file LICENSE in this tarball."
__copyright__= "Copyright (C) 2007 by hu <huys03@gmail.com>."

from time import sleep
import string
import os
from os.path import join, getsize, abspath, exists, splitext

__WinRAR__="C:\\Program Files\\WinRAR\\WinRAR.exe"

exec_rar= '\"'+__WinRAR__ + '\"'
urar_chm =""" IF EXIST *.rar """ + exec_rar +"""  e -o- -y *.rar *.chm """
urar_pdf = """IF EXIST *.rar """ + exec_rar + """  e -o- -y *.rar *.pdf"""

class MyUnrar:
###
    def __init__ (self, path=os.getcwd()):
        self.path = path
        self.count = 0

###
    def checkRAR(self):
        if exists(__WinRAR__):
            print "WinRAR is OK!"       
        else:
            print "WinRAR is not there!"
       
   
###
    def unrar(self):
        print self.count
        for f in os.listdir( self.path ) :
            (filename, ext) = splitext(f)
            if ext.lower() == ".zip":
                command =exec_rar + ' e -o- -y ' + f + ' *.r*'
                os.system( command )
               
            if ext.lower() == ".rar":
                os.system( urar_chm )
                os.system( urar_pdf )
        self.count = self.count + 1
       
    def unrar(self, path):
        print self.count
        for f in os.listdir( path ) :
            (filename, ext) = splitext(f)
            if ext.lower() == ".zip":
                command =exec_rar +' e -o- -y ' + path + '\\' + f + ' *.r*'
            #    print command
                os.system( command )
               
            if ext.lower() == ".rar":
                os.system( urar_chm )
                os.system( urar_pdf )
        self.count = self.count + 1
       
    def deleteRAR(self):
        for f in os.listdir( self.path ) :
            (filename, ext) = splitext(f)
            if ext.lower().find(".r") != -1:
                os.remove(f)
               
###
    def run(self):
        print "==============================="
        print __decription__
        print 'version:', __version__
        print __license__
        print __copyright__
        print "==============================="
        self.checkRAR();

        for root, dirs, files in os.walk( self.path ):
            for name in dirs:
                    fullpath = join(root, name)
                    print fullpath
                    self.unrar(fullpath)
                    os.system( urar_chm )
                    os.system( urar_pdf )
                    self.deleteRAR()

       
       
###
if __name__=="__main__":
    ur = MyUnrar()
    ur.run()
    sleep(5)

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多