def get_log(self, log_name: str) -> CommonLog:
     """ Get a log for a log name. """
     _log = CommonLogRegistry().register_log(
         '{}_S4CLVanillaLog'.format(log_name), 'log', 'vanilla_logs')
     _log.enable()
     self.logs.append(_log)
     return _log
Exemplo n.º 2
0
        def _inner_test_class(cls):
            name_of_class = cls.__name__
            if CommonLogRegistry is not None:
                cls.test_log_log = CommonLogRegistry.get().register_log(
                    mod_name, name_of_class)
                cls.test_log_log.enable()
                cls.test_log = lambda val: cls.test_log_log.debug(val)
            else:
                cls.test_log = lambda val: print(val)
            for method_name in dir(cls):
                method = getattr(cls, method_name)
                if not hasattr(method, 'is_test'):
                    continue

                def _test_function(class_name, test_name, test_method, *_,
                                   **__):
                    @wraps(test_method)
                    def _wrapper(*args, **kwargs):
                        arguments = (_ + args)
                        new_test_name = '{} (Arguments: {}, Keyword Arguments: {})'.format(
                            test_name, arguments, (kwargs, __))
                        # noinspection PyBroadException
                        try:
                            test_method(*(_ + args), **kwargs, **__)
                            cls.test_log(
                                CommonTestService._format_test_result(
                                    CommonTestResultType.SUCCESS,
                                    new_test_name))
                        except AssertionError:
                            cls.test_log(
                                CommonTestService._format_test_result(
                                    CommonTestResultType.FAILED,
                                    new_test_name,
                                    stacktrace=format_exc()))
                            return CommonTestResultType.FAILED
                        except Exception:
                            cls.test_log(
                                CommonTestService._format_test_result(
                                    CommonTestResultType.FAILED,
                                    new_test_name,
                                    stacktrace=format_exc()))
                            return CommonTestResultType.FAILED
                        return CommonTestResultType.SUCCESS

                    CommonTestService.get().add_test(test_name,
                                                     _wrapper,
                                                     class_name=class_name)

                if hasattr(
                        method,
                        'test_parameters') and len(method.test_parameters) > 0:
                    idx = 1
                    for test_args, test_kwargs in method.test_parameters:
                        _test_function(name_of_class,
                                       '{} {}'.format(method_name, str(idx)),
                                       method, *test_args, **test_kwargs)
                        idx += 1
                else:
                    _test_function(name_of_class, method_name, method)
            return cls
Exemplo n.º 3
0
 def log(self) -> CommonLog:
     """ The Log for this class. """
     if self._log is None:
         mod_name = 'Missing Mod Name'
         if self.mod_identity is not None:
             mod_name = self.mod_identity.name
         self._log = CommonLogRegistry.get().register_log(
             mod_name, self.log_identifier)
     return self._log
Exemplo n.º 4
0
    def log(self) -> CommonLog:
        """The Log for this class.

        .. note:: It uses the `mod_identity` and `log_identifier` when logging.
        """
        if self._log is None:
            mod_name = 'Missing Mod Name'
            if self.mod_identity is not None:
                mod_name = self.mod_identity.name
            self._log = CommonLogRegistry.get().register_log(mod_name, self.log_identifier)
        return self._log
Exemplo n.º 5
0
    def log(self) -> CommonLog:
        """The log for instances of the class.

        .. note:: It uses the `mod_identity` and `log_identifier` when logging.

        :return: An instance of CommonLog
        :rtype: CommonLog
        """
        if self._log is None:
            mod_name = CommonModIdentity._get_mod_name(self.mod_identity)
            self._log = CommonLogRegistry.get().register_log(
                mod_name, self.log_identifier)
        return self._log
    def get_log(cls) -> CommonLog:
        """get_log()

        The Log for this class.

        .. note:: It uses the `mod_identity` and `log_identifier` when logging.
        """
        if not hasattr(cls, '_log') or getattr(cls, '_log', None) is None:
            mod_name = 'Missing Mod Name'
            if cls.get_mod_identity() is not None:
                mod_name = cls.get_mod_identity().name
            setattr(cls, '_log', CommonLogRegistry.get().register_log(mod_name, cls.get_log_identifier()))
        return getattr(cls, '_log', None)
