# Path: pydatajson/custom_exceptions.py
# class BaseValidationError(object):
# class ThemeIdRepeated(BaseValidationError):
# class ThemeLabelRepeated(BaseValidationError):
# class DownloadURLRepetitionError(BaseValidationError):
# class ExtensionError(BaseValidationError):
# class BrokenLandingPageError(BaseValidationError):
# class BrokenAccessUrlError(BaseValidationError):
# class BrokenDownloadUrlError(BaseValidationError):
# class BaseUnexpectedValue(ValueError):
# class DatasetUnexpectedTitle(BaseUnexpectedValue):
# class DistributionUnexpectedTitle(BaseUnexpectedValue):
# class NonParseableCatalog(ValueError):
# class BaseRepetitionError(ValueError):
# class DistributionTitleRepetitionError(BaseRepetitionError):
# class BaseNonExistentError(ValueError):
# class DistributionTimeIndexNonExistentError(BaseNonExistentError):
# class DistributionTitleNonExistentError(BaseNonExistentError):
# class FieldTitleTooLongError(ValueError):
# class InvalidFieldTitleError(ValueError):
# class HeaderNotBlankOrIdError(ValueError):
# class TimeIndexFutureTimeValueError(ValueError):
# class FieldFewValuesError(ValueError):
# class FieldTooManyMissingsError(ValueError):
# class DatasetTemporalMetadataError(ValueError):
# class TimeValueBeforeTemporalError(ValueError):
# class TimeIndexTooShortError(ValueError):
# class BaseRepetitionError(ValueError):
# class FieldIdRepetitionError(BaseRepetitionError):
# class FieldTitleRepetitionError(BaseRepetitionError):
# class FieldDescriptionRepetitionError(BaseRepetitionError):
# class DistributionIdRepetitionError(BaseRepetitionError):
# class DatasetIdRepetitionError(BaseRepetitionError):
# class BaseNonExistentError(ValueError):
# class FieldIdNonExistentError(BaseNonExistentError):
# class FieldTitleNonExistentError(BaseNonExistentError):
# class DistributionIdNonExistentError(BaseNonExistentError):
# class DatasetIdNonExistentError(BaseNonExistentError):
# class ThemeTaxonomyNonExistentError(BaseNonExistentError):
# class ThemeNonExistentError(BaseNonExistentError):
# class DownloadURLBrokenError(BaseNonExistentError):
# class FormatNameError(ValueError):
# class NumericDistributionIdentifierError(ValueError):
#     def __init__(self, validator, message, validator_value, path,
#                  instance=None):
#     def __init__(self, repeated_ids):
#     def __init__(self, repeated_labels):
#     def __init__(self, repeated_urls):
#     def __init__(self, dataset_idx, distribution_idx, distribution, attribute):
#     def __init__(self, dataset_idx, dataset_title, broken_url, status_code):
#     def __init__(self, dataset_idx, distribution_idx,
#                  distribution_title, broken_url, status_code):
#     def __init__(self, dataset_idx, distribution_idx, distribution_title,
#                  broken_url, status_code):
#     def get_msg(self, entity_name, entity_id, value_type, value_found,
#                 value_expected):
#     def __init__(self, dataset_id, title_found, title_expected):
#     def __init__(self, distribution_id, title_found, title_expected):
#     def __init__(self, catalog, error):
#     def get_msg(self, entity_name, entity_type, entity_id, repeated_entities,
#                 extra_msg=""):
#     def __init__(self, distribution_title, repeated_distributions,
#                  extra_msg=""):
#     def get_msg(self, entity_name, entity_type, entity_id, extra_msg=""):
#     def __init__(self, distribution_title, dataset_id, extra_msg=""):
#     def __init__(self, distribution_title, dataset_id, extra_msg=""):
#     def __init__(self, field, field_len, max_field_len):
#     def __init__(self, field, char, valid_field_chars):
#     def __init__(self, worksheet, header_coord, header_value, ws_header_value):
#     def __init__(self, iso_time_value, iso_now):
#     def __init__(self, field, positive_values, minimum_values):
#     def __init__(self, field, missing_values, positive_values):
#     def __init__(self, temporal):
#     def __init__(self, iso_time_value, iso_ini_temporal):
#     def __init__(self, iso_end_index, iso_half_temporal, temporal):
#     def get_msg(self, entity_name, entity_type, entity_id=None,
#                 repeated_entities=None):
#     def __init__(self, field_id=None, repeated_fields=None):
#     def __init__(self, field_title=None, repeated_fields=None):
#     def __init__(self, field_desc=None, repeated_fields=None):
#     def __init__(self, distribution_id=None, repeated_distributions=None):
#     def __init__(self, dataset_id=None, repeated_datasets=None):
#     def get_msg(self, entity_name, entity_type, entity_id):
#     def __init__(self, field_id):
#     def __init__(self, field_title):
#     def __init__(self, distribution_id):
#     def __init__(self, dataset_id):
#     def __init__(self, dataset_id):
#     def __init__(self, theme):
#     def __init__(self, distribution_id, distribution_downloadURL, status_code):


