From ba5b4e607fa560a6840df70b235e9ccf5d3021e5 Mon Sep 17 00:00:00 2001 From: Ian Leonard Date: Fri, 26 May 2023 04:19:56 -0400 Subject: [PATCH] updates: drop lchop and rchop Addon will require Python >=3.9 Signed-off-by: Ian Leonard --- resources/lib/modules/updates.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/resources/lib/modules/updates.py b/resources/lib/modules/updates.py index 4de0399b2..fd741d896 100644 --- a/resources/lib/modules/updates.py +++ b/resources/lib/modules/updates.py @@ -184,21 +184,6 @@ def do_init(self): def exit(self): pass - @log.log_function() - def lchop(self, s, prefix): - """Remove prefix from string.""" - # TODO usage may be replaced by .removeprefix() in python >=3.9 - if prefix and s.startswith(prefix): - return s[len(prefix):] - return s - - @log.log_function() - def rchop(self, s, suffix): - """Remove suffix from string.""" - # TODO usage may be replaced by .removesuffix() in python >=3.9 - if suffix and s.endswith(suffix): - return s[:-len(suffix)] - return s # Identify connected GPU card (card0, card1 etc.) @log.log_function() @@ -479,9 +464,9 @@ def get_available_builds(self, shortname=None): def pretty_filename(s): """Make filenames prettier to users.""" - s = self.lchop(s, f'{oe.DISTRIBUTION}-{oe.ARCHITECTURE}-') - s = self.rchop(s, '.tar') - s = self.rchop(s, '.img.gz') + s = s.removeprefix(f'{oe.DISTRIBUTION}-{oe.ARCHITECTURE}-') + s = s.removesuffix('.tar') + s = s.removesuffix('.img.gz') return s channel = self.struct['update']['settings']['Channel']['value']