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.
Files changed (66) hide show
  1. aa_intel_tool/__init__.py +1 -1
  2. aa_intel_tool/app_settings.py +15 -0
  3. aa_intel_tool/constants.py +6 -5
  4. aa_intel_tool/helper/eve_character.py +24 -36
  5. aa_intel_tool/helper/static_files.py +5 -4
  6. aa_intel_tool/locale/cs_CZ/LC_MESSAGES/django.po +15 -83
  7. aa_intel_tool/locale/de/LC_MESSAGES/django.mo +0 -0
  8. aa_intel_tool/locale/de/LC_MESSAGES/django.po +71 -87
  9. aa_intel_tool/locale/django.pot +16 -84
  10. aa_intel_tool/locale/es/LC_MESSAGES/django.po +19 -83
  11. aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
  12. aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.po +72 -88
  13. aa_intel_tool/locale/it_IT/LC_MESSAGES/django.po +15 -83
  14. aa_intel_tool/locale/ja/LC_MESSAGES/django.po +15 -83
  15. aa_intel_tool/locale/ko_KR/LC_MESSAGES/django.po +67 -83
  16. aa_intel_tool/locale/nl_NL/LC_MESSAGES/django.po +15 -83
  17. aa_intel_tool/locale/pl_PL/LC_MESSAGES/django.po +15 -83
  18. aa_intel_tool/locale/ru/LC_MESSAGES/django.mo +0 -0
  19. aa_intel_tool/locale/ru/LC_MESSAGES/django.po +71 -87
  20. aa_intel_tool/locale/sk/LC_MESSAGES/django.po +15 -83
  21. aa_intel_tool/locale/uk/LC_MESSAGES/django.mo +0 -0
  22. aa_intel_tool/locale/uk/LC_MESSAGES/django.po +71 -94
  23. aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  24. aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.po +20 -87
  25. aa_intel_tool/parser/general.py +11 -16
  26. aa_intel_tool/parser/helper/db.py +8 -11
  27. aa_intel_tool/parser/module/chatlist.py +97 -126
  28. aa_intel_tool/parser/module/dscan.py +115 -147
  29. aa_intel_tool/parser/module/fleetcomp.py +85 -102
  30. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.css +6 -24
  31. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css +1 -1
  32. aa_intel_tool/static/aa_intel_tool/css/aa-intel-tool.min.css.map +1 -1
  33. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.js +104 -64
  34. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js.map +1 -1
  35. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.js +5 -5
  36. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js +1 -1
  37. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js.map +1 -1
  38. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.js +43 -43
  39. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js.map +1 -1
  40. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.js +41 -17
  41. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js +1 -1
  42. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js.map +1 -1
  43. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.js +51 -51
  44. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js.map +1 -1
  45. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.js +13 -7
  46. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js +1 -1
  47. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js.map +1 -1
  48. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.js +53 -31
  49. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js +1 -1
  50. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js.map +1 -1
  51. aa_intel_tool/templates/aa_intel_tool/base.html +7 -42
  52. aa_intel_tool/templates/aa_intel_tool/partials/scan/evetime.html +1 -1
  53. aa_intel_tool/templatetags/aa_intel_tool.py +12 -7
  54. aa_intel_tool/tests/test-data/dscan.txt +250 -0
  55. aa_intel_tool/tests/test_admin.py +50 -38
  56. aa_intel_tool/tests/test_app_settings.py +23 -1
  57. aa_intel_tool/tests/test_helper_eve_character.py +405 -0
  58. aa_intel_tool/tests/test_models.py +188 -4
  59. aa_intel_tool/tests/test_parser_general.py +771 -0
  60. aa_intel_tool/tests/test_parser_module_chatlist.py +154 -0
  61. aa_intel_tool/tests/test_templatetags.py +24 -3
  62. {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/METADATA +4 -4
  63. {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/RECORD +65 -63
  64. aa_intel_tool/tests/test_parser.py +0 -135
  65. {aa_intel_tool-2.6.0.dist-info → aa_intel_tool-2.6.2.dist-info}/WHEEL +0 -0
  66. {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
- if re.search(pattern=REGEX_PATTERN["localised_on_grid"], string=distance):
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
- return False
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
- if eve_type[1] not in ships["all"]:
125
- ships["all"][eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
126
- ships["all"][eve_type[1]]["count"] = counter["all"][eve_type[0]]
127
- ships["all"][eve_type[1]]["mass"] = (
128
- eve_type[4] * counter["all"][eve_type[0]]
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
- if eve_type[1] not in ships["ongrid"]:
134
- ships["ongrid"][eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
135
- ships["ongrid"][eve_type[1]]["count"] = counter["ongrid"][eve_type[0]]
136
- ships["ongrid"][eve_type[1]]["mass"] = (
137
- eve_type[4] * counter["ongrid"][eve_type[0]]
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
- if eve_type[1] not in ships["offgrid"]:
143
- ships["offgrid"][eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
144
- ships["offgrid"][eve_type[1]]["count"] = counter["offgrid"][eve_type[0]]
145
- ships["offgrid"][eve_type[1]]["mass"] = (
146
- eve_type[4] * counter["offgrid"][eve_type[0]]
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
- # Loop through all Upwell structures
189
- for eve_type in eve_types_structures:
190
- if eve_type[0] in counter["ongrid"]:
191
- if eve_type[1] not in upwell_structures:
192
- upwell_structures[eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
193
- upwell_structures[eve_type[1]]["count"] = counter["ongrid"][eve_type[0]]
194
-
195
- # If it is an Ansiblex Jump Gate, add the destination system
196
- if (
197
- eve_type[0] == UpwellStructureId.ANSIBLEX_JUMP_GATE
198
- and ansiblex_destination
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
- # Loop through all deployables
226
- for eve_type in eve_types_deployables:
227
- if eve_type[0] in counter["ongrid"]:
228
- if eve_type[1] not in deployables:
229
- deployables[eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
230
- deployables[eve_type[1]]["count"] = counter["ongrid"][eve_type[0]]
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
- # Loop through all starbases
254
- for eve_type in eve_types_starbase:
255
- if eve_type[0] in counter["ongrid"]:
256
- if eve_type[1] not in starbases:
257
- starbases[eve_type[1]] = _get_type_info_dict(eve_type=eve_type)
258
- starbases[eve_type[1]]["count"] = counter["ongrid"][eve_type[0]]
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
- name_parts = re.split(pattern=r" - ", string=ansiblex_name)
274
- gate_systems = re.split(pattern=r" » ", string=name_parts[0])
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 = {"all": {}, "ongrid": {}, "offgrid": {}, "type": {}}
296
- eve_ids = {"all": [], "ongrid": [], "offgrid": []}
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] = counter["all"].get(entry_id, 0) + 1
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] = counter["ongrid"].get(entry_id, 0) + 1
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] = counter["offgrid"].get(entry_id, 0) + 1
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
- message = _("The D-Scan module is currently disabled.")
351
-
352
- # Only parse the D-Scan when the module is enabled
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
- # Add "ships off grid" to parsed data when available
392
- if ships["offgrid"]:
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
- # Add "ship types" to the parsed data when available
399
- if ships["types"]:
400
- parsed_data["shiptypes"] = {
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
- # Add "Upwell structures on grid" to the parsed data when available
406
- if upwell_structures:
407
- parsed_data["sructures_on_grid"] = {
408
- "section": ScanData.Section.STRUCTURES_ON_GRID,
409
- "data": upwell_structures,
410
- }
411
-
412
- # Add "deployables on grid" to the parsed data when available
413
- if deployables:
414
- parsed_data["deployables"] = {
415
- "section": ScanData.Section.DEPLOYABLES_ON_GRID,
416
- "data": deployables,
417
- }
418
-
419
- # Add "starbases on grid" to parsed data when available
420
- if starbases:
421
- parsed_data["starbases"] = {
422
- "section": ScanData.Section.STARBASES_ON_GRID,
423
- "data": starbases,
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
- return safe_scan_to_db(scan_type=Scan.Type.DSCAN, parsed_data=parsed_data)
392
+ for key, (section, data) in sections.items():
393
+ if data:
394
+ parsed_data[key] = {"section": section, "data": data}
427
395
 
428
- raise ParserError(message=message)
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
- # Loop through ship classes
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]["id"] = ship_class.id
58
- ships["class"][ship_class.name]["name"] = ship_class.name
59
- ships["class"][ship_class.name]["type_id"] = ship_class.eve_group__id
60
- ships["class"][ship_class.name]["type_name"] = ship_class.eve_group__name
61
- ships["class"][ship_class.name]["image"] = eveimageserver.type_icon_url(
62
- type_id=ship_class.id, size=32
63
- )
64
- ships["class"][ship_class.name]["mass"] = (
65
- ship_class.mass * ships["class"][ship_class.name]["count"]
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]["id"] = ship_class.eve_group__id
70
- ships["type"][ship_class.eve_group__name]["name"] = ship_class.eve_group__name
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(set(pilots)))
74
-
75
- # Loop through pilots
76
- for pilot in pilot_details:
77
- # Get ship class details for a pilot
78
- pilot__ship_class = ship_class_details.filter(
79
- name=pilots[pilot.character_name]["ship"]
80
- ).get()
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
- pilots[pilot.character_name]["zkillboard"] = zkillboard.character_url(
89
- pilot.character_id
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(pattern=r"\t+", string=line.rstrip("\t"))
124
+ line = re.split(r"\t+", line.rstrip("\t"))
121
125
 
122
- if len(line) == 6:
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
- if line[2] not in ships["class"]:
141
- ships["class"][line[2]] = {"count": 0}
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 = None
166
-
167
- if AppSettings.INTELTOOL_ENABLE_MODULE_CHATSCAN is True:
168
- participation = parse_pilots(
169
- scan_data=list(set(pilots)),
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
- message = _("The fleet composition module is currently disabled.")
188
-
189
- if AppSettings.INTELTOOL_ENABLE_MODULE_FLEETCOMP is True:
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
- logger.debug(msg=fleet_composition)
184
+ parsed_data = {}
185
+ pilots = {}
186
+ ships = {"type": {}, "class": {}}
214
187
 
215
- # Add "ship classes" to parsed data when available
216
- if fleet_composition["classes"]:
217
- parsed_data["classes"] = {
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
- # Add "who is flying what" (the actual fleet composition) to parsed data when available
230
- if fleet_composition["pilots"]:
231
- parsed_data["pilots_flying"] = {
232
- "section": ScanData.Section.FLEETCOMPOSITION,
233
- "data": fleet_composition["pilots"],
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
- return safe_scan_to_db(scan_type=Scan.Type.FLEETCOMP, parsed_data=parsed_data)
200
+ fleet_composition, participation = handle_fleet_composition_and_participation(
201
+ pilots=pilots, ships=ships
202
+ )
241
203
 
242
- raise ParserError(message=message)
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-alliance-logo-wrapper,
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-alliance-information-wrapper,
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-alliance-name-wrapper,
53
- .aa-intel-tool .aa-intel-alliance-links-wrapper,
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-alliance-information-wrapper,
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-alliance-name-wrapper,
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
  }