def get(self, index, query=None): if self._is_empty("GET"): return if query is not None: obj = [self._obj[index]] query = parse(query)["object"] data = execute(obj, query, "focus")[0] else: data = self._obj[index] return data
def add(self, query): if self._profile._obj is None: print("Cannot use filters on empty profile segment") return doc = parse(query) data = execute(self._profile._obj, doc["object"], "filter") self._profile._obj = data self._obj.append(doc) print("added filter: {0}".format(doc["string"]))
def add(self, query: str) -> None: if isinstance(query, str): doc = parse(query) elif isinstance(query, dict): doc = query else: raise TypeError current_filters = [item["string"] for item in self._obj] if doc["string"] in current_filters: raise ValueError("duplicate filter '{0}'".format(doc["string"])) self._obj.append(doc) print("added filter: {0}".format(doc["string"]))
def focus(self, query: str = "request.url"): if self._is_empty("FOCUS"): return self._focus = parse(query) print("set view to '{0}'".format(query))
def __init__(self, workspace, name): self._workspace = workspace self._cursor = [name] self._focus = parse("request.url") self._load()