# 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


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


class DistributionDownloadUrlsValidator(UrlValidator):

    def validate(self):
        async_results = []
        for dataset in self.catalog.get('dataset', []):
            distribution_urls = \
                [distribution.get('downloadURL', '')
                 for distribution in dataset.get('distribution', [])]

# 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/distribution_download_urls_validator.py
from pydatajson import threading_helper
from pydatajson.validators.url_validator import UrlValidator

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


class DistributionDownloadUrlsValidator(UrlValidator):

    def validate(self):
        async_results = []
        for dataset in self.catalog.get('dataset', []):
            distribution_urls = \
                [distribution.get('downloadURL', '')
                 for distribution in dataset.get('distribution', [])]

            async_results += threading_helper \