# Path: hac/data.py
# class ISite(object):
#     """Site template.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64):
#         self.name = name
#         self.id = id
#         # 'url' member used to distinguish between different sites.
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
# 
#         self._info = None
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte']
# 
#     @abstractmethod
#     def match_contest(self, conf):
#         """Generates well formated URL of the contest according to user input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_contest(self, url):
#         """Fetches data from the provided contest URL and generates contest
#         object.
#         """
#         pass
# 
#     @abstractmethod
#     def match_problems(self, conf):
#         """Generates list of well formated problem URLs according to user
#         input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_problems(self, urls):
#         """Fetches data from the provided problem URLs and generates list of
#         problem objects.
#         """
#         pass
# 
# class Contest(object):
#     """Contest info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None):
#         self.name = name
#         self.id = id
#         self.url = url
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url']
# 
# class Problem(object):
#     """Problem info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64, inputs=None,
#                  outputs=None):
#         self.name = name
#         self.id = id
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
#         self.inputs = inputs or []
#         self.outputs = outputs or []
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte', 'inputs', 'outputs']


import re
import sys
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem
    # URL templates.
    url_template_contest = "http://localhost/{0}"
    url_template_suffix_problem = "/{0}"


    def __init__(self):
        self.url = "localhost"
        self.name = "Local"
        self.id = "local"
        self.time_limit_ms = None
        self.memory_limit_kbyte = None
        self.source_limit_kbyte = None

        self._info = None


    def match_contest(self, conf):
        """Overridden.
        """
        location = urlparse(conf['location']).path or '/'
        tokens = SiteLocal.pattern_contest.search(location)
        contest_id = 'local-contest' if tokens is None else tokens.group('CONTEST')
        return SiteLocal.url_template_contest.format(contest_id)


    def get_contest(self, url):
        """Overridden.
        """
        url_path = urlparse(url).path
        assert url_path

# Path: hac/data.py
# class ISite(object):
#     """Site template.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64):
#         self.name = name
#         self.id = id
#         # 'url' member used to distinguish between different sites.
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
# 
#         self._info = None
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte']
# 
#     @abstractmethod
#     def match_contest(self, conf):
#         """Generates well formated URL of the contest according to user input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_contest(self, url):
#         """Fetches data from the provided contest URL and generates contest
#         object.
#         """
#         pass
# 
#     @abstractmethod
#     def match_problems(self, conf):
#         """Generates list of well formated problem URLs according to user
#         input.
#         """
#         pass
# 
#     @abstractmethod
#     def get_problems(self, urls):
#         """Fetches data from the provided problem URLs and generates list of
#         problem objects.
#         """
#         pass
# 
# class Contest(object):
#     """Contest info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None):
#         self.name = name
#         self.id = id
#         self.url = url
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url']
# 
# class Problem(object):
#     """Problem info container.
#     """
# 
#     def __init__(self, name=None, id=None, url=None, time_limit_ms=2000,
#                  memory_limit_kbyte=262144, source_limit_kbyte=64, inputs=None,
#                  outputs=None):
#         self.name = name
#         self.id = id
#         self.url = url
#         self.time_limit_ms = time_limit_ms
#         self.memory_limit_kbyte = memory_limit_kbyte
#         self.source_limit_kbyte = source_limit_kbyte
#         self.inputs = inputs or []
#         self.outputs = outputs or []
# 
#     @staticmethod
#     def get_props(verbose=False):
#         return ['id', 'url'] if not verbose else \
#                ['name', 'id', 'url', 'time_limit_ms', 'memory_limit_kbyte',
#                 'source_limit_kbyte', 'inputs', 'outputs']


# Path: hac/config/site/local.py
import re
import sys
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem

    # URL templates.
    url_template_contest = "http://localhost/{0}"
    url_template_suffix_problem = "/{0}"


    def __init__(self):
        self.url = "localhost"
        self.name = "Local"
        self.id = "local"
        self.time_limit_ms = None
        self.memory_limit_kbyte = None
        self.source_limit_kbyte = None

        self._info = None


    def match_contest(self, conf):
        """Overridden.
        """
        location = urlparse(conf['location']).path or '/'
        tokens = SiteLocal.pattern_contest.search(location)
        contest_id = 'local-contest' if tokens is None else tokens.group('CONTEST')
        return SiteLocal.url_template_contest.format(contest_id)


    def get_contest(self, url):
        """Overridden.
        """
        url_path = urlparse(url).path
        assert url_path

        contest = Contest()