def _inner_test_class(cls) -> Any: name_of_class = cls.__name__ if CommonLogRegistry is not None: cls.test_log_log = CommonLogRegistry().register_log( mod_identifier, 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, *_, **__) -> None: @wraps(test_method) def _wrapper(*args, **kwargs) -> str: 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
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
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)
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] """
'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 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 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] """
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))
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)
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]
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