本文整理汇总了Python中Dictionary.Dictionary类的典型用法代码示例。如果您正苦于以下问题:Python Dictionary类的具体用法?Python Dictionary怎么用?Python Dictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: action27
def action27(self, lineNumber, symbol):
dictionary = Dictionary()
ss1 = SS1()
if not dictionary.isFound(symbol):
E.E(lineNumber, 0).unknownIdentifier(symbol)
else:
ss1.push(symbol)
示例2: get_dictionary
def get_dictionary( ):
""" Build a Dictionary based on the Diceware data. """
dicto = Dictionary()
print 'Parsing Diceware data...'
i = 0;
nLines = 7780
# open file for reading
with open(Diceware.fname, 'r') as fid:
for line in fid:
tokens = Diceware.parse_line(line)
if tokens is None:
continue
# save data to list
word = Word(tokens['word'], -1, -1, i);
dicto.add_word(word)
# increment counter and show progress
i = i + 1;
progress = float(i) / float(nLines)
if (progress % 0.05) < 1e-4:
sys.stdout.write("\r%2.2f%%" %(progress*100))
sys.stdout.flush()
print '\nDone.'
return dicto
示例3: action18
def action18(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
ss1 = SS1()
if dictionary.isFound(symbol):
E.E(lineNumber, 0).doubleDefinition(symbol, 'procedure or function')
ss1.push(symbol)
ss1.push('proc_params')
示例4: action8000
def action8000(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
if dictionary.isFound(symbol):
E.E(lineNumber, 0).typeDoubleDefinition(symbol)
_attrUserType = AtrClasses.AttrUserType(symbol)
ss1 = SS1()
ss1.push(_attrUserType)
示例5: action4000
def action4000(self, lineNumber, symbol):
# symbol = symbol['name']
ss1 = SS1()
value = ss1.pop()
name = ss1.pop()
name.bind(value)
dictionary = Dictionary()
dictionary.setObject(name.name, name)
示例6: action20000
def action20000(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
if not dictionary.isFound(symbol):
E.E(lineNumber, 0).typeUnknown(symbol)
type = dictionary.get(symbol)
ss1 = SS1()
ss1.push(type)
示例7: action17000
def action17000(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
if not dictionary.isFound(symbol):
E.E(lineNumber, 0).typeUnknown(symbol)
ss1 = SS1()
_attrArray = ss1.pop()
_attrArray['object'].setName(symbol)
ss1.push( _attrArray )
示例8: test_get
def test_get(self):
d = Dictionary()
d['raymond'] = 'red'
self.assertEqual(d['raymond'], 'red')
d['rachel'] = 'blue'
self.assertEqual(d['rachel'], 'blue')
d['critter'] = 'yellow'
self.assertEqual(d.get('raymond', 'not found'), 'red')
self.assertEqual(d.get('john', 'not found'), 'not found')
示例9: action7000
def action7000(self, lineNumber, symbol):
# symbol = symbol['name']
ss1 = SS1()
record = ss1.pop();
dictionary = Dictionary()
# @todo make interface for array, record, diapason and id
_class = dictionary.get(record.name.name)['class']
dictionary.setObject(record.name.name, record)
row = self.getRow(record.name.name, _class, record)
示例10: action5000
def action5000(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
if dictionary.isFound(symbol):
E.E(lineNumber, 0).varDoubleDefinition(symbol)
else:
_attrVar = AtrClasses.AttrVar(symbol)
ss1 = SS1()
ss1.push(_attrVar)
示例11: test_pop
def test_pop(self):
d = Dictionary()
d['raymond'] = 'red'
d['rachel'] = 'blue'
self.assertEqual(d.pop('rachel'), 'blue')
self.assertEqual(d['raymond'], 'red')
self.assertEqual(len(d), 1)
with self.assertRaises(KeyError):
d.pop('john')
示例12: action6000
def action6000(self, lineNumber, symbol):
# symbol = symbol['name']
ss1 = SS1()
dictionary = Dictionary()
type = ss1.pop()
while ss1.top() != None:
name = ss1.pop()
name.bindType(type['name'])
dictionary.setObject(name.name, name)
ss1.pop()
示例13: __init__
def __init__(self, aHt, aClassId, aCode, aLnotab):
self.hT = aHt
self.staticField = Dictionary(self.hT)
self.attributes = Dictionary(self.hT)
self.method = Dictionary(self.hT)
self.lnotab = aLnotab
self.code = aCode
self.name = aCode.co_name
self.Id = aClassId
self.SpecialBehaviorId = -1
示例14: Method
class Method(object):
def __init__(self, aHt, aId, aCode, aLnotab, aIdClass, aArgs):
self.hT = aHt
self.locals = Dictionary(self.hT)
self.argument = ()
self.lnotab = aLnotab
self.code = aCode
self.name = aCode.co_name
self.idClass = aIdClass
self.Id = aId
self.__updateArgument__(aArgs)
def __getId__(self):
return self.Id
def __getLnotab__(self):
return self.lnotab
def __getLocals__(self):
return self.locals
def __getTarget__(self):
return self.idClass
def __getArgs__(self):
return self.argument
def __getArgsValues__(self, aLocals):
argValues = ()
for name in self.argument:
if aLocals.has_key(name):
argValues = argValues + (aLocals[name],)
#TODO: analizar caso para cuando sean tuple, list, dict
return argValues
def __updateArgument__(self, aArgs):
#no se registra self como argumento valido
for theArg in aArgs:
if not theArg == 'self':
self.argument += (theArg,)
theParentId = self.Id
if self.hT.FLAG_DEBUGG:
for theIndex in range(len(aArgs)):
if not aArgs[theIndex] == 'self':
print self.hT.itsEvents['register'],
print self.hT.itsObjects['local'],
print theIndex + 1,
print theParentId,
print aArgs[theIndex]
raw_input()
def __registerLocals__(self, aLocal):
self.locals.__update__(aLocal,self.Id,self.argument)
示例15: action55000
def action55000(self, lineNumber, symbol):
# symbol = symbol['name']
dictionary = Dictionary()
# @todo problem Fields in record cannot have name equal to usual variables
if dictionary.isFound(symbol):
E.E(lineNumber, 0).varDoubleDefinition(symbol)
else:
_attrVar = AtrClasses.AttrVar(symbol)
ss1 = SS1()
ss1.push(None)
ss1.push(_attrVar)