<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(self, resource=None):
 """ Parse a list of directories ans :param resource: List of folders """

        if resource is None:
            resource = self.__resources__

        self.inventory = self.dispatcher.collection

        try:
            self._parse(resource)
        except MyCapytain.errors.UndispatchedTextError as E:
            if self.RAISE_ON_UNDISPATCHED is True:
                raise UndispatchedTextError(E)

        self.inventory = self.dispatcher.collection
        return self.inventory