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
|
@@ -18,23 +18,20 @@ def safe_scan_to_db(scan_type: Scan.Type, parsed_data: dict) -> Scan:
|
|
|
18
18
|
:rtype:
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
# Creating a new Scan object
|
|
22
|
-
new_scan = Scan(scan_type=scan_type)
|
|
23
|
-
new_scan.save()
|
|
21
|
+
# Creating a new Scan object and saving it
|
|
22
|
+
new_scan = Scan.objects.create(scan_type=scan_type)
|
|
24
23
|
|
|
25
|
-
# Creating the associated ScanData objects
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
scan_data_objects.append(
|
|
24
|
+
# Creating and saving the associated ScanData objects
|
|
25
|
+
ScanData.objects.bulk_create(
|
|
26
|
+
[
|
|
29
27
|
ScanData(
|
|
30
28
|
scan=new_scan,
|
|
31
29
|
section=scan_data["section"],
|
|
32
30
|
processed_data=scan_data["data"],
|
|
33
31
|
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ScanData.objects.bulk_create(scan_data_objects)
|
|
32
|
+
for scan_data in parsed_data.values()
|
|
33
|
+
]
|
|
34
|
+
)
|
|
38
35
|
|
|
39
36
|
# Return the Scan object
|
|
40
37
|
return new_scan
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Chat list parser
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
# Standard Library
|
|
6
|
+
from collections import defaultdict
|
|
7
|
+
|
|
5
8
|
# Django
|
|
6
9
|
from django.db.models import QuerySet
|
|
7
10
|
from django.utils.translation import gettext_lazy as _
|
|
@@ -38,22 +41,13 @@ def _get_character_info(scan_data: list) -> QuerySet[EveCharacter]:
|
|
|
38
41
|
:rtype:
|
|
39
42
|
"""
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
# Excluding corporation_id=1000001 (Doomheim) to potentially force an update here …
|
|
45
|
+
eve_characters = EveCharacter.objects.filter(character_name__in=scan_data).exclude(
|
|
46
|
+
corporation_id=1000001
|
|
47
|
+
)
|
|
42
48
|
|
|
43
49
|
# Check if we have to bother Eve Universe or if we have all characters already
|
|
44
|
-
|
|
45
|
-
try:
|
|
46
|
-
eve_characters = EveCharacter.objects.filter(
|
|
47
|
-
character_name__in=scan_data
|
|
48
|
-
).exclude(corporation_id=1000001)
|
|
49
|
-
except EveCharacter.DoesNotExist: # pylint: disable=no-member
|
|
50
|
-
fetch_from_eveuniverse = True
|
|
51
|
-
else:
|
|
52
|
-
if len(scan_data) != eve_characters.count():
|
|
53
|
-
fetch_from_eveuniverse = True
|
|
54
|
-
|
|
55
|
-
# Fetch the character information from Eve Universe if needed
|
|
56
|
-
if fetch_from_eveuniverse:
|
|
50
|
+
if len(scan_data) != eve_characters.count():
|
|
57
51
|
try:
|
|
58
52
|
eve_character_ids = (
|
|
59
53
|
EveEntity.objects.fetch_by_names_esi(names=scan_data, update=True)
|
|
@@ -61,21 +55,16 @@ def _get_character_info(scan_data: list) -> QuerySet[EveCharacter]:
|
|
|
61
55
|
.values_list("id", flat=True)
|
|
62
56
|
)
|
|
63
57
|
except EveEntity.DoesNotExist as exc: # pylint: disable=no-member
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
raise ParserError(message=message) from exc
|
|
70
|
-
|
|
71
|
-
logger.debug(msg=f"Got {len(eve_character_ids)} ID(s) back from Eve Universe …")
|
|
58
|
+
raise ParserError(
|
|
59
|
+
message=_(
|
|
60
|
+
"Something went wrong while fetching the character information from ESI."
|
|
61
|
+
)
|
|
62
|
+
) from exc
|
|
72
63
|
|
|
73
64
|
# In case the name does not belong to an Eve character,
|
|
74
65
|
# EveEntity returns an empty object
|
|
75
|
-
if
|
|
76
|
-
message
|
|
77
|
-
|
|
78
|
-
raise ParserError(message=message)
|
|
66
|
+
if not eve_character_ids:
|
|
67
|
+
raise ParserError(message=_("Character unknown to ESI."))
|
|
79
68
|
|
|
80
69
|
eve_characters = get_or_create_character(character_ids=eve_character_ids)
|
|
81
70
|
|
|
@@ -110,22 +99,24 @@ def _parse_alliance_info(
|
|
|
110
99
|
:rtype:
|
|
111
100
|
"""
|
|
112
101
|
|
|
113
|
-
# Build alliance info dict
|
|
114
102
|
if eve_character.alliance_id is None:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
103
|
+
return _get_unaffiliated_alliance_info()
|
|
104
|
+
|
|
105
|
+
alliance_info = {
|
|
106
|
+
"id": eve_character.alliance_id,
|
|
107
|
+
"name": eve_character.alliance_name,
|
|
108
|
+
"ticker": eve_character.alliance_ticker,
|
|
109
|
+
"logo": eve_character.alliance_logo_url_32,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Add eve links if requested
|
|
113
|
+
if with_evelinks:
|
|
114
|
+
alliance_info.update(
|
|
115
|
+
{
|
|
116
|
+
"dotlan": dotlan.alliance_url(eve_character.alliance_name),
|
|
117
|
+
"zkillboard": zkillboard.alliance_url(eve_character.alliance_id),
|
|
118
|
+
}
|
|
119
|
+
)
|
|
129
120
|
|
|
130
121
|
return alliance_info
|
|
131
122
|
|
|
@@ -153,11 +144,13 @@ def _parse_corporation_info(
|
|
|
153
144
|
|
|
154
145
|
# Add eve links if requested
|
|
155
146
|
if with_evelinks:
|
|
156
|
-
corporation_info
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
corporation_info.update(
|
|
148
|
+
{
|
|
149
|
+
"dotlan": dotlan.corporation_url(name=eve_character.corporation_name),
|
|
150
|
+
"zkillboard": zkillboard.corporation_url(
|
|
151
|
+
eve_id=eve_character.corporation_id
|
|
152
|
+
),
|
|
153
|
+
}
|
|
161
154
|
)
|
|
162
155
|
|
|
163
156
|
# Add alliance info if requested
|
|
@@ -205,52 +198,35 @@ def _parse_chatscan_data(eve_characters: QuerySet[EveCharacter]) -> dict:
|
|
|
205
198
|
:rtype:
|
|
206
199
|
"""
|
|
207
200
|
|
|
208
|
-
counter =
|
|
201
|
+
counter = defaultdict(int)
|
|
209
202
|
alliance_info = {}
|
|
210
203
|
corporation_info = {}
|
|
211
204
|
character_info = {}
|
|
212
205
|
|
|
213
206
|
# Loop through the characters
|
|
214
|
-
for eve_character in eve_characters:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
# If the character is in an alliance, use the alliance name
|
|
218
|
-
if eve_character.alliance_name is not None:
|
|
219
|
-
eve_character__alliance_name = eve_character.alliance_name
|
|
220
|
-
|
|
221
|
-
counter[eve_character__alliance_name] = (
|
|
222
|
-
counter.get(eve_character__alliance_name, 0) + 1
|
|
223
|
-
)
|
|
207
|
+
for eve_character in list(eve_characters):
|
|
208
|
+
alliance_name = eve_character.alliance_name or "Unaffiliated"
|
|
209
|
+
corporation_name = eve_character.corporation_name
|
|
224
210
|
|
|
225
|
-
counter[
|
|
226
|
-
|
|
227
|
-
)
|
|
211
|
+
counter[alliance_name] += 1
|
|
212
|
+
counter[corporation_name] += 1
|
|
228
213
|
|
|
229
214
|
# Alliance Info
|
|
230
|
-
if
|
|
231
|
-
alliance_info[
|
|
232
|
-
eve_character=eve_character
|
|
233
|
-
)
|
|
215
|
+
if alliance_name not in alliance_info:
|
|
216
|
+
alliance_info[alliance_name] = _parse_alliance_info(eve_character)
|
|
234
217
|
|
|
235
218
|
# Corporation Info
|
|
236
|
-
if
|
|
237
|
-
corporation_info[
|
|
238
|
-
eve_character=eve_character
|
|
239
|
-
)
|
|
219
|
+
if corporation_name not in corporation_info:
|
|
220
|
+
corporation_info[corporation_name] = _parse_corporation_info(eve_character)
|
|
240
221
|
|
|
241
222
|
# Character Info
|
|
242
223
|
character_info[eve_character.character_name] = _parse_character_info(
|
|
243
|
-
eve_character
|
|
224
|
+
eve_character
|
|
244
225
|
)
|
|
245
226
|
|
|
246
227
|
# Update the counter
|
|
247
|
-
alliance_info[
|
|
248
|
-
|
|
249
|
-
]
|
|
250
|
-
|
|
251
|
-
corporation_info[eve_character.corporation_name]["count"] = counter[
|
|
252
|
-
eve_character.corporation_name
|
|
253
|
-
]
|
|
228
|
+
alliance_info[alliance_name]["count"] = counter[alliance_name]
|
|
229
|
+
corporation_info[corporation_name]["count"] = counter[corporation_name]
|
|
254
230
|
|
|
255
231
|
return {
|
|
256
232
|
"pilots": dict_to_list(input_dict=character_info),
|
|
@@ -275,60 +251,55 @@ def parse(
|
|
|
275
251
|
:rtype:
|
|
276
252
|
"""
|
|
277
253
|
|
|
278
|
-
message = _("The chat list module is currently disabled.")
|
|
279
|
-
|
|
280
254
|
# Only parse the chat scan if the module is enabled
|
|
281
|
-
if AppSettings.INTELTOOL_ENABLE_MODULE_CHATSCAN
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
pilots_in_scan = len(scan_data)
|
|
285
|
-
max_allowed_pilots = AppSettings.INTELTOOL_CHATSCAN_MAX_PILOTS
|
|
286
|
-
|
|
287
|
-
# Check if the number of pilots in the scan exceeds the maximum allowed number
|
|
288
|
-
if 0 < max_allowed_pilots < pilots_in_scan and ignore_limit is False:
|
|
289
|
-
logger.debug(
|
|
290
|
-
msg=(
|
|
291
|
-
f"Number of pilots in scan ({pilots_in_scan}) exceeds the maximum "
|
|
292
|
-
f"allowed number ({max_allowed_pilots}). Throwing a tantrum …"
|
|
293
|
-
)
|
|
294
|
-
)
|
|
255
|
+
if not AppSettings.INTELTOOL_ENABLE_MODULE_CHATSCAN:
|
|
256
|
+
raise ParserError(message=_("The chat list module is currently disabled."))
|
|
295
257
|
|
|
296
|
-
|
|
297
|
-
raise ParserError(
|
|
298
|
-
message=ngettext(
|
|
299
|
-
singular=f"Chat scans are currently limited to a maximum of {max_allowed_pilots} pilot per scan. Your list of pilots exceeds this limit.", # pylint: disable=line-too-long
|
|
300
|
-
plural=f"Chat scans are currently limited to a maximum of {max_allowed_pilots} pilots per scan. Your list of pilots exceeds this limit.", # pylint: disable=line-too-long
|
|
301
|
-
number=max_allowed_pilots,
|
|
302
|
-
)
|
|
303
|
-
)
|
|
258
|
+
logger.debug(msg=f"{len(scan_data)} name(s) to work through …")
|
|
304
259
|
|
|
305
|
-
|
|
260
|
+
pilots_in_scan = len(scan_data)
|
|
261
|
+
max_allowed_pilots = AppSettings.INTELTOOL_CHATSCAN_MAX_PILOTS
|
|
306
262
|
|
|
263
|
+
# Check if the number of pilots in the scan exceeds the maximum allowed number
|
|
264
|
+
if 0 < max_allowed_pilots < pilots_in_scan and not ignore_limit:
|
|
307
265
|
logger.debug(
|
|
308
|
-
msg=
|
|
266
|
+
msg=(
|
|
267
|
+
f"Number of pilots in scan ({pilots_in_scan}) exceeds the maximum "
|
|
268
|
+
f"allowed number ({max_allowed_pilots}). Throwing a tantrum …"
|
|
269
|
+
)
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
# Throw a tantrum
|
|
273
|
+
raise ParserError(
|
|
274
|
+
message=ngettext(
|
|
275
|
+
singular=f"Chat scans are currently limited to a maximum of {max_allowed_pilots} pilot per scan. Your list of pilots exceeds this limit.",
|
|
276
|
+
plural=f"Chat scans are currently limited to a maximum of {max_allowed_pilots} pilots per scan. Your list of pilots exceeds this limit.",
|
|
277
|
+
number=max_allowed_pilots,
|
|
278
|
+
)
|
|
309
279
|
)
|
|
310
280
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
"
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
"
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
281
|
+
eve_characters = _get_character_info(scan_data=scan_data)
|
|
282
|
+
logger.debug(msg=f"Got {len(eve_characters)} EveCharacter object(s) back from AA …")
|
|
283
|
+
|
|
284
|
+
# Parse the data
|
|
285
|
+
parsed_chatscan = _parse_chatscan_data(eve_characters=eve_characters)
|
|
286
|
+
parsed_data = {
|
|
287
|
+
"pilots": {
|
|
288
|
+
"section": ScanData.Section.PILOTLIST,
|
|
289
|
+
"data": parsed_chatscan["pilots"],
|
|
290
|
+
},
|
|
291
|
+
"corporations": {
|
|
292
|
+
"section": ScanData.Section.CORPORATIONLIST,
|
|
293
|
+
"data": parsed_chatscan["corporations"],
|
|
294
|
+
},
|
|
295
|
+
"alliances": {
|
|
296
|
+
"section": ScanData.Section.ALLIANCELIST,
|
|
297
|
+
"data": parsed_chatscan["alliances"],
|
|
298
|
+
},
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
parsed_data
|
|
303
|
+
if not safe_to_db
|
|
304
|
+
else safe_scan_to_db(scan_type=Scan.Type.CHATLIST, parsed_data=parsed_data)
|
|
305
|
+
)
|