From d6da33345142b86ee7324b8d1c7ece31e19e23f2 Mon Sep 17 00:00:00 2001 From: Piotr Zierhoffer Date: Wed, 26 Aug 2020 11:00:39 +0200 Subject: [PATCH] Simplify stripping in cell_list generation --- .../skywater_pdk/cell_list.py | 3 +- .../python-skywater-pdk/skywater_pdk/utils.py | 31 ------------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/scripts/python-skywater-pdk/skywater_pdk/cell_list.py b/scripts/python-skywater-pdk/skywater_pdk/cell_list.py index 1c327ad93..0760444d0 100644 --- a/scripts/python-skywater-pdk/skywater_pdk/cell_list.py +++ b/scripts/python-skywater-pdk/skywater_pdk/cell_list.py @@ -23,6 +23,7 @@ import pathlib import pprint import sys +import textwrap from typing import Tuple, List, Dict from utils import indent @@ -121,7 +122,7 @@ def generate_rst(library_dir, library_name, cells): cell_list = cell_list + cell_template.format( cell_name = cell_json['name'], #description = cell_json['description'].replace("\n", "\n "), - description = indent(cell_json['description'], None, ' '), + description = textwrap.indent(cell_json['description'], ' ').lstrip(), type = cell_json['type'], verilog_name = cell_json['verilog_name'] ) diff --git a/scripts/python-skywater-pdk/skywater_pdk/utils.py b/scripts/python-skywater-pdk/skywater_pdk/utils.py index 4d06db19f..165690a70 100644 --- a/scripts/python-skywater-pdk/skywater_pdk/utils.py +++ b/scripts/python-skywater-pdk/skywater_pdk/utils.py @@ -287,37 +287,6 @@ def sortable_extracted_numbers(s): return tuple(o) -def indent(text, initial_indent, subsequent_indent): - """ - >>> indent(None, '-', '*') is None - True - >>> indent('', '-', '*') - '' - >>> indent('a', '- ', '* ') - '- a' - >>> indent('a\\nb\\nc', '- ', '* ') - '- a\\n* b\\n* c' - >>> indent('a\\nb\\nc', '- ', None) - '- a\\nb\\nc' - >>> indent('a\\nb\\nc', None, '* ') - 'a\\n* b\\n* c' - """ - - def prefixed_lines(): - if text is None or len(text) == 0: - return text - s = text.splitlines(True) - yield initial_indent + s[0] - for line in s[1:]: - yield subsequent_indent + line - - if text is None: - return None - initial_indent = initial_indent or '' - subsequent_indent = subsequent_indent or '' - - return ''.join(prefixed_lines()) - if __name__ == "__main__": import doctest doctest.testmod()