Exemplo n.º 7
0
    def get_log(cls) -> CommonLog:
        """get_log()

        Retrieve a log for the class.

        .. note:: This function uses the :func:`~get_mod_identity` and :func:`~get_log_identifier` functions when logging.

        :return: An instance of CommonLog
        :rtype: CommonLog
        """
        if not hasattr(cls, '_log') or getattr(cls, '_log', None) is None:
            mod_name = CommonModIdentity._get_mod_name(cls.get_mod_identity())
            setattr(
                cls, '_log',
                CommonLogRegistry().register_log(mod_name,
                                                 cls.get_log_identifier()))
        return getattr(cls, '_log', None)
                'OC menu is available for Source Sim and Target Sim.')
            return True

        # noinspection PyMissingOrEmptyDocstring
        def show(self,
                 source_sim_info: SimInfo,
                 *args,
                 target: Any = None,
                 on_close: Callable[..., Any] = CommonFunctionUtils.noop,
                 **kwargs):
            self.log.debug('Showing OC Customize Outfit.')
            target_sim_info = CommonSimUtils.get_sim_info(target)
            OCCustomizeOutfitDialog(target_sim_info, on_close=on_close).open()

    S4MSMModSettingsRegistry().register_menu_item(_OCMSMMenuItem())

    log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                           'oc_customize_outfit_interaction')

    # noinspection PyUnusedLocal
    @CommonInjectionUtils.inject_safely_into(
        ModInfo.get_identity(), OCCustomizeOutfitInteraction,
        OCCustomizeOutfitInteraction.on_test.__name__)
    def _oc_hide_settings_interaction(original, cls, *_, **__) -> TestResult:
        log.debug(
            'Hiding the Customize Outfit interaction in favor of the Mod Settings Menu.'
        )
        return TestResult.NONE
except:
    pass
from typing import Tuple
from cnoutfitcustomization.modinfo import ModInfo
from cnoutfitcustomization.outfit_parts.outfit_part import OCOutfitPartAvailableFor
from cnoutfitcustomization.outfit_parts.outfit_parts_loader import OCOutfitPartsLoader
from protocolbuffers import Dialog_pb2
from sims.outfits.outfit_enums import BodyType
from sims.sim_info_types import Gender, Age
from sims4.resources import Types
from sims4communitylib.enums.common_species import CommonSpecies
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.utils.cas.common_cas_utils import CommonCASUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4.commands import Command, CommandType, CheatOutput
from sims4communitylib.utils.localization.common_localization_utils import CommonLocalizationUtils

log = CommonLogRegistry.get().register_log(ModInfo.get_identity(),
                                           'oc_load_vanilla_cas_parts')


@Command('oc.load_vanilla_cas_parts', command_type=CommandType.Live)
def _oc_load_vanilla_cas_parts(_connection: int = None):
    output = CheatOutput(_connection)
    try:
        output('Loading')
        # noinspection PyUnresolvedReferences
        cas_part_resource_keys = list(sims4.resources.list(type=Types.CASPART))
        for key in cas_part_resource_keys:

            cas_part_id = key.instance
            body_type = CommonCASUtils.get_body_type_of_cas_part(cas_part_id)
            if body_type not in BodyType:
                continue
