<commit_before>import json

from django.db import connection

from apps.common.util import dictfetchall

#
# This script generated a JSON tree for the market browser and is automatically run with prepare_static.sh
#

def recadder(node):
	"""
	Function for recursively traversing the tree.
	"""

    if not node['has_items']:
        if not 'children' in node:
            node['children'] = []

        cursor.execute('SELECT * FROM (SELECT * FROM eve_db_invmarketgroup WHERE parent_id = ' + str(node['id']) + ' ORDER BY name) as main ORDER BY has_items')
        res = dictfetchall(cursor)

        for new_node in res:
            node['children'].append(recadder(new_node))

    # Casting and stuff to make dynatree happy
    isFolder = not bool(node['has_items'])
    del node['has_items']
    node['isFolder'] = isFolder
    node['noLink'] = isFolder

    title = node['name']
    del node['name']
    node['title'] = title

    tooltip = node['description']
    del node['description']
    node['tooltip'] = tooltip

    iconid = node['icon_id']
    del node['icon_id']

    if (iconid):
    	node['iconid'] = str(iconid) + '_32.png'

    key = node['id']
    del node['id']
    node['key'] = key

    del node['parent_id']

    return node

cursor = connection.cursor()

# Select Root Groups
cursor.execute("SELECT * FROM eve_db_invmarketgroup WHERE parent_id IS NULL ORDER BY name")
result = dictfetchall(cursor)

tree = []

# Start traversing
for node in result:
    tree.append(recadder(node))

# Write file into appropiate asset folder<commit_msg>Fixed formatting issues<commit_after>import json

from django.db import connection

from apps.common.util import dictfetchall

#
# This script generated a JSON tree for the market browser and is automatically run with prepare_static.sh
#


def recadder(node):
    """
    Function for recursively traversing the tree.
    """

    if not node['has_items']:
        if not 'children' in node:
            node['children'] = []

        cursor.execute('SELECT * FROM (SELECT * FROM eve_db_invmarketgroup WHERE parent_id = ' + str(node['id']) + ' ORDER BY name) as main ORDER BY has_items')
        res = dictfetchall(cursor)

        for new_node in res:
            node['children'].append(recadder(new_node))

    # Casting and stuff to make dynatree happy
    isFolder = not bool(node['has_items'])
    del node['has_items']
    node['isFolder'] = isFolder
    node['noLink'] = isFolder

    title = node['name']
    del node['name']
    node['title'] = title

    tooltip = node['description']
    del node['description']
    node['tooltip'] = tooltip

    iconid = node['icon_id']
    del node['icon_id']

    if (iconid):
        node['iconid'] = str(iconid) + '_32.png'

    key = node['id']
    del node['id']
    node['key'] = key

    del node['parent_id']

    return node

cursor = connection.cursor()

# Select Root Groups
cursor.execute("SELECT * FROM eve_db_invmarketgroup WHERE parent_id IS NULL ORDER BY name")
result = dictfetchall(cursor)

tree = []

# Start traversing
for node in result:
    tree.append(recadder(node))

# Write file into appropiate asset folder
{'fraction_non_alphanumeric': 0.11723478814909206, 'fraction_numerical': 0.0012742911755336094, 'mean_word_length': 3.289617486338798, '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': '5263770', 'n_tokens_mistral': 978, 'n_tokens_neox': 931, 'n_words': 289}