neelthee-mansion 3.19.13__py3-none-any.whl → 3.19.14__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.
neelthee_mansion/utils.py CHANGED
@@ -12,7 +12,6 @@ try:
12
12
  from psutil import *
13
13
  from playsound import *
14
14
 
15
-
16
15
  # Importing the whole module
17
16
  import pickle as pk
18
17
  import inspect
@@ -45,6 +44,7 @@ identifiers, and formatting dates.
45
44
  These utilities aim to simplify development processes, promote code reuse, and improve the efficiency of Python applications.
46
45
  """
47
46
 
47
+
48
48
  def perform_action_on_matches(input_list, target, action):
49
49
  """
50
50
  Perform an action on all items in the list that are the same as the target.
@@ -60,6 +60,7 @@ def perform_action_on_matches(input_list, target, action):
60
60
  input_list[i] = action(input_list[i])
61
61
  return input_list
62
62
 
63
+
63
64
  def get_all_matches(input_list, target):
64
65
  """
65
66
  Return a list of all items in the list that are the same as the target.
@@ -70,16 +71,18 @@ def get_all_matches(input_list, target):
70
71
  """
71
72
  return [item for item in input_list if item == target]
72
73
 
74
+
73
75
  def last_index(lst):
74
76
  if isinstance(lst, list):
75
77
  if lst:
76
78
  return len(lst) - 1
77
79
  return None
78
80
 
81
+
79
82
  def has_named_arg(func, arg_name):
