Skip to content

Commit

Permalink
Added RolesFromCsv
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Jul 11, 2018
1 parent 304a860 commit 434b38d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/openprocurement/api/roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
from schematics.transforms import export_loop, whitelist
import csv, os

This comment has been minimized.

Copy link
@kroman0

kroman0 Jul 11, 2018

Contributor

Дубляж os



class RolesFromCsv(dict):

def __init__(self, path, relative_to=__file__):
super(RolesFromCsv, self).__init__(())
self.base_dir = os.path.dirname(os.path.abspath(relative_to))
with open(os.path.join(self.base_dir, path)) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
self[row['rolename']] = whitelist(*[k for k in row if k != 'rolename' and row[k]])

0 comments on commit 434b38d

Please sign in to comment.