国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

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

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ù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Appendix之setup.py:附錄文件內(nèi)容記錄setup.py
如何判斷文件或目錄是否存在(python)
python sys.path
python中os操作文件及文件路徑實例匯總
Python文件操作
python實現(xiàn)代碼行數(shù)統(tǒng)計
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服