<commit_before>from google.appengine.api import users
from google.appengine.ext import db

from bo import *
from database.zimport.zoin import *
from database.person import *


class zPerson(db.Model):
    user                = db.StringProperty() # forename.surname@domain
    forename            = db.StringProperty()
    surname             = db.StringProperty()
    idcode              = db.StringProperty()
    gender              = db.StringProperty()
    birth_date          = db.DateProperty()
    leecher             = db.TextProperty()
    seeder              = db.TextProperty()

    def zimport(self):
        p = GetZoin('Person', self.key().name())
        if not p:
            p = Person()

        if self.user:
            p.user = users.User(self.user)
        p.forename = self.forename
        p.surname = self.surname
        p.idcode = self.idcode
        p.gender = self.gender
        p.birth_date = self.birth_date
        p.leecher = GetZoinKeyList('Bubble', self.leecher)
        p.seeder = GetZoinKeyList('Bubble', self.seeder)
        p.put('zimport')

        AddZoin(
            entity_kind = 'Person',
            old_key = self.key().name(),
            new_key = p.key(),
        )

        self.delete()


class zRole(db.Model):
    name_estonian       = db.StringProperty()
    name_english        = db.StringProperty()
    rights              = db.StringProperty()

    def zimport(self):
        r = GetZoin('Role', self.key().name())
        if not r:
            r = Role()

        name = Dictionary()
        name.name = 'role_name'
        name.estonian = self.name_estonian
        name.english = self.name_english

        r.name = name.add()
        r.rights = StrToList(self.rights)
        r.put('zimport')

        AddZoin(
            entity_kind = 'Role',
            old_key = self.key().name(),
            new_key = r.key(),
        )

        self.delete()


class zPersonRole(db.Model):
    person              = db.StringProperty()
    role                = db.StringProperty()
    department          = db.StringProperty()

    def zimport(self):
        pr = GetZoin('PersonRole', self.key().name())
        if not pr:
            pr = PersonRole()

        pr.person = GetZoin('Person', self.person)
        pr.role = GetZoin('Role', self.role)
        pr.department = GetZoin('Department', self.department)
        pr.put('zimport')

        AddZoin(
            entity_kind = 'PersonRole',
            old_key = self.key().name(),
            new_key = pr.key(),
        )

        self.delete()
<commit_msg>PersonRole zimport will put role to Person.roles<commit_after>from google.appengine.api import users
from google.appengine.ext import db

from bo import *
from database.zimport.zoin import *
from database.person import *


class zPerson(db.Model):
    user                = db.StringProperty() # forename.surname@domain
    forename            = db.StringProperty()
    surname             = db.StringProperty()
    idcode              = db.StringProperty()
    gender              = db.StringProperty()
    birth_date          = db.DateProperty()
    leecher             = db.TextProperty()
    seeder              = db.TextProperty()

    def zimport(self):
        p = GetZoin('Person', self.key().name())
        if not p:
            p = Person()

        if self.user:
            p.user = users.User(self.user)
        p.forename = self.forename
        p.surname = self.surname
        p.idcode = self.idcode
        p.gender = self.gender
        p.birth_date = self.birth_date
        p.leecher = GetZoinKeyList('Bubble', self.leecher)
        p.seeder = GetZoinKeyList('Bubble', self.seeder)
        p.put('zimport')

        AddZoin(
            entity_kind = 'Person',
            old_key = self.key().name(),
            new_key = p.key(),
        )

        self.delete()


class zRole(db.Model):
    name_estonian       = db.StringProperty()
    name_english        = db.StringProperty()
    rights              = db.StringProperty()

    def zimport(self):
        r = GetZoin('Role', self.key().name())
        if not r:
            r = Role()

        name = Dictionary()
        name.name = 'role_name'
        name.estonian = self.name_estonian
        name.english = self.name_english

        r.name = name.add()
        r.rights = StrToList(self.rights)
        r.put('zimport')

        AddZoin(
            entity_kind = 'Role',
            old_key = self.key().name(),
            new_key = r.key(),
        )

        self.delete()


class zPersonRole(db.Model):
    person              = db.StringProperty()
    role                = db.StringProperty()
    department          = db.StringProperty()

    def zimport(self):

        person = GetZoin('Person', self.person)
        role_key = GetZoinKey('Role', self.role)
        if person and role_key:
            person.roles = AddToList(role_key, person.roles)
            person.put('zimport')

        self.delete()

{'fraction_non_alphanumeric': 0.1164521319388576, 'fraction_numerical': 0.0, 'mean_word_length': 1.6837560712358337, 'pattern_counts': {'":': 0, '<': 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': '4136014', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1468, 'n_words': 295}