Skip to content

Commit

Permalink
updates: drop lchop and rchop
Browse files Browse the repository at this point in the history
Addon will require Python >=3.9

Signed-off-by: Ian Leonard <[email protected]>
  • Loading branch information
antonlacon committed Mar 3, 2024
1 parent cd95e05 commit ba5b4e6
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions resources/lib/modules/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit ba5b4e6

Please sign in to comment.