<commit_before>from google.appengine.ext import db

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


class zBubble(db.Expando):
    def zimport(self):
        b = GetZoin('Bubble', self.key().name())
        if not b:
            b = Bubble()

        if self.name_estonian or self.name_english:
            b.name = Dictionary(
                    name = 'bubble_name',
                    estonian = self.name_estonian,
                    english = self.name_english
                ).put('zimport')

        if self.description_estonian or self.description_english:
            b.description = Dictionary(
                    name = 'bubble_description',
                    estonian = self.description_estonian,
                    english = self.description_english
                ).put('zimport')

        if self.start_datetime:
            b.start_datetime = self.start_datetime

        if self.end_datetime:
            b.end_datetime = self.end_datetime

        if self.type:
            b.type = self.type

        if GetZoinKey('RatingScale', self.rating_scale):
            b.rating_scale = GetZoinKey('RatingScale', self.rating_scale)

        if self.badge_estonian or self.badge_english:
            b.badge = Dictionary(
                name = 'bubble_badge',
                estonian = self.badge_estonian,
                english = self.badge_english
            ).put('zimport')

        if self.points:
            b.points = self.points

        if self.minimum_points:
            b.minimum_points = self.minimum_points

        if self.minimum_bubble_count:
            b.minimum_bubble_count = self.minimum_bubble_count

        if GetZoinKeyList('Bubble', self.mandatory_bubbles):
            b.mandatory_bubbles = MergeLists(b.mandatory_bubbles, GetZoinKeyList('Bubble', self.mandatory_bubbles))

        if GetZoinKeyList('Bubble', self.optional_bubbles):
            b.optional_bubbles = MergeLists(b.optional_bubbles, GetZoinKeyList('Bubble', self.optional_bubbles))

        if GetZoinKeyList('Bubble', self.prerequisite_bubbles):
            b.prerequisite_bubbles = MergeLists(b.prerequisite_bubbles, GetZoinKeyList('Bubble', self.prerequisite_bubbles))

        if self.state:
            b.state = self.state

        if self.series:
            b.series = self.series

        if self.prefix:
            b.prefix = self.prefix

        if GetZoinKey('Counter', self.registry_number_counter):
            b.registry_number_counter = GetZoinKey('Counter', self.registry_number_counter)

        if self.registry_number:
            b.registry_number = self.registry_number

        if self.notes:
            b.notes = self.notes

        if GetZoinKeyList('Person', self.viewers):
            b.viewers = GetZoinKeyList('Person', self.viewers)

        if self.allowed_subtypes:
            b.allowed_subtypes = StrToList(self.allowed_subtypes)
        else:
            if hasattr(b, 'allowed_subtypes'):
                delattr(b, 'allowed_subtypes')

        if self.url:
            b.url = self.url

        b.put('zimport')

        AddZoin(
            entity_kind = 'Bubble',
            old_key = self.key().name(),
            new_key = b.key(),
        )
        self.delete()


class zBubbleProperty(db.Expando):
    def zimport(self):
        bp = GetZoin('BubbleProperty', self.key().name())
        if not bp:
            bp = BubbleProperty()

        bp.name                 = Dictionary(
                name = 'bubbleproperty_name',
                estonian = self.name_estonian,
                english = self.name_english
            ).put('zimport')
        bp.name_plural                 = Dictionary(
                name = 'bubbleproperty_name_plural',
                estonian = self.name_plural_estonian,
                english = self.name_plural_english
            ).put('zimport')
        bp.data_type            = self.data_type.lower()
        bp.data_property        = self.data_property.lower()
        bp.format_string        = self.format_string
        bp.target_property      = self.target_property
        bp.default              = self.default
        bp.choices              = StrToList(self.choices)
        bp.ordinal              = int(self.ordinal)
        bp.count                = int(self.count)
        bp.is_unique            = self.is_unique
        bp.is_read_only         = self.is_read_only
        bp.is_auto_complete     = self.is_auto_complete
        bp.put('zimport')

        AddZoin(
            entity_kind = 'BubbleProperty',
            old_key = self.key().name(),
            new_key = bp.key(),
        )
        self.delete()


