File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 22import json
33
44
5- def get (variable ):
6- try :
7- with io .open ('config.json' , "r" , encoding = 'UTF-8' ) as file :
8- keys = json .load (file )
9- if variable in keys :
10- return keys [variable ]
5+ class ConfigLoaderException (Exception ):
6+ """Custom docstring"""
7+
8+
9+ class ConfigLoader :
10+ def __init__ (self , config_file ):
11+ self .config_file = config_file
12+ self .variables = self .load_variables ()
13+
14+ def load_variables (self ):
15+ try :
16+ with io .open (self .config_file , "r" , encoding = 'UTF-8' ) as file :
17+ keys = json .load (file )
18+ return keys
19+ except FileNotFoundError :
20+ raise ConfigLoaderException ('No configuration file found.' )
21+
22+ def get (self , variable ):
23+ if variable in self .variables :
24+ return self .variables [variable ]
25+ else :
1126 return None
12- except FileNotFoundError :
13- return None
Original file line number Diff line number Diff line change 11from setuptools import setup
22
33setup (name = 'packages' ,
4- version = '1.0 ' ,
4+ version = '1.1 ' ,
55 description = 'Python module for Jönköping University Librarys various helper packages' ,
66 url = 'https://github.com/JonkopingUniversityLibrary/python_packages' ,
77 author = 'Gustav Lindqvist' ,
You can’t perform that action at this time.
0 commit comments