hungerlib 3.2.dev8__py3-none-any.whl → 3.2.dev9__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/datamap.py CHANGED
@@ -48,33 +48,65 @@ datamap.angles = datamap(syntax=Syntax.angles)
48
48
  datamap.dollars = datamap(syntax=Syntax.dollars)
49
49
  datamap.percents = datamap(syntax=Syntax.percents)
50
50
 
51
- def mapit(text: str, *maps, **runtime):
52
- maps = (*get_default_maps(), *maps)
53
- for m in maps:
51
+ def mapit(text: str, *maps, only_maps=None, disable=None, enable=None, **runtime):
52
+ # 1. FULL OVERRIDE MODE
53
+ if only_maps is not None:
54
+ maps_to_use = list(only_maps)
55
+
56
+ else:
57
+ # 2. Start with default maps
58
+ maps_to_use = list(get_default_maps())
59
+
60
+ # 3. Remove disabled maps
61
+ if disable:
62
+ maps_to_use = [m for m in maps_to_use if m not in disable]
63
+
64
+ # 4. Add positional maps
65
+ if maps:
66
+ maps_to_use.extend(maps)
67
+
68
+ # 5. Add enabled maps
69
+ if enable:
70
+ maps_to_use.extend(enable)
71
+
72
+ # 6. Apply maps in order
73
+ for m in maps_to_use:
54
74
  if isinstance(m, type) and is_dataclass(m):
55
75
  m = m()
76
+
56
77
  if is_dataclass(m):
57
78
  pattern = m.get_syntax()
58
79
  d = m.as_map()
80
+
59
81
  elif hasattr(m, "as_dict"):
60
82
  pattern = Syntax.angles
61
83
  d = m.as_dict()
84
+
62
85
  elif isinstance(m, dict):
63
86
  pattern = runtime.get("syntax")
64
87
  if not pattern:
65
88
  continue
66
89
  d = m
90
+
67
91
  else:
68
92
  continue
93
+
69
94
  def repl(match):
70
95
  k = match.group(1)
71
96
  return str(d.get(k, match.group(0)))
97
+
72
98
  text = re.sub(pattern, repl, text)
99
+
100
+ # 7. Runtime kwargs always apply last
73
101
  if runtime:
74
102
  pattern = Syntax.braces
75
103
  d = runtime
104
+
76
105
  def repl(match):
77
106
  k = match.group(1)
78
107
  return str(d.get(k, match.group(0)))
108
+
79
109
  text = re.sub(pattern, repl, text)
110
+
80
111
  return text
112
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hungerlib
3
- Version: 3.2.dev8
3
+ Version: 3.2.dev9
4
4
  Summary: Powerful automation library for Pterodactyl.
5
5
  Author: iFamished
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  hungerlib/__init__.py,sha256=CTLIet8Tg8Gx3wWUrUNgIsHutv0JS1YzLelp1GLaLTs,2147
2
2
  hungerlib/configloader.py,sha256=TdEFqk2zG5nT-vJqdjA36DrbRinY66n0rgI8Z-EZmAk,2548
3
- hungerlib/datamap.py,sha256=TDIL67FH_D6nP8q3czKz2PZnjvs9J0NcC7Un8584xLs,2220
3
+ hungerlib/datamap.py,sha256=Tvcjc-n-tNO9SNQeh0k3dWzbxrRnnNVUmPnq0gap_8w,2807
4
4
  hungerlib/messagerouter.py,sha256=1-4KeUT6AgTF0F53n3BtWt0ch0lnHHXYPOWvRtvUVKY,4344
5
5
  hungerlib/panel.py,sha256=LljDy3FZoabWotdrNhN89xHd2VcvbiQDshtZgMa0g08,2013
6
6
  hungerlib/api/__init__.py,sha256=xuPbWBXVTkr9Jtcmvk8PPiVvi8HDxrIOmb_gOcDZy-M,336
@@ -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.dev8.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
- hungerlib-3.2.dev8.dist-info/METADATA,sha256=s7zJxIBTVKk8M6zk5BPML7_fFqwY3Xo-1CKSODcSUU4,1535
22
- hungerlib-3.2.dev8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
- hungerlib-3.2.dev8.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
- hungerlib-3.2.dev8.dist-info/RECORD,,
20
+ hungerlib-3.2.dev9.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
21
+ hungerlib-3.2.dev9.dist-info/METADATA,sha256=vAcqjfRaHsF7mCQaaD-lf3FwNpMOJvLr5iPebOpJJ9E,1535
22
+ hungerlib-3.2.dev9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
23
+ hungerlib-3.2.dev9.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
24
+ hungerlib-3.2.dev9.dist-info/RECORD,,