[llvm-commits] [zorg] r125857 - in /zorg/trunk/llvmlab/llvmlab: data.py llvmlabtool/main.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:40:30 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:40:30 2011
New Revision: 125857
URL: http://llvm.org/viewvc/llvm-project?rev=125857&view=rev
Log:
llvmlab: Sketch top-level data object.
Added:
zorg/trunk/llvmlab/llvmlab/data.py
Modified:
zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py
Added: zorg/trunk/llvmlab/llvmlab/data.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/data.py?rev=125857&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/data.py (added)
+++ zorg/trunk/llvmlab/llvmlab/data.py Fri Feb 18 10:40:30 2011
@@ -0,0 +1,35 @@
+"""
+LLVM-Lab Data Management
+"""
+
+from llvmlab import util
+from llvmlab import user
+
+class Data(util.simple_repr_mixin):
+ @staticmethod
+ def fromdata(data):
+ version = data['version']
+ if version != 0:
+ raise ValueError, "Unknown version"
+
+ users = [user.User.fromdata(u)
+ for u in data['users']]
+ return Data(users)
+
+ def todata(self):
+ return { 'version' : 0,
+ 'users' : [u.todata()
+ for u in self.users.values()
+ if u is not self.admin_user] }
+
+ def __init__(self, users):
+ self.users = dict((u.id, u) for u in users)
+ self.admin_user = None
+
+ def set_admin_user(self, user):
+ if user.id in self.users:
+ raise ValueError, "database contains admin user %r" % user.id
+
+ self.admin_user = user
+ self.users[user.id] = user
+
Modified: zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py?rev=125857&r1=125856&r2=125857&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py (original)
+++ zorg/trunk/llvmlab/llvmlab/llvmlabtool/main.py Fri Feb 18 10:40:30 2011
@@ -7,6 +7,7 @@
import sys
import flask
+import llvmlab.data
def action_create(name, args):
"""create an llvmlab installation"""
@@ -79,9 +80,12 @@
cfg_file.write(cfg_data)
cfg_file.close()
+ # Create the inital data file.
+ data = llvmlab.data.Data(users = [])
+
# Write the initial (empty) data file.
data_file = open(data_path, 'w')
- flask.json.dump({}, data_file, indent=2)
+ flask.json.dump(data.todata(), data_file, indent=2)
print >>data_file
data_file.close()
More information about the llvm-commits
mailing list