Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/boto/sdb/db/query.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 from boto.compat import six | |
2 # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ | |
3 # | |
4 # Permission is hereby granted, free of charge, to any person obtaining a | |
5 # copy of this software and associated documentation files (the | |
6 # "Software"), to deal in the Software without restriction, including | |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
8 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
9 # persons to whom the Software is furnished to do so, subject to the fol- | |
10 # lowing conditions: | |
11 # | |
12 # The above copyright notice and this permission notice shall be included | |
13 # in all copies or substantial portions of the Software. | |
14 # | |
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
21 # IN THE SOFTWARE. | |
22 | |
23 class Query(object): | |
24 __local_iter__ = None | |
25 def __init__(self, model_class, limit=None, next_token=None, manager=None): | |
26 self.model_class = model_class | |
27 self.limit = limit | |
28 self.offset = 0 | |
29 if manager: | |
30 self.manager = manager | |
31 else: | |
32 self.manager = self.model_class._manager | |
33 self.filters = [] | |
34 self.select = None | |
35 self.sort_by = None | |
36 self.rs = None | |
37 self.next_token = next_token | |
38 | |
39 def __iter__(self): | |
40 return iter(self.manager.query(self)) | |
41 | |
42 def next(self): | |
43 if self.__local_iter__ is None: | |
44 self.__local_iter__ = self.__iter__() | |
45 return next(self.__local_iter__) | |
46 | |
47 def filter(self, property_operator, value): | |
48 self.filters.append((property_operator, value)) | |
49 return self | |
50 | |
51 def fetch(self, limit, offset=0): | |
52 """Not currently fully supported, but we can use this | |
53 to allow them to set a limit in a chainable method""" | |
54 self.limit = limit | |
55 self.offset = offset | |
56 return self | |
57 | |
58 def count(self, quick=True): | |
59 return self.manager.count(self.model_class, self.filters, quick, self.sort_by, self.select) | |
60 | |
61 def get_query(self): | |
62 return self.manager._build_filter_part(self.model_class, self.filters, self.sort_by, self.select) | |
63 | |
64 def order(self, key): | |
65 self.sort_by = key | |
66 return self | |
67 | |
68 def to_xml(self, doc=None): | |
69 if not doc: | |
70 xmlmanager = self.model_class.get_xmlmanager() | |
71 doc = xmlmanager.new_doc() | |
72 for obj in self: | |
73 obj.to_xml(doc) | |
74 return doc | |
75 | |
76 def get_next_token(self): | |
77 if self.rs: | |
78 return self.rs.next_token | |
79 if self._next_token: | |
80 return self._next_token | |
81 return None | |
82 | |
83 def set_next_token(self, token): | |
84 self._next_token = token | |
85 | |
86 next_token = property(get_next_token, set_next_token) |