"""
The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0).
https://creativecommons.org/licenses/by/4.0/
https://creativecommons.org/licenses/by/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Any, Callable, Iterator

from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.mod_support.mod_identity import CommonModIdentity
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_log_registry import CommonLog, CommonLogRegistry

func_utils_log = CommonLogRegistry.get().register_log(ModInfo.get_identity().name, 's4clib_common_function_utils')


class CommonFunctionUtils:
    """Utilities for manipulating functions.

    """

    @staticmethod
    def noop(*_, **__) -> None:
        """noop(*_, **__)

        An empty function that does nothing. Useful when you need something to do nothing.

        .. note:: Use this when you want something to do nothing.

        """
Exemplo n.º 11
0
        return self.data_manager.get_data_store_by_type(data_store_type)

    def get_all_data(self) -> Dict[str, Dict[str, Any]]:
        """ Get all data. """
        return self.data_manager._data_store_data

    def save(self) -> bool:
        """ Save data. """
        return self.data_manager.save()

    def reset(self, prevent_save: bool = False) -> bool:
        """ Reset data. """
        return self.data_manager.remove_all_data(prevent_save=prevent_save)


log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                       'cgs.print_mod_data')


@Command('cgs.print_mod_data', command_type=CommandType.Live)
def _cgs_command_print_mod_data(_connection: int = None):
    output = CheatOutput(_connection)
    output(
        'Printing CGS Mod Data to Messages.txt file. This may take a little bit, be patient.'
    )
    log.enable()
    log.format(data_store_data=CGSDataManagerUtils().get_all_data())
    log.disable()
    output('Done')


@Command('cgs.clear_mod_data', command_type=CommandType.Live)
The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0).
https://creativecommons.org/licenses/by/4.0/
https://creativecommons.org/licenses/by/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Callable, Any, Dict, List
from functools import wraps
from traceback import format_exc
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.services.common_service import CommonService
try:
    from sims4communitylib.utils.common_log_registry import CommonLogRegistry

    community_test_log_log = CommonLogRegistry.get().register_log(
        ModInfo.get_identity().name, 'community_test_log')
    community_test_log_log.enable()

    def _community_test_log(val: str):
        community_test_log_log.debug(val)
except ModuleNotFoundError:
    CommonLogRegistry = None

    def _community_test_log(_: str):
        pass


class CommonTestResultType:
    """Use to identify the results of running a test.

    """
Exemplo n.º 13
0
This file is part of the Custom Slider Framework licensed under the Creative Commons Attribution-NoDerivatives 4.0 International public license (CC BY-ND 4.0).

https://creativecommons.org/licenses/by-nd/4.0/
https://creativecommons.org/licenses/by-nd/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Any, Dict, Set

from cncustomsliderframework.dtos.sliders.slider import CSFSlider
from cncustomsliderframework.modinfo import ModInfo
from cncustomsliderframework.sliders.slider_query_registry import CSFSliderQueryRegistry
from sims4.commands import Command, CommandType, CheatOutput
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                       'csf_slider_query')


@Command('csf.log_slider_tags', command_type=CommandType.Live)
def _csf_command_log_slider_tags(_connection: int = None):
    output = CheatOutput(_connection)
    output(
        'Logging Slider tags, this will take awhile and your game may freeze. Be Patient!'
    )
    try:
        log.enable()
        slider_results = []
        for slider_tag_value in CSFSliderQueryRegistry()._slider_library.keys(
        ):
            sliders = CSFSliderQueryRegistry(
            )._slider_library[slider_tag_value]
Exemplo n.º 14
0
"""
The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0).
https://creativecommons.org/licenses/by/4.0/
https://creativecommons.org/licenses/by/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from sims.sim_info import SimInfo
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4communitylib.utils.sims.common_age_utils import CommonAgeUtils
from sims4communitylib.utils.sims.common_species_utils import CommonSpeciesUtils

log = CommonLogRegistry.get().register_log(ModInfo.get_identity().name,
                                           's4cl_age_species_utils')


