示例#1
0
    def create_index(self):
        """Create information for all plugins available."""
        makefile(os.path.join(self.path, '__init__.py'), exist_ok=True)

        a = time.time()
        for _type in self.TYPES:
            self.plugins[_type] = self.parse(_type)

        self.log.debug('Created index of plugins for {0} in {1:.2f} ms'.format(
            self.path, (time.time() - a) * 1000))
示例#2
0
文件: debug.py 项目: xswvfr/pyload
def report(value, dirname):
    frame = inspect.currentframe()
    try:
        filename = f"{frame.f_back.f_code.co_name}_line{frame.f_back.f_lineno}.report"
        filepath = os.path.join(dirname, filename)
        makefile(filepath, exist_ok=True)
        with io.open(filepath, mode="wb") as fp:
            fp.write(value)
    finally:
        del frame  # delete it just now or wont be cleaned by gc
示例#3
0
    def create_index(self):
        """Create information for all plugins available."""
        makefile(os.path.join(self.path, '__init__.py'), exist_ok=True)

        a = time.time()
        for _type in self.TYPES:
            self.plugins[_type] = self.parse(_type)

        self.log.debug(
            'Created index of plugins for {0} in {1:.2f} ms'.format(
                self.path, (time.time() - a) * 1000)
        )
示例#4
0
    def parse(self, folder):
        """Analyze and parses all plugins in folder."""
        plugins = {}
        pfolder = os.path.join(self.path, folder)
        makefile(os.path.join(pfolder, '__init__.py'), exist_ok=True)

        for fname in os.listdir(pfolder):
            filepath = os.path.join(pfolder, fname)
            if os.path.isfile(filepath) and fname.endswith(
                    '.py') and not fname.startswith('_'):
                # replace suffix and version tag
                name = fname[:-3]
                if name[-1] == '.':
                    name = name[:-4]

                plugin = self.parse_plugin(os.path.join(pfolder, fname),
                                           folder, name)
                if plugin:
                    plugins[name] = plugin

        return plugins
示例#5
0
    def parse(self, folder):
        """Analyze and parses all plugins in folder."""
        plugins = {}
        pfolder = os.path.join(self.path, folder)
        makefile(os.path.join(pfolder, '__init__.py'), exist_ok=True)

        for fname in os.listdir(pfolder):
            filepath = os.path.join(pfolder, fname)
            if os.path.isfile(filepath) and fname.endswith(
                    '.py') and not fname.startswith('_'):
                # replace suffix and version tag
                name = fname[:-3]
                if name[-1] == '.':
                    name = name[:-4]

                plugin = self.parse_plugin(
                    os.path.join(pfolder, fname), folder, name)
                if plugin:
                    plugins[name] = plugin

        return plugins