-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
25 lines (21 loc) · 875 Bytes
/
template.py
File metadata and controls
25 lines (21 loc) · 875 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
# -*- coding: utf-8 -*-
import json
import os
from sys import exit
class Template:
""""Этот класс отвечает за работу с шаблонами"""
def __init__(self, template):
self.template = template
def get_template(self):
f = os.getcwd() + '/template.json'
if os.path.exists(f):
with open(f, 'r', encoding='utf-8') as f:
try:
self.template = json.loads(f.read())
for key in self.template.keys():
if key not in self.template:
print('Не хватает параметров в шаблоне')
exit()
except json.decoder.JSONDecodeError:
print('Не удалось загрузить шаблон')
return self.template