# Path: pydatajson/threading_helper.py
# def apply_threading(l, function, cant_threads, **kwargs):
# 
# Path: pydatajson/validators/url_validator.py
# class UrlValidator(SimpleValidator):
# 
#     def __init__(self, catalog, verify_ssl, url_check_timeout, threads_count):
#         super(UrlValidator, self).__init__(catalog)
#         self.verify_ssl = verify_ssl
#         self.url_check_timeout = url_check_timeout
#         self.threads_count = threads_count
# 
#     def validate(self):
#         raise NotImplementedError
# 
#     def is_working_url(self, url):
#         try:
#             response = requests.head(url,
#                                      timeout=self.url_check_timeout,
#                                      verify=self.verify_ssl)
#             matches = []
#             if response.status_code not in EXCEPTION_STATUS_CODES:
#                 matches = \
#                     [re.match(pattern, str(response.status_code)) is not None
#                      for pattern in INVALID_STATUS_CODES_REGEX]
#             return True not in matches, response.status_code
#         except Timeout:
#             return False, 408
#         except (RequestException, Exception):
#             return False, None


import pydatajson.custom_exceptions as ce
from pydatajson import threading_helper
from pydatajson.validators.url_validator import UrlValidator
#!/usr/bin/env python
# -*- coding: utf-8 -*-



class LandingPagesValidator(UrlValidator):

    def validate(self):
        datasets = self.catalog.get('dataset')
        datasets = filter(lambda x: x.get('landingPage'), datasets)

        metadata = []
        urls = []

        for dataset_idx, dataset in enumerate(datasets):
            metadata.append({
                "dataset_idx": dataset_idx,
                "dataset_title": dataset.get('title'),
                "landing_page": dataset.get('landingPage'),
            })
            urls.append(dataset.get('landingPage'))


# Path: pydatajson/threading_helper.py
# def apply_threading(l, function, cant_threads, **kwargs):
# 
# Path: pydatajson/validators/url_validator.py
# class UrlValidator(SimpleValidator):
# 
#     def __init__(self, catalog, verify_ssl, url_check_timeout, threads_count):
#         super(UrlValidator, self).__init__(catalog)
#         self.verify_ssl = verify_ssl
#         self.url_check_timeout = url_check_timeout
#         self.threads_count = threads_count
# 
#     def validate(self):
#         raise NotImplementedError
# 
#     def is_working_url(self, url):
#         try:
#             response = requests.head(url,
#                                      timeout=self.url_check_timeout,
#                                      verify=self.verify_ssl)
#             matches = []
#             if response.status_code not in EXCEPTION_STATUS_CODES:
#                 matches = \
#                     [re.match(pattern, str(response.status_code)) is not None
#                      for pattern in INVALID_STATUS_CODES_REGEX]
#             return True not in matches, response.status_code
#         except Timeout:
#             return False, 408
#         except (RequestException, Exception):
#             return False, None


# Path: pydatajson/validators/landing_pages_validator.py
import pydatajson.custom_exceptions as ce
from pydatajson import threading_helper
from pydatajson.validators.url_validator import UrlValidator

#!/usr/bin/env python
# -*- coding: utf-8 -*-



class LandingPagesValidator(UrlValidator):

    def validate(self):
        datasets = self.catalog.get('dataset')
        datasets = filter(lambda x: x.get('landingPage'), datasets)

        metadata = []
        urls = []

        for dataset_idx, dataset in enumerate(datasets):
            metadata.append({
                "dataset_idx": dataset_idx,
                "dataset_title": dataset.get('title'),
                "landing_page": dataset.get('landingPage'),
            })
            urls.append(dataset.get('landingPage'))


        sync_res = threading_helper \