[Ocfs2-tools-commits] manish commits r837 -
trunk/ocfs2console/ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Apr 25 17:12:56 CDT 2005
Author: manish
Date: 2005-04-25 17:12:54 -0500 (Mon, 25 Apr 2005)
New Revision: 837
Modified:
trunk/ocfs2console/ocfs2interface/fstab.py
Log:
Use introspection for field loading in FSTabEntry
Modified: trunk/ocfs2console/ocfs2interface/fstab.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/fstab.py 2005-04-23 02:36:53 UTC (rev 836)
+++ trunk/ocfs2console/ocfs2interface/fstab.py 2005-04-25 22:12:54 UTC (rev 837)
@@ -63,28 +63,25 @@
return entry
return None
-
-str_fields = ('spec', 'mountpoint', 'vfstype', 'options')
-int_fields = ('freq', 'passno')
-entry_fmt = ('\t'.join(['%%(%s)s' % f for f in str_fields]) + '\t' +
- '\t'.join(['%%(%s)d' % f for f in int_fields]))
-
class FSTabEntry:
def __init__(self, spec, mountpoint, vfstype, options, freq=0, passno=0):
symtab = locals()
- for attr in str_fields:
+ code = self.__init__.func_code
+
+ names = []
+ for attr in code.co_varnames[1:code.co_argcount]:
setattr(self, attr, symtab[attr])
+ names.append(attr)
- for attr in int_fields:
- setattr(self, attr, int(symtab[attr]))
+ self.entry_fmt = '\t'.join(['%%(%s)s' % f for f in names])
if self.spec.startswith('UUID='):
self.spec = 'UUID=' + self.spec[5:].lower()
def __str__(self):
- return entry_fmt % self.__dict__
+ return self.entry_fmt % self.__dict__
def __repr__(self):
return "<FSTabEntry: '%s'>" % str(self)
More information about the Ocfs2-tools-commits
mailing list