当前位置: 首页>>代码示例>>Python>>正文


Python Project.get_files方法代码示例

本文整理汇总了Python中chiptools.core.project.Project.get_files方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_files方法的具体用法?Python Project.get_files怎么用?Python Project.get_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chiptools.core.project.Project的用法示例。


在下文中一共展示了Project.get_files方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_preprocessor

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
 def test_preprocessor(self):
     """Invalid preprocessors should not be executed on files."""
     project = Project()
     project.load_project(self.project_path)
     files = project.get_files()
     preprocessors = list(
         filter(
             lambda x: os.path.exists(x.preprocessor), files
         )
     )
     self.assertTrue(len(preprocessors) > 0)
     project.run_preprocessors()
     regex = re.compile('library ieee;')
     for libname in self.project_structure.keys():
         files = self.project_structure[libname]
         for path in files:
             path = os.path.join(self.root, libname, path)
             with open(path, 'r') as f:
                 data = f.readlines()
                 match = regex.match(data[0])
                 self.assertIsNotNone(
                     match,
                     msg='File {0} was not correctly preserved.'.format(
                         path
                     )
                 )
开发者ID:pabennett,项目名称:chiptools,代码行数:28,代码来源:test_project.py

示例2: testPreprocessor

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
 def testPreprocessor(self):
     project = Project()
     XmlProjectParser.load_project(self.project_path, project)
     files = project.get_files()
     preprocessors = list(
         filter(
             lambda x: os.path.exists(x.preprocessor), files
         )
     )
     self.assertTrue(len(preprocessors) > 0)
     project.run_preprocessors()
开发者ID:hoangt,项目名称:chiptools,代码行数:13,代码来源:testProjectFunctionality.py

示例3: testFileSet

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
    def testFileSet(self):
        project = Project()

        expected_files = []
        for libname in self.project_structure.keys():
            files = self.project_structure[libname]
            for path in files:
                expected_files.append(os.path.basename(path))
                project.add_file(path, libname)

        self.assertEqual(
            sorted(expected_files),
            sorted([os.path.basename(f.path) for f in project.get_files()]),
        )
开发者ID:hoangt,项目名称:chiptools,代码行数:16,代码来源:testProjectFunctionality.py

示例4: locateProjects

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
 def locateProjects(self):
     """
     Return a list of projects found in the current path.
     """
     projects = []
     logging.getLogger("chiptools").setLevel(
         logging.CRITICAL
     )
     for filePath in os.listdir(os.getcwd()):
         if filePath.endswith('.xml'):
             try:
                 tempProject = Project()
                 # Load the XML file
                 XmlProjectParser.load_project(filePath, tempProject)
                 # If the project contains files we can add it to our list
                 files = tempProject.get_files()
                 files = files if files is not None else []
                 if len(files) != 0:
                     projects.append(filePath)
             except:
                 pass
     logging.getLogger("chiptools").setLevel(logging.INFO)
     return projects
开发者ID:hoangt,项目名称:chiptools,代码行数:25,代码来源:cli.py

示例5: testAddAll

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
    def testAddAll(self):
        project = Project()
        expected_files = []
        expected_libs = []
        for libname in self.project_structure.keys():
            files = self.project_structure[libname]
            expected_libs.append(libname)
            project.add_files(
                root=os.path.join(self.root, libname),
                library=libname,
                pattern='*.vhd'
            )
            for path in files:
                expected_files.append(os.path.basename(path))

        self.assertEqual(
            sorted(expected_files),
            sorted([os.path.basename(f.path) for f in project.get_files()]),
        )

        self.assertEqual(
            sorted(expected_libs),
            sorted(list(project.get_libraries()),)
        )
开发者ID:hoangt,项目名称:chiptools,代码行数:26,代码来源:testProjectFunctionality.py

示例6: CommandLine

# 需要导入模块: from chiptools.core.project import Project [as 别名]
# 或者: from chiptools.core.project.Project import get_files [as 别名]
class CommandLine(cmd.Cmd):
    def __init__(self, project=None):
        super(CommandLine, self).__init__()
        prj = ''
        if project is None:
            try:
                self.project = Project()
                projects = self.locateProjects()
                if len(projects) > 0:
                    prj = (
                        'Type ' + term.colourise(
                            '\'load_project <path>\'', fg='yellow'
                        ) +
                        ' to load a project.\n'
                    )
                    prj += (
                        'The current directory contains ' +
                        'the following projects:\n'
                    )
                    prj += term.colourise(
                        '\n'.join('\t{0}: {1}'.format(
                            idx+1,
                            path
                        ) for idx, path in enumerate(projects)),
                        fg='yellow'
                    )
                    self.intro = INTRO_TEMPL % dict(
                        version=_version.__version__,
                        projects=prj,
                    )
            except exceptions.ProjectFileException:
                log.error(
                    'The project file contains errors, ' +
                    'fix them and then type \'reload\''
                )
            except:
                log.error(
                    'The software has to terminate due to the following error:'
                )
                log.error(traceback.format_exc())
                sys.exit(1)
        else:
            self.project = project
            prj = (
                'Project contains ' + term.colourise(
                    str(len(self.project.get_files())),
                    fg='yellow'
                ) + ' file(s) and ' + term.colourise(
                    str(len(self.project.get_tests())),
                    fg='yellow'
                ) + ' test(s).'
            )
            self.intro = INTRO_TEMPL % dict(
                version=_version.__version__,
                projects=prj,
            )

        self.test_set = set()

    def locateProjects(self):
        """
        Return a list of projects found in the current path.
        """
        projects = []
        logging.getLogger("chiptools").setLevel(
            logging.CRITICAL
        )
        for filePath in os.listdir(os.getcwd()):
            if filePath.endswith('.xml'):
                try:
                    tempProject = Project()
                    # Load the XML file
                    XmlProjectParser.load_project(filePath, tempProject)
                    # If the project contains files we can add it to our list
                    files = tempProject.get_files()
                    files = files if files is not None else []
                    if len(files) != 0:
                        projects.append(filePath)
                except:
                    pass
        logging.getLogger("chiptools").setLevel(logging.INFO)
        return projects

    @wraps_do_commands
    def do_load_project(self, path):
        """Load the given project XML file: load_project <path_to_project>"""
        path = os.path.abspath(path)
        if os.path.exists(path) and os.path.isfile(path):
            try:
                log.info(
                    'Loading {0} in current working directory: {1}'.format(
                        path,
                        os.getcwd()
                    )
                )
                XmlProjectParser.load_project(path, self.project)
            except:
                log.error('The project could not be loaded due to an error:')
                log.error(traceback.format_exc())
        else:
#.........这里部分代码省略.........
开发者ID:hoangt,项目名称:chiptools,代码行数:103,代码来源:cli.py


注:本文中的chiptools.core.project.Project.get_files方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。