diff options
| author | Paul Varner <fuzzyray@gentoo.org> | 2011-04-18 13:27:17 -0500 |
|---|---|---|
| committer | Paul Varner <fuzzyray@gentoo.org> | 2011-04-18 13:27:17 -0500 |
| commit | 6e7df927a6225066de1c4f100cd4e8541b5aa3f0 (patch) | |
| tree | b4a1c101ce8707adc3083fc0823b8b388d25a20f | |
| parent | cf5ee10b16f9b7be11a281de5d6814927a47ed73 (diff) | |
| download | gentoolkit-6e7df927a6225066de1c4f100cd4e8541b5aa3f0.tar.gz | |
Change eprefix.py to only look at portage for the value of EPREFIX
| -rw-r--r-- | pym/gentoolkit/eprefix.py | 28 |
1 files 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) |
