# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# def load_module(name: str):
# def _format_args(args):
#     def format_arg(a):
# def _wrap_in_dbus_variant(value):
#     def __init__(self, bus_name: str, path: str, interface: str, props: PropsType,
#                  logfile: Optional[str] = None, is_object_manager: bool = False) -> None:
#     def __del__(self) -> None:
#     def _set_up_object_manager(self) -> None:
#     def _reset(self, props: PropsType) -> None:
#     def Get(self, interface_name: str, property_name: str) -> Any:
#     def GetAll(self, interface_name: str, *_, **__) -> PropsType:
#     def Set(self, interface_name: str, property_name: str, value: Any, *_, **__) -> None:
#     def AddObject(self, path: str, interface: str, properties: PropsType, methods: List[MethodType]) -> None:
#     def RemoveObject(self, path: str) -> None:  # pylint: disable=no-self-use
#     def Reset(self) -> None:
#     def AddMethod(self, interface, name: str, in_sig: str, out_sig: str, code: str) -> None:
#     def AddMethods(self, interface: str, methods: List[MethodType]) -> None:
#     def _set_property(self, interface, name, value):
#     def UpdateProperties(self, interface: str, properties: PropsType) -> None:
#     def AddProperty(self, interface: str, name: str, value: Any) -> None:
#     def AddProperties(self, interface: str, properties: PropsType) -> None:
#     def AddTemplate(self, template: str, parameters: PropsType) -> None:
#     def EmitSignal(self, interface: str, name: str, signature: str, args: List[Any]) -> None:
#     def GetCalls(self) -> List[CallLogType]:
#     def GetMethodCalls(self, method: str) -> List[Tuple[int, Sequence[Any]]]:
#     def ClearCalls(self) -> None:
#     def MethodCalled(self, name, args):
#     def object_manager_emit_added(self, path: str) -> None:
#     def object_manager_emit_removed(self, path: str) -> None:
#     def mock_method(self, interface: str, dbus_method: str, in_signature: str, *args, **_) -> Any:
#     def log(self, msg: str) -> None:
#     def Introspect(self, object_path: str, connection: dbus.connection.Connection) -> str:
# def _dbusmock_method_lookup(obj, method_name, dbus_interface):
# def get_objects() -> KeysView[str]:
# def get_object(path) -> DBusMockObject:
# class DBusMockObject(dbus.service.Object):  # pylint: disable=too-many-instance-attributes


import sys
import time
import dbus
from dbusmock import MOCK_IFACE, mockobject


def load(mock, parameters=None):
    parameters = parameters if parameters else {}
    mock.mock_users = {}
    mock.cached_users = []
    mock.automatic_login_users = set()
    mock.users_auto_uids = 2000

    mock.AddProperties(MAIN_IFACE, mock.GetAll(MAIN_IFACE))

    for uid, name in parameters.get('users', {}).items():
        mock.AddUser(uid, name)


def emit_properties_changed(mock, interface=MAIN_IFACE, properties=None):
    if properties is None:
        properties = mock.GetAll(interface)
    elif isinstance(properties, str):
        properties = [properties]

    if isinstance(properties, (list, set)):
        properties = {p: mock.Get(interface, p) for p in properties}
    elif not isinstance(properties, dict):
        raise TypeError('Unsupported properties type')

    mock.EmitSignal(dbus.PROPERTIES_IFACE, 'PropertiesChanged', 'sa{sv}as', (
        interface, properties, []))



# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# def load_module(name: str):
# def _format_args(args):
#     def format_arg(a):
# def _wrap_in_dbus_variant(value):
#     def __init__(self, bus_name: str, path: str, interface: str, props: PropsType,
#                  logfile: Optional[str] = None, is_object_manager: bool = False) -> None:
#     def __del__(self) -> None:
#     def _set_up_object_manager(self) -> None:
#     def _reset(self, props: PropsType) -> None:
#     def Get(self, interface_name: str, property_name: str) -> Any:
#     def GetAll(self, interface_name: str, *_, **__) -> PropsType:
#     def Set(self, interface_name: str, property_name: str, value: Any, *_, **__) -> None:
#     def AddObject(self, path: str, interface: str, properties: PropsType, methods: List[MethodType]) -> None:
#     def RemoveObject(self, path: str) -> None:  # pylint: disable=no-self-use
#     def Reset(self) -> None:
#     def AddMethod(self, interface, name: str, in_sig: str, out_sig: str, code: str) -> None:
#     def AddMethods(self, interface: str, methods: List[MethodType]) -> None:
#     def _set_property(self, interface, name, value):
#     def UpdateProperties(self, interface: str, properties: PropsType) -> None:
#     def AddProperty(self, interface: str, name: str, value: Any) -> None:
#     def AddProperties(self, interface: str, properties: PropsType) -> None:
#     def AddTemplate(self, template: str, parameters: PropsType) -> None:
#     def EmitSignal(self, interface: str, name: str, signature: str, args: List[Any]) -> None:
#     def GetCalls(self) -> List[CallLogType]:
#     def GetMethodCalls(self, method: str) -> List[Tuple[int, Sequence[Any]]]:
#     def ClearCalls(self) -> None:
#     def MethodCalled(self, name, args):
#     def object_manager_emit_added(self, path: str) -> None:
#     def object_manager_emit_removed(self, path: str) -> None:
#     def mock_method(self, interface: str, dbus_method: str, in_signature: str, *args, **_) -> Any:
#     def log(self, msg: str) -> None:
#     def Introspect(self, object_path: str, connection: dbus.connection.Connection) -> str:
# def _dbusmock_method_lookup(obj, method_name, dbus_interface):
# def get_objects() -> KeysView[str]:
# def get_object(path) -> DBusMockObject:
# class DBusMockObject(dbus.service.Object):  # pylint: disable=too-many-instance-attributes


# Path: dbusmock/templates/accounts_service.py
import sys
import time
import dbus
from dbusmock import MOCK_IFACE, mockobject



def load(mock, parameters=None):
    parameters = parameters if parameters else {}
    mock.mock_users = {}
    mock.cached_users = []
    mock.automatic_login_users = set()
    mock.users_auto_uids = 2000

    mock.AddProperties(MAIN_IFACE, mock.GetAll(MAIN_IFACE))

    for uid, name in parameters.get('users', {}).items():
        mock.AddUser(uid, name)


def emit_properties_changed(mock, interface=MAIN_IFACE, properties=None):
    if properties is None:
        properties = mock.GetAll(interface)
    elif isinstance(properties, str):
        properties = [properties]

    if isinstance(properties, (list, set)):
        properties = {p: mock.Get(interface, p) for p in properties}
    elif not isinstance(properties, dict):
        raise TypeError('Unsupported properties type')

    mock.EmitSignal(dbus.PROPERTIES_IFACE, 'PropertiesChanged', 'sa{sv}as', (
        interface, properties, []))



@dbus.service.method(MOCK_IFACE, in_signature='xssa{sv}a{sv}',