emmental/trackdb/stack.py

21 lines
462 B
Python
Raw Normal View History

# Copyright 2021 (c) Anna Schumaker.
from . import tags
class TagStack:
def __init__(self):
self.tags = [ ]
def pop(self):
self.tags.pop(0)
def push(self, tag):
if tag == tags.User["Previous"]:
return
if tag == tags.User["Collection"]:
self.tags.clear()
return
if tag in self.tags:
self.tags.remove(tag)
self.tags.insert(0, tag)
tag.stacked()