[27517] in Source-Commits

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

python-hesiod commit: Selectively disable filesystem type parsing

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Fri Oct 25 11:06:15 2013

Date: Fri, 25 Oct 2013 11:06:08 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201310251506.r9PF68RJ021294@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/python-hesiod/commit/bcf3c3f0197df791c1ef15d02067b1c5619e201c
commit bcf3c3f0197df791c1ef15d02067b1c5619e201c
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Thu Oct 10 09:48:23 2013 -0400

    Selectively disable filesystem type parsing
    
    Allow callers to decide whether FilsysLookup should "know" about
    filesystem types or not.  Useful for higher-level APIs that have
    their own understanding of lockers.  Priority parsing is still
    performed (e.g. for FSGROUPs), and the record format of:
    TYPE DATA [PRIORITY]
    is still enforced.

 hesiod.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/hesiod.py b/hesiod.py
index 596289a..530575a 100755
--- a/hesiod.py
+++ b/hesiod.py
@@ -23,7 +23,10 @@ class Lookup(object):
         pass
 
 class FilsysLookup(Lookup):
-    def __init__(self, name):
+    def __init__(self, name, **kwargs):
+        self.parseTypes = True
+        if 'parseFilsysTypes' in kwargs:
+            self.parseTypes = kwargs['parseFilsysTypes']
         Lookup.__init__(self, name, 'filsys')
     
     def parseRecords(self):
@@ -39,6 +42,13 @@ class FilsysLookup(Lookup):
                 priority = int(priority)
             
             parts = result.split(" ")
+            if len(parts) < 2:
+                raise HesiodParseError("Invalid filsys record: %s" % (result))
+            if not self.parseTypes:
+                self.filsys.append(dict(type=parts[0],
+                                        data=" ".join(parts[1::]),
+                                        priority=priority))
+                continue
             type = parts[0]
             if type == 'AFS':
                 self.filsys.append(dict(type=type,

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