Files
bearhub/bauh/gems/arch/pkgbuild.py
2019-09-19 10:49:15 -03:00

23 lines
590 B
Python

import re
from typing import Set
RE_PKGBUILD_OPTDEPS = re.compile(r"optdepends = (.+)")
RE_PKGBUILD_DEPSON = re.compile(r"\s+depends = (.+)")
def read_optdeps_as_dict(srcinfo: str) -> dict:
res = {}
for optdep in read_optdeps(srcinfo):
split_dep = optdep.split(':')
res[split_dep[0].strip()] = split_dep[1].strip() if len(split_dep) > 1 else None
return res
def read_optdeps(srcinfo: str) -> Set[str]:
return set(RE_PKGBUILD_OPTDEPS.findall(srcinfo))
def read_depends_on(srcinfo: str) -> Set[str]:
return set(RE_PKGBUILD_DEPSON.findall(srcinfo))