用python解壓分析jar包實例
寫這個玩意的背景:在u8多渠道打包里,需要分析jar包,并把里面的文件按目錄和類型分別放在root和assets文件夾里,之前師兄都是手動解壓,一個一個文件夾找文件,效率比較低,剛好最近手上的android項目已經(jīng)做完了,就決定寫一個自動化分析jar文件并復(fù)制粘貼到指定文件夾的腳本。
# -*- coding: utf-8 -*-
import os
import shutil
import zipfile
count = 1
def getSumDir():
sumfilelist = os.listdir(os.getcwd())
for dir in sumfilelist:
if ".idea" not in dir:
classify(dir)
def getlibDir():
sumfilelist = os.listdir(os.getcwd())
for dir in sumfilelist:
if "libs" in dir:
jieyajar(dir)
def jieyajar(dir):
files = os.listdir(dir)
for jars in files:
if "jar" in jars:
zfile = zipfile.ZipFile('libs/' + jars, 'r')
if not os.path.exists(os.getcwd() + '/jarlog/' + jars):
os.makedirs(os.getcwd() + '/jarlog/' + jars)
zfile.extractall(os.getcwd() + '/jarlog/' + jars)
if not os.path.exists(os.getcwd() + '/jars/'):
os.makedirs(os.getcwd() + '/jars/')
zfile.extractall(os.getcwd() + '/jars/')
zfile.close
for file in os.listdir(os.getcwd()):
if "jars" in file:
classify(file)
# def classify(path):
# if os.path.isfile(path):
# if ".class" not in path:
# if "assets" in os.path.dirname(path):
# if not os.path.exists(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path)):
# os.makedirs(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path))
# shutil.copy(path, os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path))
# else:
# if not os.path.exists(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path)):
# os.makedirs(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path))
# shutil.copy(path,os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path))
# else :
# list = os.listdir(path)
# for dir in list:
# classify(path+"/"+dir)
def classify(path):
global count
if os.path.isfile(path):
if ".class" not in path:
if not os.path.exists(os.getcwd() + '/root/' + os.path.dirname(path)):
os.makedirs(os.getcwd() + '/root/' + os.path.dirname(path))
shutil.copy(path, os.getcwd() + '/root/' + os.path.dirname(path))
else:
if 'assets' in path and count == 1:
count = count + 1
shutil.copytree(os.getcwd()+'/'+path, os.getcwd() + '/assets')
elif 'META-INF' not in path:
list = os.listdir(path)
for dir in list:
classify(path + "/" + dir)
# getSumDir()
getlibDir()
嗯,主要就是對文件夾和文件的操作。。
以上這篇用python解壓分析jar包實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- Python爬蟲逆向分析某云音樂加密參數(shù)的實例分析
- Python調(diào)用jar包方法實現(xiàn)過程解析
- Python使用jpype模塊調(diào)用jar包過程解析
- Python代碼一鍵轉(zhuǎn)Jar包及Java調(diào)用Python新姿勢
- python如何使用jt400.jar包代碼實例
- 利用python腳本如何簡化jar操作命令
- Python3 使用cookiejar管理cookie的方法
- python調(diào)用java的jar包方法
- Java實現(xiàn)的執(zhí)行python腳本工具類示例【使用jython.jar】
- 將Python代碼打包為jar軟件的簡單方法
- python 逆向爬蟲正確調(diào)用 JAR 加密邏輯
相關(guān)文章
YOLOv5車牌識別實戰(zhàn)教程(七)實時監(jiān)控與分析
這篇文章主要介紹了YOLOv5車牌識別實戰(zhàn)教程(七)實時監(jiān)控與分析,在這個教程中,我們將一步步教你如何使用YOLOv5進行車牌識別,幫助你快速掌握YOLOv5車牌識別技能,需要的朋友可以參考下2023-04-04
python matplotlib實現(xiàn)雙Y軸的實例
今天小編就為大家分享一篇python matplotlib實現(xiàn)雙Y軸的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-02-02
對Pycharm創(chuàng)建py文件時自定義頭部模板的方法詳解
今天小編就為大家分享一篇對Pycharm創(chuàng)建py文件時自定義頭部模板的方法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-02-02
python內(nèi)置模塊datetime.timedelta計算時間間隔示例代碼
Python的datetime模塊提供了處理日期和時間的功能,包括datetime.date、datetime.time、datetime.datetime、datetime.timedelta等類,timedelta用于表示時間間隔,支持日期和時間的加減運算,文中給出了詳細的代碼示例,需要的朋友可以參考下2025-04-04
基于Python實現(xiàn)一個春節(jié)倒計時腳本
春節(jié)即將到來,本文將為大家介紹一個通過Python實現(xiàn)的春節(jié)倒計時腳本,文中的示例代碼簡潔易懂,感興趣的小伙伴可以自己動手嘗試一下2022-01-01
selenium+headless chrome爬蟲的實現(xiàn)示例
這篇文章主要介紹了selenium+headless chrome爬蟲的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01

