From e50ae80781fe612a0533eb17abd4c8df615cc63a Mon Sep 17 00:00:00 2001 From: 61Duke Date: Sun, 16 Aug 2020 15:34:20 +0800 Subject: [PATCH] fix specification --- auto_py2to3/parse/parse.py | 15 ++++++++++++++- auto_py2to3/py2to3.py | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/auto_py2to3/parse/parse.py b/auto_py2to3/parse/parse.py index 18d66bb..68d3d79 100644 --- a/auto_py2to3/parse/parse.py +++ b/auto_py2to3/parse/parse.py @@ -11,12 +11,25 @@ # See the Mulan PSL v2 for more details. # Create: 2020-8-1 +__all__ = ['ParsePyFiles'] + class ParsePyFiles(object): + """ + 解析Py文件类 + """ def __init__(self, file_path): + """ + 读入文件内容 + :param file_path: + """ with open(file_path, 'r') as f: self.content = f.readlines() - def next(self): + def rows_next(self): + """ + 遍历每一行内容 + :return: + """ for con in self.content: yield con diff --git a/auto_py2to3/py2to3.py b/auto_py2to3/py2to3.py index 4bb017b..aa08e51 100644 --- a/auto_py2to3/py2to3.py +++ b/auto_py2to3/py2to3.py @@ -13,11 +13,12 @@ """Main module.""" import os + from utils import find_all_py_files from parse import ParsePyFiles 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 row_content in ParsePyFiles(file_path=file_path).next(): + for row_content in ParsePyFiles(file_path=file_path).rows_next(): print(row_content) -- GitLab