[llvm-commits] [zorg] r125856 - in /zorg/trunk/llvmlab/llvmlab: user.py util.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:40:27 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:40:27 2011
New Revision: 125856
URL: http://llvm.org/viewvc/llvm-project?rev=125856&view=rev
Log:
llvmlab: Sketch User objects.
Added:
zorg/trunk/llvmlab/llvmlab/user.py
zorg/trunk/llvmlab/llvmlab/util.py
Added: zorg/trunk/llvmlab/llvmlab/user.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/user.py?rev=125856&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/user.py (added)
+++ zorg/trunk/llvmlab/llvmlab/user.py Fri Feb 18 10:40:27 2011
@@ -0,0 +1,28 @@
+"""
+LLVM-Lab User Objects
+"""
+
+from llvmlab import util
+
+class User(util.simple_repr_mixin):
+ @staticmethod
+ def fromdata(data):
+ version = data['version']
+ if version != 0:
+ raise ValueError, "Unknown version"
+
+ return User(data['id'], data['passhash'],
+ data['name'], data['email'])
+
+ def todata(self):
+ return { 'version' : 0,
+ 'id' : self.id,
+ 'passhash' : self.passhash,
+ 'name' : self.name,
+ 'email' : self.email }
+
+ def __init__(self, id, passhash, name, email):
+ self.id = id
+ self.passhash = passhash
+ self.name = name
+ self.email = email
Added: zorg/trunk/llvmlab/llvmlab/util.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/util.py?rev=125856&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/util.py (added)
+++ zorg/trunk/llvmlab/llvmlab/util.py Fri Feb 18 10:40:27 2011
@@ -0,0 +1,12 @@
+__all__ = []
+
+def sorted(items):
+ items = list(items)
+ items.sort()
+ return items
+
+class simple_repr_mixin(object):
+ def __repr__(self):
+ return "%s(%s)" % (self.__class__.__name__,
+ ", ".join("%s=%r" % (k,v)
+ for k,v in sorted(self.__dict__.items())))
More information about the llvm-commits
mailing list