温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么用python解压分析jar包

发布时间:2021-04-25 14:20:55 来源:亿速云 阅读:317 作者:小新 栏目:开发技术

小编给大家分享一下怎么用python解压分析jar包,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

Python主要用来做什么

Python主要应用于:1、Web开发;2、数据科学研究;3、网络爬虫;4、嵌入式应用开发;5、游戏开发;6、桌面应用开发。

代码如下:

# -*- 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包”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI