# Path: django_flickr_gallery/utils/import_tools.py
# def load_class(class_path):
#     """
#     Load class by path.
#     :param class_path:
#         Class path with comma separate.
#     :return: Class
# 
#     :example:
#         >>> from django_flickr_gallery.utils.import_tools import load_class
#         >>> load_class("mysiste.MyClass")
# 
#     """
#     if not class_path:
#         return None
# 
#     if not isinstance(class_path, (str, bytes)):
#         return class_path
# 
#     class_path, class_name = class_path.rsplit(".", 1)
#     module = import_module(class_path)
#     return getattr(module, class_name)
# 
# Path: django_flickr_gallery/paginator.py
# class Paginator(object):
#     def __init__(self, iterator, per_page=10, page=None, pages=None, total=None):
#         self.data = iterator
#         self.per_page = per_page
#         self.num_pages = pages or 1
#         self.total = total or 1
#         self.current_page_number = int(page or 1)
#         self.page = Page(self.data, self.current_page_number, self)
# 
#     def __repr__(self):
#         return "<Paginator />"
# 
#     def _page_range(self):
#         return range(1, self.num_pages + 1)
#     page_range = property(_page_range)
# 
#     def validate_number(self, number):
#         """
#         Validates the given 1-based page number.
#         """
#         try:
#             number = int(number)
#         except (TypeError, ValueError):
#             raise PageNotAnInteger('That page number is not an integer')
#         if number < 1:
#             raise EmptyPage('That page number is less than 1')
#         if number > self.num_pages:
#             if number == 1 and self.allow_empty_first_page:
#                 pass
#             else:
#                 raise EmptyPage('That page contains no results')
#         return number
# 
#     def _first_page(self):
#         return 1
#     first_page = property(_first_page)
# 
#     def _last_page(self):
#         return self.num_pages
#     last_page = property(_last_page)


from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import ugettext as _
from django_flickr_gallery.utils.import_tools import load_class
from flickrapi.cache import SimpleCache
from django_flickr_gallery.paginator import Paginator



##############################
###### REQUIRED SETTIGS ######
##############################
try:
    API_KEY = settings.FLICKR_API_KEY
    SECRET = settings.FLICKR_SECRET
    USER_ID = settings.FLICKR_USER_ID
except AttributeError:
    raise ImproperlyConfigured(_(
        "Need to define FLICKR_API_KEY and "
        "FLICKR_SECRET and FLICKR_USER_ID"))


##############################
###### OPTIONAL SETTIGS ######
##############################
PHOTOSETS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOSETS_LIST_TEMPLATE', "gallery/flickr/photoset_list.html")
PHOTOS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOS_LIST_TEMPLATE', "gallery/flickr/photo_list.html")


# Path: django_flickr_gallery/utils/import_tools.py
# def load_class(class_path):
#     """
#     Load class by path.
#     :param class_path:
#         Class path with comma separate.
#     :return: Class
# 
#     :example:
#         >>> from django_flickr_gallery.utils.import_tools import load_class
#         >>> load_class("mysiste.MyClass")
# 
#     """
#     if not class_path:
#         return None
# 
#     if not isinstance(class_path, (str, bytes)):
#         return class_path
# 
#     class_path, class_name = class_path.rsplit(".", 1)
#     module = import_module(class_path)
#     return getattr(module, class_name)
# 
# Path: django_flickr_gallery/paginator.py
# class Paginator(object):
#     def __init__(self, iterator, per_page=10, page=None, pages=None, total=None):
#         self.data = iterator
#         self.per_page = per_page
#         self.num_pages = pages or 1
#         self.total = total or 1
#         self.current_page_number = int(page or 1)
#         self.page = Page(self.data, self.current_page_number, self)
# 
#     def __repr__(self):
#         return "<Paginator />"
# 
#     def _page_range(self):
#         return range(1, self.num_pages + 1)
#     page_range = property(_page_range)
# 
#     def validate_number(self, number):
#         """
#         Validates the given 1-based page number.
#         """
#         try:
#             number = int(number)
#         except (TypeError, ValueError):
#             raise PageNotAnInteger('That page number is not an integer')
#         if number < 1:
#             raise EmptyPage('That page number is less than 1')
#         if number > self.num_pages:
#             if number == 1 and self.allow_empty_first_page:
#                 pass
#             else:
#                 raise EmptyPage('That page contains no results')
#         return number
# 
#     def _first_page(self):
#         return 1
#     first_page = property(_first_page)
# 
#     def _last_page(self):
#         return self.num_pages
#     last_page = property(_last_page)


# Path: django_flickr_gallery/settings.py
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.translation import ugettext as _
from django_flickr_gallery.utils.import_tools import load_class
from flickrapi.cache import SimpleCache
from django_flickr_gallery.paginator import Paginator




##############################
###### REQUIRED SETTIGS ######
##############################
try:
    API_KEY = settings.FLICKR_API_KEY
    SECRET = settings.FLICKR_SECRET
    USER_ID = settings.FLICKR_USER_ID
except AttributeError:
    raise ImproperlyConfigured(_(
        "Need to define FLICKR_API_KEY and "
        "FLICKR_SECRET and FLICKR_USER_ID"))


##############################
###### OPTIONAL SETTIGS ######
##############################
PHOTOSETS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOSETS_LIST_TEMPLATE', "gallery/flickr/photoset_list.html")
PHOTOS_LIST_TEMPLATE = getattr(settings, 'FLICKR_PHOTOS_LIST_TEMPLATE', "gallery/flickr/photo_list.html")


PHOTOSET_LIST_VIEW = getattr(settings, 'FLICKR_PHOTOSET_LIST_VIEW', 'django_flickr_gallery.FlickrPhotosetListView')