<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from auth import create_service
from dicttoxml import dicttoxml
from lxml import objectify
from totvserprm.utils import ClassFactory, normalize_xml
from totvserprm.exceptions import ApiError

class BaseApi(object):
    dataservername = ''

    def __init__(self, server, username, password):
        self.service = create_service(server, username, password)

    def create(self, dict, context):
        xml = dicttoxml(dict, attr_type=False)
        response = self.service.SaveRecord(DataServerName=self.dataservername, XML=xml, Contexto=context)
        if len(response.split(';')) == 2:
            codcoligada = response.split(';')[0]
            element_id = response.split(';')[1]
            custom_class = ClassFactory(self.__class__.__name__, ['codcoligada', 'id'])
            return custom_class(codcoligada=codcoligada, id=element_id)
        else:
            raise ApiError('Error trying to create {}:\n{}'.format(self.__class__.__name__, response))

    def get(self, codcoligada, id):
        primary_key = '{};{}'.format(codcoligada, id)
        return_from_api = self.service.ReadRecord(
            DataServerName=self.dataservername, PrimaryKey=primary_key, Contexto='CODCOLIGADA={}'.format(codcoligada))
        return_from_api = normalize_xml(return_from_api)
        return objectify.fromstring(return_from_api)

    def all(self, codcoligada):
        return_from_api = self.service.ReadView(
            DataServerName=self.dataservername, Filtro='CODCOLIGADA={}'.format(
            codcoligada), Contexto='CODCOLIGADA={}'.format(codcoligada))
        return_from_api = normalize_xml(return_from_api)
        return objectify.fromstring(return_from_api)<commit_msg>change mensage except<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from auth import create_service
from dicttoxml import dicttoxml
from lxml import objectify
from totvserprm.utils import ClassFactory, normalize_xml
from totvserprm.exceptions import ApiError


class BaseApi(object):
    dataservername = ''

    def __init__(self, server, username, password):
        self.service = create_service(server, username, password)

    def create(self, dict, context):
        xml = dicttoxml(dict, attr_type=False)
        response = self.service.SaveRecord(
            DataServerName=self.dataservername, XML=xml, Contexto=context)
        if len(response.split(';')) == 2:
            codcoligada = response.split(';')[0]
            element_id = response.split(';')[1]
            custom_class = ClassFactory(
                self.__class__.__name__, ['codcoligada', 'id'])
            return custom_class(codcoligada=codcoligada, id=element_id)
        else:
            raise ApiError('Error trying to create {}:\n{}'.format(
                self.__class__.__name__, response.encode('ascii', 'ignore')))

    def get(self, codcoligada, id):
        primary_key = '{};{}'.format(codcoligada, id)
        return_from_api = self.service.ReadRecord(
            DataServerName=self.dataservername, PrimaryKey=primary_key, Contexto='CODCOLIGADA={}'.format(codcoligada))
        return_from_api = normalize_xml(return_from_api)
        return objectify.fromstring(return_from_api)

    def all(self, codcoligada):
        return_from_api = self.service.ReadView(
            DataServerName=self.dataservername, Filtro='CODCOLIGADA={}'.format(
                codcoligada), Contexto='CODCOLIGADA={}'.format(codcoligada))
        return_from_api = normalize_xml(return_from_api)
        return objectify.fromstring(return_from_api)
{'fraction_non_alphanumeric': 0.11080485115766263, 'fraction_numerical': 0.002205071664829107, 'mean_word_length': 3.599493029150824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, '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': '4401929', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1092, 'n_words': 209}