tf2-sku-to-name 2.0.0__py3-none-any.whl → 2.0.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.
sku/__init__.py CHANGED
@@ -2,7 +2,7 @@ from sku.parser import Sku, get_schema
2
2
  from sku.models import itemClass
3
3
  from sku.schema import Schema
4
4
 
5
- __version__ = "2.0.0"
5
+ __version__ = "2.0.2"
6
6
  __all__ = ["Sku", "itemClass", "Schema", "get_schema", "update_schema"]
7
7
 
8
8
  # Main functions
sku/parser.py CHANGED
@@ -149,7 +149,7 @@ class Sku:
149
149
  name = schema.get_name(item_dict, proper_name)
150
150
  if not name:
151
151
  raise ValueError(f"Failed to get name from SKU: {sku}")
152
-
152
+
153
153
  return name
154
154
 
155
155
  @staticmethod
@@ -281,110 +281,56 @@ class Sku:
281
281
  item['quality'] = quality_id
282
282
  break
283
283
 
284
+ for effect_name, effect_id in schema.effects.items():
285
+ effect_lower = effect_name.lower()
284
286
 
285
- effect_short_forms = {
286
- 'burning': 'Burning Flames',
287
- 'scorching': 'Scorching Flames',
288
- 'green energy': 'Green Energy',
289
- 'purple energy': 'Purple Energy',
290
- 'circling tf': 'Circling TF Logo',
291
- 'massed': 'Massed Flies',
292
- 'nuts': 'Nuts n\' Bolts',
293
- 'p fetti': 'Purple Confetti',
294
- 'g fetti': 'Green Confetti',
295
- 'haunted': 'Haunted Ghosts',
296
- 'green black hole': 'Green Black Hole',
297
- 'roboactive': 'Roboactive',
298
- 'sulph': 'Sulphurous',
299
- 'phos': 'Phosphorous',
300
- 'c&d': 'Circling Peace Sign',
301
- 'peace': 'Circling Peace Sign',
302
- 'logo': 'Circling TF Logo',
303
- 'hearts': 'Circling Heart',
304
- 'tf logo': 'Circling TF Logo',
305
- 'heart': 'Circling Heart',
306
- 'frostbite': 'Frostbite',
307
- 'scorching': 'Scorching Flames',
308
- 'plasma': 'Vivid Plasma',
309
- 'searing': 'Searing Plasma',
310
- 'miami': 'Miami Nights',
311
- 'disco': 'Disco Beat Down',
312
- 'phosph': 'Phosphorous',
313
- 'sulph': 'Sulphurous',
314
- 'memory': 'Memory Leak',
315
- 'overclocked': 'Overclocked',
316
- 'electrostatic': 'Electrostatic',
317
- 'harvest': 'Harvest Moon',
318
- 'bonzo': 'Bonzo The All-Gnawing',
319
- 'antifreeze': 'Anti-Freeze',
320
- 'arcana': 'Arcana',
321
- 'spellbound': 'Spellbound',
322
- }
323
-
324
- for short_form, full_effect in effect_short_forms.items():
325
- if short_form in name_lower:
326
- for effect_name, effect_id in schema.effects.items():
327
- if effect_name == full_effect:
328
- name_lower = name_lower.replace(short_form, '').strip()
329
- item['effect'] = effect_id
330
- if item['quality'] != 5:
331
- item['quality2'] = item['quality'] or item['quality2']
332
- item['quality'] = 5
333
- break
334
- if item['effect']:
335
- break
336
-
337
- if not item['effect']:
338
- for effect_name, effect_id in schema.effects.items():
339
- effect_lower = effect_name.lower()
340
-
341
- if effect_lower == 'stardust' and 'starduster' in name_lower:
342
- if 'starduster' in name_lower.replace('stardust', ''):
343
- continue
344
-
345
- if effect_lower == 'showstopper' and 'taunt: ' not in name_lower and 'shred alert' not in name_lower:
346
- continue
347
-
348
- if effect_lower == 'smoking' and name_lower in ['smoking jacket', 'the smoking skid lid'] or 'smoking skid lid' in name_lower:
349
- if not name_lower.startswith('smoking smoking'):
350
- continue
351
-
352
- if effect_lower in ['haunted ghosts', 'pumpkin patch', 'stardust'] and item['wear']:
353
- continue
354
-
355
- if effect_lower == 'atomic' and ('subatomic' in name_lower or any(x in name_lower for x in ['bonk! atomic punch', 'atomic accolade'])):
356
- continue
357
-
358
- if effect_lower == 'spellbound' and ('taunt:' in name_lower or 'shred alert' in name_lower):
359
- continue
360
-
361
- if effect_lower == 'accursed' and 'accursed apparition' in name_lower:
362
- continue
363
-
364
- if effect_lower == 'haunted' and 'haunted kraken' in name_lower:
365
- continue
366
-
367
- if effect_lower == 'frostbite' and 'frostbite bonnet' in name_lower:
368
- continue
369
-
370
- if effect_lower == 'hot' and not item['wear']:
287
+ if effect_lower == 'stardust' and 'starduster' in name_lower:
288
+ if 'starduster' in name_lower.replace('stardust', ''):
371
289
  continue
