From 3c4b305871a4e83fc0995dc8701acbe8b0955b5c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 7 Feb 2010 20:11:57 +0100 Subject: added mimeo package (easy file opening) --- x11-misc/mimeo/files/__init__.py | 2 ++ x11-misc/mimeo/files/mimeo | 37 +++++++++++++++++++++++++++++++++++++ x11-misc/mimeo/files/mimeo-2.6 | 5 +++++ 3 files changed, 44 insertions(+) create mode 100644 x11-misc/mimeo/files/__init__.py create mode 100644 x11-misc/mimeo/files/mimeo create mode 100644 x11-misc/mimeo/files/mimeo-2.6 (limited to 'x11-misc/mimeo/files') diff --git a/x11-misc/mimeo/files/__init__.py b/x11-misc/mimeo/files/__init__.py new file mode 100644 index 0000000..eae587c --- /dev/null +++ b/x11-misc/mimeo/files/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python +from mimeo import main diff --git a/x11-misc/mimeo/files/mimeo b/x11-misc/mimeo/files/mimeo new file mode 100644 index 0000000..4c4fff4 --- /dev/null +++ b/x11-misc/mimeo/files/mimeo @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# Gentoo 'mimeo' wrapper script + +import os +import re +import subprocess +import sys + +EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") + +try: + eselect_process = subprocess.Popen(["/usr/bin/eselect", "python", "show", "--python2"], stdout=subprocess.PIPE) + if eselect_process.wait() != 0: + raise ValueError +except (OSError, ValueError): + sys.stderr.write("Execution of 'eselect python show --python2' failed\n") + sys.exit(1) + +eselect_output = eselect_process.stdout.read() +if not isinstance(eselect_output, str): + # Python 3 + eselect_output = eselect_output.decode() + +EPYTHON_matched = EPYTHON_re.match(eselect_output) +if EPYTHON_matched: + PYTHON_ABI = EPYTHON_matched.group(1) +else: + sys.stderr.write("'eselect python show --python2' printed unrecognized value '%s" % eselect_output) + sys.exit(1) + +os.environ["PYTHON_PROCESS_NAME"] = sys.argv[0] +target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI) +if not os.path.exists(target_executable): + sys.stderr.write("'%s' does not exist\n" % target_executable) + sys.exit(1) + +os.execv(target_executable, sys.argv) diff --git a/x11-misc/mimeo/files/mimeo-2.6 b/x11-misc/mimeo/files/mimeo-2.6 new file mode 100644 index 0000000..5e86b20 --- /dev/null +++ b/x11-misc/mimeo/files/mimeo-2.6 @@ -0,0 +1,5 @@ +#!/usr/bin/env python +# Gentoo 'mimeo' wrapper script +import mimeo + +mimeo.main() -- cgit v1.2.3