forked from mtxr/SublimeText-SQLTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistory.py
More file actions
47 lines (31 loc) · 942 Bytes
/
Copy pathHistory.py
File metadata and controls
47 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
__version__ = "v0.1.0"
class SizeException(Exception):
pass
class NotFoundException(Exception):
pass
class History:
def __init__(self, maxSize=100):
self.items = []
self.maxSize = maxSize
def add(self, query):
if self.getSize() >= self.getMaxSize():
self.items.pop(0)
self.items.insert(0, query)
def get(self, index):
if index < 0 or index > (len(self.items) - 1):
raise NotFoundException("No query selected")
return self.items[index]
def setMaxSize(self, size=100):
if size < 1:
raise SizeException("Size can't be lower than 1")
self.maxSize = size
return self.maxSize
def getMaxSize(self):
return self.maxSize
def getSize(self):
return len(self.items)
def all(self):
return self.items
def clear(self):
self.items = []
return self.items