hungerlib 3.2.dev2__py3-none-any.whl → 3.2.dev4__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.
hungerlib/__init__.py CHANGED
@@ -8,7 +8,6 @@ except PackageNotFoundError:
8
8
  __version__ = '0.0.0'
9
9
 
10
10
  # modules
11
- CONFIG_MODE = "config"
12
11
  from .configloader import loadConfig
13
12
  from .datamap import set_default_maps, get_default_maps, Syntax, DataMap, datamap, mapit
14
13
  from .messagerouter import MessageRouter
@@ -69,7 +68,6 @@ datamap_api = SimpleNamespace(
69
68
 
70
69
  __all__ = [
71
70
  '__version__',
72
- 'CONFIG_MODE',
73
71
 
74
72
  # modules
75
73
  'loadConfig',
hungerlib/configloader.py CHANGED
@@ -2,7 +2,7 @@ import inspect
2
2
  import os
3
3
  import yaml
4
4
  import importlib
5
- from dataclasses import fields
5
+ from dataclasses import fields, MISSING
6
6
 
7
7
  class Namespace:
8
8
  def __init__(self):
@@ -32,6 +32,15 @@ def load_yaml(path):
32
32
  with open(path, "r") as f:
33
33
  return yaml.safe_load(f) or {}
34
34
 
35
+ def convert_value(value, annotation):
36
+ if annotation is int:
37
+ return int(value)
38
+ if annotation is float:
39
+ return float(value)
40
+ if annotation is bool:
41
+ return bool(value)
42
+ return value
43
+
35
44
  def loadConfig(path, default_path, schema):
36
45
  abs_path = os.path.abspath(path)
37
46
  os.makedirs(os.path.dirname(abs_path), exist_ok=True)
@@ -50,18 +59,30 @@ def loadConfig(path, default_path, schema):
50
59
  f.write("# No default config found.\n")
51
60
 
52
61
  raw = load_yaml(abs_path)
53
-
54
62
  values = {}
55
63
 
64
+ mode = getattr(schema, "__mode__", None)
65
+
56
66
  for f in fields(schema):
57
- yaml_path = f.metadata.get("yaml_key")
58
- if not yaml_path:
67
+ # --- OLD SYSTEM SUPPORT (yaml_key) ---
68
+ yaml_path = f.metadata.get("yaml_key") if f.metadata else None
69
+ if yaml_path:
70
+ value = deep_get(raw, yaml_path)
71
+ if value is not None:
72
+ values[f.name] = convert_value(value, f.type)
59
73
  continue
60
74
 
61
- value = deep_get(raw, yaml_path)
62
- if value is None:
75
+ # --- NEW SYSTEM: mode="config" + string defaults ---
76
+ default = f.default
77
+ if mode == "config" and isinstance(default, str):
78
+ yaml_path = default
79
+ value = deep_get(raw, yaml_path)
80
+ if value is not None:
81
+ values[f.name] = convert_value(value, f.type)
63
82
  continue
64
83
 
65
- values[f.name] = value
84
+ # --- FALLBACK: use dataclass default ---
85
+ if default is not MISSING:
86
+ values[f.name] = default
66
87
 
67
88
  return schema(**values)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hungerlib
3
- Version: 3.2.dev2
3
+ Version: 3.2.dev4
4
4
  Summary: Powerful automation library for Pterodactyl.
5
5
  Author: iFamished
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
- hungerlib/__init__.py,sha256=CExLyU07UUVzaERKZnkzNilUz_FnFE9zRaQg_8qecKo,2189
2
- hungerlib/configloader.py,sha256=IEAFk57ikcUn4eR-_ncY1csi41l8f1iGnUVQS79UN0g,1722
1
+ hungerlib/__init__.py,sha256=CTLIet8Tg8Gx3wWUrUNgIsHutv0JS1YzLelp1GLaLTs,2147
2
+ hungerlib/configloader.py,sha256=TdEFqk2zG5nT-vJqdjA36DrbRinY66n0rgI8Z-EZmAk,2548
3
3
  hungerlib/datamap.py,sha256=lEaS5mAweNE0sQA-9eRW1F9QbHoUADPhhASpT29NTvs,2164
4
4
  hungerlib/messagerouter.py,sha256=1-4KeUT6AgTF0F53n3BtWt0ch0lnHHXYPOWvRtvUVKY,4344
5
5
  hungerlib/panel.py,sha256=LljDy3FZoabWotdrNhN89xHd2VcvbiQDshtZgMa0g08,2013
@@ -17,8 +17,8 @@ hungerlib/utils/__init__.py,sha256=xyUldIwkVopZrp0Yp5g18vqGDUp3OOT4KknntLU4oes,5
17
17
  hungerlib/utils/colormaps.py,sha256=88eIDSI1hZYbtXmd7XujgmR1nhOXAkyB8ospQTqSHns,1240
18
18
  hungerlib/utils/time.py,sha256=lhLHMkL5NEP9f7j5k24k5brr1ZvAL22t07eV2rxTZ50,2354
19
19
  hungerlib/utils/utils.py,sha256=rGVXiK-ZaN1riNL_1QHKJZdOAX53vGlSDUzEP1Aqle4,1404
20
- hungerlib-3.2.dev2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
- hungerlib-3.2.dev2.dist-info/METADATA,sha256=NIXq-6F1hk2qdJQvpJuHEljCV2RKHwD0YSEDimkBscE,1535
22
- hungerlib-3.2.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
- hungerlib-3.2.dev2.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
- hungerlib-3.2.dev2.dist-info/RECORD,,
20
+ hungerlib-3.2.dev4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
+ hungerlib-3.2.dev4.dist-info/METADATA,sha256=94ddXVDOwclzdOeFuaB_z8MP1H6b0r-DKgZaLx8UyCQ,1535
22
+ hungerlib-3.2.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
+ hungerlib-3.2.dev4.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
+ hungerlib-3.2.dev4.dist-info/RECORD,,