def __getitem__(self, item): if is_string(item): return getattr(self, item) elif is_integer(item): return getattr(self, self.__producer__.columns[item]) else: raise LookupError(item)
def __getitem__(self, item): if is_integer(item): return self.__values__[item] elif is_string(item): return getattr(self, item) else: raise LookupError(item)
def presubstitute(statement, parameters): more = True while more: before, opener, key = statement.partition(u"«") if opener: key, closer, after = key.partition(u"»") try: value = parameters.pop(key) except KeyError: raise KeyError("Expected a presubstitution parameter named %r" % key) if is_integer(value): value = ustr(value) elif isinstance(value, tuple) and all(map(is_integer, value)): value = u"%d..%d" % (value[0], value[-1]) elif is_collection(value): value = ":".join(map(cypher_escape, value)) else: value = cypher_escape(value) statement = before + value + after else: more = False return statement, parameters
def presubstitute(statement, parameters): more = True while more: before, opener, key = statement.partition(u"«") if opener: key, closer, after = key.partition(u"»") try: value = parameters.pop(key) except KeyError: raise KeyError( "Expected a presubstitution parameter named %r" % key) if is_integer(value): value = ustr(value) elif isinstance(value, tuple) and all(map(is_integer, value)): value = u"%d..%d" % (value[0], value[-1]) elif is_collection(value): value = ":".join(map(cypher_escape, value)) else: value = cypher_escape(value) statement = before + value + after else: more = False return statement, parameters