hungerlib 3.2.dev0__py3-none-any.whl → 3.2.dev3__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,6 +8,7 @@ except PackageNotFoundError:
8
8
  __version__ = '0.0.0'
9
9
 
10
10
  # modules
11
+ CONFIG_MODE = "config"
11
12
  from .configloader import loadConfig
12
13
  from .datamap import set_default_maps, get_default_maps, Syntax, DataMap, datamap, mapit
13
14
  from .messagerouter import MessageRouter
@@ -68,6 +69,7 @@ datamap_api = SimpleNamespace(
68
69
 
69
70
  __all__ = [
70
71
  '__version__',
72
+ 'CONFIG_MODE',
71
73
 
72
74
  # modules
73
75
  '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,16 @@ 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
+ # YAML already parses true/false correctly
42
+ return bool(value)
43
+ return value
44
+
35
45
  def loadConfig(path, default_path, schema):
36
46
  abs_path = os.path.abspath(path)
37
47
  os.makedirs(os.path.dirname(abs_path), exist_ok=True)
@@ -50,18 +60,30 @@ def loadConfig(path, default_path, schema):
50
60
  f.write("# No default config found.\n")
51
61
 
52
62
  raw = load_yaml(abs_path)
53
-
54
63
  values = {}
55
64
 
65
+ mode = getattr(schema, "__mode__", None)
66
+
56
67
  for f in fields(schema):
57
- yaml_path = f.metadata.get("yaml_key")
58
- if not yaml_path:
68
+ # --- OLD SYSTEM SUPPORT (yaml_key) ---
69
+ yaml_path = f.metadata.get("yaml_key") if f.metadata else None
70
+ if yaml_path:
71
+ value = deep_get(raw, yaml_path)
72
+ if value is not None:
73
+ values[f.name] = convert_value(value, f.type)
59
74
  continue
60
75
 
61
- value = deep_get(raw, yaml_path)
62
- if value is None:
76
+ # --- NEW SYSTEM: mode="config" + string defaults ---
77
+ default = f.default
78
+ if mode == "config" and isinstance(default, str):
79
+ yaml_path = default
80
+ value = deep_get(raw, yaml_path)
81
+ if value is not None:
82
+ values[f.name] = convert_value(value, f.type)
63
83
  continue
64
84
 
65
- values[f.name] = value
85
+ # --- FALLBACK: use dataclass default ---
86
+ if default is not MISSING:
87
+ values[f.name] = default
66
88
 
67
89
  return schema(**values)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hungerlib
3
- Version: 3.2.dev0
3
+ Version: 3.2.dev3
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=CTLIet8Tg8Gx3wWUrUNgIsHutv0JS1YzLelp1GLaLTs,2147
2
- hungerlib/configloader.py,sha256=IEAFk57ikcUn4eR-_ncY1csi41l8f1iGnUVQS79UN0g,1722
1
+ hungerlib/__init__.py,sha256=CExLyU07UUVzaERKZnkzNilUz_FnFE9zRaQg_8qecKo,2189
2
+ hungerlib/configloader.py,sha256=H2WXVcgUbN-F9961eshArMWFUc6WErHacXPu6TuDIlY,2599
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.dev0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
- hungerlib-3.2.dev0.dist-info/METADATA,sha256=MAfltTp-r0QrJEOcsr2vZalKRSpgK9qeTU08IXr0dw0,1535
22
- hungerlib-3.2.dev0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
- hungerlib-3.2.dev0.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
- hungerlib-3.2.dev0.dist-info/RECORD,,
20
+ hungerlib-3.2.dev3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
+ hungerlib-3.2.dev3.dist-info/METADATA,sha256=JIit-rWDhUufCxw43c9pOXT_MLw43FdoQObSNl-ef6c,1535
22
+ hungerlib-3.2.dev3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
+ hungerlib-3.2.dev3.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
+ hungerlib-3.2.dev3.dist-info/RECORD,,