class zBubbleType(db.Expando):
    def zimport(self):
        bt = GetZoin('BubbleType', self.key().name())
        if not bt:
            bt = BubbleType()

        bt.type                 = self.type
        bt.name                 = Dictionary(
                name = 'bubbletype_name',
                estonian = self.name_estonian,
                english = self.name_english
            ).put('zimport')
        bt.menugroup            = Dictionary(
                name = 'bubbletype_menugroup',
                estonian = self.menugroup_estonian,
                english = self.menugroup_english
            ).put('zimport')
        bt.name_plural          = Dictionary(
                name = 'bubbletype_name_plural',
                estonian = self.name_plural_estonian,
                english = self.name_plural_english
            ).put('zimport')
        bt.description          = Dictionary(
                name = 'bubbletype_description',
                estonian = self.description_estonian,
                english = self.description_english
            ).put('zimport')
        bt.allowed_subtypes     = StrToList(self.allowed_subtypes)
        bt.grade_display_method = self.grade_display_method
        bt.property_displayname = self.property_displayname
        bt.property_displayinfo = self.property_displayinfo
        bt.bubble_properties    = GetZoinKeyList('BubbleProperty', self.bubble_properties)
        bt.mandatory_properties = GetZoinKeyList('BubbleProperty', self.mandatory_properties)
        bt.public_properties    = GetZoinKeyList('BubbleProperty', self.public_properties)
        bt.propagated_properties = GetZoinKeyList('BubbleProperty', self.propagated_properties)
        bt.escalated_properties = GetZoinKeyList('BubbleProperty', self.escalated_properties)
        bt.inherited_properties = GetZoinKeyList('BubbleProperty', self.inherited_properties)
        bt.read_only_properties   = GetZoinKeyList('BubbleProperty', self.read_only_properties)
        bt.create_only_properties = GetZoinKeyList('BubbleProperty', self.create_only_properties)
        bt.put('zimport')

        AddZoin(
            entity_kind = 'BubbleType',
            old_key = self.key().name(),
            new_key = bt.key(),
        )
        self.delete()


class zCounter(db.Expando):
    def zimport(self):
        c = GetZoin('Counter', self.key().name())
        if not c:<commit_msg>beautify<commit_after>from google.appengine.ext import db

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


class zBubble(db.Expando):
    def zimport(self):
        b = GetZoin('Bubble', self.key().name())
        if not b:
            b = Bubble()

        if self.name_estonian or self.name_english:
            b.name = Dictionary(
                    name = 'bubble_name',
                    estonian = self.name_estonian,
                    english = self.name_english
                ).put('zimport')

        if self.description_estonian or self.description_english:
            b.description = Dictionary(
                    name = 'bubble_description',
                    estonian = self.description_estonian,
                    english = self.description_english
                ).put('zimport')

        if self.start_datetime:
            b.start_datetime = self.start_datetime

        if self.end_datetime:
            b.end_datetime = self.end_datetime

        if self.type:
            b.type = self.type

        if GetZoinKey('RatingScale', self.rating_scale):
            b.rating_scale = GetZoinKey('RatingScale', self.rating_scale)

        if self.badge_estonian or self.badge_english:
            b.badge = Dictionary(
                name = 'bubble_badge',
                estonian = self.badge_estonian,
                english = self.badge_english
            ).put('zimport')

        if self.points:
            b.points = self.points

        if self.minimum_points:
            b.minimum_points = self.minimum_points

        if self.minimum_bubble_count:
            b.minimum_bubble_count = self.minimum_bubble_count

        if GetZoinKeyList('Bubble', self.mandatory_bubbles):
            b.mandatory_bubbles = MergeLists(b.mandatory_bubbles, GetZoinKeyList('Bubble', self.mandatory_bubbles))

        if GetZoinKeyList('Bubble', self.optional_bubbles):
            b.optional_bubbles = MergeLists(b.optional_bubbles, GetZoinKeyList('Bubble', self.optional_bubbles))

        if GetZoinKeyList('Bubble', self.prerequisite_bubbles):
            b.prerequisite_bubbles = MergeLists(b.prerequisite_bubbles, GetZoinKeyList('Bubble', self.prerequisite_bubbles))

        if self.state:
            b.state = self.state

        if self.series:
            b.series = self.series

        if self.prefix:
            b.prefix = self.prefix

        if GetZoinKey('Counter', self.registry_number_counter):
            b.registry_number_counter = GetZoinKey('Counter', self.registry_number_counter)

        if self.registry_number:
            b.registry_number = self.registry_number

        if self.notes:
            b.notes = self.notes

        if GetZoinKeyList('Person', self.viewers):
            b.viewers = GetZoinKeyList('Person', self.viewers)

        if self.allowed_subtypes:
            b.allowed_subtypes = StrToList(self.allowed_subtypes)
        else:
            if hasattr(b, 'allowed_subtypes'):
                delattr(b, 'allowed_subtypes')

        if self.url:
            b.url = self.url

        b.put('zimport')

        AddZoin(
            entity_kind = 'Bubble',
            old_key = self.key().name(),
            new_key = b.key(),
        )
        self.delete()


