<commit_before>import boto3
import usermgmtlib.usermgmt as usermgmt
from usermgmtlib.backends import Backend

def sanitize_attribute(item, attr):
    try:
        return item[attr]
    except (KeyError, AttributeError):
        return None

class Role(usermgmt.Role):
    def refresh(self):
        conn = connection()
        r = conn.get_role(rolename)
        return True

    def save(self):
        conn = connection()
        conn.delete_role(rolename)
        conn.table_roles.put_item(Item=self.get_dict())
        return True

class Group(usermgmt.Group):
    def refresh(self):
        g = self.table_groups.get_item(Key={'groupname': self.groupname})['Item']
        self.groupname = sanitize_attribute(g, 'groupname')
        self.gid = sanitize_attribute(g, 'gid')
        return True

    def save(self):
        conn = connection()
        conn.table_groups.delete_item(Key={'groupname': self.groupname})
        conn.table_groups.put_item(Item=self.get_dict())
        return True

class User(usermgmt.User):
    def set(self, attribute, value):
        self.refresh()
        print('AC: %s, ACD: %s' % (u.auth_code, u.auth_code_date))
        print('ATTR: %s, VAL: %s' % (attribute, value))
        attr = getattr(self, attribute)
        attr = value
        print('2AC: %s, 2ACD: %s' % (u.auth_code, u.auth_code_date))
        self.save()
        return True

    def refresh(self):
        conn = connection()
        u = conn.table_users.get_item(Key={'username': self.username})['Item']<commit_msg>Save after setting user attributes.<commit_after>import boto3
import usermgmtlib.usermgmt as usermgmt
from usermgmtlib.backends import Backend

def sanitize_attribute(item, attr):
    try:
        return item[attr]
    except (KeyError, AttributeError):
        return None

class Role(usermgmt.Role):
    def refresh(self):
        conn = connection()
        r = conn.get_role(rolename)
        return True

    def save(self):
        conn = connection()
        conn.delete_role(rolename)
        conn.table_roles.put_item(Item=self.get_dict())
        return True

class Group(usermgmt.Group):
    def refresh(self):
        g = self.table_groups.get_item(Key={'groupname': self.groupname})['Item']
        self.groupname = sanitize_attribute(g, 'groupname')
        self.gid = sanitize_attribute(g, 'gid')
        return True

    def save(self):
        conn = connection()
        conn.table_groups.delete_item(Key={'groupname': self.groupname})
        conn.table_groups.put_item(Item=self.get_dict())
        return True

class User(usermgmt.User):
    def set(self, attribute, value):
        self.refresh()
        print('AC: %s, ACD: %s' % (self.auth_code, self.auth_code_date))
        print('ATTR: %s, VAL: %s' % (attribute, value))
        attr = getattr(self, attribute)
        attr = value
        print('2AC: %s, 2ACD: %s' % (self.auth_code, self.auth_code_date))
        self.save()
        return True

    def refresh(self):
        conn = connection()
        u = conn.table_users.get_item(Key={'username': self.username})['Item']
{'fraction_non_alphanumeric': 0.1265452179570592, 'fraction_numerical': 0.001951854261548471, 'mean_word_length': 2.8056930693069306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '72304', 'n_tokens_mistral': 991, 'n_tokens_neox': 990, 'n_words': 209}