<commit_before>#!/usr/bin/env python
import os
import json
import random
import subprocess

from billy import db
from billy.utils import metadata
from billy.conf import settings, base_arg_parser
from billy.bin.dump_json import APIValidator, api_url

import scrapelib
import lxml.etree
import validictory


def get_xml_schema():
    cwd = os.path.split(__file__)[0]
    schema_dir = os.path.join(cwd, "../schemas/relax/")

    rnc_path = os.path.join(schema_dir, 'api.rnc')
    rng_path = os.path.join(schema_dir, 'api_gen.rng')

    subprocess.check_call(["trang", rnc_path, rng_path])

    with open(rng_path) as f:
        schema = lxml.etree.RelaxNG(lxml.etree.parse(f))

    return schema


def validate_xml(url, schema):<commit_msg>don't require writes to schema directory for XML validation<commit_after>#!/usr/bin/env python
import os
import json
import random
import subprocess

from billy import db
from billy.utils import metadata
from billy.conf import settings, base_arg_parser
from billy.bin.dump_json import APIValidator, api_url

import scrapelib
import lxml.etree
import validictory


def get_xml_schema():
    cwd = os.path.split(__file__)[0]
    schema_dir = os.path.join(cwd, "../schemas/relax/")

    rnc_path = os.path.join(schema_dir, 'api.rnc')
    rng_path = '/tmp/api_gen.rng'

    subprocess.check_call(["trang", rnc_path, rng_path])

    with open(rng_path) as f:
        schema = lxml.etree.RelaxNG(lxml.etree.parse(f))

    return schema


def validate_xml(url, schema):
{'fraction_non_alphanumeric': 0.1067378252168112, 'fraction_numerical': 0.00133422281521014, 'mean_word_length': 4.244755244755245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '1649437', 'n_tokens_mistral': 545, 'n_tokens_neox': 525, 'n_words': 128}