|
8 | 8 |
|
9 | 9 | sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/')) |
10 | 10 | import ConfigLoader |
| 11 | +import Decoded |
11 | 12 |
|
12 | 13 | sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/')) |
13 | 14 | import Date |
14 | 15 | import Tag |
| 16 | +from Cryptocurrency import cryptocurrency |
| 17 | +from Pgp import pgp |
15 | 18 |
|
16 | 19 | config_loader = ConfigLoader.ConfigLoader() |
17 | 20 | PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], config_loader.get_config_str("Directories", "pastes")) + '/' |
@@ -126,26 +129,85 @@ def get_item(request_dict): |
126 | 129 | ### |
127 | 130 | ### correlation |
128 | 131 | ### |
| 132 | +def get_item_cryptocurrency(item_id, currencies_type=None, get_nb=False): |
| 133 | + ''' |
| 134 | + Return all cryptocurrencies of a given item. |
| 135 | +
|
| 136 | + :param item_id: item id |
| 137 | + :param currencies_type: list of cryptocurrencies type |
| 138 | + :type currencies_type: list, optional |
| 139 | + ''' |
| 140 | + return cryptocurrency.get_item_correlation_dict(item_id, correlation_type=currencies_type, get_nb=get_nb) |
| 141 | + |
| 142 | +def get_item_pgp(item_id, currencies_type=None, get_nb=False): |
| 143 | + ''' |
| 144 | + Return all pgp of a given item. |
| 145 | +
|
| 146 | + :param item_id: item id |
| 147 | + :param currencies_type: list of cryptocurrencies type |
| 148 | + :type currencies_type: list, optional |
| 149 | + ''' |
| 150 | + return pgp.get_item_correlation_dict(item_id, correlation_type=currencies_type, get_nb=get_nb) |
| 151 | + |
| 152 | +def get_item_decoded(item_id): |
| 153 | + ''' |
| 154 | + Return all pgp of a given item. |
| 155 | +
|
| 156 | + :param item_id: item id |
| 157 | + :param currencies_type: list of cryptocurrencies type |
| 158 | + :type currencies_type: list, optional |
| 159 | + ''' |
| 160 | + return Decoded.get_item_decoded(item_id) |
| 161 | + |
| 162 | +def get_item_all_correlation(item_id, correlation_type=None, get_nb=False): |
| 163 | + ''' |
| 164 | + Retun all correlation of a given item id. |
| 165 | +
|
| 166 | + :param item_id: item id |
| 167 | + :type domain: str |
| 168 | +
|
| 169 | + :return: a dict of all correlation for a item id |
| 170 | + :rtype: dict |
| 171 | + ''' |
| 172 | + item_correl = {} |
| 173 | + res = get_item_cryptocurrency(item_id, get_nb=get_nb) |
| 174 | + if res: |
| 175 | + item_correl['cryptocurrency'] = res |
| 176 | + res = get_item_pgp(item_id, get_nb=get_nb) |
| 177 | + if res: |
| 178 | + item_correl['pgp'] = res |
| 179 | + res = get_item_decoded(item_id) |
| 180 | + if res: |
| 181 | + item_correl['decoded'] = res |
| 182 | + return item_correl |
| 183 | + |
| 184 | + |
129 | 185 |
|
| 186 | +## TODO: REFRACTOR |
130 | 187 | def _get_item_correlation(correlation_name, correlation_type, item_id): |
131 | 188 | res = r_serv_metadata.smembers('item_{}_{}:{}'.format(correlation_name, correlation_type, item_id)) |
132 | 189 | if res: |
133 | 190 | return list(res) |
134 | 191 | else: |
135 | 192 | return [] |
136 | 193 |
|
| 194 | +## TODO: REFRACTOR |
137 | 195 | def get_item_bitcoin(item_id): |
138 | 196 | return _get_item_correlation('cryptocurrency', 'bitcoin', item_id) |
139 | 197 |
|
| 198 | +## TODO: REFRACTOR |
140 | 199 | def get_item_pgp_key(item_id): |
141 | 200 | return _get_item_correlation('pgpdump', 'key', item_id) |
142 | 201 |
|
| 202 | +## TODO: REFRACTOR |
143 | 203 | def get_item_pgp_name(item_id): |
144 | 204 | return _get_item_correlation('pgpdump', 'name', item_id) |
145 | 205 |
|
| 206 | +## TODO: REFRACTOR |
146 | 207 | def get_item_pgp_mail(item_id): |
147 | 208 | return _get_item_correlation('pgpdump', 'mail', item_id) |
148 | 209 |
|
| 210 | +## TODO: REFRACTOR |
149 | 211 | def get_item_pgp_correlation(item_id): |
150 | 212 | pass |
151 | 213 |
|
|
0 commit comments