-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
31 lines (24 loc) · 880 Bytes
/
setup.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
from typing import List
from decouple import config
import simplejson as json
from app.configuration import Configuration
from app.core.database.provider import SQLProvider
from app.domain.acm.roles.sql_repository import SQLRoleRepository
from app.settings import EXISTING_ROLES
def main():
configuration = Configuration.get_instance()
database_provider = SQLProvider(
uri=configuration.database_uri(),
debug=config('DEBUG', default=True, cast=bool))
database_provider.initialize()
repository = SQLRoleRepository(data_source=database_provider.provider())
roles: List[str] = read_roles()
for role in roles:
repository.save(name=role)
def read_roles() -> List[str]:
roles = []
with open(EXISTING_ROLES, "rb") as role_reader:
roles = json.load(role_reader)
return roles
if __name__ == "__main__":
main()