annotate tripal.py @ 6:64e36c3f0dd6 draft default tip

"planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit ea279e5b47cf3d5767328d17b0e40e57b0238ea1"
author gga
date Wed, 14 Aug 2019 10:04:55 -0400
parents e621d1187d73
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
1 import collections
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
2 import os
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
3 import time
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
4 from abc import abstractmethod
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
5
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
6 import tripal
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
7
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
8
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
9 #############################################
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
10 # BEGIN IMPORT OF CACHING LIBRARY #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
11 #############################################
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
12 # This code is licensed under the MIT #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
13 # License and is a copy of code publicly #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
14 # available in rev. #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
15 # e27332bc82f4e327aedaec17c9b656ae719322ed #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
16 # of https://github.com/tkem/cachetools/ #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
17 #############################################
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
18 class DefaultMapping(collections.MutableMapping):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
19
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
20 __slots__ = ()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
21
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
22 @abstractmethod
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
23 def __contains__(self, key): # pragma: nocover
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
24 return False
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
25
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
26 @abstractmethod
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
27 def __getitem__(self, key): # pragma: nocover
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
28 if hasattr(self.__class__, '__missing__'):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
29 return self.__class__.__missing__(self, key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
30 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
31 raise KeyError(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
32
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
33 def get(self, key, default=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
34 if key in self:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
35 return self[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
36 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
37 return default
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
38
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
39 __marker = object()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
40
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
41 def pop(self, key, default=__marker):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
42 if key in self:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
43 value = self[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
44 del self[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
45 elif default is self.__marker:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
46 raise KeyError(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
47 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
48 value = default
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
49 return value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
50
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
51 def setdefault(self, key, default=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
52 if key in self:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
53 value = self[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
54 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
55 self[key] = value = default
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
56 return value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
57
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
58
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
59 DefaultMapping.register(dict)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
60
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
61
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
62 class _DefaultSize(object):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
63 def __getitem__(self, _):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
64 return 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
65
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
66 def __setitem__(self, _, value):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
67 assert value == 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
68
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
69 def pop(self, _):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
70 return 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
71
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
72
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
73 class Cache(DefaultMapping):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
74 """Mutable mapping to serve as a simple cache or cache base class."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
75
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
76 __size = _DefaultSize()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
77
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
78 def __init__(self, maxsize, missing=None, getsizeof=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
79 if missing:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
80 self.__missing = missing
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
81 if getsizeof:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
82 self.__getsizeof = getsizeof
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
83 self.__size = dict()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
84 self.__data = dict()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
85 self.__currsize = 0
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
86 self.__maxsize = maxsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
87
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
88 def __repr__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
89 return '%s(%r, maxsize=%r, currsize=%r)' % (
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
90 self.__class__.__name__,
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
91 list(self.__data.items()),
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
92 self.__maxsize,
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
93 self.__currsize,
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
94 )
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
95
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
96 def __getitem__(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
97 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
98 return self.__data[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
99 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
100 return self.__missing__(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
101
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
102 def __setitem__(self, key, value):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
103 maxsize = self.__maxsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
104 size = self.getsizeof(value)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
105 if size > maxsize:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
106 raise ValueError('value too large')
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
107 if key not in self.__data or self.__size[key] < size:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
108 while self.__currsize + size > maxsize:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
109 self.popitem()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
110 if key in self.__data:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
111 diffsize = size - self.__size[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
112 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
113 diffsize = size
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
114 self.__data[key] = value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
115 self.__size[key] = size
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
116 self.__currsize += diffsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
117
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
118 def __delitem__(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
119 size = self.__size.pop(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
120 del self.__data[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
121 self.__currsize -= size
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
122
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
123 def __contains__(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
124 return key in self.__data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
125
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
126 def __missing__(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
127 value = self.__missing(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
128 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
129 self.__setitem__(key, value)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
130 except ValueError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
131 pass # value too large
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
132 return value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
133
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
134 def __iter__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
135 return iter(self.__data)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
136
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
137 def __len__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
138 return len(self.__data)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
139
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
140 @staticmethod
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
141 def __getsizeof(value):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
142 return 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
143
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
144 @staticmethod
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
145 def __missing(key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
146 raise KeyError(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
147
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
148 @property
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
149 def maxsize(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
150 """The maximum size of the cache."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
151 return self.__maxsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
152
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
153 @property
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
154 def currsize(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
155 """The current size of the cache."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
156 return self.__currsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
157
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
158 def getsizeof(self, value):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
159 """Return the size of a cache element's value."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
160 return self.__getsizeof(value)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
161
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
162
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
163 class _Link(object):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
164
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
165 __slots__ = ('key', 'expire', 'next', 'prev')
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
166
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
167 def __init__(self, key=None, expire=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
168 self.key = key
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
169 self.expire = expire
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
170
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
171 def __reduce__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
172 return _Link, (self.key, self.expire)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
173
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
174 def unlink(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
175 next = self.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
176 prev = self.prev
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
177 prev.next = next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
178 next.prev = prev
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
179
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
180
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
181 class _Timer(object):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
182
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
183 def __init__(self, timer):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
184 self.__timer = timer
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
185 self.__nesting = 0
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
186
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
187 def __call__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
188 if self.__nesting == 0:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
189 return self.__timer()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
190 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
191 return self.__time
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
192
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
193 def __enter__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
194 if self.__nesting == 0:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
195 self.__time = time = self.__timer()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
196 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
197 time = self.__time
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
198 self.__nesting += 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
199 return time
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
200
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
201 def __exit__(self, *exc):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
202 self.__nesting -= 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
203
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
204 def __reduce__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
205 return _Timer, (self.__timer,)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
206
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
207 def __getattr__(self, name):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
208 return getattr(self.__timer, name)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
209
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
210
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
211 class TTLCache(Cache):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
212 """LRU Cache implementation with per-item time-to-live (TTL) value."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
213
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
214 def __init__(self, maxsize, ttl, timer=time.time, missing=None,
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
215 getsizeof=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
216 Cache.__init__(self, maxsize, missing, getsizeof)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
217 self.__root = root = _Link()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
218 root.prev = root.next = root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
219 self.__links = collections.OrderedDict()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
220 self.__timer = _Timer(timer)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
221 self.__ttl = ttl
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
222
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
223 def __contains__(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
224 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
225 link = self.__links[key] # no reordering
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
226 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
227 return False
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
228 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
229 return not (link.expire < self.__timer())
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
230
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
231 def __getitem__(self, key, cache_getitem=Cache.__getitem__):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
232 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
233 link = self.__getlink(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
234 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
235 expired = False
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
236 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
237 expired = link.expire < self.__timer()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
238 if expired:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
239 return self.__missing__(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
240 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
241 return cache_getitem(self, key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
242
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
243 def __setitem__(self, key, value, cache_setitem=Cache.__setitem__):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
244 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
245 self.expire(time)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
246 cache_setitem(self, key, value)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
247 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
248 link = self.__getlink(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
249 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
250 self.__links[key] = link = _Link(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
251 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
252 link.unlink()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
253 link.expire = time + self.__ttl
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
254 link.next = root = self.__root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
255 link.prev = prev = root.prev
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
256 prev.next = root.prev = link
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
257
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
258 def __delitem__(self, key, cache_delitem=Cache.__delitem__):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
259 cache_delitem(self, key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
260 link = self.__links.pop(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
261 link.unlink()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
262 if link.expire < self.__timer():
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
263 raise KeyError(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
264
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
265 def __iter__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
266 root = self.__root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
267 curr = root.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
268 while curr is not root:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
269 # "freeze" time for iterator access
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
270 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
271 if not (curr.expire < time):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
272 yield curr.key
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
273 curr = curr.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
274
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
275 def __len__(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
276 root = self.__root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
277 curr = root.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
278 time = self.__timer()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
279 count = len(self.__links)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
280 while curr is not root and curr.expire < time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
281 count -= 1
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
282 curr = curr.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
283 return count
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
284
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
285 def __setstate__(self, state):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
286 self.__dict__.update(state)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
287 root = self.__root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
288 root.prev = root.next = root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
289 for link in sorted(self.__links.values(), key=lambda obj: obj.expire):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
290 link.next = root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
291 link.prev = prev = root.prev
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
292 prev.next = root.prev = link
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
293 self.expire(self.__timer())
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
294
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
295 def __repr__(self, cache_repr=Cache.__repr__):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
296 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
297 self.expire(time)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
298 return cache_repr(self)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
299
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
300 @property
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
301 def currsize(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
302 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
303 self.expire(time)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
304 return super(TTLCache, self).currsize
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
305
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
306 @property
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
307 def timer(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
308 """The timer function used by the cache."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
309 return self.__timer
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
310
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
311 @property
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
312 def ttl(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
313 """The time-to-live value of the cache's items."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
314 return self.__ttl
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
315
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
316 def expire(self, time=None):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
317 """Remove expired items from the cache."""
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
318 if time is None:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
319 time = self.__timer()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
320 root = self.__root
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
321 curr = root.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
322 links = self.__links
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
323 cache_delitem = Cache.__delitem__
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
324 while curr is not root and curr.expire < time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
325 cache_delitem(self, curr.key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
326 del links[curr.key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
327 next = curr.next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
328 curr.unlink()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
329 curr = next
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
330
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
331 def clear(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
332 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
333 self.expire(time)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
334 Cache.clear(self)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
335
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
336 def get(self, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
337 with self.__timer:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
338 return Cache.get(self, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
339
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
340 def pop(self, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
341 with self.__timer:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
342 return Cache.pop(self, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
343
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
344 def setdefault(self, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
345 with self.__timer:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
346 return Cache.setdefault(self, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
347
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
348 def popitem(self):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
349 """Remove and return the `(key, value)` pair least recently used that
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
350 has not already expired.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
351
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
352 """
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
353 with self.__timer as time:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
354 self.expire(time)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
355 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
356 key = next(iter(self.__links))
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
357 except StopIteration:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
358 raise KeyError('%s is empty' % self.__class__.__name__)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
359 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
360 return (key, self.pop(key))
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
361
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
362 if hasattr(collections.OrderedDict, 'move_to_end'):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
363 def __getlink(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
364 value = self.__links[key]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
365 self.__links.move_to_end(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
366 return value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
367 else:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
368 def __getlink(self, key):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
369 value = self.__links.pop(key)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
370 self.__links[key] = value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
371 return value
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
372
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
373
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
374 #############################################
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
375 # END IMPORT OF CACHING LIBRARY #
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
376 #############################################
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
377
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
378 cache = TTLCache(
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
379 100, # Up to 100 items
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
380 1 * 60 # 5 minute cache life
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
381 )
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
382
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
383
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
384 def _get_instance():
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
385 return tripal.TripalInstance(
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
386 os.environ['GALAXY_TRIPAL_URL'],
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
387 os.environ['GALAXY_TRIPAL_USER'],
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
388 os.environ['GALAXY_TRIPAL_PASSWORD']
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
389 )
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
390
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
391
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
392 def list_organisms(*args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
393
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
394 ti = _get_instance()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
395
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
396 # Key for cached data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
397 cacheKey = 'orgs'
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
398 # We don't want to trust "if key in cache" because between asking and fetch
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
399 # it might through key error.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
400 if cacheKey not in cache:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
401 # However if it ISN'T there, we know we're safe to fetch + put in
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
402 # there.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
403 data = _list_organisms(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
404 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
405 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
406 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
407 # The cache key may or may not be in the cache at this point, it
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
408 # /likely/ is. However we take no chances that it wasn't evicted between
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
409 # when we checked above and now, so we reference the object from the
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
410 # cache in preparation to return.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
411 data = cache[cacheKey]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
412 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
413 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
414 # If access fails due to eviction, we will fail over and can ensure that
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
415 # data is inserted.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
416 data = _list_organisms(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
417 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
418 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
419
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
420
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
421 def _list_organisms(ti, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
422 # Fetch the orgs.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
423 orgs_data = []
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
424 for org in ti.organism.get_organisms():
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
425 clean_name = '%s %s' % (org['genus'], org['species'])
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
426 if org['infraspecific_name']:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
427 clean_name += ' (%s)' % (org['infraspecific_name'])
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
428 orgs_data.append((clean_name, org['organism_id'], False))
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
429 return orgs_data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
430
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
431
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
432 def list_analyses(*args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
433
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
434 ti = _get_instance()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
435
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
436 # Key for cached data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
437 cacheKey = 'analyses'
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
438 # We don't want to trust "if key in cache" because between asking and fetch
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
439 # it might through key error.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
440 if cacheKey not in cache:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
441 # However if it ISN'T there, we know we're safe to fetch + put in
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
442 # there.<?xml version="1.0"?>
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
443
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
444 data = _list_analyses(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
445 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
446 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
447 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
448 # The cache key may or may not be in the cache at this point, it
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
449 # /likely/ is. However we take no chances that it wasn't evicted between
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
450 # when we checked above and now, so we reference the object from the
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
451 # cache in preparation to return.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
452 data = cache[cacheKey]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
453 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
454 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
455 # If access fails due to eviction, we will fail over and can ensure that
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
456 # data is inserted.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
457 data = _list_analyses(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
458 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
459 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
460
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
461
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
462 def _list_analyses(ti, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
463 ans_data = []
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
464 for an in ti.analysis.get_analyses():
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
465 ans_data.append((an['name'], an['analysis_id'], False))
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
466 return ans_data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
467
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
468
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
469 def list_blastdbs(*args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
470
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
471 ti = _get_instance()
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
472
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
473 # Key for cached data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
474 cacheKey = 'blastdbs'
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
475 # We don't want to trust "if key in cache" because between asking and fetch
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
476 # it might through key error.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
477 if cacheKey not in cache:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
478 # However if it ISN'T there, we know we're safe to fetch + put in
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
479 # there.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
480 data = _list_blastdbs(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
481 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
482 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
483 try:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
484 # The cache key may or may not be in the cache at this point, it
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
485 # /likely/ is. However we take no chances that it wasn't evicted between
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
486 # when we checked above and now, so we reference the object from the
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
487 # cache in preparation to return.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
488 data = cache[cacheKey]
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
489 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
490 except KeyError:
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
491 # If access fails due to eviction, we will fail over and can ensure that
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
492 # data is inserted.
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
493 data = _list_blastdbs(ti, *args, **kwargs)
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
494 cache[cacheKey] = data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
495 return data
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
496
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
497
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
498 def _list_blastdbs(ti, *args, **kwargs):
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
499 dbs_data = []
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
500 for db in ti.db.get_dbs():
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
501 dbs_data.append((db['name'], db['db_id'], False))
c01c63c043f0 planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff changeset
502 return dbs_data