summaryrefslogtreecommitdiffstats
path: root/pym/portage/util
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-24 13:38:41 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-24 13:38:41 -0800
commiteac9deb5f2a11997cc012856a235575f658d6d7a (patch)
tree82a33c580693491b51bee5b3a633668a45c452da /pym/portage/util
parent3a43b4392d5c23bc049a5ac925cdda981c751178 (diff)
downloadportage-eac9deb5f2a11997cc012856a235575f658d6d7a.tar.gz
portage-eac9deb5f2a11997cc012856a235575f658d6d7a.tar.bz2
portage-eac9deb5f2a11997cc012856a235575f658d6d7a.zip
RepoConfigLoader: raise PermissionDenied more
Diffstat (limited to 'pym/portage/util')
-rw-r--r--pym/portage/util/_path.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/pym/portage/util/_path.py b/pym/portage/util/_path.py
new file mode 100644
index 000000000..6fbcb438c
--- /dev/null
+++ b/pym/portage/util/_path.py
@@ -0,0 +1,27 @@
+# Copyright 2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import stat
+
+from portage import os
+from portage.exception import PermissionDenied
+
+def exists_raise_eaccess(path):
+ try:
+ os.stat(path)
+ except OSError as e:
+ if e.errno == PermissionDenied.errno:
+ raise PermissionDenied("stat('%s')" % path)
+ return False
+ else:
+ return True
+
+def isdir_raise_eaccess(path):
+ try:
+ st = os.stat(path)
+ except OSError as e:
+ if e.errno == PermissionDenied.errno:
+ raise PermissionDenied("stat('%s')" % path)
+ return False
+ else:
+ return stat.S_ISDIR(st.st_mode)