From 2208cb99e8a9a60cfd648a719ceb9d47d8d1e1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@ericsson.com> Date: Mon, 12 Aug 2024 22:25:27 +0200 Subject: [PATCH] remove satella --- MANIFEST.in | 1 - snakehouse/requirements.py | 2 +- snakehouse/satella.py | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index fae74cb..95e8138 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include LICENSE include README.md include CONTRIBUTORS.md -include snakehouse/templates/*.mako include requirements.txt diff --git a/snakehouse/requirements.py b/snakehouse/requirements.py index 4fce3ee..dd317fd 100644 --- a/snakehouse/requirements.py +++ b/snakehouse/requirements.py @@ -1,7 +1,7 @@ import typing as tp import warnings -from satella.files import read_lines, find_files +from .satella import read_lines, find_files def find_pyx(directory_path: str) -> tp.List[str]: diff --git a/snakehouse/satella.py b/snakehouse/satella.py index 636288a..0803644 100644 --- a/snakehouse/satella.py +++ b/snakehouse/satella.py @@ -67,6 +67,23 @@ def find_files(path: str, wildcard: str = r'(.*)', if re.match(wildcard, fn_path): yield _cond_join(prefix_with, filename) +def read_lines(path: str, delete_empty_lines: bool = True, + encoding: str = 'utf-8') -> tp.List[str]: + """ + Read lines from a particular file, removing end-of-line characters and optionally + empty lines. Additionally whitespaces (and end-of-line characters) will be removed + from both ends of each line. + + :param path: path of file to read + :param delete_empty_lines: set to False if empty lines are not to be removed + :param encoding: encoding to read the file with + :return: each line as a separate entry + """ + with codecs.open(path, 'r', encoding) as f_in: + lines = [line.strip() for line in f_in.readlines()] + if delete_empty_lines: + lines = [line for line in lines if line] + return lines def split(path: str) -> tp.List[str]: """ -- GitLab