<commit_before>from ics_demo.dao.interfaces import base
from ics_demo.dao.orm.host import Host

from ics_demo.helpers import uuidgen

def get_all():
    return base.get_all_by_class(Host)

def get_one(identifier):
    return base.get_one_by_class(Host, identifier)

def get_obj(identifier):
    return base.get_obj_by_class(Host, identifier)

def get_keys():
    return base.get_keys_by_class(Host)

def save(properties_dict):
    name = properties_dict['name']
    ipaddr = properties_dict['ipaddr']
    initialized = properties_dict['initialized']
    return Host(uuid=uuidgen(), name=name, ipaddr=ipaddr, initialized=initialized)<commit_msg>add get_by_ip to Host dao<commit_after>from ics_demo.dao.interfaces import base
from ics_demo.dao.orm.host import Host

from ics_demo.helpers import uuidgen

def get_all():
    return base.get_all_by_class(Host)

def get_one(identifier):
    return base.get_one_by_class(Host, identifier)

def get_obj(identifier):
    return base.get_obj_by_class(Host, identifier)

def get_obj_by_ipaddr(ipaddr):
    try:
        return Host.selectBy(ipaddr=ipaddr).getOne()
    except SQLObjectNotFound:
        raise NotFoundError('Host ip address', ipaddr)

def get_keys():
    return base.get_keys_by_class(Host)

def save(properties_dict):
    name = properties_dict['name']
    ipaddr = properties_dict['ipaddr']
    initialized = properties_dict['initialized']
    return Host(uuid=uuidgen(), name=name, ipaddr=ipaddr, initialized=initialized)
{'fraction_non_alphanumeric': 0.09803921568627451, 'fraction_numerical': 0.0, 'mean_word_length': 5.434782608695652, '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': '7367774', 'n_tokens_mistral': 481, 'n_tokens_neox': 493, 'n_words': 101}