[27528] in Source-Commits

home help back first fref pref prev next nref lref last post

python-afs commit: Stop exporting __all__; stop importing whichcell

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Tue Nov 12 18:27:56 2013

Date: Tue, 12 Nov 2013 18:27:49 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201311122327.rACNRntV018732@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/python-afs/commits/2603a7c7d649827d9e3e865c007caa91e24aa957
commit 2603a7c7d649827d9e3e865c007caa91e24aa957
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Wed Oct 30 14:11:59 2013 -0400

    Stop exporting __all__; stop importing whichcell
    
    Don't import anything from afs._fs into afs.fs; instead provide
    a higher-level whichcell which returns None when the path is not
    in AFS (rather than throwing OSError).  Rename the calls to
    _fs functions as appropriate.

 afs/_fs.pyx |    4 ----
 afs/fs.py   |   15 ++++++++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/afs/_fs.pyx b/afs/_fs.pyx
index 31ee0f6..465da67 100644
--- a/afs/_fs.pyx
+++ b/afs/_fs.pyx
@@ -6,10 +6,6 @@ import logging
 
 log = logging.getLogger('afs._fs')
 
-__all__ = ['whichcell',
-           '_lsmount',
-           ]
-
 def whichcell(char* path):
     """
     whichcell(path) -> str
diff --git a/afs/fs.py b/afs/fs.py
index 6106508..bd6a638 100644
--- a/afs/fs.py
+++ b/afs/fs.py
@@ -1,12 +1,21 @@
 import errno
 import os.path
 from afs import _fs
-from afs._fs import *
+
+def whichcell(path):
+    """Return the cell name or None if the path is not in AFS"""
+    try:
+        return _fs.whichcell(path)
+    except OSError as e:
+        if e.errno == errno.EINVAL:
+            return None
+        else:
+            raise
 
 def inafs(path):
     """Return True if a path is in AFS."""
     try:
-        whichcell(path)
+        _fs.whichcell(path)
     except OSError, e:
         if e.errno in (errno.EINVAL, errno.ENOENT):
             return False
@@ -20,7 +29,7 @@ def lsmount(path):
     # strip off any trailing slash
     (dirname, basename) = os.path.split(os.path.realpath(path))
     try:
-        return _lsmount(dirname, basename)
+        return _fs._lsmount(dirname, basename)
     except OSError as e:
         if e.errno == errno.EINVAL:
             return None

home help back first fref pref prev next nref lref last post