<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Interpreter version: python 2.7
#
# Imports =====================================================================
from functools import partial
from operator import contains

from schema import Schema
from schema import And
from schema import Decimal
from schema import Optional

from isbn_validator import is_valid_isbn

from . import riv
from . import libraries


# Validators ==================================================================
epublication = Schema({
    'title': And(unicode, len),
    'poradi_vydani': And(unicode, len),
    'misto_vydani': And(unicode, len),
    'rok_vydani': int,
    'misto_vydani': And(unicode, len),
    "libraries_that_can_access": partial(contains, libraries.ids),
    'zpracovatel_zaznamu': "",
    Optional('podnazev'): And(unicode, len),
    Optional('cast'): And(unicode, len),
    Optional('nazev_casti'): And(unicode, len),
    Optional('isbn'): is_valid_isbn,
    Optional('isbn_souboru_publikaci'): is_valid_isbn,
    Optional('author1'): And(unicode, len),
    Optional('author2'): And(unicode, len),
    Optional('author3'): And(unicode, len),
    Optional('nakladatel_vydavatel'): And(unicode, len),
    Optional('vydano_v_koedici_s'): And(unicode, len),
    Optional('cena'): Decimal,
    Optional("category_for_riv"): And(int, partial(contains, riv.ids)),
    Optional("url"): And(str, len),
    Optional("anotace"): And(unicode, len)
})<commit_msg>Fixed few more bugs.<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Interpreter version: python 2.7
#
# Imports =====================================================================
from functools import partial
from operator import contains

from schema import And
from schema import Schema
from schema import Optional

from isbn_validator import is_valid_isbn

from . import riv
from . import libraries


# Validators ==================================================================
epublication = Schema({
    'title': And(unicode, len),
    'poradi_vydani': And(unicode, len),
    'misto_vydani': And(unicode, len),
    'rok_vydani': int,
    'misto_vydani': And(unicode, len),
    "libraries_that_can_access": partial(contains, libraries.ids),
    'zpracovatel_zaznamu': "",
    Optional('podnazev'): And(unicode, len),
    Optional('cast'): And(unicode, len),
    Optional('nazev_casti'): And(unicode, len),
    Optional('isbn'): is_valid_isbn,
    Optional('isbn_souboru_publikaci'): is_valid_isbn,
    Optional('author1'): And(unicode, len),
    Optional('author2'): And(unicode, len),
    Optional('author3'): And(unicode, len),
    Optional('nakladatel_vydavatel'): And(unicode, len),
    Optional('vydano_v_koedici_s'): And(unicode, len),
    Optional('cena'): int,
    Optional("category_for_riv"): And(int, partial(contains, riv.ids)),
    Optional("url"): And(str, len),
    Optional("anotace"): And(unicode, len)
})
{'fraction_non_alphanumeric': 0.22758384668035592, 'fraction_numerical': 0.004106776180698152, 'mean_word_length': 5.598194130925508, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6942133', 'n_tokens_mistral': 933, 'n_tokens_neox': 898, 'n_words': 209}