################################################################################
#
# Four Worlds
# Copyright (c) 2009-????
#
# Package: polc
# File: data.py
#
# The automatic Python OLC system, capable of generating an online content editor
# for a given Python class or dict by using dictionaries to discover properties.
#
# OLC Data Storage
#
# Author: Stendec
#
################################################################################
import mudsys, auxiliary, storage, copy
################################################################################
# Variables
################################################################################
menukeys = "1234567890ABCDEFGHIJKLMNOPRSTUVWXYZ"
fancy_keys = {
'desc' : 'Description',
'rdesc' : 'Room Description',
'mdesc' : 'Room Description for Multiple Occurences',
'edesc' : 'Extra Descriptions',
'mname' : 'Name for Multiple Occurences',
}
################################################################################
# Storage Class
################################################################################
class OLCAuxData:
def __init__(self, set = None):
self.working = None
self.key = None
def copy(self):
c = OLCAuxData()
self.copyTo(c)
return c
def copyTo(self, to):
to.working = self.working
to.key = self.key
def store(self):
set = storage.StorageSet()
return set
class OLCData:
def __init__(self, set = None):
self.reset()
def reset(self):
self.object = None
self.saver = None
self.key = None
self.opts = None
self.sock = None
self.ekey = None
def hk(self, key, okey = None):
'''Determines if we have a key. No value.'''
key = "_" + key
return self.opts.has_key(key) and self.opts[key].has_key(okey)
def k(self, key, okey = None):
'''Get the value of the option in key, or None if it doesn't exist.'''
if self.hk(key,okey): return self.opts['_'+key][okey]
return None
def copy(self):
newdata = OLCData()
self.copyTo(newdata)
return newdata
def copyTo(self, to):
to.object = self.object
to.saver = self.saver
to.key = self.key
to.opts = self.opts
to.sock = self.sock
to.ekey = self.ekey
def store(self):
set = storage.StorageSet()
return set
################################################################################
# Initialization
################################################################################
auxiliary.install("olc", OLCAuxData, "socket")