def custom(srcpaths, event_cb=None, poll_interval=1, recurse=True,
           restart_cb=None, restart_func=None, close_fds=True):
    if _active:
        msg = 'lazarus is already active'
        raise RuntimeWarning(msg)

    if restart_cb and not callable(restart_cb):
        msg = 'restart_cb keyword argument is not callable'
        raise TypeError(msg)

    if restart_func and not callable(restart_func):
        msg = 'restart_func keyword argument is not callable'
        raise TypeError(msg)

    global _close_fds
    _close_fds = close_fds

    try:
        from watchdog.observers import Observer
        from watchdog.events import FileSystemEventHandler
    except ImportError as ie:
        msg = 'no watchdog support (%s)' % str(ie)
        raise RuntimeError(msg)

    class _Handler(FileSystemEventHandler):

        def __init__(self):
            self.active = True

        def dispatch(self, event):
            if not self.active:
                return
            super(_Handler, self).dispatch(event)

        def all_events(self, event):
            # if caller wants event_cb control, defer _restart logic to them
            # (caller decides whether this is a restart event)
            if event_cb:
                if event_cb(event):
                    cancelled = _restart()
                    if not cancelled:
                        self.active = False

            # use default is_restart_event logic
            elif is_restart_event(event):
                cancelled = _restart()
                if not cancelled:
                    self.active = False
                self.active = False

        def on_created(self, event):
            self.all_events(event)

        def on_deleted(self, event):
            self.all_events(event)

        def on_modified(self, event):
            self.all_events(event)

        def on_moved(self, event):
            self.all_events(event)

    global _observer
    kwargs = {'timeout': poll_interval}
    _observer = Observer(**kwargs)
    global _restart_cb
    _restart_cb = restart_cb

    handler = _Handler()
    srcpaths = _as_list(srcpaths)
    kwargs = {}
    if recurse:
        kwargs['recursive'] = True
    for srcpath in srcpaths:
        _observer.schedule(handler, srcpath, **kwargs)
    _activate()
    _observer.start()
Sets up lazarus in custom mode.
dataset/ETHPy150Open formwork-io/lazarus/lazarus/__init__.py/custom