<commit_before>#!/usr/bin/env python3
'''
This script imports users and groups from json to KYPO AAI database.
JSON files were generated by perun-service named kypo_portal.

author:  <NAME>
date:    2016-05-02 
version: 1.0.0

2016-05-13: In getting data from DB added code to ignore testing DB entries with no external_id
2016-11-17: Correct typo in code, parrent -> parent
2016-11-30: Fixed errors with parent groups, error messages
2016-12-01: Subgroups are stored in DB without prefix of parent group
'''

import sys
import json
import psycopg2

'''Information to access DB'''
DB_NAME = 'SET DB NAME HERE'
DB_USER = 'SET DB USER HERE'
DB_HOST = 'SET DB HOST HERE'
DB_PSSWD = 'SET PASSWORD HERE'

CONN_STRING = "dbname='{0}' user='{1}' host='{2}' password='{3}'".format(DB_NAME, DB_USER, DB_HOST, DB_PSSWD)

''' Names of tables in DB'''
USER_TABLE = 'users'
GROUP_TABLE = 'idm_group'
IDENTITY_TABLE = 'user_identity'
USERINGROUP_TABLE = 'user_idm_group'

''' Source JSON files '''
USERS_SRC = '/tmp/users.scim'
GROUPS_SRC = '/tmp/groups.scim'

try:
	conn = psycopg2.connect(CONN_STRING)
except:
	print("Unable to connect to DB")
	sys.exit(1)

''' DEFINING VARIABLES '''
class User(object):
	def __init__(self):<commit_msg>updated proccess-kypo_portal.py to load information to access DB from external file<commit_after>#!/usr/bin/env python3
'''
This script imports users and groups from json to KYPO AAI database.
JSON files were generated by perun-service named kypo_portal.

author:  Frantisek Hrdina
date:    2016-05-02 
version: 1.0.0

2016-05-13: In getting data from DB added code to ignore testing DB entries with no external_id
2016-11-17: Correct typo in code, parrent -> parent
2016-11-30: Fixed errors with parent groups, error messages
2016-12-01: Subgroups are stored in DB without prefix of parent group
'''

import sys
import json
import psycopg2
import configparser

''' Loading connection information from db_settings.ini'''
try:
	config = configparser.ConfigParser()
	config.read('db_settings.ini')
	
	DB_NAME = config.get('database', 'name')
	DB_USER = config.get('database', 'user')
	DB_HOST = config.get('database', 'host')
	DB_PSSWD = config.get('database', 'password')
except:
	print("Failed reading from file with information to access DB")
	sys.exit(1)

CONN_STRING = "dbname='{0}' user='{1}' host='{2}' password='{3}'".format(DB_NAME, DB_USER, DB_HOST, DB_PSSWD)

''' Names of tables in DB'''
USER_TABLE = 'users'
GROUP_TABLE = 'idm_group'
IDENTITY_TABLE = 'user_identity'
USERINGROUP_TABLE = 'user_idm_group'

''' Source JSON files '''
USERS_SRC = '/tmp/users.scim'
GROUPS_SRC = '/tmp/groups.scim'

try:
	conn = psycopg2.connect(CONN_STRING)
except:
	print("Unable to connect to DB")
	sys.exit(1)

''' DEFINING VARIABLES '''
class User(object):
	def __init__(self):
{'fraction_non_alphanumeric': 0.12303290414878398, 'fraction_numerical': 0.03683834048640915, 'mean_word_length': 5.054112554112554, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1785853', 'n_tokens_mistral': 1026, 'n_tokens_neox': 962, 'n_words': 307}