Mercurial > repos > gga > tripal_analysis_add_analysis
annotate tripal.py @ 0:f8dab3351d1b 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:49:35 -0400 |
parents | |
children | ab0942a9ae18 |
rev | line source |
---|---|
0
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
4 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
6 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
8 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
9 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
10 ############################################# |
f8dab3351d1b
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 # |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
12 ############################################# |
f8dab3351d1b
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 # |
f8dab3351d1b
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 # |
f8dab3351d1b
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. # |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
16 # e27332bc82f4e327aedaec17c9b656ae719322ed # |
f8dab3351d1b
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/ # |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
18 ############################################# |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
20 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
21 __slots__ = () |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
22 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
23 @abstractmethod |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
26 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
27 @abstractmethod |
f8dab3351d1b
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 |
f8dab3351d1b
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__'): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
31 else: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
33 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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] |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
37 else: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
39 |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
41 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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] |
f8dab3351d1b
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] |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
48 else: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
51 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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] |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
55 else: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
58 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
59 |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
61 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
62 |
f8dab3351d1b
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): |
f8dab3351d1b
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, _): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
66 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
69 |
f8dab3351d1b
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, _): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
72 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
73 |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
76 |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
78 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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() |
f8dab3351d1b
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() |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
88 |
f8dab3351d1b
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): |
f8dab3351d1b
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)' % ( |
f8dab3351d1b
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__, |
f8dab3351d1b
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()), |
f8dab3351d1b
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, |
f8dab3351d1b
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, |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
95 ) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
96 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
98 try: |
f8dab3351d1b
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] |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
102 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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) |
f8dab3351d1b
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: |
f8dab3351d1b
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') |
f8dab3351d1b
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: |
f8dab3351d1b
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: |
f8dab3351d1b
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() |
f8dab3351d1b
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: |
f8dab3351d1b
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] |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
113 else: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
118 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
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] |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
123 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
126 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
129 try: |
f8dab3351d1b
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) |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
134 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
137 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
140 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
141 @staticmethod |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
144 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
145 @staticmethod |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
148 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
149 @property |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
153 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
154 @property |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
158 |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
162 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
163 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
165 |
f8dab3351d1b
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') |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
167 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
171 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
174 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
180 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
181 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
183 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
187 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
191 else: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
193 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
197 else: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
201 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
204 |
f8dab3351d1b
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): |
f8dab3351d1b
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,) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
207 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
210 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
211 |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
214 |
f8dab3351d1b
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, |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
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() |
f8dab3351d1b
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 |
f8dab3351d1b
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() |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
223 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
225 try: |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
229 else: |
f8dab3351d1b
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()) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
231 |
f8dab3351d1b
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__): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
233 try: |
f8dab3351d1b
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) |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
237 else: |
f8dab3351d1b
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() |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
241 else: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
243 |
f8dab3351d1b
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__): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
248 try: |
f8dab3351d1b
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) |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
252 else: |
f8dab3351d1b
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() |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
258 |
f8dab3351d1b
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__): |
f8dab3351d1b
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) |
f8dab3351d1b
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) |
f8dab3351d1b
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() |
f8dab3351d1b
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(): |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
265 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
275 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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() |
f8dab3351d1b
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) |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
285 |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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()) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
295 |
f8dab3351d1b
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__): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
300 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
301 @property |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
306 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
307 @property |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
311 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
312 @property |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
316 |
f8dab3351d1b
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): |
f8dab3351d1b
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.""" |
f8dab3351d1b
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: |
f8dab3351d1b
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() |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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__ |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
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] |
f8dab3351d1b
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 |
f8dab3351d1b
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() |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
331 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
336 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
340 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
344 |
f8dab3351d1b
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): |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
348 |
f8dab3351d1b
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): |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
352 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
353 """ |
f8dab3351d1b
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: |
f8dab3351d1b
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) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
356 try: |
f8dab3351d1b
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)) |
f8dab3351d1b
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: |
f8dab3351d1b
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__) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
360 else: |
f8dab3351d1b
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)) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
362 |
f8dab3351d1b
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'): |
f8dab3351d1b
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): |
f8dab3351d1b
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] |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
368 else: |
f8dab3351d1b
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): |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
373 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
374 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
375 ############################################# |
f8dab3351d1b
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 # |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
377 ############################################# |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
378 |
f8dab3351d1b
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( |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
382 ) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
383 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
384 |
f8dab3351d1b
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(): |
f8dab3351d1b
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( |
f8dab3351d1b
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'], |
f8dab3351d1b
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'], |
f8dab3351d1b
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'] |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
390 ) |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
391 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
392 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
394 |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
396 |
f8dab3351d1b
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 |
f8dab3351d1b
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' |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
403 # there. |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
407 try: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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] |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
420 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
421 |
f8dab3351d1b
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): |
f8dab3351d1b
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. |
f8dab3351d1b
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 = [] |
f8dab3351d1b
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(): |
f8dab3351d1b
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']) |
f8dab3351d1b
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']: |
f8dab3351d1b
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']) |
f8dab3351d1b
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)) |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
431 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
432 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
434 |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
436 |
f8dab3351d1b
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 |
f8dab3351d1b
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' |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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"?> |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
444 |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
448 try: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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] |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
461 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
462 |
f8dab3351d1b
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): |
f8dab3351d1b
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 = [] |
f8dab3351d1b
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(): |
f8dab3351d1b
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)) |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
468 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
469 |
f8dab3351d1b
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): |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
471 |
f8dab3351d1b
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() |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
473 |
f8dab3351d1b
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 |
f8dab3351d1b
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' |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
480 # there. |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
484 try: |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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] |
f8dab3351d1b
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 |
f8dab3351d1b
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: |
f8dab3351d1b
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 |
f8dab3351d1b
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. |
f8dab3351d1b
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) |
f8dab3351d1b
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 |
f8dab3351d1b
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 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
497 |
f8dab3351d1b
planemo upload for repository https://github.com/galaxy-genome-annotation/galaxy-tools/tree/master/tools/tripal commit f745b23c84a615bf434d717c8c0e553a012f0268
gga
parents:
diff
changeset
|
498 |
f8dab3351d1b
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): |
f8dab3351d1b
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 = [] |
f8dab3351d1b
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(): |
f8dab3351d1b
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)) |
f8dab3351d1b
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 |