summaryrefslogtreecommitdiffstats
path: root/cobbler/serializer.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2006-05-05 17:48:01 -0400
committerJim Meyering <jim@meyering.net>2006-05-05 17:48:01 -0400
commit8e434ed6574a5b391d9b57f3cbb10f73e62a403c (patch)
tree0ccf20785615db6ae452a674959451a77af8eebc /cobbler/serializer.py
parent297525dcb3c500d086bb4a5006a5839d98f8522b (diff)
downloadthird_party-cobbler-8e434ed6574a5b391d9b57f3cbb10f73e62a403c.tar.gz
third_party-cobbler-8e434ed6574a5b391d9b57f3cbb10f73e62a403c.tar.xz
third_party-cobbler-8e434ed6574a5b391d9b57f3cbb10f73e62a403c.zip
Interim commit
Diffstat (limited to 'cobbler/serializer.py')
-rw-r--r--cobbler/serializer.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/cobbler/serializer.py b/cobbler/serializer.py
index 847be6e..112025e 100644
--- a/cobbler/serializer.py
+++ b/cobbler/serializer.py
@@ -1,9 +1,13 @@
# Michael DeHaan <mdehaan@redhat.com>
import api
-import util
+import utils
+import syck # PySyck 0.61 or greater, not syck-python 0.55
+import msg
def serialize(obj):
+ if obj.filename() is None:
+ raise Exception("not serializable")
fd = open(obj.filename(),"w+")
datastruct = obj.to_datastruct()
yaml = syck.dump(datastruct)
@@ -12,8 +16,15 @@ def serialize(obj):
return True
def deserialize(obj):
- fd = open(obj.filename(),"r")
+ if obj.filename() is None:
+ raise Exception("not serializable")
+ try:
+ fd = open(obj.filename(),"r")
+ except:
+ print msg.m("parse_error") % obj.filename()
+ return
data = fd.read()
datastruct = yaml.load(data)
fd.close()
- return obj.from_datastruct(datastruct)
+ obj.from_datastruct(datastruct)
+ return True