<commit_before>#!/usr/bin/env python

import json
from typing import List
from contact import Contact
from transaction import Transaction

class DAO:
    id = ""

    def __init__(self, id: str) -> None:
        self.id = id


    ### Interface methods ###

    def load_contacts(self) -> List[Contact]:
        with open("dummy_data.json", "r") as data_file:
            data = json.loads(data_file.read())
            users = data["users"]
            contacts_json = []
            for u in users:
                if u["id"] == self.id:
                    contacts_json = u["contacts"]

            contacts = []
            for c in contacts_json:
                contacts.append(self.json_to_Contact(c))

            return contacts


    def save_contact(self, contact: Contact) -> None:
        contacts = self.load_contacts()
        for c in contacts:
            if (c.iban == contact.iban and c.bic == contact.bic):
                c.name = contact.name
        
        for c in contacts:
            print(c.name)


    def save_contacts(self, contacts: List[Contact]) -> None:
        for c in contacts:
            self.save_contact(c)<commit_msg>Implements first step of new dao logic<commit_after>#!/usr/bin/env python

import json
from typing import List
from contact import Contact
from transaction import Transaction

class DAO:
    id = ""

    def __init__(self, id: str) -> None:
        self.id = id


    ### Interface methods ###

    def load_contacts(self) -> List[Contact]:
        with open("dummy_data.json", "r") as data_file:
            data = json.loads(data_file.read())
            contacts_json = data["users"][self.id]["contacts"]

            contacts = []
            for c in contacts_json:
                contacts.append(self.json_to_Contact(c))

            return contacts


    def save_contact(self, contact: Contact) -> None:
        contacts = self.load_contacts()
        for c in contacts:
            if (c.iban == contact.iban and c.bic == contact.bic):
                c.name = contact.name
        
        with open("dummy_data.json", "w") as data_file:
            data = json.loads(data_file.read())
            print(data["users"]["1"])


    def save_contacts(self, contacts: List[Contact]) -> None:
        for c in contacts:
            self.save_contact(c)
{'fraction_non_alphanumeric': 0.1128823782852219, 'fraction_numerical': 0.00043084877208099956, 'mean_word_length': 1.9655172413793103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '871540', 'n_tokens_mistral': 683, 'n_tokens_neox': 659, 'n_words': 182}