annotate tripal.py @ 0:81f5e6980725 draft

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