提交 e50ae807 编写于 作者: 6 61Duke

fix specification

上级 7b9ce51e
...@@ -11,12 +11,25 @@ ...@@ -11,12 +11,25 @@
# See the Mulan PSL v2 for more details. # See the Mulan PSL v2 for more details.
# Create: 2020-8-1 # Create: 2020-8-1
__all__ = ['ParsePyFiles']
class ParsePyFiles(object): class ParsePyFiles(object):
"""
解析Py文件类
"""
def __init__(self, file_path): def __init__(self, file_path):
"""
读入文件内容
:param file_path:
"""
with open(file_path, 'r') as f: with open(file_path, 'r') as f:
self.content = f.readlines() self.content = f.readlines()
def next(self): def rows_next(self):
"""
遍历每一行内容
:return:
"""
for con in self.content: for con in self.content:
yield con yield con
...@@ -13,11 +13,12 @@ ...@@ -13,11 +13,12 @@
"""Main module.""" """Main module."""
import os import os
from utils import find_all_py_files from utils import find_all_py_files
from parse import ParsePyFiles from parse import ParsePyFiles
transfer_abs_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/tests/test_project/" transfer_abs_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + "/tests/test_project/"
for file_path in find_all_py_files(path=transfer_abs_path): for file_path in find_all_py_files(path=transfer_abs_path):
for row_content in ParsePyFiles(file_path=file_path).next(): for row_content in ParsePyFiles(file_path=file_path).rows_next():
print(row_content) print(row_content)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册