# Path: kraut_intel/models.py
# class NamespaceIcon(models.Model):
#     namespace = models.CharField(max_length=255, unique=True)
#     icon = models.CharField(max_length=255)
# 
#     def __unicode__(self):
#         return u"%s (%s)" % (self.namespace, self.icon)


from django.templatetags.static import static
from kraut_intel.models import NamespaceIcon
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4



def get_icon_for_namespace(namespace):
    """ Return the static path to the icon associated with given namespace
    """
    try:
        if namespace.count(':')>0:
            namespace = namespace.split(':')[0]

# Path: kraut_intel/models.py
# class NamespaceIcon(models.Model):
#     namespace = models.CharField(max_length=255, unique=True)
#     icon = models.CharField(max_length=255)
# 
#     def __unicode__(self):
#         return u"%s (%s)" % (self.namespace, self.icon)


# Path: kraut_intel/utils.py
from django.templatetags.static import static
from kraut_intel.models import NamespaceIcon

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4



def get_icon_for_namespace(namespace):
    """ Return the static path to the icon associated with given namespace
    """
    try:
        if namespace.count(':')>0:
            namespace = namespace.split(':')[0]

        icon = NamespaceIcon.objects.get(namespace=namespace)