372
-
373
- if effect_lower == 'cool' and not item['wear']:
290
+
291
+ if effect_lower == 'showstopper' and 'taunt: ' not in name_lower and 'shred alert' not in name_lower:
292
+ continue
293
+
294
+ if effect_lower == 'smoking' and name_lower in ['smoking jacket', 'the smoking skid lid'] or 'smoking skid lid' in name_lower:
295
+ if not name_lower.startswith('smoking smoking'):
374
296
  continue
297
+
298
+ if effect_lower in ['haunted ghosts', 'pumpkin patch', 'stardust'] and item['wear']:
299
+ continue
300
+
301
+ if effect_lower == 'atomic' and ('subatomic' in name_lower or any(x in name_lower for x in ['bonk! atomic punch', 'atomic accolade'])):
302
+ continue
303
+
304
+ if effect_lower == 'spellbound' and ('taunt:' in name_lower or 'shred alert' in name_lower):
305
+ continue
306
+
307
+ if effect_lower == 'accursed' and 'accursed apparition' in name_lower:
308
+ continue
309
+
310
+ if effect_lower == 'haunted' and 'haunted kraken' in name_lower:
311
+ continue
312
+
313
+ if effect_lower == 'frostbite' and 'frostbite bonnet' in name_lower:
314
+ continue
315
+
316
+ if effect_lower == 'hot' and not item['wear']:
317
+ continue
318
+
319
+ if effect_lower == 'cool' and not item['wear']:
320
+ continue
321
+
322
+ if effect_lower in name_lower:
323
+ name_lower = name_lower.replace(effect_lower, '').strip()
324
+ item['effect'] = effect_id
375
325
 
376
- if effect_lower in name_lower:
377
- name_lower = name_lower.replace(effect_lower, '').strip()
378
- item['effect'] = effect_id
379
-
380
- if effect_id == 4: # Community Sparkle
381
- if not item['quality']:
382
- item['quality'] = 5
383
- elif item['quality'] != 5:
384
- item['quality2'] = item['quality'] or item['quality2']
326
+ if effect_id == 4: # Community Sparkle
327
+ if not item['quality']:
385
328
  item['quality'] = 5
386
-
387
- break
329
+ elif item['quality'] != 5:
330
+ item['quality2'] = item['quality'] or item['quality2']
331
+ item['quality'] = 5
332
+
333
+ break
388
334
 
389
335
  if item['wear']:
390
336
  for paintkit_name, paintkit_id in schema.paintkits.items():
@@ -501,7 +447,7 @@ class Sku:
501
447
  item['craftnumber'] = int(number)
502
448
 
503
449
  return Sku._dict_to_sku(item)
504
-
450
+
505
451
  @staticmethod
506
452
  def _process_special_items(name_lower: str, item: dict, schema: Schema) -> str:
507
453
 
@@ -585,7 +531,7 @@ class Sku:
585
531
  break
586
532
 
587
533
  return name_lower
588
-
534
+
589
535
  @staticmethod
590
536
  def _handle_weapon_skins(name_lower: str, item: dict, schema: Schema):
591
537
  """Handle weapon skin defindex mapping"""