class CommonAgeSpeciesUtils:
    """Utilities for checking the age and species of Sims.

    """
    @staticmethod
    def is_baby_human(sim_info: SimInfo) -> bool:
        """is_baby_human(sim_info)

        Determine if a sim is a Baby Human.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is a Baby Human. False, if the Sim is not.
        :rtype: bool
Exemplo n.º 15
0
        def show(self,
                 source_sim_info: SimInfo,
                 *args,
                 target: Any = None,
                 on_close: Callable[..., Any] = CommonFunctionUtils.noop,
                 **kwargs):
            self.log.debug('Showing Change Motives dialog.')
            if target is None:
                if on_close is not None:
                    on_close()
                return
            target_sim_info = CommonSimUtils.get_sim_info(target)
            CMChangeMotivesDialog(on_close=on_close).open(target_sim_info)

    S4MSMModSettingsRegistry().register_menu_item(_CMMSMMenuItem())

    log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                           'cm_change_motives')

    # noinspection PyUnusedLocal
    @CommonInjectionUtils.inject_safely_into(
        ModInfo.get_identity(), CMChangeMotivesInteraction,
        CMChangeMotivesInteraction.on_test.__name__)
    def _cm_hide_interaction(original, cls, *_, **__) -> TestResult:
        log.debug(
            'Hiding the CM Change Motives interaction in favor of the Mod Settings Menu.'
        )
        return TestResult.NONE
except:
    pass
Copyright (c) COLONOLNUTTY
"""
import sims4.commands
from typing import Any, Union, Iterator
from distributor.shared_messages import IconInfoData
from protocolbuffers.Localization_pb2 import LocalizedString
from sims4communitylib.enums.strings_enum import CommonStringId
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.localization.common_localized_string_colors import CommonLocalizedStringColor
from sims4communitylib.utils.localization.common_localization_utils import CommonLocalizationUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
from ui.ui_dialog_notification import UiDialogNotification
log = CommonLogRegistry.get().register_log(ModInfo.get_identity().name,
                                           'common_basic_notification')


class CommonBasicNotification:
    """CommonBasicNotification(\
        title_identifier,\
        description_identifier,\
        title_tokens=(),\
        description_tokens=(),\
        urgency=UiDialogNotification.UiDialogNotificationUrgency.DEFAULT,\
        information_level=UiDialogNotification.UiDialogNotificationLevel.SIM,\
        expand_behavior=UiDialogNotification.UiDialogNotificationExpandBehavior.USER_SETTING\
    )

    A basic notification.
Exemplo n.º 17
0
"""
from typing import Union, Iterator

import services
from sims.household import Household
from sims.sim_info import SimInfo
from sims.sim_spawner import SimSpawner
from sims4communitylib.modinfo import ModInfo
from world.lot import Lot
from sims4communitylib.utils.sims.common_sim_name_utils import CommonSimNameUtils
from sims4communitylib.utils.sims.common_sim_state_utils import CommonSimStateUtils
from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

# noinspection PyTypeChecker
log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                       's4cl_household_utils')


class CommonHouseholdUtils:
    """Utilities for manipulating households.

    """
    @staticmethod
    def get_active_household() -> Union[Household, None]:
        """get_active_household()

        Retrieve the Household of the Active Sim.

        :return: The Household of the Active Sim or None if no household is found.
        :rtype: Union[Household, None]
        """
Exemplo n.º 18
0
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.services.common_service import CommonService
from sims4communitylib.utils.common_injection_utils import CommonInjectionUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
# ReadTheDocs
ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'

if not ON_RTD:
    from services.persistence_service import SaveGameData
else:

    class SaveGameData:
        pass


log = CommonLogRegistry().register_log(ModInfo.get_identity(), 'thing')
log.enable()


class CommonSaveEventDispatcher(CommonService):
    """A service that dispatches save file save/load events.

    .. warning:: Do not use this service directly to listen for events!\
        Use the :class:`.CommonEventRegistry` to listen for dispatched events.

    """
    def __init__(self) -> None:
        self._current_save_slot_guid = None

    def _on_game_save(self, save_game_data: SaveGameData):
        CommonEventRegistry.get().dispatch(S4CLSaveSavedEvent(save_game_data))
"""
The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0).
https://creativecommons.org/licenses/by/4.0/
https://creativecommons.org/licenses/by/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Union

from sims.sim_info import SimInfo
from sims.sim_info_types import Species
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

log = CommonLogRegistry.get().register_log(ModInfo.get_identity(),
                                           'common_species_utils')


class CommonSpeciesUtils:
    """Utilities for manipulating and checking the Species of Sims.

    """
    @staticmethod
    def get_species(sim_info: SimInfo) -> Union[Species, None]:
        """get_species(sim_info)

        Retrieve the Species of a sim.

        :param sim_info: The Sim to get the Species of.
        :type sim_info: SimInfo
        :return: The Species of the Sim or None if the Sim does not have a Species.
