Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 7d1d6cf

Browse files
authored
Merge pull request #16 from peppelinux/master
just code linting and dep to oidcop removed. util.py improved
2 parents 848cc0a + 087785a commit 7d1d6cf

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

flask_rp/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from cryptojwt import KeyJar
44
from cryptojwt.key_jar import init_key_jar
55
from flask.app import Flask
6-
from oidcop.utils import load_yaml_config
76

87
from oidcrp import RPHandler
8+
from oidcrp.util import load_yaml_config
99

1010
dir_path = os.path.dirname(os.path.realpath(__file__))
1111

src/oidcrp/util.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
from http.cookiejar import Cookie
77
from http.cookiejar import http2time
88

9+
import io
10+
import json
911
import yaml
12+
1013
from oidcservice import sanitize
1114
from oidcservice.exception import TimeFormatError
1215
from oidcservice.exception import WrongContentType
@@ -249,6 +252,28 @@ def load_configuration(filename):
249252

250253

251254
def do_add_ons(add_ons, services):
252-
for key, spec in add_ons.items():
253-
_func = importer(spec['function'])
254-
_func(services, **spec['kwargs'])
255+
for key, spec in add_ons.items():
256+
_func = importer(spec['function'])
257+
_func(services, **spec['kwargs'])
258+
259+
260+
def load_json(file_name):
261+
with open(file_name) as fp:
262+
js = json.load(fp)
263+
return js
264+
265+
266+
def load_yaml_config(file_name):
267+
with open(file_name) as fp:
268+
c = yaml.safe_load(fp)
269+
return c
270+
271+
272+
def yaml_to_py_stream(file_name):
273+
d = load_yaml_config(file_name)
274+
fstream = io.StringIO()
275+
for i in d:
276+
section = '{} = {}\n\n'.format(i, json.dumps(d[i], indent=2))
277+
fstream.write(section)
278+
fstream.seek(0)
279+
return fstream

0 commit comments

Comments
 (0)