@@ -617,7 +563,7 @@ class Sku:
617
563
  item['defindex'] = schema.WRENCH_SKINS[item['paintkit']]
618
564
  elif 'knife' in name_lower and item['paintkit'] in schema.KNIFE_SKINS:
619
565
  item['defindex'] = schema.KNIFE_SKINS[item['paintkit']]
620
-
566
+
621
567
  @staticmethod
622
568
  def _dict_to_sku(item: dict) -> str:
623
569
  """Convert item dict to SKU string"""
@@ -639,7 +585,7 @@ class Sku:
639
585
  item_obj.OutputQuality = item['outputQuality']
640
586
 
641
587
  return Sku.object_to_sku(item_obj)
642
-
588
+
643
589
  @staticmethod
644
590
  def update_schema(api_key: str = None, use_autobot: bool = True):
645
591
  global _schema
sku/schema.py CHANGED
@@ -245,7 +245,10 @@ class Schema:
245
245
 
246
246
  def _fetch_from_autobot(self):
247
247
  try:
248
- response = requests.get('https://schema.autobot.tf/schema')
248
+ headers = {
249
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
250
+ }
251
+ response = requests.get('https://schema.autobot.tf/schema', headers=headers)
249
252
  response.raise_for_status()
250
253
  data = response.json()
251
254
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tf2-sku-to-name
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: A python library that parses TF2 item SKU to the item's name and vice versa.
5
5
  Home-page: https://github.com/purplebarber/tf2-sku
6
6
  Author: Purple Barber
@@ -0,0 +1,9 @@
1
+ sku/__init__.py,sha256=k1itDEvvourNzn06rF2N7_83Nqokp5eG6KfVcevztIM,377
2
+ sku/models.py,sha256=9jQimlGwJrJRmAY5o9PTKfdgp5kRajjMcH-Xp3GA35k,804
3
+ sku/parser.py,sha256=CMDQ-pWVk59Pvzx7QdiPKOXjUdCfaA3POFmStP3LSTg,24241
4
+ sku/schema.py,sha256=U_L-p4p7eJstR3lVKu6Bca6vxEZXbA0wBpEt9c5nXtE,25254
5
+ tf2_sku_to_name-2.0.2.dist-info/licenses/LICENSE,sha256=oZXGpA1oKt4L1lkrblMbut3_ClR3etussSbI0pBkL38,1070
6
+ tf2_sku_to_name-2.0.2.dist-info/METADATA,sha256=Wh63cL7ZKtR8KIH3khV6SnKIObZe5puwh3ECqj5bjFE,2723
7
+ tf2_sku_to_name-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ tf2_sku_to_name-2.0.2.dist-info/top_level.txt,sha256=2ekTXVLQ1fHUW3ge6PK7EaoEwkUy0tnsaDvoNkPXfNw,4
9
+ tf2_sku_to_name-2.0.2.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- sku/__init__.py,sha256=77dSD2mzT1jgk-OYCWpuHVBTBCmWMdqfbwCONzmd2s0,377
2
- sku/models.py,sha256=9jQimlGwJrJRmAY5o9PTKfdgp5kRajjMcH-Xp3GA35k,804
3
- sku/parser.py,sha256=f-myoUIpbNyAT9tUct0gsZSG14VKnZA9IV6SllsTvKA,26650
4
- sku/schema.py,sha256=MxfQGo8dAm5O_YZ0uzicQwULSz-4khoz_-l04i6uEZ8,25051
5
- tf2_sku_to_name-2.0.0.dist-info/licenses/LICENSE,sha256=oZXGpA1oKt4L1lkrblMbut3_ClR3etussSbI0pBkL38,1070
6
- tf2_sku_to_name-2.0.0.dist-info/METADATA,sha256=vMREIUXo44PBZcUhbWTWCKksodvujdKiwPTeZgCSh2c,2723
7
- tf2_sku_to_name-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- tf2_sku_to_name-2.0.0.dist-info/top_level.txt,sha256=2ekTXVLQ1fHUW3ge6PK7EaoEwkUy0tnsaDvoNkPXfNw,4
9
- tf2_sku_to_name-2.0.0.dist-info/RECORD,,