From 6e7df927a6225066de1c4f100cd4e8541b5aa3f0 Mon Sep 17 00:00:00 2001 From: Paul Varner Date: Mon, 18 Apr 2011 13:27:17 -0500 Subject: [PATCH] Change eprefix.py to only look at portage for the value of EPREFIX --- pym/gentoolkit/eprefix.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) 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) -- 2.26.2