summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/visible.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/_emerge/visible.py')
-rw-r--r--pym/_emerge/visible.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/pym/_emerge/visible.py b/pym/_emerge/visible.py
new file mode 100644
index 000000000..5ae04ce03
--- /dev/null
+++ b/pym/_emerge/visible.py
@@ -0,0 +1,40 @@
+try:
+ import portage
+except ImportError:
+ from os import path as osp
+ import sys
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
+ import portage
+
+def visible(pkgsettings, pkg):
+ """
+ Check if a package is visible. This can raise an InvalidDependString
+ exception if LICENSE is invalid.
+ TODO: optionally generate a list of masking reasons
+ @rtype: Boolean
+ @returns: True if the package is visible, False otherwise.
+ """
+ if not pkg.metadata["SLOT"]:
+ return False
+ if not pkg.installed:
+ if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata):
+ return False
+ eapi = pkg.metadata["EAPI"]
+ if not portage.eapi_is_supported(eapi):
+ return False
+ if not pkg.installed:
+ if portage._eapi_is_deprecated(eapi):
+ return False
+ if pkgsettings._getMissingKeywords(pkg.cpv, pkg.metadata):
+ return False
+ if pkgsettings._getMaskAtom(pkg.cpv, pkg.metadata):
+ return False
+ if pkgsettings._getProfileMaskAtom(pkg.cpv, pkg.metadata):
+ return False
+ try:
+ if pkgsettings._getMissingLicenses(pkg.cpv, pkg.metadata):
+ return False
+ except portage.exception.InvalidDependString:
+ return False
+ return True
+