projects
/
mudpy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switch basic data loader unit from element to node
[mudpy.git]
/
lib
/
mudpy
/
data.py
diff --git
a/lib/mudpy/data.py
b/lib/mudpy/data.py
index
062bd87
..
97032e2
100644
(file)
--- a/
lib/mudpy/data.py
+++ b/
lib/mudpy/data.py
@@
-1,6
+1,6
@@
"""Data interface functions for the mudpy engine."""
"""Data interface functions for the mudpy engine."""
-# Copyright (c) 2004-201
5
Jeremy Stanley <fungi@yuggoth.org>. Permission
+# Copyright (c) 2004-201
6
Jeremy Stanley <fungi@yuggoth.org>. Permission
# to use, copy, modify, and distribute this software is granted under
# terms provided in the LICENSE file distributed with this software.
# to use, copy, modify, and distribute this software is granted under
# terms provided in the LICENSE file distributed with this software.
@@
-14,7
+14,7
@@
import yaml
class DataFile:
class DataFile:
- """A file containing universe elements."""
+ """A file containing universe elements
and their facets
."""
def __init__(self, filename, universe):
self.filename = filename
def __init__(self, filename, universe):
self.filename = filename
@@
-23,10
+23,10
@@
class DataFile:
self.load()
def load(self):
self.load()
def load(self):
- """Read a file
and create elemen
ts accordingly."""
+ """Read a file
, create elements and poplulate face
ts accordingly."""
self.modified = False
try:
self.modified = False
try:
- self.data = yaml.load(open(self.filename))
+ self.data = yaml.
safe_
load(open(self.filename))
except FileNotFoundError:
# it's normal if the file is one which doesn't exist yet
log_entry = ("File %s is unavailable." % self.filename, 6)
except FileNotFoundError:
# it's normal if the file is one which doesn't exist yet
log_entry = ("File %s is unavailable." % self.filename, 6)
@@
-84,9
+84,9
@@
class DataFile:
includes.append(item)
if item not in self.universe.private_files:
self.universe.private_files.append(item)
includes.append(item)
if item not in self.universe.private_files:
self.universe.private_files.append(item)
- for
element
in self.data:
- if
element
!= "__control__":
- mudpy.misc.Element(
element
, self.universe, self.filename)
+ for
node
in self.data:
+ if
node
!= "__control__":
+ mudpy.misc.Element(
node
, self.universe, self.filename)
for include_file in includes:
if not os.path.isabs(include_file):
include_file = find_file(
for include_file in includes:
if not os.path.isabs(include_file):
include_file = find_file(
@@
-162,8
+162,8
@@
class DataFile:
os.umask(old_umask)
# write and close the file
os.umask(old_umask)
# write and close the file
- yaml.
dump(self.data, allow_unicode=True, default_flow_style=Fals
e,
- stream=file_descriptor)
+ yaml.
safe_dump(self.data, allow_unicode=Tru
e,
+
default_flow_style=False,
stream=file_descriptor)
file_descriptor.close()
# unset the modified flag
file_descriptor.close()
# unset the modified flag
@@
-252,7
+252,7
@@
def find_file(
else:
search_path = search_path[:]
else:
search_path = search_path[:]
- # if there's no default path, use the last
elem
ent of the search path
+ # if there's no default path, use the last
compon
ent of the search path
if not default_dir:
default_dir = search_path[-1]
if not default_dir:
default_dir = search_path[-1]