From: Paul Varner Date: Mon, 18 Apr 2011 18:27:17 +0000 (-0500) Subject: Change eprefix.py to only look at portage for the value of EPREFIX X-Git-Tag: gentoolkit-0.3.0.1~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6e7df927a6225066de1c4f100cd4e8541b5aa3f0;p=gentoolkit.git Change eprefix.py to only look at portage for the value of EPREFIX --- diff --git a/pym/gentoolkit/eprefix.py b/pym/gentoolkit/eprefix.py index 9a04e4b..48bd140 100644 --- a/pym/gentoolkit/eprefix.py +++ b/pym/gentoolkit/eprefix.py @@ -10,25 +10,15 @@ used in all gentoolkit modules Example useage: from gentoolkit.eprefix import EPREFIX -then in code add it to the filepath eg.: +then in code add it to the filepath eg.: exclude_file = "%s/etc/%s/%s.exclude" % (EPREFIX,__productname__ , action) """ - -import os - - -EPREFIX = '' - -# the following code is used to set it when -# non-installed code is being run -if 'EPREFIX' in os.environ: - EPREFIX = os.environ['EPREFIX'] -else: - try: - import portage.const - EPREFIX = portage.BPREFIX - except AttributeError: - EPREFIX = '' - -#print("EPREFIX set to:", EPREFIX) +# Load EPREFIX from Portage, fall back to the empty string if it fails +try: + from portage.const import EPREFIX +except ImportError: + EPREFIX = '' + +if __name__ == "__main__": + print("EPREFIX set to:", EPREFIX)