class zBubbleProperty(db.Expando):
    def zimport(self):
        bp = GetZoin('BubbleProperty', self.key().name())
        if not bp:
            bp = BubbleProperty()

        bp.name                 = Dictionary(
                name = 'bubbleproperty_name',
                estonian = self.name_estonian,
                english = self.name_english
            ).put('zimport')
        bp.name_plural                 = Dictionary(
                name = 'bubbleproperty_name_plural',
                estonian = self.name_plural_estonian,
                english = self.name_plural_english
            ).put('zimport')
        bp.data_type            = self.data_type.lower()
        bp.data_property        = self.data_property.lower()
        bp.format_string        = self.format_string
        bp.target_property      = self.target_property
        bp.default              = self.default
        bp.choices              = StrToList(self.choices)
        bp.ordinal              = int(self.ordinal)
        bp.count                = int(self.count)
        bp.is_unique            = self.is_unique
        bp.is_read_only         = self.is_read_only
        bp.is_auto_complete     = self.is_auto_complete
        bp.put('zimport')

        AddZoin(
            entity_kind = 'BubbleProperty',
            old_key = self.key().name(),
            new_key = bp.key(),
        )
        self.delete()


class zBubbleType(db.Expando):
    def zimport(self):
        bt = GetZoin('BubbleType', self.key().name())
        if not bt:
            bt = BubbleType()

        bt.type                 = self.type
        bt.name                 = Dictionary(
                name = 'bubbletype_name',
                estonian = self.name_estonian,
                english = self.name_english
            ).put('zimport')
        bt.menugroup            = Dictionary(
                name = 'bubbletype_menugroup',
                estonian = self.menugroup_estonian,
                english = self.menugroup_english
            ).put('zimport')
        bt.name_plural          = Dictionary(
                name = 'bubbletype_name_plural',
                estonian = self.name_plural_estonian,
                english = self.name_plural_english
            ).put('zimport')
        bt.description          = Dictionary(
                name = 'bubbletype_description',
                estonian = self.description_estonian,
                english = self.description_english
            ).put('zimport')
        bt.allowed_subtypes       = StrToList(self.allowed_subtypes)
        bt.grade_display_method   = self.grade_display_method
        bt.property_displayname   = self.property_displayname
        bt.property_displayinfo   = self.property_displayinfo
        bt.bubble_properties      = GetZoinKeyList('BubbleProperty', self.bubble_properties)
        bt.mandatory_properties   = GetZoinKeyList('BubbleProperty', self.mandatory_properties)
        bt.read_only_properties   = GetZoinKeyList('BubbleProperty', self.read_only_properties)
        bt.create_only_properties = GetZoinKeyList('BubbleProperty', self.create_only_properties)
        bt.public_properties      = GetZoinKeyList('BubbleProperty', self.public_properties)
        bt.propagated_properties  = GetZoinKeyList('BubbleProperty', self.propagated_properties)
        bt.escalated_properties   = GetZoinKeyList('BubbleProperty', self.escalated_properties)
        bt.inherited_properties   = GetZoinKeyList('BubbleProperty', self.inherited_properties)
        bt.put('zimport')

        AddZoin(
            entity_kind = 'BubbleType',
            old_key = self.key().name(),
            new_key = bt.key(),
        )
        self.delete()


class zCounter(db.Expando):
    def zimport(self):
        c = GetZoin('Counter', self.key().name())
        if not c:
{'fraction_non_alphanumeric': 0.09290850133934865, 'fraction_numerical': 0.0, 'mean_word_length': 1.8568264196536448, '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': '3815342', 'n_tokens_mistral': 4260, 'n_tokens_neox': 4021, 'n_words': 663}