Пример #1
0
    def reload(self, descriptors, co=None):
        """
        Reload module code, update dependency graph
        """
        LOGGER.info("Reload module descriptor '%s' at %s" % (self.name, relativepath(self.filename)))

        try:
            self.module_code.reload(co)
        except SyntaxError:
            # SyntaxError is OK
            LOGGER.warn("SyntaxError found in %s" % self.filename, exc_info=True)
        else:
            self.update_dependencies(descriptors)
Пример #2
0
    def describe(self, indent=1, width=80, depth=None):
        """
        Return the formatted representation of ``ModuleDescriptor``
        as a string. *indent*, *width* and *depth* will be passed to
        the ``PrettyPrinter`` constructor as formatting parameters.
        """

        def _format_monitor_list(modules):
            import re
            from pprint import pformat

            s = pformat(list(m.name for m in modules), indent=indent, width=width, depth=depth)
            # bug?
            return re.sub(r"\[( +)", "[\n\\1 ", s)

        messages = []
        messages.append("%s: %s" % (self.name, relativepath(self.filename)))
        messages.append("  Dependencies: %s" % _format_monitor_list(self.__dependencies))
        messages.append("  Reverse: %s" % _format_monitor_list(self.__reverse_dependencies))
        return "\n".join(messages)
Пример #3
0
 def test_empty(self):
     self.assertRaises(TypeError, utils.relativepath, None)
     self.assertEqual("", utils.relativepath(""))