diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-03-11 22:32:06 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-03-11 22:32:06 +0100 |
| commit | a58d0947eb1edad5c665ad565a3081b1cf4102d3 (patch) | |
| tree | 1e713edc61465028a0d677d05045c43fb549b67f | |
| parent | 7e4105c54294e28d4cf2ec94c8746ed47e7ae532 (diff) | |
Remove package.py
This was a leftover from the following commit:
commit 7e4105c54294e28d4cf2ec94c8746ed47e7ae532
Author: Xavier Del Campo Romero
Date: Sat Nov 22 23:04:09 2025 +0100
Use appimage-builder fork
| -rw-r--r-- | package.py | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/package.py b/package.py deleted file mode 100644 index 7aab10c..0000000 --- a/package.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2020 Alexis Lopez Zubieta -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -import re -import urllib -from pathlib import Path - -from packaging import version - - -class Package: - def __init__(self, name, version, arch): - # remove arch from the name - colon_idx = name.find(":") - if colon_idx != -1: - self.name = name[:colon_idx] - self.arch = name[colon_idx + 1 :] - else: - self.name = name - - self.version = version - self.arch = arch - - def get_expected_file_name(self): - file_name = "%s_%s_%s.deb" % (self.name, self.version, self.arch) - - # apt encodes invalid chars to comply the deb file naming convention - file_name = urllib.parse.quote(file_name, safe="+*~") - - # Only converts the case of letters from percent-encoding, not the entire string. - file_name = re.sub( - r"%[0-9A-Z]{2}", lambda matchobj: matchobj.group(0).lower(), file_name - ) - return file_name - - def get_apt_install_string(self): - return "%s:%s=%s" % (self.name, self.arch, self.version) - - @staticmethod - def from_file_path(path): - path = Path(path) - name_parts = path.stem.split("_") - - return Package( - urllib.parse.unquote(name_parts[0]), - urllib.parse.unquote(name_parts[1]), - urllib.parse.unquote(name_parts[2]), - ) - - def __eq__(self, other: object) -> bool: - """Overrides the default implementation""" - if isinstance(other, Package): - return ( - self.name == other.name - and self.version == other.version - and self.arch == other.arch - ) - return False - - def __str__(self): - """apt input format""" - output = self.name - if self.arch: - output = "%s:%s" % (output, self.arch) - if self.version: - output = "%s=%s" % (output, self.version) - return output - - def __gt__(self, other): - if isinstance(other, Package): - return True - # return version.parse(self.version) > version.parse(other.version) - - def __hash__(self): - return self.__str__().__hash__() |
