-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.py
More file actions
25 lines (21 loc) · 874 Bytes
/
variable.py
File metadata and controls
25 lines (21 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from pathlib import Path
class Variable:
def __init__(self, name, outer):
self.name = name
self.outer = outer
def reference(self):
return self.name, True # True is for checking if its an refrence or if you want to apply it.
def apply(self):
return self.name + " = ", False
def set(self, item):
'''
:param item: Item to set the variable to. Must be string or int.
'''
if not isinstance(item, int) and not isinstance(item, str):
raise TypeError("Item must be int or string")
else:
high_comma = "\""
with open(f'{str(Path(__file__).absolute())[:-11]}\\files\\{self.outer.filename}.vbs', 'a') as f:
f.write(
f"{self.name} = {high_comma + item + high_comma if isinstance(item, str) else item}\n"
)