Esempio n. 1
0
    def categorize_type(self, options, path, subdirs, files):
        """
        :returns: list of String
        """
        result = {}
        if files is None:
            if os.path.basename(os.path.dirname(path)) in ["nodes", "scripts", "script"]:
                if is_script(path):
                    result[path] = ["script"]
        else:
            if os.path.basename(path) in ["nodes", "scripts", "script"]:
                for filename in files:
                    fullname = os.path.join(path, filename)
                    if not filename.endswith(".py") and is_script(fullname):
                        result[fullname] = ["script"]
                return result

            if os.path.basename(path) in ["srv", "msg", "cfg"]:
                is_generated = False
                for filename in files:
                    if filename == "__init__.py":
                        is_generated = True
                if is_generated:
                    result[path] = ["generated"]
                    return result
                else:
                    result[path] = [os.path.basename(path)]
            if "stack.xml" in files:
                result[os.path.join(path)] = ["rosstack"]
            if "manifest.xml" in files:
                result[os.path.join(path)] = ["rospackage"]
        return result
Esempio n. 2
0
    def categorize_type(self, options, path, subdirs, files):
        result = {}
        if files is not None:
            if os.path.basename(path) in ['bin', 'scripts']:
                for filename in files:
                    fullname = os.path.join(path, filename)
                    if is_script(fullname):
                        result[fullname] = ['script']
        else:
            if is_script(path):
                result[path] = ['script']

        path_elts = splitpath(path)
        if 'doc' in path_elts or 'doc-pak' in path_elts:
            if path not in result:
                result[path] = ['doc']
            else:
                result[path].append('doc')

        # only categorize actual test folder as tests, so pointing at
        # resource below works without -t option
        if path_elts[-1] in ['test', 'tests']:
            if path not in result:
                result[path] = ['test']
            else:
                result[path].append('test')

        if not files:
            files = [path]

        for filepath in files:
            if os.path.islink(path) and \
                    not os.path.exists(os.readlink(filepath)):
                result[fullname] = ['broken']
            filename = os.path.basename(filepath)

            def _categorize(path, filepath, category):
                'assigns hidden and backup category'
                if filepath != path:
                    filepath = os.path.join(path, filepath)
                result[filepath] = [category]

            for prefix in ['.', '#']:
                if filename.startswith(prefix):
                    _categorize(path, filepath, 'hidden')
                    break
            for suffix in ['~', '.orig', '.bak']:
                if filename.endswith(suffix):
                    _categorize(path, filepath, 'backup')
                    break
            for infix in ['.BACKUP.', '.BASE.', '.LOCAL.', '.REMOTE.']:
                if infix in filename:
                    _categorize(path, filepath, 'backup')
                    break
        return result