# 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/util_common.py
# def warn(msg):
#     sys.stderr.write("WARNING: " + msg + os.linesep)
# 
# Path: hac/util_data.py
# class RequestsCache(object):
# 
#     def __init__(self):
#         self._store = {}
# 
#     def get(self, url):
#         if url not in self._store:
#             self._store[url] = requests.get(url)
#         return self._store[url]


import os
import re
import sys
from lxml import html
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem
from hac.util_common import warn
from hac.util_data import RequestsCache
            return []

        ids_selected = []
        # Match single problem from 'location'.
        location = urlparse(conf["location"]).path or "/"
        tokens = SiteCodeChef.pattern_contest.search(location)
        if tokens is not None:
            problem = tokens.group("PROBLEM")
            if problem is not None:
                ids_selected.append(problem)

        # Match potentially multiple problems from 'problems'.
        for problem in conf["problems"]:
            tokens = SiteCodeChef.pattern_problem.findall(problem)
            ids_selected.extend(tokens)

        # If no problems are successfully manually selected, select them all.
        if not ids_selected:
            ids = ids_available
        else:
            ids = SiteCodeChef.get_problem_ids(ids_selected, ids_available)

        return [url_template_problem.format(id) for id in ids]


    def get_problems(self, urls):
        """Overridden.
        """
        problems = []
        for url in urls:

# 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/util_common.py
# def warn(msg):
#     sys.stderr.write("WARNING: " + msg + os.linesep)
# 
# Path: hac/util_data.py
# class RequestsCache(object):
# 
#     def __init__(self):
#         self._store = {}
# 
#     def get(self, url):
#         if url not in self._store:
#             self._store[url] = requests.get(url)
#         return self._store[url]


# Path: hac/config/site/codechef.py
import os
import re
import sys
from lxml import html
    from urlparse import urlparse
    from urllib.parse import urlparse
from hac.data import ISite, Contest, Problem
from hac.util_common import warn
from hac.util_data import RequestsCache

            return []

        ids_selected = []
        # Match single problem from 'location'.
        location = urlparse(conf["location"]).path or "/"
        tokens = SiteCodeChef.pattern_contest.search(location)
        if tokens is not None:
            problem = tokens.group("PROBLEM")
            if problem is not None:
                ids_selected.append(problem)

        # Match potentially multiple problems from 'problems'.
        for problem in conf["problems"]:
            tokens = SiteCodeChef.pattern_problem.findall(problem)
            ids_selected.extend(tokens)

        # If no problems are successfully manually selected, select them all.
        if not ids_selected:
            ids = ids_available
        else:
            ids = SiteCodeChef.get_problem_ids(ids_selected, ids_available)

        return [url_template_problem.format(id) for id in ids]


    def get_problems(self, urls):
        """Overridden.
        """
        problems = []
        for url in urls:

            problem = Problem()