# Path: shiori/bookmark/agents/feed_parser.py
# class FeedParser(object):
#     """ FeedParser class """
# 
#     def __init__(self, url):
#         try:
#             response = requests.get(url, stream=True)
#         except requests.ConnectionError as error:
#             print(error)
#             sys.exit(1)
#         try:
#             etree = lxml.fromstring(response.content)
#         except XMLSyntaxError as error:
#             print(error)
#             sys.exit(1)
#         self.nsmap = etree.nsmap
#         self.namespace = get_ns(etree.nsmap, None)
# 
#         self.updated = get_updated(etree, self.nsmap)
#         self.title = get_title(etree, self.namespace)
#         self.items = get_items(etree, self.namespace)
#         self.etree = etree
# 
#     def retrieve_items(self):
#         """ retrieve feed items """
#         return [dict(title=get_title(item, self.namespace),
#                      link=get_link(item, self.namespace),
#                      updated=get_updated(item, self.nsmap))
#                 for item in self.items]
# 
# Path: shiori/bookmark/validators.py
# def validate_url(value):
# def getaddr(hostname):


from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User
from shortuuidfield import ShortUUIDField
from pyquery import PyQuery
from shiori.bookmark.agents.feed_parser import FeedParser
from shiori.bookmark import validators
import jsonfield
    class Meta(object):
        """ meta class """
        db_table = 'bookmark_tag'
        unique_together = ('bookmark', 'tag')


class FeedSubscription(BaseObject):
    """ FeedSubsscription model """
    url = models.URLField()
    name = models.CharField(max_length=255, editable=False)
    owner = models.ForeignKey(User)
    default_category = models.ForeignKey(Category)

    class Meta(object):
        """ meta class """
        db_table = 'feed_subscription'
        unique_together = ('url', 'owner')

    def __unicode__(self):
        return self.url


def update_title(sender, instance, **kwargs):
    """ Update title of FeedSubscription for pre_save.

    Arguments:
        sender: model (FeedSubscription)
        instance: FeedSubscription instance
        **kwargs: not use
    """

# Path: shiori/bookmark/agents/feed_parser.py
# class FeedParser(object):
#     """ FeedParser class """
# 
#     def __init__(self, url):
#         try:
#             response = requests.get(url, stream=True)
#         except requests.ConnectionError as error:
#             print(error)
#             sys.exit(1)
#         try:
#             etree = lxml.fromstring(response.content)
#         except XMLSyntaxError as error:
#             print(error)
#             sys.exit(1)
#         self.nsmap = etree.nsmap
#         self.namespace = get_ns(etree.nsmap, None)
# 
#         self.updated = get_updated(etree, self.nsmap)
#         self.title = get_title(etree, self.namespace)
#         self.items = get_items(etree, self.namespace)
#         self.etree = etree
# 
#     def retrieve_items(self):
#         """ retrieve feed items """
#         return [dict(title=get_title(item, self.namespace),
#                      link=get_link(item, self.namespace),
#                      updated=get_updated(item, self.nsmap))
#                 for item in self.items]
# 
# Path: shiori/bookmark/validators.py
# def validate_url(value):
# def getaddr(hostname):


# Path: shiori/bookmark/models.py
from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User
from shortuuidfield import ShortUUIDField
from pyquery import PyQuery
from shiori.bookmark.agents.feed_parser import FeedParser
from shiori.bookmark import validators
import jsonfield

    class Meta(object):
        """ meta class """
        db_table = 'bookmark_tag'
        unique_together = ('bookmark', 'tag')


class FeedSubscription(BaseObject):
    """ FeedSubsscription model """
    url = models.URLField()
    name = models.CharField(max_length=255, editable=False)
    owner = models.ForeignKey(User)
    default_category = models.ForeignKey(Category)

    class Meta(object):
        """ meta class """
        db_table = 'feed_subscription'
        unique_together = ('url', 'owner')

    def __unicode__(self):
        return self.url


def update_title(sender, instance, **kwargs):
    """ Update title of FeedSubscription for pre_save.

    Arguments:
        sender: model (FeedSubscription)
        instance: FeedSubscription instance
        **kwargs: not use
    """

    if validators.validate_url(instance.url):