<commit_before>import boto3
import json
import random
from .vars import DYNAMODB_TABLE, AWS_ACCOUNT_NUMBER, AWS_REGION
from .utils import printlog


class IAM(object):

    account_id = AWS_ACCOUNT_NUMBER
    region = AWS_REGION

    def __init__(self, bucket_names, user_group_tag, run_task_lambda_name='run_task_awsem',
                 check_task_lambda_name='check_task_awsem', lambda_type='', no_randomize=False):
        self.bucket_names = bucket_names
        self.user_group_tag = user_group_tag
        self.lambda_type = lambda_type  # lambda_type : '' for unicorn, 'pony' for pony, 'zebra' for zebra
        self.run_task_lambda_name = run_task_lambda_name
        self.check_task_lambda_name = check_task_lambda_name
        self.lambda_names = [self.run_task_lambda_name, self.check_task_lambda_name]
        self.client = boto3.client('iam')
        self.iam = boto3.resource('iam')
        self.generate_policy_prefix(no_randomize)

    def generate_policy_prefix(self, no_randomize=False):
        """policy prefix for user group
        lambda_type : '' for unicorn, 'pony' for pony, 'zebra' for zebra
        example>
          user_group_tag : default
          user_group_name : default_3465
          tibanna_policy_prefix : tibanna_unicorn_default_3465
          prefix : tibanna_unicorn_
        """
        # add rangom tag to avoid attempting to overwrite a previously created and deleted policy and silently failing.
        if self.lambda_type:
            self.prefix = 'tibanna_' + self.lambda_type + '_'
        else:
            self.prefix = 'tibanna_'
        if no_randomize:
            self.user_group_name = self.user_group_tag
        else:
            random_tag = str(int(random.random() * 10000))
            self.user_group_name = self.user_group_tag + '_' + random_tag
        self.tibanna_policy_prefix = self.prefix + self.user_group_name

    @property
    def iam_group_name(self):
        return self.tibanna_policy_prefix

    @property<commit_msg>slight simplification of IAM class<commit_after>import boto3
import json
import random
from .vars import DYNAMODB_TABLE, AWS_ACCOUNT_NUMBER, AWS_REGION
from .utils import printlog


class IAM(object):

    account_id = AWS_ACCOUNT_NUMBER
    region = AWS_REGION

    def __init__(self, bucket_names, user_group_tag, run_task_lambda_name='run_task_awsem',
                 check_task_lambda_name='check_task_awsem', lambda_type='', no_randomize=False):
        """policy prefix for user group
        lambda_type : '' for unicorn, 'pony' for pony, 'zebra' for zebra
        example>
          user_group_tag : default
          user_group_name : default_3465
          tibanna_policy_prefix : tibanna_unicorn_default_3465
          prefix : tibanna_unicorn_
        """
        self.bucket_names = bucket_names
        self.user_group_tag = user_group_tag
        self.lambda_type = lambda_type  # lambda_type : '' for unicorn, 'pony' for pony, 'zebra' for zebra
        self.run_task_lambda_name = run_task_lambda_name
        self.check_task_lambda_name = check_task_lambda_name
        self.lambda_names = [self.run_task_lambda_name, self.check_task_lambda_name]
        if self.lambda_type:
            self.prefix = 'tibanna_' + self.lambda_type + '_'
        else:
            self.prefix = 'tibanna_'
        # add rangom tag to avoid attempting to overwrite a previously created and deleted policy and silently failing.
        if no_randomize:
            self.user_group_name = self.user_group_tag
        else:
            random_tag = str(int(random.random() * 10000))
            self.user_group_name = self.user_group_tag + '_' + random_tag
        self.tibanna_policy_prefix = self.prefix + self.user_group_name

        self.client = boto3.client('iam')
        self.iam = boto3.resource('iam')

    @property
    def iam_group_name(self):
        return self.tibanna_policy_prefix

    @property
{'fraction_non_alphanumeric': 0.07469941161422358, 'fraction_numerical': 0.008186236889229983, 'mean_word_length': 2.92570281124498, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3473925', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1196, 'n_words': 255}