def getDictionary(self, dict): ret = {} i = 0 for key, val in DictIterItems(dict): i += 1 #we need to add the id because otherwise we cannot find the real object to get its contents later on. key = '%s (%s)' % (self.keyStr(key), id(key)) ret[key] = val if i > MAX_ITEMS_TO_HANDLE: ret[TOO_LARGE_ATTR] = TOO_LARGE_MSG break ret['__len__'] = len(dict) return ret
def resolve(self, dict, key): if key in ('__len__', TOO_LARGE_ATTR): return None if '(' not in key: #we have to treat that because the dict resolver is also used to directly resolve the global and local #scopes (which already have the items directly) return dict[key] #ok, we have to iterate over the items to find the one that matches the id, because that's the only way #to actually find the reference from the string we have before. expected_id = int(key.split('(')[-1][:-1]) for key, val in DictIterItems(dict): if id(key) == expected_id: return val raise UnableToResolveVariableException()
def has_line_breaks(plugin): for file, breakpoints in DictIterItems( plugin.main_debugger.jinja2_breakpoints): if len(breakpoints) > 0: return True return False