Esempio n. 1
0
    def _get_files_without_assistants(cls, dap, dirname, files):
        folders = set()
        assistants = set()
        assistant_dirs = set(['crt', 'twk', 'prep', 'extra'])

        for f in files:
            # Directories
            if dap._is_dir(f):
                prefix = os.path.join(dirname, 'files', '')
                if f.startswith(prefix):
                    remainder = strip_prefix(f, prefix)  # crt/foo/bar/baz
                    name = os.path.join(*remainder.split(
                        os.path.sep)[:2])  # crt/foo
                    folders.add(name)
            else:
                # Assistants
                prefix = os.path.join(dirname, 'assistants', '')
                remainder = strip_prefix(f, prefix)
                for kind in assistant_dirs:
                    if remainder.startswith(kind + os.path.sep):
                        name = strip_suffix(remainder, '.yaml')
                        assistants.add(name)

                # Snippets
                prefix = os.path.join(dirname, 'snippets', '')
                if f.startswith(prefix):
                    name = strip_suffix(strip_prefix(f, dirname + os.path.sep),
                                        '.yaml')
                    assistants.add(name)

        return list(folders - assistant_dirs - set(('snippets', )) -
                    assistants)
Esempio n. 2
0
    def _get_files_without_assistants(cls, dap, dirname, files):
        folders = set()
        assistants = set()
        assistant_dirs = set(['crt', 'twk', 'prep', 'extra'])

        for f in files:
            # Directories
            if dap._is_dir(f):
                prefix = os.path.join(dirname, 'files', '')
                if f.startswith(prefix):
                    remainder = strip_prefix(f, prefix) # crt/foo/bar/baz
                    name = os.path.join(*remainder.split(os.path.sep)[:2]) # crt/foo
                    folders.add(name)
            else:
                # Assistants
                prefix = os.path.join(dirname, 'assistants', '')
                remainder = strip_prefix(f, prefix)
                for kind in assistant_dirs:
                    if remainder.startswith(kind + os.path.sep):
                        name = strip_suffix(remainder, '.yaml')
                        assistants.add(name)

                # Snippets
                prefix = os.path.join(dirname, 'snippets', '')
                if f.startswith(prefix):
                    name = strip_suffix(strip_prefix(f, dirname + os.path.sep), '.yaml')
                    assistants.add(name)

        return list(folders - assistant_dirs - set(('snippets',)) - assistants)
Esempio n. 3
0
    def icons(self, strip_ext=False):
        '''Get all icons in this DAP, optionally strip extensions'''
        result =  [f for f in self._stripped_files if self._icons_pattern.match(f)]
        if strip_ext:
            result = [strip_suffix(f, '\.({ext})'.format(ext=self._icons_ext), regex=True) for f in result]

        return result
Esempio n. 4
0
    def icons(self, strip_ext=False):
        '''Get all icons in this DAP, optionally strip extensions'''
        result = [
            f for f in self._stripped_files if self._icons_pattern.match(f)
        ]
        if strip_ext:
            result = [
                strip_suffix(f,
                             '\.({ext})'.format(ext=self._icons_ext),
                             regex=True) for f in result
            ]

        return result
Esempio n. 5
0
 def test_fails(self, inp, suffix):
     with pytest.raises(TypeError) as e:
         utils.strip_suffix(inp, suffix)
Esempio n. 6
0
 def test_strip_regex(self, inp, prefix, out):
     assert utils.strip_suffix(inp, prefix, regex=True) == out
Esempio n. 7
0
 def test_strip_noregex(self, inp, suffix, out):
     assert utils.strip_suffix(inp, suffix) == out
Esempio n. 8
0
 def snippets(self):
     '''Get all snippets in this DAP'''
     return [strip_suffix(f, '.yaml') for f in self._stripped_files if self._snippets_pattern.match(f)]
Esempio n. 9
0
 def snippets(self):
     '''Get all snippets in this DAP'''
     return [
         strip_suffix(f, '.yaml') for f in self._stripped_files
         if self._snippets_pattern.match(f)
     ]
Esempio n. 10
0
 def test_fails(self, inp, suffix):
     with pytest.raises(TypeError) as e:
         utils.strip_suffix(inp, suffix)
Esempio n. 11
0
 def test_strip_regex(self, inp, prefix, out):
     assert utils.strip_suffix(inp, prefix, regex=True) == out
Esempio n. 12
0
 def test_strip_noregex(self, inp, suffix, out):
     assert utils.strip_suffix(inp, suffix) == out