mirror of
https://github.com/drasko/codezero.git
synced 2026-02-28 17:53:13 +01:00
More progress on parsing custom and typed capability symbols
This commit is contained in:
@@ -162,32 +162,61 @@ cap_strings = { 'ipc' : \
|
|||||||
#
|
#
|
||||||
# Prepares descriptions of all non-memory capabilities
|
# Prepares descriptions of all non-memory capabilities
|
||||||
#
|
#
|
||||||
def prepare_capability(cont, param, val):
|
# custom use
|
||||||
# USE makes us assign the initial cap string with blank fields
|
# custom type rest
|
||||||
if 'USE' in param:
|
# type use
|
||||||
captype, rest = param.split('_', 1)
|
# type rest
|
||||||
|
|
||||||
|
def prepare_custom_capability(cont, param, val):
|
||||||
|
if 'TYPE' in param:
|
||||||
|
capkey, captype, rest = param.split('_', 2)
|
||||||
|
capkey = capkey.lower()
|
||||||
captype = captype.lower()
|
captype = captype.lower()
|
||||||
|
cont.caps[capkey] = cap_strings[captype]
|
||||||
|
if 'TARGET' in param:
|
||||||
|
target_parts = param.split('_', 2)
|
||||||
|
if len(target_parts) == 2:
|
||||||
|
capkey = target_parts[0].lower()
|
||||||
|
templ = Template(cont.caps[capkey])
|
||||||
|
cont.caps[capkey] = templ.safe_substitute(cid = val)
|
||||||
|
elif len(target_parts) == 3:
|
||||||
|
capkey = target_parts[0].lower()
|
||||||
|
ttype = target_parts[2]
|
||||||
|
templ = Template(cont.caps[capkey])
|
||||||
|
|
||||||
|
# Insert current container id, if target has current
|
||||||
|
if ttype[:len('CURRENT')] == 'CURRENT':
|
||||||
|
cont.caps[capkey] = templ.safe_substitute(target_type = ttype, cid = cont.id)
|
||||||
|
else:
|
||||||
|
cont.caps[capkey] = templ.safe_substitute(target_type = ttype)
|
||||||
|
|
||||||
|
def prepare_typed_capability(cont, param, val):
|
||||||
|
captype, params = param.split('_', 1)
|
||||||
|
captype = captype.lower()
|
||||||
|
|
||||||
|
# USE makes us assign the initial cap string with blank fields
|
||||||
|
if 'USE' in params:
|
||||||
cont.caps[captype] = cap_strings[captype]
|
cont.caps[captype] = cap_strings[captype]
|
||||||
|
|
||||||
|
# Prepare string template from capability type
|
||||||
|
templ = Template(cont.caps[captype])
|
||||||
|
|
||||||
# If it is a pool, amend default target type and id
|
# If it is a pool, amend default target type and id
|
||||||
if captype[-len('pool'):] == 'pool':
|
if captype[-len('pool'):] == 'pool':
|
||||||
templ = Template(cont.caps[captype])
|
cont.caps[captype] = templ.safe_substitute(target_type = 'CURRENT_PAGER_SPACE',
|
||||||
cont.caps[captype] = templ.safe_substitute(target_type = 'CURRENT_CONT',
|
|
||||||
cid = cont.id)
|
cid = cont.id)
|
||||||
|
|
||||||
# Fill in the blank size field
|
# Fill in the blank size field
|
||||||
elif 'SIZE' in param:
|
elif 'SIZE' in params:
|
||||||
captype, rest = param.split('_', 1)
|
# Get reference to capability string template
|
||||||
captype = captype.lower()
|
|
||||||
templ = Template(cont.caps[captype])
|
templ = Template(cont.caps[captype])
|
||||||
cont.caps[captype] = templ.safe_substitute(size = val)
|
cont.caps[captype] = templ.safe_substitute(size = val)
|
||||||
print cont.caps[captype]
|
|
||||||
|
|
||||||
# Fill in capability target type and target id fields
|
# Fill in capability target type and target id fields
|
||||||
elif 'TARGET' in param:
|
elif 'TARGET' in params:
|
||||||
captype, target, ttype = param.split('_', 2)
|
# Get reference to capability string template
|
||||||
captype = captype.lower()
|
|
||||||
templ = Template(cont.caps[captype])
|
templ = Template(cont.caps[captype])
|
||||||
|
target, ttype = params.split('_', 1)
|
||||||
|
|
||||||
# Target type
|
# Target type
|
||||||
if ttype != None:
|
if ttype != None:
|
||||||
@@ -199,12 +228,16 @@ def prepare_capability(cont, param, val):
|
|||||||
# Get target value supplied by user
|
# Get target value supplied by user
|
||||||
else:
|
else:
|
||||||
cont.caps[captype] = templ.safe_substitute(cid = val)
|
cont.caps[captype] = templ.safe_substitute(cid = val)
|
||||||
else:
|
|
||||||
print "No match: ", param
|
|
||||||
|
|
||||||
print captype
|
print captype
|
||||||
print cont.caps[captype]
|
print cont.caps[captype]
|
||||||
|
|
||||||
|
def prepare_capability(cont, param, val):
|
||||||
|
if 'CUSTOM' in param:
|
||||||
|
prepare_custom_capability(cont, param, val)
|
||||||
|
else:
|
||||||
|
prepare_typed_capability(cont, param, val)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
self.threadpool = ''
|
self.threadpool = ''
|
||||||
self.spacepool = ''
|
self.spacepool = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user