This file is part of the Outfit Customization mod licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International public license (CC BY-NC-ND 4.0).
https://creativecommons.org/licenses/by-nc-nd/4.0/
https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Tuple, Union

from cnoutfitcustomization.modinfo import ModInfo
from cnoutfitcustomization.outfit_parts.outfit_part import OCOutfitPart
from sims.outfits.outfit_enums import BodyType
from sims.sim_info import SimInfo
from sims4communitylib.utils.cas.common_cas_utils import CommonCASUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

log = CommonLogRegistry.get().register_log(ModInfo.get_identity(),
                                           'oc_outfit_part_utils')


class OCOutfitPartUtils:
    """ Utilities for managing outfit parts of sims. """
    @staticmethod
    def remove_outfit_parts(sim_info: SimInfo,
                            outfit_parts: Tuple[OCOutfitPart]):
        """ Remove the specified outfit parts from a sim. """
        log.format_with_message('Removing outfit parts',
                                outfit_parts=outfit_parts)
        for outfit_part in outfit_parts:
            if OCOutfitPartUtils.remove_cas_part(sim_info,
                                                 outfit_part.part_id,
                                                 body_type=None):
                log.format_with_message('Removed outfit part.',
"""
from typing import Union

from sims.pregnancy.pregnancy_enums import PregnancyOrigin
from sims.pregnancy.pregnancy_tracker import PregnancyTracker
from sims.sim_info import SimInfo
from sims4communitylib.enums.buffs_enum import CommonBuffId
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4communitylib.utils.sims.common_sim_name_utils import CommonSimNameUtils
from sims4communitylib.utils.sims.common_species_utils import CommonSpeciesUtils
from sims4communitylib.enums.statistics_enum import CommonStatisticId
from sims4communitylib.utils.sims.common_household_utils import CommonHouseholdUtils
from sims4communitylib.utils.sims.common_sim_statistic_utils import CommonSimStatisticUtils

log = CommonLogRegistry().register_log(ModInfo.get_identity(),
                                       's4cl_pregnancy')


class CommonSimPregnancyUtils:
    """Utilities for manipulating the pregnancy status of Sims.

    """
    @staticmethod
    def is_pregnant(sim_info: SimInfo) -> bool:
        """is_pregnant(sim_info)

        Determine if the specified Sim is pregnant.

        :param sim_info: The Sim to check.
        :type sim_info: SimInfo
        :return: True, if the Sim is pregnant. False, if not.
from pprint import pformat
from protocolbuffers.Localization_pb2 import LocalizedString
from sims4communitylib.dialogs.common_choice_outcome import CommonChoiceOutcome
from sims4communitylib.dialogs.utils.common_dialog_utils import CommonDialogUtils
from sims4communitylib.enums.strings_enum import CommonStringId
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_function_utils import CommonFunctionUtils
from sims4communitylib.utils.common_icon_utils import CommonIconUtils
from sims4communitylib.utils.localization.common_localized_string_colors import CommonLocalizedStringColor
from sims4communitylib.utils.localization.common_localization_utils import CommonLocalizationUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
from ui.ui_dialog_picker import UiObjectPicker, ObjectPickerRow

log = CommonLogRegistry.get().register_log(ModInfo.get_identity().name,
                                           'choose_object_dialog')


class CommonChooseObjectDialog:
    """
        Create a dialog that asks the player to make a choice.
    """
    def __init__(self,
                 title_identifier: Union[int, LocalizedString],
                 description_identifier: Union[int, LocalizedString],
                 choices: Tuple[ObjectPickerRow],
                 title_tokens: Tuple[Any] = (),
                 description_tokens: Tuple[Any] = (),
                 per_page: int = 25):
        """
            Create a dialog for displaying a list of objects.
"""
The Sims 4 Community Library is licensed under the Creative Commons Attribution 4.0 International public license (CC BY 4.0).
https://creativecommons.org/licenses/by/4.0/
https://creativecommons.org/licenses/by/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Tuple, Union
from sims.outfits.outfit_enums import OutfitCategory, BodyType
from sims.sim_info import SimInfo
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.services.sim.cas.common_sim_outfit_io import CommonSimOutfitIO
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

log = CommonLogRegistry.get().register_log(ModInfo.get_identity(), 's4cl_common_cas_utils')


class CommonCASUtils:
    """Utilities for manipulating the CAS parts of Sims.

    """

    @staticmethod
    def is_cas_part_loaded(cas_part_id: int) -> bool:
        """is_cas_part_loaded(cas_part_id)

        Determine if a CAS part is loaded within the game.

        .. note:: If the CAS part is part of a package that is not installed, it will be considered as not loaded.

        .. note:: A CAS part is considered as "loaded" when the BodyType it has can be found within the sims.outfits.outfit_enums.BodyType enum.
Exemplo n.º 24
0
This file is part of the Sims 4 Community Library, licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International public license (CC BY-NC-ND 4.0).
https://creativecommons.org/licenses/by-nc-nd/4.0/
https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode

Copyright (c) COLONOLNUTTY
"""
from typing import Callable, Any, Dict, List
from functools import wraps
from traceback import format_exc
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.services.common_service import CommonService
try:
    from sims4communitylib.utils.common_log_registry import CommonLogRegistry

    community_test_log_log = CommonLogRegistry.get().register_log(
        ModInfo.MOD_NAME, 'community_test_log')
    community_test_log_log.enable()

    def community_test_log(val: str):
        community_test_log_log.debug(val)
except ModuleNotFoundError:
    CommonLogRegistry = None

    def community_test_log(val: str):
        pass


class CommonTestResultType:
    """ Use to identify the results of running a test. """
    FAILED = 'FAILED'
    SUCCESS = 'SUCCESS'
Exemplo n.º 25
0
Copyright (c) COLONOLNUTTY
"""
from typing import Union, Iterator

import services
from sims.household import Household
from sims.sim_info import SimInfo
from sims.sim_spawner import SimSpawner
from world.lot import Lot
from sims4communitylib.utils.sims.common_sim_name_utils import CommonSimNameUtils
from sims4communitylib.utils.sims.common_sim_state_utils import CommonSimStateUtils
from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry

# noinspection PyTypeChecker
log = CommonLogRegistry().register_log(None, 's4cl_household_utils')


class CommonHouseholdUtils:
    """Utilities for manipulating households.

    """
    @staticmethod
    def get_active_household() -> Union[Household, None]:
        """get_active_household()

        Retrieve the Household of the Active Sim.

        :return: The Household of the Active Sim or None if no household is found.
        :rtype: Union[Household, None]
        """
Exemplo n.º 26
0
Copyright (c) COLONOLNUTTY
"""
import sims4.commands
from typing import Tuple, Any, Callable, Union

from protocolbuffers.Localization_pb2 import LocalizedString
from sims4communitylib.enums.strings_enum import CommonStringId
from sims4communitylib.exceptions.common_exceptions_handler import CommonExceptionHandler
from sims4communitylib.modinfo import ModInfo
from sims4communitylib.utils.common_function_utils import CommonFunctionUtils
from sims4communitylib.utils.localization.common_localized_string_colors import CommonLocalizedStringColor
from sims4communitylib.utils.localization.common_localization_utils import CommonLocalizationUtils
from sims4communitylib.utils.common_log_registry import CommonLogRegistry
from sims4communitylib.utils.sims.common_sim_utils import CommonSimUtils
from ui.ui_dialog import UiDialogOkCancel
log = CommonLogRegistry.get().register_log(ModInfo.get_identity().name, 'ok_cancel_dialog')


class CommonOkCancelDialog:
    """
        Use to create a prompt dialog.
    """
    def __init__(self,
                 title_identifier: Union[int, LocalizedString],
                 description_identifier: Union[int, LocalizedString],
                 title_tokens: Tuple[Any]=(),
                 description_tokens: Tuple[Any]=(),
                 ok_text_identifier: Union[int, LocalizedString]=CommonStringId.OK,
                 ok_text_tokens: Tuple[Any]=(),
                 cancel_text_identifier: Union[int, LocalizedString]=CommonStringId.CANCEL,
                 cancel_text_tokens: Tuple[Any]=()):