80
83
  """
81
84
  Check if the function 'func' has an argument named 'arg_name'.
82
-
85
+
83
86
  :param func: Function to inspect
84
87
  :param arg_name: Name of the argument to check
85
88
  :return: True if the argument exists, False otherwise
@@ -87,8 +90,10 @@ def has_named_arg(func, arg_name):
87
90
  signature = inspect.signature(func)
88
91
  return arg_name in signature.parameters
89
92
 
93
+
90
94
  def get_random_string(length=10):
91
- return ''.join(choice(ascii_letters + digits) for _ in range(length))
95
+ return "".join(choice(ascii_letters + digits) for _ in range(length))
96
+
92
97
 
93
98
  def retry_on_exception(func, retries=3):
94
99
  for _ in range(retries):
@@ -98,6 +103,7 @@ def retry_on_exception(func, retries=3):
98
103
  print(f"Retry due to: {e}")
99
104
  print("Max retries exceeded")
100
105
 
106
+
101
107
  def measure_execution_time(func):
102
108
  start_time = time()
103
109
  result = func()
@@ -105,33 +111,44 @@ def measure_execution_time(func):
105
111
  print(f"Execution time: {end_time - start_time} seconds")
106
112
  return result
107
113
 
114
+
108
115
  def int_to_binary(n):
109
116
  return bin(n)[2:]
110
117
 
118
+
111
119
  def binary_to_int(b):
112
120
  return int(b, 2)
113
121
 
122
+
114
123
  def str_to_base64(s):
115
124
  import base64
125
+
116
126
  return base64.b64encode(s.encode()).decode()
117
127
 
128
+
118
129
  def base64_to_str(b64):
119
130
  import base64
131
+
120
132
  return base64.b64decode(b64.encode()).decode()
121
133
 
134
+
122
135
  def get_memory_usage():
123
136
  memory_info = virtual_memory()
124
137
  return memory_info.percent
125
138
 
139
+
126
140
  def get_os_info():
127
141
  return system(), release()
128
142
 
143
+
129
144
  def get_process_list():
130
- return [(p.pid, p.info['name']) for p in process_iter(['name'])]
145
+ return [(p.pid, p.info["name"]) for p in process_iter(["name"])]
146
+
131
147
 
132
148
  def get_ip_address():
133
149
  return gethostbyname(gethostname())
134
150
 
151
+
135
152
  def download_content(url):
136
153
  response = requests.get(url)
137
154
  if response.status_code == 200:
@@ -139,121 +156,156 @@ def download_content(url):
139
156
  else:
140
157
  return None
141
158
 
159
+
142
160
  def get_host_name():
143
161
  return gethostname()
144
162
 
163
+
145
164
  def reverse_string(s):
146
165
  return s[::-1]
147
166
 
167
+
148
168
  def is_palindrome(s):
149
- cleaned = ''.join(c.lower() for c in s if c.isalnum())
169
+ cleaned = "".join(c.lower() for c in s if c.isalnum())
150
170
  return cleaned == reverse_string(cleaned)
151
171
 
172
+
152
173
  def add_days(date, days):
153
174
  return date + timedelta(days=days)
154
175
 
176
+
155
177
  def get_days_between_dates(date1, date2):
156
178
  delta = date2 - date1
157
179
  return delta.days
158
180
 
181
+
159
182
  def get_weekday(date):
160
183
  return date.strftime("%A")
161
184
 
185
+
162
186
  def word_count(s):
163
187
  from collections import Counter
188
+
164
189
  words = s.split()
165
190
  return Counter(words)
166
191
 
192
+
167
193
  def get_cpu_usage():
168
194
  return cpu_percent(interval=1)
169
195
 
196
+
170
197
  def get_disk_space():
171
- usage = disk_usage('/')
172
- return usage.free / (1024 ** 3) # Free space in GB
198
+ usage = disk_usage("/")
199
+ return usage.free / (1024**3) # Free space in GB
200
+
173
201
 
174
202
  def get_system_uptime():
175
203
  return time() - boot_time()
176
204
 
205
+
177
206
  def is_valid_email(email):
178
- pattern = r'^[\w\.-]+@[\w\.-]+\.\w+$'
207
+ pattern = r"^[\w\.-]+@[\w\.-]+\.\w+$"
179
208
  return match(pattern, email) is not None
180
209
 
210
+
181
211
  def is_valid_url(url):
182
212
  import validators
213
+
183
214
  return validators.url(url)
184
215
 
216
+
185
217
  def is_valid_ip(ip):
186
218
  import ipaddress
219
+
187
220
  try:
188
221
  ipaddress.ip_address(ip)
189
222
  return True
190
223
  except ValueError:
191
224
  return False
192
225
 
193
- def celsius_fahrenheit_conversion(Temp, IsCelsius = True):
226
+
227
+ def celsius_fahrenheit_conversion(Temp, IsCelsius=True):
194
228
  if IsCelsius:
195
- return (Temp * 9/5) + 32
229
+ return (Temp * 9 / 5) + 32
196
230
  else:
197
- return 5 / 9*(Temp - 32)
231
+ return 5 / 9 * (Temp - 32)
232
+
198
233
 
199
234
  def json_to_xml(json_data):
200
235
  import json
201
236
  import dicttoxml
237
+
202
238
  return dicttoxml.dicttoxml(json.loads(json_data))
203
239
 
240
+
204
241
  def flatten_list(nested_list):
205
242
  import itertools
243
+
206
244
  return list(itertools.chain(*nested_list))
207
245
 
246
+
208
247
  def merge_dicts(*dicts):
209
248
  result = {}
210
249
  for d in dicts:
211
250
  result.update(d)
212
251
  return result
213
252
 
253
+
214
254
  def shuffle_list(lst):
215
255
  import random
256
+
216
257
  shuffle(lst)
217
258
  return lst
218
259
 
260
+
219
261
  def date_difference(date1, date2):
220
262
  delta = date2 - date1
221
263
  return delta.days
222
264
 
265
+
223
266
  def is_leap_year(year):
224
267
  return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
225
268
 
269
+
226
270
  def get_current_time_in_timezone(timezone_str):
227
271
  import pytz
272
+
228
273
  tz = pytz.timezone(timezone_str)
229
274
  return datetime.now(tz)
230
275
 
231
- def clamp(value, min = 0, max = 0):
276
+
277
+ def clamp(value, min=0, max=0):
232
278
  if value < min:
233
279
  value = min
234
280
  if value > max:
235
281
  value = max
236
282
  return value
237
283
 
284
+
238
285
  def is_executable(code_str):
239
286
  code_str = code_str.strip()
240
287
  if not code_str: # Check for empty or whitespace-only string
241
288
  return False
242
289
  try:
243
290
  # Parse the code to ensure it is syntactically correct
244
- tree = ast.parse(code_str, mode='exec')
245
-
291
+ tree = ast.parse(code_str, mode="exec")
292
+
246
293
  # Walk through the AST to find undefined names
247
294
  for node in ast.walk(tree):
248
295
  if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load):
249
296
  # Check if the name is a built-in, defined locally in code, or globally available
250
- if node.id not in dir(builtins) and node.id not in globals() and node.id not in locals():
297
+ if (
298
+ node.id not in dir(builtins)
299
+ and node.id not in globals()
300
+ and node.id not in locals()
301
+ ):
251
302
  return False # Name is not defined
252
-
303
+
253
304
  return True
254
305
  except (SyntaxError, TypeError):
255
306
  return False
256
307
 
308
+
257
309
  def get_holiday():
258
310
  today = date.today()
259
311
  year = today.year
@@ -271,20 +323,21 @@ def get_holiday():
271
323
 
272
324
  # Check if today is near Halloween
273
325
  if halloween_start <= today <= halloween_end:
274
- return 'halloween'
275
-
326
+ return "halloween"
327
+
276
328
  # Check if today is near Christmas
277
329
  elif christmas_start <= today <= christmas_end:
278
- return 'christmas'
279
-
330
+ return "christmas"
331
+
280
332
  # Check if today is near Easter
281
333
  elif easter_start <= today <= easter_end:
282
- return 'easter'
283
-
334
+ return "easter"
335
+
284
336
  # No holiday near today
285
337
  else:
286
338
  return None
287
339
 
340
+
288
341
  # Easter calculation (based on the "Computus" algorithm)
289
342
  def calculate_easter_date(year):
290
343
  a = year % 19
@@ -304,18 +357,22 @@ def calculate_easter_date(year):
304
357
 
305
358
  return date(year, month, day)
306
359
 
360
+
307
361
  def play_sound(sound_file):
308
362
  playsound(sound_file)
309
363
 
364
+
310
365
  def truncate_text(text: str, max_length: int = 234):
311
- return text[:max_length] + '...' if len(text) > max_length else text
366
+ return text[:max_length] + "..." if len(text) > max_length else text
367
+
312
368
 
313
369
  def download_file(url, filename):
314
370
  response = requests.get(url)
315
371
  if response.status_code == 200:
316
- with open(filename, 'wb') as file:
372
+ with open(filename, "wb") as file:
317
373
  file.write(response.content)
318
374
 
375
+
319
376
  def check_internet_connection():
320
377
  try:
321
378
  create_connection(("www.google.com", 80))
@@ -323,75 +380,85 @@ def check_internet_connection():
323
380
  except OSError:
324
381
  return False
325
382
 
383
+
326
384
  def get_current_timestamp():
327
385
  return datetime.now().timestamp()
328
386
 
387
+
329
388
  def format_date(date: datetime):
330
389
  return date.strftime("%Y-%m-%d %H:%M:%S")
331
390
 
391
+
332
392
  def delay(seconds):
333
393
  sleep(seconds)
334
394
 
395
+
335
396
  # All classes:
336
397
  class TextEdits:
337
398
  # Text colors
338
- BLACK = '\033[30m' # Black
339
- RED = '\033[31m' # Red
340
- GREEN = '\033[32m' # Green
341
- YELLOW = '\033[33m' # Yellow
342
- BLUE = '\033[34m' # Blue
343
- MAGENTA = '\033[35m' # Magenta
344
- CYAN = '\033[36m' # Cyan
345
- WHITE = '\033[37m' # White
346
-
399
+ BLACK = "\033[30m" # Black
400
+ RED = "\033[31m" # Red
401
+ GREEN = "\033[32m" # Green
402
+ YELLOW = "\033[33m" # Yellow
403
+ BLUE = "\033[34m" # Blue
404
+ MAGENTA = "\033[35m" # Magenta
405
+ CYAN = "\033[36m" # Cyan
406
+ WHITE = "\033[37m" # White
407
+
347
408
  # Custom colors (adjusted for more contrast)
348
- PINK = '\033[38;5;205m' # Brighter Pink (ANSI 256-color code)
349
- PURPLE = '\033[38;5;53m' # Darker Purple (ANSI 256-color code)
350
- ORANGE = '\033[38;5;208m' # Orange (ANSI 256-color code)
351
- BROWN = '\033[38;5;94m' # Brown (ANSI 256-color code)
409
+ PINK = "\033[38;5;205m" # Brighter Pink (ANSI 256-color code)
410
+ PURPLE = "\033[38;5;53m" # Darker Purple (ANSI 256-color code)
411
+ ORANGE = "\033[38;5;208m" # Orange (ANSI 256-color code)
412
+ BROWN = "\033[38;5;94m" # Brown (ANSI 256-color code)
352
413
 
353
414
  # Background colors
354
- BLACK_BG = '\033[40m' # Black background
355
- RED_BG = '\033[41m' # Red background
356
- GREEN_BG = '\033[42m' # Green background
357
- YELLOW_BG = '\033[43m' # Yellow background
358
- BLUE_BG = '\033[44m' # Blue background
359
- MAGENTA_BG = '\033[45m' # Magenta background
360
- CYAN_BG = '\033[46m' # Cyan background
361
- WHITE_BG = '\033[47m' # White background
415
+ BLACK_BG = "\033[40m" # Black background
416
+ RED_BG = "\033[41m" # Red background
417
+ GREEN_BG = "\033[42m" # Green background
418
+ YELLOW_BG = "\033[43m" # Yellow background
419
+ BLUE_BG = "\033[44m" # Blue background
420
+ MAGENTA_BG = "\033[45m" # Magenta background
421
+ CYAN_BG = "\033[46m" # Cyan background
422
+ WHITE_BG = "\033[47m" # White background
362
423
 
363
424
  # Text styles
364
- BOLD = '\033[1m' # Bold text
365
- UNDERLINE = '\033[4m' # Underlined text
366
- BLINK = '\033[5m' # Blinking text, nonworking
367
- REVERSE = '\033[7m' # Reversed (invert the foreground and background colors)
368
- HIDDEN = '\033[8m' # Hidden (invisible) text
369
- LINETHROUGH = '\033[9m' # Strikethrough (linethrough) text
370
- ITALIC = '\033[3m'
425
+ BOLD = "\033[1m" # Bold text
426
+ UNDERLINE = "\033[4m" # Underlined text
427
+ BLINK = "\033[5m" # Blinking text, nonworking
428
+ REVERSE = "\033[7m" # Reversed (invert the foreground and background colors)
429
+ HIDDEN = "\033[8m" # Hidden (invisible) text
430
+ LINETHROUGH = "\033[9m" # Strikethrough (linethrough) text
431
+ ITALIC = "\033[3m"
371
432
 
372
433
  # Reset all formatting
373
- RESET = '\033[0m'
434
+ RESET = "\033[0m"
435
+
374
436
 
375
437
  class Y_N:
376
438
  def __init__(self, Value: str) -> None:
377
439
  Value = Value.lower()
378
- if Value == 'y':
440
+ if Value == "y":
379
441
  Value = True
380
- elif Value == 'n':
442
+ elif Value == "n":
381
443
  Value = False
382
444
  else:
383
445
  raise ValueError("That wasn't Y or N")
384
446
  self.value = Value
385
447
 
448
+
386
449
  def all_same_value(lst, value):
387
450
  return all(x == value for x in lst)
388
451
 
452
+
389
453
  def generate_id(start_str: str = "ObjectName_ObjectDetals", length: int = 32):
390
454
  characters = ascii_letters + digits
391
- random_part = ''.join(choice(characters) for _ in range(length - len(start_str)))
455
+ random_part = "".join(choice(characters) for _ in range(length - len(start_str)))
392
456
  return start_str + "_" + random_part
393
457
 
394
- def type_text(text: str, newline: bool = True, delay: float = 0.075, colorTrue: bool = True):
458
+
459
+ def type_text(
460
+ text: str, newline: bool = True, delay: float = 0.075, colorTrue: bool = True
461
+ ):
395
462
  """
