# 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 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
    >>> path2 = "/wfmd/"
    >>> SiteRosalind.pattern_contest.search(path2).group("PROBLEM")
    'wfmd'

    >>> path3 = ""
    >>> SiteRosalind.pattern_contest.search(path3) is None
    True

    >>> path4 = "/"
    >>> SiteRosalind.pattern_contest.search(path4) is None
    True
    """

    # Regex patterns.
    pattern_contest = re.compile(
        r"(/problems)?/(?P<PROBLEM>[a-zA-Z]+)"    # (mandatory) problem identifier
        r"(/)?"                                      # (optional) slash
    )
    pattern_problem = re.compile(r"[a-zA-Z]+")

    # URL templates.
    url_contest = "http://rosalind.info"
    url_template_suffix_problem = "/problems/{0}/"

    # Xpath selectors.
    xpath_problem_name = '//h1/text()'
    xpath_problem_ins = '//*[@id="sample-dataset"]/following::div[1]//pre/text()'
    xpath_problem_outs = '//*[@id="sample-output"]/following::div[1]//pre/text()'

    # Proxy for HTTP requests (handles request caching during single run of the program).

# 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/rosalind.py
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

    >>> path2 = "/wfmd/"
    >>> SiteRosalind.pattern_contest.search(path2).group("PROBLEM")
    'wfmd'

    >>> path3 = ""
    >>> SiteRosalind.pattern_contest.search(path3) is None
    True

    >>> path4 = "/"
    >>> SiteRosalind.pattern_contest.search(path4) is None
    True
    """

    # Regex patterns.
    pattern_contest = re.compile(
        r"(/problems)?/(?P<PROBLEM>[a-zA-Z]+)"    # (mandatory) problem identifier
        r"(/)?"                                      # (optional) slash
    )
    pattern_problem = re.compile(r"[a-zA-Z]+")

    # URL templates.
    url_contest = "http://rosalind.info"
    url_template_suffix_problem = "/problems/{0}/"

    # Xpath selectors.
    xpath_problem_name = '//h1/text()'
    xpath_problem_ins = '//*[@id="sample-dataset"]/following::div[1]//pre/text()'
    xpath_problem_outs = '//*[@id="sample-output"]/following::div[1]//pre/text()'

    # Proxy for HTTP requests (handles request caching during single run of the program).

    _proxy = RequestsCache()