<commit_before># -*- coding: utf-8 -*-
from uuid import uuid4
from random import randrange, choice
from SpiffyWorld import Item

class ItemGenerator:
    """
    Generates items dynamically.
    TODO: use ItemBuilder so this can make
    items with effects
    """
    def generate(self, **kwargs):
        item_id = uuid4()
        item_name = "TestItem-%s" % item_id
        item_types = ("rock", "scissors", "paper", "lizard", "spock")
        item_type = choice(item_types)
        is_permanent = 0
        charges = 0
        can_use = 0

        if "item_type" in kwargs:
            specified_item_type = kwargs["item_type"]

            if specified_item_type not in item_types:
                raise ValueError("Invalid item_type")

            item_type = specified_item_type

        if "is_permanent" in kwargs:
            is_permanent = kwargs["is_permanent"]

        if "charges" in kwargs:
            charges = kwargs["charges"]

        if "can_use" in kwargs:
            can_use = kwargs["can_use"]

        item_model = {
            "id": item_id,
            "name": item_name,
            "description": "foo",
            "effects": [],
            "min_level": 1,
            "max_level": 100,
            "rarity": "dank",
            "equipment_slot": "main hand",
            "is_permanent": is_permanent,
            "unit_type_id": 0,
            "can_use": charges,
            "charges": can_use,
            "created_at": "1",
            "item_type": item_type
        }

        item = Item(item=item_model)

        return item
<commit_msg>Adds item_name option for ItemGenerator<commit_after># -*- coding: utf-8 -*-
from uuid import uuid4
from random import randrange, choice
from SpiffyWorld import Item

class ItemGenerator:
    """
    Generates items dynamically.
    TODO: use ItemBuilder so this can make
    items with effects
    """
    def generate(self, **kwargs):
        item_id = uuid4()
        item_name = "TestItem-%s" % item_id
        item_types = ("rock", "scissors", "paper", "lizard", "spock")
        item_type = choice(item_types)
        is_permanent = 0
        charges = 0
        can_use = 0

        if "item_name" in kwargs:
            item_name = kwargs["item_name"]
        
        if "item_type" in kwargs:
            specified_item_type = kwargs["item_type"]

            if specified_item_type not in item_types:
                raise ValueError("Invalid item_type")

            item_type = specified_item_type

        if "is_permanent" in kwargs:
            is_permanent = kwargs["is_permanent"]

        if "charges" in kwargs:
            charges = kwargs["charges"]

        if "can_use" in kwargs:
            can_use = kwargs["can_use"]

        item_model = {
            "id": item_id,
            "name": item_name,
            "description": "foo",
            "effects": [],
            "min_level": 1,
            "max_level": 100,
            "rarity": "dank",
            "equipment_slot": "main hand",
            "is_permanent": is_permanent,
            "unit_type_id": 0,
            "can_use": charges,
            "charges": can_use,
            "created_at": "1",
            "item_type": item_type
        }

        item = Item(item=item_model)

        return item

{'fraction_non_alphanumeric': 0.1064545732639951, 'fraction_numerical': 0.007341694707861731, 'mean_word_length': 1.821397756686799, 'pattern_counts': {'":': 28, '<': 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': '5202370', 'n_tokens_mistral': 998, 'n_tokens_neox': 985, 'n_words': 250}