cmds.projects.lib.pkg_relations: Integrate lib.version
- The pkg_relations() function is a horribly bad read. It contains a mind-bending amount of interwoven case distinctions that are not clearly reflected in the participating variable and function names. Much of it is version handling. That's intricate by nature, but much of it has now been implemented in the lib.version module, so moving the logic there makes the function a good deal more readable than before. That's most of what this commit does. - Use version syntax macros from lib.version instead of pkg_relations-defined macros, and fix the fallout in BaseCmdPkgRelations and CmdCreateFile. - Use lib.version also as a central place for dep string parsing from App. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c9cbef15bb
commit
0c808f9383
4 changed files with 46 additions and 113 deletions
|
|
@ -11,10 +11,11 @@ from enum import Enum, auto
|
|||
from functools import cache
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
from .lib.ExecApp import ExecApp as Base
|
||||
from .lib.Distro import Distro
|
||||
from .lib.ExecApp import ExecApp as Base
|
||||
from .lib.log import DEBUG, ERR, log
|
||||
from .lib.ProjectConf import ProjectConf
|
||||
from .lib.version.Dependency import Dependency
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import argparse
|
||||
|
|
@ -435,7 +436,7 @@ class App(Base):
|
|||
return self.find_dir(name, ['/tmpl'], ['/opt/' + name + '/share/tmpl'])
|
||||
|
||||
def strip_module_from_spec(self, mod: str) -> str:
|
||||
return re.sub(r'-dev$|-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip())
|
||||
return Dependency(mod).base_name
|
||||
|
||||
@cache
|
||||
def get_value(self, project: str, section: str, key: str) -> str | None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue