fullscript.spellbook 2.1__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.
spellbook/utils.py ADDED
@@ -0,0 +1,93 @@
1
+ import os
2
+ import yaml
3
+ import re
4
+ import warnings
5
+ import random
6
+ import importlib.resources
7
+
8
+ def load_config(file_path):
9
+ """
10
+ Load the configuration file
11
+ :param file_path: The path to the configuration file
12
+ :return: config variable
13
+ """
14
+ with open(file_path, 'r') as file:
15
+ config = yaml.safe_load(file)
16
+ return config
17
+
18
+
19
+ def parse_env_variables(config, configurations):
20
+ """
21
+ Parse the environment variables in the configuration file
22
+ :param configurations: The key of the configuration block
23
+ :param config: The configuration dictionary
24
+ :return: config variable
25
+ """
26
+ sensitive_keys = {'account', 'user', 'password', 'private_key', 'private_key_passphrase', 'host'}
27
+ pattern = re.compile(r'\$\{(\w+)\}')
28
+
29
+ for block in config[configurations]:
30
+ for key, value in block.items():
31
+ if isinstance(value, str):
32
+ matches = pattern.findall(value)
33
+ if not matches: # If the value is not referencing an environment variable
34
+ if key in sensitive_keys:
35
+ warnings.warn(
36
+ f"The key '{key}' is hardcoded in the configuration file. "
37
+ "It is recommended to use environment variables for sensitive information."
38
+ )
39
+ else:
40
+ # Replace environment variable placeholders with their values
41
+ for match in matches:
42
+ env_value = os.getenv(match, '')
43
+ block[key] = block[key].replace(f'${{{match}}}', env_value)
44
+ return config
45
+
46
+
47
+ # Load and parse the configuration
48
+ # def load_and_parse_config(config_file_path='spellbook_config.yaml', configurations=None):
49
+ def load_and_parse_config(config_file_path=os.path.expanduser('~')+'/'+'spellbook_config.yaml', configurations=None):
50
+ """
51
+ Load and parse the configuration
52
+ :return: config variable
53
+ """
54
+
55
+ # Use the home folder version but if a local file exists it overwrites the home folder version
56
+ if os.path.isfile('spellbook_config.yaml'):
57
+ config_file_path='spellbook_config.yaml'
58
+ else:
59
+ pass
60
+
61
+ config = load_config(file_path=config_file_path)
62
+ config = parse_env_variables(config, configurations=configurations)
63
+ return config
64
+
65
+ # load wizard file from the wizard directory
66
+
67
+ def get_wizard():
68
+ try:
69
+ # Get a reference to the 'wizards' directory
70
+ wizards_dir = importlib.resources.files('spellbook.wizards')
71
+
72
+ # List all text files in the directory
73
+ wizard_files = [f.name for f in wizards_dir.iterdir() if f.is_file() and f.name.endswith('.txt')]
74
+
75
+ # Ensure there are wizard files available
76
+ if not wizard_files:
77
+ raise FileNotFoundError("No wizard files found in the directory.")
78
+
79
+ # Choose a random file from the list
80
+ random_file = random.choice(wizard_files)
81
+
82
+ # Load the content of the randomly chosen file
83
+ with importlib.resources.open_text('spellbook.wizards', random_file) as f:
84
+ wizard = f.read()
85
+
86
+ except FileNotFoundError as e:
87
+ print(e)
88
+ wizard = None
89
+ except Exception as e:
90
+ print('An error was encountered loading the wizard:', e)
91
+ wizard = None
92
+
93
+ return wizard
@@ -0,0 +1,11 @@
1
+ db_magic spell cast
2
+ /\ "V"
3
+ //..\\\ I
4
+ \\\.`// I o
5
+ /l\/j\ (I 0 .
6
+ /. ~~ ,\ / I . o
7
+ \\\L__j ^\/ I o .
8
+ \/ --v} I _________
9
+ | | I c(` ')o
10
+ | l I \. ,/
11
+ _/j L l\_ ! _//^---^\\\_
@@ -0,0 +1,18 @@
1
+ ___====-_ _-====___
2
+ _--^^^#####// \`\#####^^^--_
3
+ _-^##########//( ) \`\##########^-_
4
+ -############// |\^^/| \`\############-
5
+ _/############// (@: :@) \`\############\_
6
+ /#############(( \`\/`/ ))#############\`
7
+ -###############\ (oo) //###############-
8
+ -#################\ / VV \ //#################-
9
+ -###################\/ \//###################-
10
+ _#/|##########/\######( /\ )######/\##########|\#_
11
+ |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
12
+ ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
13
+ ` ` ` ` / | | | | \ ' ' ' '
14
+ ( | | | | )
15
+ __\ | | | | /__
16
+ (vvv(VVV)(VVV)vvv)
17
+
18
+ *** db magic spell cast ***
@@ -0,0 +1,14 @@
1
+ _,,......_
2
+ ,-' `'--.
3
+ ,-' _ '-.
4
+ (`. ,' , `-. `.
5
+ \ \ - / ) \ \
6
+ `\`-^^^, )/ | / :
7
+ )^ ^ ^V/ / '.
8
+ | ) | `.
9
+ 9 9 /,--,\ |._:` .._`.
10
+ | / / `. \ `. ( `.`.
11
+ | / \ \ \ \ `--\ ) `.`.___
12
+ -hrr- .;;./ ' ) ' ) ///' `-"'
13
+ `--' 7//\ ///\
14
+ db_magic spell cast ***>>
@@ -0,0 +1,13 @@
1
+ , \ / ,
2
+ / \ )\__/( / \
3
+ / \ (_\ /_) / \
4
+ ____/_____\__\@ @/___/_____\____
5
+ | |\../| |
6
+ | \VV/ |
7
+ | ---------------- |
8
+ |_________________________________|
9
+ | /\ / \\ \ /\ |
10
+ | / V )) V \ |
11
+ |/ ` // ' \|
12
+ ` V '
13
+ db_magic spell cast >>>>>***
@@ -0,0 +1,2 @@
1
+ db_magic spell cast
2
+ ( ◔ ౪◔)⊃━☆゚.*・
@@ -0,0 +1,2 @@
1
+ db_magic spell cast
2
+ (∩ ͡° ͜ʖ ͡°)⊃━☆゚. *
@@ -0,0 +1,7 @@
1
+ db_magic spell cast
2
+ (\\. \\ ,/)
3
+ \\( |\\ )/
4
+ //\\ | \\ /\\\\
5
+ (/ /\\_#oo#_/\\ \\)
6
+ \\/\\ #### /\\/
7
+ `##'
@@ -0,0 +1,4 @@
1
+ db_magic spell cast
2
+ || ,_ . _ _ _ || _ _|-
3
+ (||) |||(|(||(_ _\\|)(/_|| (_(|_\\|_
4
+ _| |
@@ -0,0 +1,3 @@
1
+ .✫*゚・゚。.☆.*。・゚✫*.*。・
2
+ db magic spell cast
3
+ .✫*゚・゚。.★.*。・゚✫*.*。・
@@ -0,0 +1,4 @@
1
+ _/﹋\_
2
+ (҂`_´)
3
+ <,︻╦╤─ ҉ - - M a g i c S p e l l !!
4
+ _/﹋\_
@@ -0,0 +1,22 @@
1
+ db magic spell cast
2
+ /
3
+ __ //
4
+ -\= \=\ //
5
+ --=_\=---//=--
6
+ -_==/ \/ //\/--
7
+ ==/ /O O\==--
8
+ _ _ _ _ /_/ \ ] /--
9
+ /\ ( (- \ / ] ] ]==-
10
+ (\ _\_\_\-\__/ \ (,_,)--
11
+ (\_/ \ \-
12
+ \/ / ( ( \ ] /)
13
+ / ( \ \_ \./ )
14
+ ( \ \ ) \
15
+ ( /\_ _ _ _ /---/ /\_ \
16
+ \ / \ / ____/ / \ \
17
+ ( / ) / / /__ ) ( )
18
+ ( ) / __/ '---` / /
19
+ \ / \ \ _/ /
20
+ ] ] )_\_ /__\/
21
+ /_\ ]___\
22
+ (___)
@@ -0,0 +1,24 @@
1
+ *** db magic spell cast ***
2
+ ,--, ,.-.
3
+ , \, '-,-`,'-.' | ._
4
+ /| \ , |\ } )/ / `-,',
5
+ [ , |\ /| | | / \| |/` ,`
6
+ | | ,.` `,` `, | | _,...( ( .',
7
+ \ \ __ ,-` ` , , `/ |,' Y ( /_\`
8
+ \ \_\,``, ` , , / | ) _,/
9
+ \ ' ` ,_ _`_,-,<._.< / /
10
+ ', `>.,` ` ` ,., |_ | /
11
+ \/` `, ` ,` | /__,.-` _, `\`
12
+ -,-..\ _ \ ` / , / `._) _,-\` \`
13
+ \_,,.) /\ ` / / ) (-,, `` , |
14
+ ,` ) | \_\ '-` | `( \`
15
+ / /```( , --, ,' \ |`<` , |
16
+ / /_,--`\ <\ V /> ,` )<_/) | \ _____)
17
+ ,-, ,` ` (_,\ \ | /) / __/ / `----`
18
+ (-, \ ) \ ('_.-._)/ /,` /
19
+ | / ` `/ \`\ V V, /` /
20
+ ,--\( , <_/`\`\ || /
21
+ ( ,``- \/| \-A.A-`| /
22
+ ,>,_ )_,..( )\ -,,_-` _--`
23
+ (_ \|` _,/_ / \_ ,--`
24
+ \( ` <.,../` `-.._ _,-`