# Path: kraut_parser/models.py
# class URI_Object(models.Model):
#     uri_value = models.CharField(max_length=255)
#     uri_type = models.CharField(max_length=255)
#     condition = models.CharField(max_length=255, default="equals")
#     observables = models.ManyToManyField(Observable)
# 
#     def __unicode__(self):
#         if self.uri_value:
#             return u"%s" % (self.uri_value)
#         else:
#             return u"URI Object"
# 
#     class Meta:
#         unique_together = (("uri_value", "uri_type", "condition"),)
# 
# class Port_Object(models.Model):
#     port = models.IntegerField(unique=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.port)


import dateutil, pytz, json
from kraut_parser.models import URI_Object, Port_Object
            link_dict['condition'] = li_obj['value'].get('condition', 'equals').lower()
    if 'url_label' in li_obj:
        if isinstance(li_obj['url_label'], dict):
            link_dict['url_label'] = li_obj['url_label'].get('value', 'No Label')
    if 'type' in li_obj:
        link_dict['link_type'] = li_obj.get('type', 'No Type')
    return link_dict

def handle_dns_query_object(dns_obj):
    query_dict = {
        'qname': None,
        'qtype': None,
        'qclass': None,
    }
    if 'question' in dns_obj:
        query_dict['qclass'] = dns_obj['question'].get('qclass', None)
        query_dict['qtype'] = dns_obj['question'].get('qtype', None)
        qname = dns_obj['question'].get('qname', None)
        if isinstance(qname, dict):
            uri_dict = {
                'uri_value': qname.get('value', 'No Value'),
                'uri_type': 'Domain Name',
                'condition': 'equals'
            }
        else:
            uri_dict = {
                'uri_value': qname,
                'uri_type': 'Domain Name',
                'condition': 'equals'
            }

# Path: kraut_parser/models.py
# class URI_Object(models.Model):
#     uri_value = models.CharField(max_length=255)
#     uri_type = models.CharField(max_length=255)
#     condition = models.CharField(max_length=255, default="equals")
#     observables = models.ManyToManyField(Observable)
# 
#     def __unicode__(self):
#         if self.uri_value:
#             return u"%s" % (self.uri_value)
#         else:
#             return u"URI Object"
# 
#     class Meta:
#         unique_together = (("uri_value", "uri_type", "condition"),)
# 
# class Port_Object(models.Model):
#     port = models.IntegerField(unique=True)
# 
#     def __unicode__(self):
#         return u"%s" % (self.port)


# Path: kraut_parser/cybox_functions.py
import dateutil, pytz, json
from kraut_parser.models import URI_Object, Port_Object

            link_dict['condition'] = li_obj['value'].get('condition', 'equals').lower()
    if 'url_label' in li_obj:
        if isinstance(li_obj['url_label'], dict):
            link_dict['url_label'] = li_obj['url_label'].get('value', 'No Label')
    if 'type' in li_obj:
        link_dict['link_type'] = li_obj.get('type', 'No Type')
    return link_dict

def handle_dns_query_object(dns_obj):
    query_dict = {
        'qname': None,
        'qtype': None,
        'qclass': None,
    }
    if 'question' in dns_obj:
        query_dict['qclass'] = dns_obj['question'].get('qclass', None)
        query_dict['qtype'] = dns_obj['question'].get('qtype', None)
        qname = dns_obj['question'].get('qname', None)
        if isinstance(qname, dict):
            uri_dict = {
                'uri_value': qname.get('value', 'No Value'),
                'uri_type': 'Domain Name',
                'condition': 'equals'
            }
        else:
            uri_dict = {
                'uri_value': qname,
                'uri_type': 'Domain Name',
                'condition': 'equals'
            }

        uri_object, uri_object_created = URI_Object.objects.get_or_create(**uri_dict)