Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

修复python3.8运行环境下的执行问题 #1401

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cobra/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ def __init__(self, absolute_path):
"""

def collect_files(self):
t1 = time.clock()

version = sys.version

if version[:3] == '3.7':
t1 = time.clock()
else:
t1 = time.perf_counter()
self.files(self.absolute_path)
self.result['no_extension'] = {'count': 0, 'list': []}
for extension, values in self.type_nums.items():
Expand All @@ -197,7 +203,10 @@ def collect_files(self):
self.result['no_extension']['list'].append(f)
if self.result['no_extension']['count'] == 0:
del self.result['no_extension']
t2 = time.clock()
if version[:3] == "3.7":
t2 = time.clock()
else:
t2 = time.perf_counter()
# reverse list count
self.result = sorted(self.result.items(), key=lambda t: t[0], reverse=False)
return self.result, self.file_sum, t2 - t1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ requests==2.20.0
pytest==3.0.6
pip==9.0.1
phply==1.0.0
Werkzeug==0.15.3
Werkzeug==0.15.5
ConcurrentLogHandler==0.9.1
23 changes: 23 additions & 0 deletions tests/test_pickup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

"""
tests.pickup
~~~~~~~~~~~~

Tests cobra.pickup

:author: banbooboo <1798736436@qq.com>
:homepage: https://github.com/WhaleShark-Team/cobra
:license: MIT, see LICENSE for more details.
:copyright: Copyright (c) 2018 Feei. All rights reserved
"""

from cobra.pickup import Directory
import os

def test_vulnerabilities():


dt =Directory(os.path.dirname(__file__)+"/vulnerabilities")

assert dt.collect_files()