diff --git a/auto_py2to3/parse/parse.py b/auto_py2to3/parse/parse.py index 18d66bb8b5363d9b5c2391a4c7422ce80a30213d..68d3d7900fc109bf0825fbf3d68fa8b00c187841 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 4bb017b5449b90fc549b0c3503db3debdb618d14..aa08e51a5d2baa6814c6b605054e5526230e0829 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)