-
Notifications
You must be signed in to change notification settings - Fork 3
/
helpers.py
44 lines (33 loc) · 905 Bytes
/
helpers.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import List
import logging
from base64 import b64encode
from model import *
import config
from utilities import *
@DataTracker
def base64encode(input: AceBytes) -> AceStr:
data = b64encode(input).decode()
return AceStr(data)
@DataTracker
def renderTemplate(path: str, **kwargs) -> AceStr:
template = getTemplate(path)
rendered = template.render(kwargs)
return AceStr(rendered)
@DataTracker
def readFileContent(filename: str) -> AceBytes:
f = open(filename, 'rb')
data = f.read()
f.close()
return AceBytes(data)
@DataTracker
def readFileContentStr(filename: str) -> AceBytes:
f = open(filename, 'r')
data = f.read()
f.close()
return AceStr(data)
@DataTracker
def makeAceFile(name: str, data: bytes) -> AceFile:
aceFile = AceFile(name, data)
if config.ENABLE_SCANNING is not None:
scanAv(aceFile)
return aceFile