396
463
  Function to type text with optional color formatting.
397
464
 
@@ -400,8 +467,8 @@ def type_text(text: str, newline: bool = True, delay: float = 0.075, colorTrue:
400
467
  newline -- whether to print a newline at the end (default: True)
401
468
  delay -- delay between each character in seconds (default: 0.075)
402
469
  """
403
- color_start = '%*'
404
- color_end = '*%'
470
+ color_start = "%*"
471
+ color_end = "*%"
405
472
 
406
473
  key_pressed = False
407
474
 
@@ -410,16 +477,16 @@ def type_text(text: str, newline: bool = True, delay: float = 0.075, colorTrue:
410
477
  key_pressed = True
411
478
 
412
479
  keyboard.hook(on_key_event)
413
-
480
+
414
481
  i = 0
415
482
  while i < len(text):
416
483
  if key_pressed:
417
484
  delay = 0
418
485
 
419
- if text[i:i+len(color_start)] == color_start:
486
+ if text[i : i + len(color_start)] == color_start:
420
487
  color_end_index = text.find(color_end, i)
421
488
  if color_end_index != -1:
422
- color_code = text[i+len(color_start):color_end_index]
489
+ color_code = text[i + len(color_start) : color_end_index]
423
490
  color = getattr(TextEdits, color_code, TextEdits.RESET)
424
491
  if colorTrue:
425
492
  stdout.write(color)
@@ -430,18 +497,26 @@ def type_text(text: str, newline: bool = True, delay: float = 0.075, colorTrue:
430
497
  i += 1
431
498
  stdout.flush()
432
499
  sleep(delay)
433
-
500
+
434
501
  stdout.write(TextEdits.RESET) # Reset color
435
502
  stdout.flush()
436
503
  if newline:
437
504
  print()
438
-
505
+
439
506
  keyboard.unhook(on_key_event)
440
507
 
508
+
441
509
  def rounding(x: int, base: int = 5):
442
- return int(base * round(x/base))
510
+ return int(base * round(x / base))
511
+
443
512
 
444
- def loop_til_valid_input(input_text: str, bad_text: str, Class: classmethod, delay: int = 0.075, input_method: str = '>'):
513
+ def loop_til_valid_input(
514
+ input_text: str,
515
+ bad_text: str,
516
+ Class: classmethod,
517
+ delay: int = 0.075,
518
+ input_method: str = ">",
519
+ ):
445
520
  while True:
446
521
  try:
447
522
  type_text(input_text, delay=delay)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neelthee-mansion
3
- Version: 3.19.13
3
+ Version: 3.19.14
4
4
  Summary: A text-based adventure game set in Neel-thee’s mansion.
5
5
  Home-page: https://github.com/Flameblade375/neelthee_mansion
6
6
  Author: Alexander.E.F
@@ -0,0 +1,16 @@
1
+ neelthee_mansion/Books.py,sha256=ABAdO2LQJ0PwPlHXpvdANoyz6uNbMTkI8-_RDpq6Qcc,25627
2
+ neelthee_mansion/Mansion_of_Amnesia.py,sha256=9TM_PNDB60xeh9LEYtq15UJWLrMvvqr2oM50ecNLAQ8,49152
3
+ neelthee_mansion/Quests.py,sha256=pUlru2RugP57MACQORZaF_X9lsbefTdPYTSO474phgo,2791
4
+ neelthee_mansion/Rooms.py,sha256=DUTN0OpYvr-JjKvu9aGteyvvgKl2LAskvgt1onlTNXE,78243
5
+ neelthee_mansion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ neelthee_mansion/__main__.py,sha256=OIAWZ04le70DyjtR4hlmK9csHej7EHxeUrMoNnM-Vjc,95
7
+ neelthee_mansion/all_game_utils.py,sha256=AasunTkFmgAqt9ZIoYmymi4R7leBe4ubW-C1ts0Qclo,351
8
+ neelthee_mansion/creatures.py,sha256=aJtEMzanOL9sYkozmZuzJ2Tutl85cWgQ2LbFbZ-Edao,15869
9
+ neelthee_mansion/items.py,sha256=mV4K3Ep522LypL74NOT112bpP6ywQ1DR0A38KiHJFa8,5816
10
+ neelthee_mansion/utils.py,sha256=GaCkein6dppeufYfBMk59gHAE2b4p9TJW2MsRjyyFvQ,13702
11
+ neelthee_mansion-3.19.14.dist-info/LICENSE.md,sha256=CV8XGZaCyyAMdbkYFQUjb8AjBq9vkoyqdZCq1_hetms,1105
12
+ neelthee_mansion-3.19.14.dist-info/METADATA,sha256=Z6GDglDjMZF718feeUjx2Uzj14LmqbsUea2Znc3SJcE,1757
13
+ neelthee_mansion-3.19.14.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
14
+ neelthee_mansion-3.19.14.dist-info/entry_points.txt,sha256=j5ScTTyIidFhmT3F6hcX9pnlom4cJdDmfe26BmM6Igo,56
15
+ neelthee_mansion-3.19.14.dist-info/top_level.txt,sha256=woQImQewylhly5Rb24HwPEGMxPY6do_PaUwGd5BNLOM,17
16
+ neelthee_mansion-3.19.14.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- neelthee_mansion/Books.py,sha256=P608nxbspB5wnGTKjK6ATrb4p-rCvfOxjwJ1O5tMhjY,25595
2
- neelthee_mansion/Mansion_of_Amnesia.py,sha256=WG0r4Vb3BwlBeYto4iGPek4I9UtmOP5AQEd4OfAA4_8,46784
3
- neelthee_mansion/Quests.py,sha256=q6VzR3mt9AYe29ACWZuf-suz4yOKrL946aJ493eQRS0,2611
4
- neelthee_mansion/Rooms.py,sha256=UgI0U6yXEtrhX_W3goARqxa20TdvuXg-MY3HJc_N-5Q,90805
5
- neelthee_mansion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- neelthee_mansion/__main__.py,sha256=OIAWZ04le70DyjtR4hlmK9csHej7EHxeUrMoNnM-Vjc,95
7
- neelthee_mansion/all_game_utils.py,sha256=mnxws_YEnsoftkkBMZv1k_zlnGKWGenUvsZnNKjuFJQ,349
8
- neelthee_mansion/creatures.py,sha256=nc-6YQ7S89teDiypJdHKLLuq-q3UpbQCVGfJ4hnCb7M,15600
9
- neelthee_mansion/items.py,sha256=HTy9BhHWB0T_S53HFls0y6ER5jD7XAeI6PlY1ZnCZug,5711
10
- neelthee_mansion/utils.py,sha256=Wt1CdK4eCskrxRXkeKgzVoa_NIzwQ047dJU-b_e8pb8,13559
11
- neelthee_mansion-3.19.13.dist-info/LICENSE.md,sha256=CV8XGZaCyyAMdbkYFQUjb8AjBq9vkoyqdZCq1_hetms,1105
12
- neelthee_mansion-3.19.13.dist-info/METADATA,sha256=qtYTlYn_NOgw5ApjKbXMqiG3FhWY_Rzif7p2Lfy1Kbo,1757
13
- neelthee_mansion-3.19.13.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
14
- neelthee_mansion-3.19.13.dist-info/entry_points.txt,sha256=j5ScTTyIidFhmT3F6hcX9pnlom4cJdDmfe26BmM6Igo,56
15
- neelthee_mansion-3.19.13.dist-info/top_level.txt,sha256=woQImQewylhly5Rb24HwPEGMxPY6do_PaUwGd5BNLOM,17
16
- neelthee_mansion-3.19.13.dist-info/RECORD,,