Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderWanFeng committed Sep 8, 2022
2 parents cc9a114 + 1049a88 commit cb95569
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 2 deletions.
7 changes: 6 additions & 1 deletion office/api/testApi/ruiming.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ def screen_unmarked_image(dir_path):

@except_dec()
def change_label_in_xml(dir_path, old_label, new_label):
ruiming.change_label_in_xml(dir_path, old_label, new_label)
ruiming.change_label_in_xml(dir_path, old_label, new_label)


@except_dec()
def screen_without_label_json_file(dir_path):
ruiming.screen_without_label_json_file(dir_path)
20 changes: 20 additions & 0 deletions office/core/TestTypes/RuimingType.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib
import shutil
import xml.etree.ElementTree
import json


class MainRuiming():
Expand Down Expand Up @@ -69,3 +70,22 @@ def change_label_in_xml(self, dir_path, old_label, new_label):
xml_file.write(str(file), encoding="utf-8")
else:
print("请输入正确的路径!")

def screen_without_label_json_file(self, dir_path):
dir_path = pathlib.Path(dir_path).resolve()
if dir_path.is_dir():
print("正在筛选无标签内容的json文件")
without_label_json_storage_path = dir_path.joinpath("无标签json文件")
self.__make_dir(dir_path, "无标签json文件")
dir_path_file_list = list(dir_path.iterdir())
for file_name in dir_path_file_list:
if file_name.is_file() and file_name.suffix == ".json":
json_file = open(file_name, "r")
json_file_text = json.load(json_file)
json_file.close()
if json_file_text["shapes"] == []:
shutil.move(dir_path.joinpath(file_name.name),
without_label_json_storage_path.joinpath(file_name.name))
print("筛选完成")
else:
print("路径输入有误,请检查!")
34 changes: 34 additions & 0 deletions tests/test_files/json/1.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/10.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/11.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/12.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/148.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/15.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_files/json/152.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion tests/test_ruiming.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from office.api.testApi.ruiming import screen_unmarked_image, change_label_in_xml
from office.api.testApi.ruiming import screen_unmarked_image, change_label_in_xml, screen_without_label_json_file


class TestExcel(unittest.TestCase):
Expand All @@ -9,3 +9,7 @@ def test_screen_unmarked_image(self):

def test_change_label_in_xml(self):
change_label_in_xml(dir_path=r".\xml", old_label="测试", new_label="测试1")

def test_screen_without_label_json_file(self):
screen_without_label_json_file(dir_path="./test_files/json")
# 预期结果:除1.json外均被移动到”无标签json文件“文件夹中

0 comments on commit cb95569

Please sign in to comment.