From afd54fcaf79ea13f6838e7f01fbb77bcba143cf7 Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Fri, 8 Nov 2019 23:27:03 +0800 Subject: [PATCH] New distribution [0.3.4] * polished code insertion allocation --- poseur.py | 33 +++++++++++++++++++++++++++++++-- scripts/setup.pypi.py | 2 +- scripts/setup.pypitest.py | 2 +- share/poseur.1 | 2 +- share/poseur.rst | 4 ++-- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/poseur.py b/poseur.py index 82f4f7f..f51379f 100644 --- a/poseur.py +++ b/poseur.py @@ -31,7 +31,7 @@ del multiprocessing # version string -__version__ = '0.3.3' +__version__ = '0.3.4' # from configparser BOOLEAN_STATES = {'1': True, '0': False, @@ -501,6 +501,33 @@ def find_poseur(node, root=0): return -1 +def check_suffix(string): + """Strip comments from string. + + Args: + - `string` -- `str`, buffer string + + Returns: + - `str` -- prefix comments + - `str` -- suffix strings + + """ + prefix = '' + suffix = '' + + lines = iter(string.splitlines(True)) + for line in lines: + if line.strip().startswith('#'): + prefix += line + continue + suffix += line + break + + for line in lines: + suffix += line + return prefix, suffix + + def process_module(node): """Walk top nodes of the AST module. @@ -524,7 +551,9 @@ def process_module(node): if index < postmt: prefix += walk(child) else: - suffix += walk(child) + bufpre, bufsuf = check_suffix(walk(child)) + prefix += bufpre + suffix += bufsuf if postmt >= 0: POSEUR_LINESEP = os.getenv('POSEUR_LINESEP', os.linesep) diff --git a/scripts/setup.pypi.py b/scripts/setup.pypi.py index 4ac5367..03984b4 100644 --- a/scripts/setup.pypi.py +++ b/scripts/setup.pypi.py @@ -15,7 +15,7 @@ long_desc = file.read() # version string -__version__ = '0.3.3' +__version__ = '0.3.4' # set-up script for pip distribution setup( diff --git a/scripts/setup.pypitest.py b/scripts/setup.pypitest.py index 8483067..e597125 100644 --- a/scripts/setup.pypitest.py +++ b/scripts/setup.pypitest.py @@ -15,7 +15,7 @@ long_desc = file.read() # version string -__version__ = '0.3.3' +__version__ = '0.3.4' # set-up script for pip distribution setup( diff --git a/share/poseur.1 b/share/poseur.1 index 4fcc3cc..6538916 100644 --- a/share/poseur.1 +++ b/share/poseur.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH POSEUR 1 "October 29, 2019" "v0.3.3" "" +.TH POSEUR 1 "November 08, 2019" "v0.3.4" "" .SH NAME poseur \- back-port compiler for Python 3.8 positional-only parameter syntax . diff --git a/share/poseur.rst b/share/poseur.rst index 27ed829..5f33de8 100644 --- a/share/poseur.rst +++ b/share/poseur.rst @@ -6,8 +6,8 @@ poseur back-port compiler for Python 3.8 positional-only parameter syntax ------------------------------------------------------------------ -:Version: v0.3.3 -:Date: October 29, 2019 +:Version: v0.3.4 +:Date: November 08, 2019 :Manual section: 1 :Author: Jarry Shaw, a newbie programmer, is the author, owner and maintainer