aa-intel-tool 2.6.0__py3-none-any.whl → 2.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aa_intel_tool/__init__.py +1 -1
- aa_intel_tool/app_settings.py +15 -0
- aa_intel_tool/constants.py +6 -5
- aa_intel_tool/helper/eve_character.py +24 -36
- aa_intel_tool/helper/static_files.py +5 -4
- aa_intel_tool/locale/cs_CZ/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/de/LC_MESSAGES/django.mo +0 -0
- aa_intel_tool/locale/de/LC_MESSAGES/django.po +71 -87
- aa_intel_tool/locale/django.pot +16 -84
- aa_intel_tool/locale/es/LC_MESSAGES/django.po +19 -83
- aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
- aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.po +72 -88
- aa_intel_tool/locale/it_IT/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/ja/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/ko_KR/LC_MESSAGES/django.po +67 -83
- aa_intel_tool/locale/nl_NL/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/pl_PL/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/ru/LC_MESSAGES/django.mo +0 -0
- aa_intel_tool/locale/ru/LC_MESSAGES/django.po +71 -87
- aa_intel_tool/locale/sk/LC_MESSAGES/django.po +15 -83
- aa_intel_tool/locale/uk/LC_MESSAGES/django.mo +0 -0
- aa_intel_tool/locale/uk/LC_MESSAGES/django.po +71 -94
- aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
- aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.po +20 -87
- aa_intel_tool/parser/general.py +11 -16
- aa_intel_tool/parser/helper/db.py +8 -11
- aa_intel_tool/parser/module/chatlist.py +97 -126
- aa_intel_tool/parser/module/dscan.py +115 -147
- aa_intel_tool/parser/module/fleetcomp.py +85 -102
- aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.css +6 -24
- aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css +1 -1
- aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.js +104 -64
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.js +5 -5
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.js +43 -43
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.js +41 -17
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.js +51 -51
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.js +13 -7
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js.map +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.js +53 -31
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js +1 -1
- aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js.map +1 -1
- aa_intel_tool/templates/aa_intel_tool/base.html +7 -42
- aa_intel_tool/templates/aa_intel_tool/partials/scan/evetime.html +1 -1
- aa_intel_tool/templatetags/aa_intel_tool.py +12 -7
- aa_intel_tool/tests/test-data/dscan.txt +250 -0
- aa_intel_tool/tests/test_admin.py +50 -38
- aa_intel_tool/tests/test_app_settings.py +23 -1
- aa_intel_tool/tests/test_helper_eve_character.py +405 -0
- aa_intel_tool/tests/test_models.py +188 -4
- aa_intel_tool/tests/test_parser_general.py +771 -0
- aa_intel_tool/tests/test_parser_module_chatlist.py +154 -0
- aa_intel_tool/tests/test_templatetags.py +24 -3
- {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/METADATA +4 -4
- {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/RECORD +65 -63
- aa_intel_tool/tests/test_parser.py +0 -135
- {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/WHEEL +0 -0
- {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,6 +4,7 @@ D-Scan parser
|
|
|
4
4
|
|
|
5
5
|
# Standard Library
|
|
6
6
|
import re
|
|
7
|
+
from collections import defaultdict
|
|
7
8
|
|
|
8
9
|
# Django
|
|
9
10
|
from django.db.models import QuerySet
|
|
@@ -49,14 +50,12 @@ def _is_on_grid(distance: str) -> bool:
|
|
|
49
50
|
)
|
|
50
51
|
|
|
51
52
|
# Check if we have a distance
|
|
52
|
-
|
|
53
|
-
distance_sanitised = int(re.sub(pattern=r"[^0-9]", repl="", string=distance))
|
|
54
|
-
|
|
55
|
-
# Check if the distance is within the grid size
|
|
56
|
-
if distance_sanitised <= AppSettings.INTELTOOL_DSCAN_GRID_SIZE:
|
|
57
|
-
return True
|
|
53
|
+
match = re.search(pattern=REGEX_PATTERN["localised_on_grid"], string=distance)
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
# Check if the distance is within the grid size
|
|
56
|
+
if match:
|
|
57
|
+
distance_sanitised = int(re.sub(pattern=r"[^0-9]", repl="", string=distance))
|
|
58
|
+
return distance_sanitised <= AppSettings.INTELTOOL_DSCAN_GRID_SIZE
|
|
60
59
|
|
|
61
60
|
return False
|
|
62
61
|
|
|
@@ -104,6 +103,25 @@ def _get_ships(eve_types: QuerySet, counter: dict) -> dict:
|
|
|
104
103
|
|
|
105
104
|
ships = {"all": {}, "ongrid": {}, "offgrid": {}, "types": {}}
|
|
106
105
|
|
|
106
|
+
def _add_ship_info(ship_dict: dict, eve_type: tuple, count: int):
|
|
107
|
+
"""
|
|
108
|
+
Add ship info to the ship_dict
|
|
109
|
+
|
|
110
|
+
:param ship_dict:
|
|
111
|
+
:type ship_dict:
|
|
112
|
+
:param eve_type:
|
|
113
|
+
:type eve_type:
|
|
114
|
+
:param count:
|
|
115
|
+
:type count:
|
|
116
|
+
:return:
|
|
117
|
+
:rtype:
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
if eve_type[1] not in ship_dict:
|
|
121
|
+
ship_dict[eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
|
|
122
|
+
ship_dict[eve_type[1]]["count"] = count
|
|
123
|
+
ship_dict[eve_type[1]]["mass"] = eve_type[4] * count
|
|
124
|
+
|
|
107
125
|
# Ship types
|
|
108
126
|
# Get all ship types
|
|
109
127
|
#
|
|
@@ -118,33 +136,30 @@ def _get_ships(eve_types: QuerySet, counter: dict) -> dict:
|
|
|
118
136
|
)
|
|
119
137
|
|
|
120
138
|
# Loop through all ships types
|
|
121
|
-
for eve_type in eve_types_ships:
|
|
139
|
+
for eve_type in list(eve_types_ships):
|
|
122
140
|
# Info for "All Ships" table
|
|
123
141
|
if eve_type[0] in counter["all"]:
|
|
124
|
-
|
|
125
|
-
ships["all"]
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
142
|
+
_add_ship_info(
|
|
143
|
+
ship_dict=ships["all"],
|
|
144
|
+
eve_type=eve_type,
|
|
145
|
+
count=counter["all"][eve_type[0]],
|
|
146
|
+
)
|
|
130
147
|
|
|
131
148
|
# Info for "On Grid" table
|
|
132
149
|
if eve_type[0] in counter["ongrid"]:
|
|
133
|
-
|
|
134
|
-
ships["ongrid"]
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
150
|
+
_add_ship_info(
|
|
151
|
+
ship_dict=ships["ongrid"],
|
|
152
|
+
eve_type=eve_type,
|
|
153
|
+
count=counter["ongrid"][eve_type[0]],
|
|
154
|
+
)
|
|
139
155
|
|
|
140
156
|
# Info for "Off Grid" table
|
|
141
157
|
if eve_type[0] in counter["offgrid"]:
|
|
142
|
-
|
|
143
|
-
ships["offgrid"]
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
)
|
|
158
|
+
_add_ship_info(
|
|
159
|
+
ship_dict=ships["offgrid"],
|
|
160
|
+
eve_type=eve_type,
|
|
161
|
+
count=counter["offgrid"][eve_type[0]],
|
|
162
|
+
)
|
|
148
163
|
|
|
149
164
|
# Info for "Ship Types" table
|
|
150
165
|
if eve_type[3] not in ships["types"]:
|
|
@@ -183,25 +198,22 @@ def _get_upwell_structures_on_grid(
|
|
|
183
198
|
eve_group__eve_category_id__exact=EveCategoryId.STRUCTURE
|
|
184
199
|
)
|
|
185
200
|
|
|
186
|
-
upwell_structures = {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
upwell_structures[eve_type[1]][
|
|
201
|
-
"name"
|
|
202
|
-
] += f" » {ansiblex_destination}"
|
|
201
|
+
upwell_structures = {
|
|
202
|
+
eve_type[1]: {
|
|
203
|
+
**_get_type_info_dict(eve_type=eve_type),
|
|
204
|
+
"count": counter["ongrid"][eve_type[0]],
|
|
205
|
+
"name": (
|
|
206
|
+
f"{eve_type[1]} » {ansiblex_destination}"
|
|
207
|
+
if eve_type[0] == UpwellStructureId.ANSIBLEX_JUMP_GATE
|
|
208
|
+
and ansiblex_destination
|
|
209
|
+
else eve_type[1]
|
|
210
|
+
),
|
|
211
|
+
}
|
|
212
|
+
for eve_type in list(eve_types_structures)
|
|
213
|
+
if eve_type[0] in counter["ongrid"]
|
|
214
|
+
}
|
|
203
215
|
|
|
204
|
-
return dict_to_list(upwell_structures)
|
|
216
|
+
return dict_to_list(input_dict=upwell_structures)
|
|
205
217
|
|
|
206
218
|
|
|
207
219
|
def _get_deployables_on_grid(eve_types: QuerySet, counter: dict) -> list:
|
|
@@ -220,16 +232,16 @@ def _get_deployables_on_grid(eve_types: QuerySet, counter: dict) -> list:
|
|
|
220
232
|
eve_group__eve_category_id__exact=AdditionalEveCategoryId.DEPLOYABLE
|
|
221
233
|
)
|
|
222
234
|
|
|
223
|
-
deployables = {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
deployables = {
|
|
236
|
+
eve_type[1]: {
|
|
237
|
+
**_get_type_info_dict(eve_type=eve_type),
|
|
238
|
+
"count": counter["ongrid"][eve_type[0]],
|
|
239
|
+
}
|
|
240
|
+
for eve_type in list(eve_types_deployables)
|
|
241
|
+
if eve_type[0] in counter["ongrid"]
|
|
242
|
+
}
|
|
231
243
|
|
|
232
|
-
return dict_to_list(deployables)
|
|
244
|
+
return dict_to_list(input_dict=deployables)
|
|
233
245
|
|
|
234
246
|
|
|
235
247
|
def _get_starbases_on_grid(eve_types: QuerySet, counter: dict) -> list:
|
|
@@ -248,16 +260,16 @@ def _get_starbases_on_grid(eve_types: QuerySet, counter: dict) -> list:
|
|
|
248
260
|
eve_group__eve_category_id__exact=AdditionalEveCategoryId.STARBASE
|
|
249
261
|
)
|
|
250
262
|
|
|
251
|
-
starbases = {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
263
|
+
starbases = {
|
|
264
|
+
eve_type[1]: {
|
|
265
|
+
**_get_type_info_dict(eve_type=eve_type),
|
|
266
|
+
"count": counter["ongrid"][eve_type[0]],
|
|
267
|
+
}
|
|
268
|
+
for eve_type in list(eve_types_starbase)
|
|
269
|
+
if eve_type[0] in counter["ongrid"]
|
|
270
|
+
}
|
|
259
271
|
|
|
260
|
-
return dict_to_list(starbases)
|
|
272
|
+
return dict_to_list(input_dict=starbases)
|
|
261
273
|
|
|
262
274
|
|
|
263
275
|
def _get_ansiblex_jumpgate_destination(ansiblex_name: str) -> str:
|
|
@@ -270,10 +282,9 @@ def _get_ansiblex_jumpgate_destination(ansiblex_name: str) -> str:
|
|
|
270
282
|
:rtype:
|
|
271
283
|
"""
|
|
272
284
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return gate_systems[1]
|
|
285
|
+
return re.split(
|
|
286
|
+
pattern=r" » ", string=re.split(pattern=r" - ", string=ansiblex_name)[0]
|
|
287
|
+
)[1]
|
|
277
288
|
|
|
278
289
|
|
|
279
290
|
def _get_scan_details(scan_data: list) -> tuple:
|
|
@@ -292,8 +303,8 @@ def _get_scan_details(scan_data: list) -> tuple:
|
|
|
292
303
|
)
|
|
293
304
|
|
|
294
305
|
ansiblex_destination = None
|
|
295
|
-
counter =
|
|
296
|
-
eve_ids =
|
|
306
|
+
counter = defaultdict(lambda: defaultdict(int))
|
|
307
|
+
eve_ids = defaultdict(list)
|
|
297
308
|
|
|
298
309
|
# Let's split this list up
|
|
299
310
|
#
|
|
@@ -314,11 +325,11 @@ def _get_scan_details(scan_data: list) -> tuple:
|
|
|
314
325
|
line = re.search(pattern=REGEX_PATTERN["dscan"], string=entry)
|
|
315
326
|
entry_id = int(line.group(1))
|
|
316
327
|
|
|
317
|
-
counter["all"][entry_id]
|
|
328
|
+
counter["all"][entry_id] += 1
|
|
318
329
|
|
|
319
330
|
# Check if the entry is "on grid" or not
|
|
320
|
-
if _is_on_grid(line.group(4)):
|
|
321
|
-
counter["ongrid"][entry_id]
|
|
331
|
+
if _is_on_grid(distance=line.group(4)):
|
|
332
|
+
counter["ongrid"][entry_id] += 1
|
|
322
333
|
|
|
323
334
|
# If it is an Ansiblex Jump Gate, get its destination system
|
|
324
335
|
if entry_id == UpwellStructureId.ANSIBLEX_JUMP_GATE:
|
|
@@ -328,8 +339,7 @@ def _get_scan_details(scan_data: list) -> tuple:
|
|
|
328
339
|
|
|
329
340
|
eve_ids["ongrid"].append(entry_id)
|
|
330
341
|
else:
|
|
331
|
-
counter["offgrid"][entry_id]
|
|
332
|
-
|
|
342
|
+
counter["offgrid"][entry_id] += 1
|
|
333
343
|
eve_ids["offgrid"].append(entry_id)
|
|
334
344
|
|
|
335
345
|
eve_ids["all"].append(entry_id)
|
|
@@ -347,82 +357,40 @@ def parse(scan_data: list) -> Scan:
|
|
|
347
357
|
:rtype:
|
|
348
358
|
"""
|
|
349
359
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if AppSettings.INTELTOOL_ENABLE_MODULE_DSCAN is True:
|
|
354
|
-
parsed_data = {}
|
|
355
|
-
(
|
|
356
|
-
ansiblex_destination, # pylint: disable=unused-variable
|
|
357
|
-
counter,
|
|
358
|
-
eve_ids,
|
|
359
|
-
) = _get_scan_details(scan_data=scan_data)
|
|
360
|
-
|
|
361
|
-
eve_types = EveType.objects.bulk_get_or_create_esi(
|
|
362
|
-
ids=set(eve_ids["all"]), include_children=True
|
|
363
|
-
).values_list(
|
|
364
|
-
"id", "name", "eve_group__id", "eve_group__name", "mass", named=True
|
|
365
|
-
)
|
|
366
|
-
|
|
367
|
-
# Parse the data parts
|
|
368
|
-
ships = _get_ships(eve_types=eve_types, counter=counter)
|
|
369
|
-
upwell_structures = _get_upwell_structures_on_grid(
|
|
370
|
-
eve_types=eve_types,
|
|
371
|
-
counter=counter,
|
|
372
|
-
# ansiblex_destination=ansiblex_destination,
|
|
373
|
-
)
|
|
374
|
-
deployables = _get_deployables_on_grid(eve_types=eve_types, counter=counter)
|
|
375
|
-
starbases = _get_starbases_on_grid(eve_types=eve_types, counter=counter)
|
|
376
|
-
|
|
377
|
-
# Add "ships all" to the parsed data when available
|
|
378
|
-
if ships["all"]:
|
|
379
|
-
parsed_data["all"] = {
|
|
380
|
-
"section": ScanData.Section.SHIPLIST,
|
|
381
|
-
"data": ships["all"],
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
# Add "ships on grid" to the parsed data when available
|
|
385
|
-
if ships["ongrid"]:
|
|
386
|
-
parsed_data["ongrid"] = {
|
|
387
|
-
"section": ScanData.Section.SHIPLIST_ON_GRID,
|
|
388
|
-
"data": ships["ongrid"],
|
|
389
|
-
}
|
|
360
|
+
# Only parse the d-scan if the module is enabled
|
|
361
|
+
if not AppSettings.INTELTOOL_ENABLE_MODULE_DSCAN:
|
|
362
|
+
raise ParserError(message=_("The D-Scan module is currently disabled."))
|
|
390
363
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
parsed_data["offgrid"] = {
|
|
394
|
-
"section": ScanData.Section.SHIPLIST_OFF_GRID,
|
|
395
|
-
"data": ships["offgrid"],
|
|
396
|
-
}
|
|
364
|
+
parsed_data = {}
|
|
365
|
+
ansiblex_destination, counter, eve_ids = _get_scan_details(scan_data=scan_data)
|
|
397
366
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
"section": ScanData.Section.SHIPTYPES,
|
|
402
|
-
"data": ships["types"],
|
|
403
|
-
}
|
|
367
|
+
eve_types = EveType.objects.bulk_get_or_create_esi(
|
|
368
|
+
ids=set(eve_ids["all"]), include_children=True
|
|
369
|
+
).values_list("id", "name", "eve_group__id", "eve_group__name", "mass", named=True)
|
|
404
370
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
371
|
+
# Parse the data parts
|
|
372
|
+
ships = _get_ships(eve_types=eve_types, counter=counter)
|
|
373
|
+
upwell_structures = _get_upwell_structures_on_grid(
|
|
374
|
+
eve_types=eve_types,
|
|
375
|
+
counter=counter,
|
|
376
|
+
ansiblex_destination=ansiblex_destination,
|
|
377
|
+
)
|
|
378
|
+
deployables = _get_deployables_on_grid(eve_types=eve_types, counter=counter)
|
|
379
|
+
starbases = _get_starbases_on_grid(eve_types=eve_types, counter=counter)
|
|
380
|
+
|
|
381
|
+
# Add parsed data when available
|
|
382
|
+
sections = {
|
|
383
|
+
"all": (ScanData.Section.SHIPLIST, ships["all"]),
|
|
384
|
+
"ongrid": (ScanData.Section.SHIPLIST_ON_GRID, ships["ongrid"]),
|
|
385
|
+
"offgrid": (ScanData.Section.SHIPLIST_OFF_GRID, ships["offgrid"]),
|
|
386
|
+
"shiptypes": (ScanData.Section.SHIPTYPES, ships["types"]),
|
|
387
|
+
"structures_on_grid": (ScanData.Section.STRUCTURES_ON_GRID, upwell_structures),
|
|
388
|
+
"deployables": (ScanData.Section.DEPLOYABLES_ON_GRID, deployables),
|
|
389
|
+
"starbases": (ScanData.Section.STARBASES_ON_GRID, starbases),
|
|
390
|
+
}
|
|
425
391
|
|
|
426
|
-
|
|
392
|
+
for key, (section, data) in sections.items():
|
|
393
|
+
if data:
|
|
394
|
+
parsed_data[key] = {"section": section, "data": data}
|
|
427
395
|
|
|
428
|
-
|
|
396
|
+
return safe_scan_to_db(scan_type=Scan.Type.DSCAN, parsed_data=parsed_data)
|
|
@@ -51,45 +51,49 @@ def get_fleet_composition(pilots: dict, ships: dict) -> dict:
|
|
|
51
51
|
ids=set(ship_class_ids), include_children=True
|
|
52
52
|
).values_list("id", "name", "eve_group__id", "eve_group__name", "mass", named=True)
|
|
53
53
|
|
|
54
|
-
#
|
|
55
|
-
for ship_class in ship_class_details:
|
|
54
|
+
# Build ship class and type dictionaries
|
|
55
|
+
for ship_class in list(ship_class_details):
|
|
56
56
|
# Build ship class dict
|
|
57
|
-
ships["class"][ship_class.name]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
ships["class"][ship_class.name].update(
|
|
58
|
+
{
|
|
59
|
+
"id": ship_class.id,
|
|
60
|
+
"name": ship_class.name,
|
|
61
|
+
"type_id": ship_class.eve_group__id,
|
|
62
|
+
"type_name": ship_class.eve_group__name,
|
|
63
|
+
"image": eveimageserver.type_icon_url(type_id=ship_class.id, size=32),
|
|
64
|
+
"mass": ship_class.mass * ships["class"][ship_class.name]["count"],
|
|
65
|
+
}
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
# Build ship type dict
|
|
69
|
-
ships["type"][ship_class.eve_group__name]
|
|
70
|
-
|
|
69
|
+
ships["type"][ship_class.eve_group__name].update(
|
|
70
|
+
{
|
|
71
|
+
"id": ship_class.eve_group__id,
|
|
72
|
+
"name": ship_class.eve_group__name,
|
|
73
|
+
}
|
|
74
|
+
)
|
|
71
75
|
|
|
72
76
|
# Pilots
|
|
73
|
-
pilot_details = _get_character_info(scan_data=list(
|
|
74
|
-
|
|
75
|
-
#
|
|
76
|
-
for pilot in pilot_details:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
# Build pilots dict
|
|
83
|
-
pilots[pilot.character_name]["id"] = pilot.character_id
|
|
84
|
-
pilots[pilot.character_name]["portrait"] = pilot.portrait_url_32
|
|
85
|
-
pilots[pilot.character_name]["evewho"] = evewho.character_url(
|
|
86
|
-
pilot.character_id
|
|
77
|
+
pilot_details = _get_character_info(scan_data=list(pilots))
|
|
78
|
+
|
|
79
|
+
# Build pilots dictionary
|
|
80
|
+
for pilot in list(pilot_details):
|
|
81
|
+
pilot_ship_class = next(
|
|
82
|
+
ship_class
|
|
83
|
+
for ship_class in ship_class_details
|
|
84
|
+
if ship_class.name == pilots[pilot.character_name]["ship"]
|
|
87
85
|
)
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
|
|
87
|
+
pilots[pilot.character_name].update(
|
|
88
|
+
{
|
|
89
|
+
"id": pilot.character_id,
|
|
90
|
+
"portrait": pilot.portrait_url_32,
|
|
91
|
+
"evewho": evewho.character_url(pilot.character_id),
|
|
92
|
+
"zkillboard": zkillboard.character_url(pilot.character_id),
|
|
93
|
+
"ship_id": pilot_ship_class.id,
|
|
94
|
+
"ship_type_id": pilot_ship_class.eve_group__id,
|
|
95
|
+
}
|
|
90
96
|
)
|
|
91
|
-
pilots[pilot.character_name]["ship_id"] = pilot__ship_class.id
|
|
92
|
-
pilots[pilot.character_name]["ship_type_id"] = pilot__ship_class.eve_group__id
|
|
93
97
|
|
|
94
98
|
return {
|
|
95
99
|
"classes": dict_to_list(input_dict=ships["class"]),
|
|
@@ -117,12 +121,9 @@ def parse_line(line) -> list:
|
|
|
117
121
|
# line[4] => Position in Fleet
|
|
118
122
|
# line[5] => Skills (FC - WC - SC)
|
|
119
123
|
# line[6] => Wing Name / Squad Name
|
|
120
|
-
line = re.split(
|
|
124
|
+
line = re.split(r"\t+", line.rstrip("\t"))
|
|
121
125
|
|
|
122
|
-
if len(line)
|
|
123
|
-
line.append("")
|
|
124
|
-
|
|
125
|
-
return line
|
|
126
|
+
return line if len(line) > 6 else line + [""]
|
|
126
127
|
|
|
127
128
|
|
|
128
129
|
def update_ships(ships, line) -> dict:
|
|
@@ -137,14 +138,8 @@ def update_ships(ships, line) -> dict:
|
|
|
137
138
|
:rtype:
|
|
138
139
|
"""
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if line[3] not in ships["type"]:
|
|
144
|
-
ships["type"][line[3]] = {"count": 0}
|
|
145
|
-
|
|
146
|
-
ships["class"][line[2]]["count"] += 1
|
|
147
|
-
ships["type"][line[3]]["count"] += 1
|
|
141
|
+
ships["class"].setdefault(line[2], {"count": 0})["count"] += 1
|
|
142
|
+
ships["type"].setdefault(line[3], {"count": 0})["count"] += 1
|
|
148
143
|
|
|
149
144
|
return ships
|
|
150
145
|
|
|
@@ -162,14 +157,11 @@ def handle_fleet_composition_and_participation(pilots, ships) -> tuple:
|
|
|
162
157
|
"""
|
|
163
158
|
|
|
164
159
|
fleet_composition = get_fleet_composition(pilots=pilots, ships=ships)
|
|
165
|
-
participation =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
safe_to_db=False,
|
|
171
|
-
ignore_limit=True,
|
|
172
|
-
)
|
|
160
|
+
participation = (
|
|
161
|
+
parse_pilots(scan_data=list(set(pilots)), safe_to_db=False, ignore_limit=True)
|
|
162
|
+
if AppSettings.INTELTOOL_ENABLE_MODULE_CHATSCAN
|
|
163
|
+
else None
|
|
164
|
+
)
|
|
173
165
|
|
|
174
166
|
return fleet_composition, participation
|
|
175
167
|
|
|
@@ -184,59 +176,50 @@ def parse(scan_data: list) -> Scan:
|
|
|
184
176
|
:rtype:
|
|
185
177
|
"""
|
|
186
178
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
parsed_data = {}
|
|
191
|
-
pilots = {}
|
|
192
|
-
ships = {"type": {}, "class": {}}
|
|
193
|
-
lines = []
|
|
194
|
-
|
|
195
|
-
# Loop through the scan data
|
|
196
|
-
for entry in scan_data:
|
|
197
|
-
line = parse_line(entry)
|
|
198
|
-
|
|
199
|
-
pilots[line[0]] = {
|
|
200
|
-
"name": line[0],
|
|
201
|
-
"solarsystem": line[1],
|
|
202
|
-
"ship": line[2],
|
|
203
|
-
"ship_type": line[3],
|
|
204
|
-
}
|
|
205
|
-
ships = update_ships(ships=ships, line=line)
|
|
206
|
-
|
|
207
|
-
lines.append(line)
|
|
208
|
-
|
|
209
|
-
fleet_composition, participation = handle_fleet_composition_and_participation(
|
|
210
|
-
pilots=pilots, ships=ships
|
|
179
|
+
if not AppSettings.INTELTOOL_ENABLE_MODULE_FLEETCOMP:
|
|
180
|
+
raise ParserError(
|
|
181
|
+
message=_("The fleet composition module is currently disabled.")
|
|
211
182
|
)
|
|
212
183
|
|
|
213
|
-
|
|
184
|
+
parsed_data = {}
|
|
185
|
+
pilots = {}
|
|
186
|
+
ships = {"type": {}, "class": {}}
|
|
214
187
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"section": ScanData.Section.SHIPLIST,
|
|
219
|
-
"data": fleet_composition["classes"],
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
# Add "ship types" to parsed data when available
|
|
223
|
-
if fleet_composition["types"]:
|
|
224
|
-
parsed_data["shiptypes"] = {
|
|
225
|
-
"section": ScanData.Section.SHIPTYPES,
|
|
226
|
-
"data": fleet_composition["types"],
|
|
227
|
-
}
|
|
188
|
+
# Loop through the scan data
|
|
189
|
+
for entry in scan_data:
|
|
190
|
+
line = parse_line(entry)
|
|
228
191
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
# Add fleet participation data to the parsed data
|
|
237
|
-
if participation:
|
|
238
|
-
parsed_data.update(participation)
|
|
192
|
+
pilots[line[0]] = {
|
|
193
|
+
"name": line[0],
|
|
194
|
+
"solarsystem": line[1],
|
|
195
|
+
"ship": line[2],
|
|
196
|
+
"ship_type": line[3],
|
|
197
|
+
}
|
|
198
|
+
ships = update_ships(ships=ships, line=line)
|
|
239
199
|
|
|
240
|
-
|
|
200
|
+
fleet_composition, participation = handle_fleet_composition_and_participation(
|
|
201
|
+
pilots=pilots, ships=ships
|
|
202
|
+
)
|
|
241
203
|
|
|
242
|
-
|
|
204
|
+
logger.debug(msg=fleet_composition)
|
|
205
|
+
|
|
206
|
+
# Add parsed data when available
|
|
207
|
+
if fleet_composition["classes"]:
|
|
208
|
+
parsed_data["classes"] = {
|
|
209
|
+
"section": ScanData.Section.SHIPLIST,
|
|
210
|
+
"data": fleet_composition["classes"],
|
|
211
|
+
}
|
|
212
|
+
if fleet_composition["types"]:
|
|
213
|
+
parsed_data["shiptypes"] = {
|
|
214
|
+
"section": ScanData.Section.SHIPTYPES,
|
|
215
|
+
"data": fleet_composition["types"],
|
|
216
|
+
}
|
|
217
|
+
if fleet_composition["pilots"]:
|
|
218
|
+
parsed_data["pilots_flying"] = {
|
|
219
|
+
"section": ScanData.Section.FLEETCOMPOSITION,
|
|
220
|
+
"data": fleet_composition["pilots"],
|
|
221
|
+
}
|
|
222
|
+
if participation:
|
|
223
|
+
parsed_data.update(participation)
|
|
224
|
+
|
|
225
|
+
return safe_scan_to_db(scan_type=Scan.Type.FLEETCOMP, parsed_data=parsed_data)
|
|
@@ -34,27 +34,18 @@
|
|
|
34
34
|
font-size: 1.25em;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
.aa-intel-tool .aa-intel-
|
|
38
|
-
.aa-intel-tool .aa-intel-corporation-logo-wrapper,
|
|
39
|
-
.aa-intel-tool .aa-intel-pilot-avatar-wrapper,
|
|
40
|
-
.aa-intel-tool .aa-intel-ship-image-wrapper {
|
|
37
|
+
.aa-intel-tool .aa-intel-eve-image-wrapper {
|
|
41
38
|
display: inline-block;
|
|
42
39
|
margin-right: 0.5rem;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
.aa-intel-tool .aa-intel-
|
|
46
|
-
.aa-intel-tool .aa-intel-corporation-information-wrapper,
|
|
47
|
-
.aa-intel-tool .aa-intel-pilot-information-wrapper {
|
|
42
|
+
.aa-intel-tool .aa-intel-eve-information-wrapper {
|
|
48
43
|
display: inline-block;
|
|
49
44
|
vertical-align: inherit;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
.aa-intel-tool .aa-intel-
|
|
53
|
-
.aa-intel-tool .aa-intel-
|
|
54
|
-
.aa-intel-tool .aa-intel-corporation-name-wrapper,
|
|
55
|
-
.aa-intel-tool .aa-intel-corporation-links-wrapper,
|
|
56
|
-
.aa-intel-tool .aa-intel-pilot-name-wrapper,
|
|
57
|
-
.aa-intel-tool .aa-intel-pilot-links-wrapper {
|
|
47
|
+
.aa-intel-tool .aa-intel-eve-name-wrapper,
|
|
48
|
+
.aa-intel-tool .aa-intel-additional-information-wrapper {
|
|
58
49
|
display: block;
|
|
59
50
|
}
|
|
60
51
|
}
|
|
@@ -84,11 +75,6 @@
|
|
|
84
75
|
/* Data Tables
|
|
85
76
|
------------------------------------------------------------------------------------- */
|
|
86
77
|
@media all {
|
|
87
|
-
.aa-intel-tool div.dataTables_filter input[type="search"] {
|
|
88
|
-
margin-left: 0 !important;
|
|
89
|
-
width: 100% !important;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
78
|
.aa-intel-tool div.dataTables_wrapper div.dataTables_info {
|
|
93
79
|
padding-top: 8px;
|
|
94
80
|
white-space: initial;
|
|
@@ -124,15 +110,11 @@
|
|
|
124
110
|
white-space: nowrap;
|
|
125
111
|
}
|
|
126
112
|
|
|
127
|
-
.aa-intel-
|
|
128
|
-
.aa-intel-corporation-information-wrapper,
|
|
129
|
-
.aa-intel-pilot-information-wrapper {
|
|
113
|
+
.aa-intel-tool .aa-intel-eve-information-wrapper {
|
|
130
114
|
max-width: calc(100% - 35px);
|
|
131
115
|
}
|
|
132
116
|
|
|
133
|
-
.aa-intel-
|
|
134
|
-
.aa-intel-corporation-name-wrapper,
|
|
135
|
-
.aa-intel-pilot-name-wrapper {
|
|
117
|
+
.aa-intel-tool .aa-intel-eve-name-wrapper {
|
|
136
118
|
overflow: hidden;
|
|
137
119
|
text-overflow: ellipsis;
|
|
138
120
|
}
|