from . import custom_exceptions as ce
definidas según la extensión del perfil de metadatos para series de tiempo.
"""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement



def field_is_time_series(field, distribution=None):
    field_may_be_ts = (
        not field.get("specialType") and
        not field.get("specialTypeDetail") and
        (
            field.get("type", "").lower() == "number" or
            field.get("type", "").lower() == "integer"
        ) and
        field.get("id")
    )
    distribution_may_has_ts = (
        not distribution or distribution_has_time_index(distribution)
    )
    return field_may_be_ts and distribution_may_has_ts


def get_distribution_time_index(distribution):
    for field in distribution.get('field', []):
        if field.get('specialType') == 'time_index':
            return field.get('title')


# Path: pydatajson/custom_exceptions.py
# class BaseValidationError(object):
# class ThemeIdRepeated(BaseValidationError):
# class ThemeLabelRepeated(BaseValidationError):
# class DownloadURLRepetitionError(BaseValidationError):
# class ExtensionError(BaseValidationError):
# class BrokenLandingPageError(BaseValidationError):
# class BrokenAccessUrlError(BaseValidationError):
# class BrokenDownloadUrlError(BaseValidationError):
# class BaseUnexpectedValue(ValueError):
# class DatasetUnexpectedTitle(BaseUnexpectedValue):
# class DistributionUnexpectedTitle(BaseUnexpectedValue):
# class NonParseableCatalog(ValueError):
# class BaseRepetitionError(ValueError):
# class DistributionTitleRepetitionError(BaseRepetitionError):
# class BaseNonExistentError(ValueError):
# class DistributionTimeIndexNonExistentError(BaseNonExistentError):
# class DistributionTitleNonExistentError(BaseNonExistentError):
# class FieldTitleTooLongError(ValueError):
# class InvalidFieldTitleError(ValueError):
# class HeaderNotBlankOrIdError(ValueError):
# class TimeIndexFutureTimeValueError(ValueError):
# class FieldFewValuesError(ValueError):
# class FieldTooManyMissingsError(ValueError):
# class DatasetTemporalMetadataError(ValueError):
# class TimeValueBeforeTemporalError(ValueError):
# class TimeIndexTooShortError(ValueError):
# class BaseRepetitionError(ValueError):
# class FieldIdRepetitionError(BaseRepetitionError):
# class FieldTitleRepetitionError(BaseRepetitionError):
# class FieldDescriptionRepetitionError(BaseRepetitionError):
# class DistributionIdRepetitionError(BaseRepetitionError):
# class DatasetIdRepetitionError(BaseRepetitionError):
# class BaseNonExistentError(ValueError):
# class FieldIdNonExistentError(BaseNonExistentError):
# class FieldTitleNonExistentError(BaseNonExistentError):
# class DistributionIdNonExistentError(BaseNonExistentError):
# class DatasetIdNonExistentError(BaseNonExistentError):
# class ThemeTaxonomyNonExistentError(BaseNonExistentError):
# class ThemeNonExistentError(BaseNonExistentError):
# class DownloadURLBrokenError(BaseNonExistentError):
# class FormatNameError(ValueError):
# class NumericDistributionIdentifierError(ValueError):
#     def __init__(self, validator, message, validator_value, path,
#                  instance=None):
#     def __init__(self, repeated_ids):
#     def __init__(self, repeated_labels):
#     def __init__(self, repeated_urls):
#     def __init__(self, dataset_idx, distribution_idx, distribution, attribute):
#     def __init__(self, dataset_idx, dataset_title, broken_url, status_code):
#     def __init__(self, dataset_idx, distribution_idx,
#                  distribution_title, broken_url, status_code):
#     def __init__(self, dataset_idx, distribution_idx, distribution_title,
#                  broken_url, status_code):
#     def get_msg(self, entity_name, entity_id, value_type, value_found,
#                 value_expected):
#     def __init__(self, dataset_id, title_found, title_expected):
#     def __init__(self, distribution_id, title_found, title_expected):
#     def __init__(self, catalog, error):
#     def get_msg(self, entity_name, entity_type, entity_id, repeated_entities,
#                 extra_msg=""):
#     def __init__(self, distribution_title, repeated_distributions,
#                  extra_msg=""):
#     def get_msg(self, entity_name, entity_type, entity_id, extra_msg=""):
#     def __init__(self, distribution_title, dataset_id, extra_msg=""):
#     def __init__(self, distribution_title, dataset_id, extra_msg=""):
#     def __init__(self, field, field_len, max_field_len):
#     def __init__(self, field, char, valid_field_chars):
#     def __init__(self, worksheet, header_coord, header_value, ws_header_value):
#     def __init__(self, iso_time_value, iso_now):
#     def __init__(self, field, positive_values, minimum_values):
#     def __init__(self, field, missing_values, positive_values):
#     def __init__(self, temporal):
#     def __init__(self, iso_time_value, iso_ini_temporal):
#     def __init__(self, iso_end_index, iso_half_temporal, temporal):
#     def get_msg(self, entity_name, entity_type, entity_id=None,
#                 repeated_entities=None):
#     def __init__(self, field_id=None, repeated_fields=None):
#     def __init__(self, field_title=None, repeated_fields=None):
#     def __init__(self, field_desc=None, repeated_fields=None):
#     def __init__(self, distribution_id=None, repeated_distributions=None):
#     def __init__(self, dataset_id=None, repeated_datasets=None):
#     def get_msg(self, entity_name, entity_type, entity_id):
#     def __init__(self, field_id):
#     def __init__(self, field_title):
#     def __init__(self, distribution_id):
#     def __init__(self, dataset_id):
#     def __init__(self, dataset_id):
#     def __init__(self, theme):
#     def __init__(self, distribution_id, distribution_downloadURL, status_code):


# Path: pydatajson/time_series.py
from . import custom_exceptions as ce

definidas según la extensión del perfil de metadatos para series de tiempo.
"""

from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement



def field_is_time_series(field, distribution=None):
    field_may_be_ts = (
        not field.get("specialType") and
        not field.get("specialTypeDetail") and
        (
            field.get("type", "").lower() == "number" or
            field.get("type", "").lower() == "integer"
        ) and
        field.get("id")
    )
    distribution_may_has_ts = (
        not distribution or distribution_has_time_index(distribution)
    )
    return field_may_be_ts and distribution_may_has_ts


def get_distribution_time_index(distribution):
    for field in distribution.get('field', []):
        if field.get('specialType') == 'time_index':
            return field.get('title')


    raise ce.DistributionTimeIndexNonExistentError(