# Path: src/sii/lib/types/Company.py
# class Company(object):
# 
#     def __init__(self, data):
#         self.__dict__.update(data)
#         self.branches = [Branch(b) for b in self.branches]
# 
#     def __getattr__(self, key):
#         if key.startswith('__'):
#             return super().__getattr__(key)
# 
#         if key in self.__dict__:
#             return super().__getattr__(key)
#         else:
#             raise RuntimeError("Expected and did not find <{0}> in company YAML.".format(key))
# 
# Path: src/sii/lib/types/Branch.py
# class Branch(object):
# 
#     def __init__(self, yml):
#         self.__dict__.update(yml)
# 
#     def __getattr__(self, key):
#         if key.startswith('__'):
#             return super().__getattr__(key)
# 
#         if key in self.__dict__:
#             return super().__getattr__(key)
#         else:
#             raise RuntimeError("Expected and did not find <{0}> in branch section of YAML.".format(key))


import io
import yaml
from sii.lib.lib import fileio
from .Company import Company
from .Branch  import Branch
""" Company Pool to resolve Company objects from (coming from YAML)

For a Template example look into files/companies.yml at the root of the repository. Such a file can
hold more than one instances of company metadata inside, allowing for multiple companies being
handled transparently by the same library or client/server application.
"""





class CompanyPool(object):

    def __init__(self, yml):
        self._companies = {}

        for rut, data in yml.items():

# Path: src/sii/lib/types/Company.py
# class Company(object):
# 
#     def __init__(self, data):
#         self.__dict__.update(data)
#         self.branches = [Branch(b) for b in self.branches]
# 
#     def __getattr__(self, key):
#         if key.startswith('__'):
#             return super().__getattr__(key)
# 
#         if key in self.__dict__:
#             return super().__getattr__(key)
#         else:
#             raise RuntimeError("Expected and did not find <{0}> in company YAML.".format(key))
# 
# Path: src/sii/lib/types/Branch.py
# class Branch(object):
# 
#     def __init__(self, yml):
#         self.__dict__.update(yml)
# 
#     def __getattr__(self, key):
#         if key.startswith('__'):
#             return super().__getattr__(key)
# 
#         if key in self.__dict__:
#             return super().__getattr__(key)
#         else:
#             raise RuntimeError("Expected and did not find <{0}> in branch section of YAML.".format(key))


# Path: src/sii/lib/types/CompanyPool.py
import io
import yaml
from sii.lib.lib import fileio
from .Company import Company
from .Branch  import Branch

""" Company Pool to resolve Company objects from (coming from YAML)

For a Template example look into files/companies.yml at the root of the repository. Such a file can
hold more than one instances of company metadata inside, allowing for multiple companies being
handled transparently by the same library or client/server application.
"""





class CompanyPool(object):

    def __init__(self, yml):
        self._companies = {}

        for rut, data in yml.items():

            self._companies[rut] = Company(data)