Пример #1
0
def test_expand_globs(testing_workdir):
    sub_dir = os.path.join(testing_workdir, 'sub1')
    os.mkdir(sub_dir)
    ssub_dir = os.path.join(sub_dir, 'ssub1')
    os.mkdir(ssub_dir)
    files = [
        'abc', 'acb',
        os.path.join(sub_dir, 'def'),
        os.path.join(sub_dir, 'abc'),
        os.path.join(ssub_dir, 'ghi'),
        os.path.join(ssub_dir, 'abc')
    ]
    for f in files:
        with open(f, 'w') as _f:
            _f.write('weee')

    # Test dirs
    exp = utils.expand_globs([os.path.join('sub1', 'ssub1')], testing_workdir)
    assert sorted(exp) == sorted([
        os.path.sep.join(('sub1', 'ssub1', 'ghi')),
        os.path.sep.join(('sub1', 'ssub1', 'abc'))
    ])

    # Test files
    exp = sorted(utils.expand_globs(['abc', files[2]], testing_workdir))
    assert exp == sorted(['abc', os.path.sep.join(('sub1', 'def'))])

    # Test globs
    exp = sorted(utils.expand_globs(['a*', '*/*f', '**/*i'], testing_workdir))
    assert exp == sorted([
        'abc', 'acb',
        os.path.sep.join(('sub1', 'def')),
        os.path.sep.join(('sub1', 'ssub1', 'ghi'))
    ])
Пример #2
0
def test_expand_globs(testing_workdir):
    files = ['abc', 'acb']
    for f in files:
        with open(f, 'w') as _f:
            _f.write('weee')
    assert utils.expand_globs(files, testing_workdir) == files
    assert utils.expand_globs(['a*'], testing_workdir) == files
Пример #3
0
def test_expand_globs(testing_workdir):
    files = ['abc', 'acb']
    for f in files:
        with open(f, 'w') as _f:
            _f.write('weee')
    assert utils.expand_globs(files, testing_workdir) == files
    assert utils.expand_globs(['a*'], testing_workdir) == files
Пример #4
0
def test_expand_globs(testing_workdir):
    sub_dir = os.path.join(testing_workdir, 'sub1')
    os.mkdir(sub_dir)
    ssub_dir = os.path.join(sub_dir, 'ssub1')
    os.mkdir(ssub_dir)
    files = ['abc', 'acb',
             os.path.join(sub_dir, 'def'),
             os.path.join(sub_dir, 'abc'),
             os.path.join(ssub_dir, 'ghi'),
             os.path.join(ssub_dir, 'abc')]
    for f in files:
        with open(f, 'w') as _f:
            _f.write('weee')

    # Test dirs
    exp = utils.expand_globs([os.path.join('sub1', 'ssub1')], testing_workdir)
    assert sorted(exp) == sorted([os.path.sep.join(('sub1', 'ssub1', 'ghi')),
                                  os.path.sep.join(('sub1', 'ssub1', 'abc'))])

    # Test files
    exp = sorted(utils.expand_globs(['abc', files[2]], testing_workdir))
    assert exp == sorted(['abc', os.path.sep.join(('sub1', 'def'))])

    # Test globs
    exp = sorted(utils.expand_globs(['a*', '*/*f', '**/*i'], testing_workdir))
    assert exp == sorted(['abc', 'acb', os.path.sep.join(('sub1', 'def')),
                          os.path.sep.join(('sub1', 'ssub1', 'ghi'))])
Пример #5
0
    def always_include_files(self):
        files = ensure_list(self.get_value('build/always_include_files', []))
        if any('\\' in i for i in files):
            raise RuntimeError("build/always_include_files paths must use / "
                               "as the path delimiter on Windows")
        if on_win:
            files = [f.replace("/", "\\") for f in files]

        return expand_globs(files, self.config.build_prefix)
Пример #6
0
 def binary_has_prefix_files(self):
     ret = ensure_list(self.get_value('build/binary_has_prefix_files', []))
     if not isinstance(ret, list):
         raise RuntimeError('build/binary_has_prefix_files should be a list of paths')
     if sys.platform == 'win32':
         if any('\\' in i for i in ret):
             raise RuntimeError("build/binary_has_prefix_files paths must use / "
                                "as the path delimiter on Windows")
     return expand_globs(ret, self.config.build_prefix)
Пример #7
0
 def binary_has_prefix_files(self):
     ret = ensure_list(self.get_value('build/binary_has_prefix_files', []))
     if not isinstance(ret, list):
         raise RuntimeError('build/binary_has_prefix_files should be a list of paths')
     if sys.platform == 'win32':
         if any('\\' in i for i in ret):
             raise RuntimeError("build/binary_has_prefix_files paths must use / "
                                "as the path delimiter on Windows")
     return expand_globs(ret, self.config.build_prefix)
Пример #8
0
    def always_include_files(self):
        files = ensure_list(self.get_value('build/always_include_files', []))
        if any('\\' in i for i in files):
            raise RuntimeError("build/always_include_files paths must use / "
                                "as the path delimiter on Windows")
        if on_win:
            files = [f.replace("/", "\\") for f in files]

        return expand_globs(files, self.config.build_prefix)
Пример #9
0
 def binary_relocation(self):
     ret = self.get_value('build/binary_relocation', True)
     if type(ret) not in (list, bool):
         raise RuntimeError('build/ignore_prefix_files should be boolean or a list of paths '
                            '(optionally globs)')
     if sys.platform == 'win32':
         if type(ret) is list and any('\\' in i for i in ret):
             raise RuntimeError("build/ignore_prefix_files paths must use / "
                                "as the path delimiter on Windows")
     return expand_globs(ret, self.config.build_prefix) if type(ret) is list else ret
Пример #10
0
 def binary_relocation(self):
     ret = self.get_value('build/binary_relocation', True)
     if type(ret) not in (list, bool):
         raise RuntimeError('build/ignore_prefix_files should be boolean or a list of paths '
                            '(optionally globs)')
     if sys.platform == 'win32':
         if type(ret) is list and any('\\' in i for i in ret):
             raise RuntimeError("build/ignore_prefix_files paths must use / "
                                "as the path delimiter on Windows")
     return expand_globs(ret, self.config.build_prefix) if type(ret) is list else ret