<commit_before>"""
Serialize into a tiddlywiki wiki, leaving out most of the tiddlers
so they can be loaded later by something else.

The missing tiddlers are placed in a tiddler called LazyTiddlers.
"""

from tiddlywebwiki.serialization import (
        Serialization as WikiSerialization, MARKUPS)


from tiddlyweb.model.tiddler import Tiddler
from tiddlyweb.web.util import server_base_url, encode_name

ACTIVE_TITLES = [
        'DefaultTiddlers',
        'MainMenu',
        'WindowTitle',
        'SiteTitle',
        'SiteSubtitle',
        ]

FRAGMENTS = [
        'Commands',
        'Template',
        'StyleSheet',
        ]

TAGS = [
        'systemConfig',
        'excludeLists',
        'systemTheme',
        ]

BAGS = [
        'system',
        ]

class Serialization(WikiSerialization):

    def _create_tiddlers(self, title, tiddlers):
        """
        Figure out the content to be pushed into the
        wiki and calculate the title.
        """
        saves = []
        lines = []
        window_title = None
        candidate_title = None
        candidate_subtitle = None
        markup_tiddlers = MARKUPS.keys()
        found_markup_tiddlers = {}
        tiddler_count = 0
        for tiddler in tiddlers:
            if self._lazy_eligible(tiddler):
                saves.append(tiddler)
            else:
                lines.append(self._tiddler_as_div(tiddler))
            tiddler_title = tiddler.title
            if tiddler_title == 'WindowTitle':
                window_title = tiddler.text
            if tiddler_title == 'SiteTitle':
                candidate_title = tiddler.text
            if tiddler_title == 'SiteSubtitle':
                candidate_subtitle = tiddler.text
            if tiddler_title in markup_tiddlers:
                found_markup_tiddlers[tiddler_title] = tiddler.text
            tiddler_count += 1

        if tiddler_count == 1:
            default_tiddler = Tiddler('DefaultTiddlers')
            default_tiddler.tags = ['excludeLists']
            default_tiddler.text = '[[' + tiddler.title + ']]'
            lines.append(self._tiddler_as_div(default_tiddler))

        if saves:
            save_tiddler = Tiddler('LazyTiddlers')<commit_msg>Set the bag to '', otherwise server.etag will error out.<commit_after>"""
Serialize into a tiddlywiki wiki, leaving out most of the tiddlers
so they can be loaded later by something else.

The missing tiddlers are placed in a tiddler called LazyTiddlers.
"""

from tiddlywebwiki.serialization import (
        Serialization as WikiSerialization, MARKUPS)


from tiddlyweb.model.tiddler import Tiddler
from tiddlyweb.web.util import server_base_url, encode_name

ACTIVE_TITLES = [
        'DefaultTiddlers',
        'MainMenu',
        'WindowTitle',
        'SiteTitle',
        'SiteSubtitle',
        ]

FRAGMENTS = [
        'Commands',
        'Template',
        'StyleSheet',
        ]

TAGS = [
        'systemConfig',
        'excludeLists',
        'systemTheme',
        ]

BAGS = [
        'system',
        ]

class Serialization(WikiSerialization):

    def _create_tiddlers(self, title, tiddlers):
        """
        Figure out the content to be pushed into the
        wiki and calculate the title.
        """
        saves = []
        lines = []
        window_title = None
        candidate_title = None
        candidate_subtitle = None
        markup_tiddlers = MARKUPS.keys()
        found_markup_tiddlers = {}
        tiddler_count = 0
        for tiddler in tiddlers:
            if self._lazy_eligible(tiddler):
                saves.append(tiddler)
            else:
                lines.append(self._tiddler_as_div(tiddler))
            tiddler_title = tiddler.title
            if tiddler_title == 'WindowTitle':
                window_title = tiddler.text
            if tiddler_title == 'SiteTitle':
                candidate_title = tiddler.text
            if tiddler_title == 'SiteSubtitle':
                candidate_subtitle = tiddler.text
            if tiddler_title in markup_tiddlers:
                found_markup_tiddlers[tiddler_title] = tiddler.text
            tiddler_count += 1

        if tiddler_count == 1:
            default_tiddler = Tiddler('DefaultTiddlers', '')
            default_tiddler.tags = ['excludeLists']
            default_tiddler.text = '[[' + tiddler.title + ']]'
            lines.append(self._tiddler_as_div(default_tiddler))

        if saves:
            save_tiddler = Tiddler('LazyTiddlers', '')
{'fraction_non_alphanumeric': 0.0848741367787926, 'fraction_numerical': 0.0013366005791935842, 'mean_word_length': 2.0256064690026956, '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': '511260', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1354, 'n_words': 295}