def test_process_template_line(self): # testing all MANIFEST.in template patterns file_list = FileList() ml = make_local_path # simulated file list self.make_files([ 'foo.tmp', 'ok', 'xo', 'four.txt', 'buildout.cfg', # filelist does not filter out VCS directories, # it's sdist that does ml('.hg/last-message.txt'), ml('global/one.txt'), ml('global/two.txt'), ml('global/files.x'), ml('global/here.tmp'), ml('f/o/f.oo'), ml('dir/graft-one'), ml('dir/dir2/graft2'), ml('dir3/ok'), ml('dir3/sub/ok.txt'), ]) MANIFEST_IN = DALS("""\ include ok include xo exclude xo include foo.tmp include buildout.cfg global-include *.x global-include *.txt global-exclude *.tmp recursive-include f *.oo recursive-exclude global *.x graft dir prune dir3 """) for line in MANIFEST_IN.split('\n'): if not line: continue file_list.process_template_line(line) wanted = [ 'buildout.cfg', 'four.txt', 'ok', ml('.hg/last-message.txt'), ml('dir/graft-one'), ml('dir/dir2/graft2'), ml('f/o/f.oo'), ml('global/one.txt'), ml('global/two.txt'), ] file_list.sort() assert file_list.files == wanted
def test_process_template_line(self): # testing all MANIFEST.in template patterns file_list = FileList() ml = make_local_path # simulated file list self.make_files([ 'foo.tmp', 'ok', 'xo', 'four.txt', 'buildout.cfg', # filelist does not filter out VCS directories, # it's sdist that does ml('.hg/last-message.txt'), ml('global/one.txt'), ml('global/two.txt'), ml('global/files.x'), ml('global/here.tmp'), ml('f/o/f.oo'), ml('dir/graft-one'), ml('dir/dir2/graft2'), ml('dir3/ok'), ml('dir3/sub/ok.txt'), ]) MANIFEST_IN = DALS("""\ include ok include xo exclude xo include foo.tmp include buildout.cfg global-include *.x global-include *.txt global-exclude *.tmp recursive-include f *.oo recursive-exclude global *.x graft dir prune dir3 """) for line in MANIFEST_IN.split('\n'): if not line: continue file_list.process_template_line(line) wanted = [ 'buildout.cfg', 'four.txt', 'ok', ml('.hg/last-message.txt'), ml('dir/graft-one'), ml('dir/dir2/graft2'), ml('f/o/f.oo'), ml('global/one.txt'), ml('global/two.txt'), ] file_list.sort() assert file_list.files == wanted
def test_prune(self): ml = make_local_path # prune file_list = FileList() file_list.files = ['a.py', ml('d/b.py'), ml('d/d/e.py'), ml('f/f.py')] file_list.process_template_line('prune d') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] self.assertNoWarnings() file_list.process_template_line('prune e') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] self.assertWarnings()
def test_prune(self): ml = make_local_path # prune file_list = FileList() file_list.files = ['a.py', ml('d/b.py'), ml('d/d/e.py'), ml('f/f.py')] file_list.process_template_line('prune d') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] self.assertNoWarnings() file_list.process_template_line('prune e') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] self.assertWarnings()
def test_recursive_exclude(self): ml = make_local_path # recursive-exclude file_list = FileList() file_list.files = ['a.py', ml('d/b.py'), ml('d/c.txt'), ml('d/d/e.py')] file_list.process_template_line('recursive-exclude d *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] self.assertNoWarnings() file_list.process_template_line('recursive-exclude e *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] self.assertWarnings()
def test_graft(self): ml = make_local_path # graft file_list = FileList() self.make_files(['a.py', ml('d/b.py'), ml('d/d/e.py'), ml('f/f.py')]) file_list.process_template_line('graft d') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] self.assertNoWarnings() file_list.process_template_line('graft e') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] self.assertWarnings()
def test_include(self): ml = make_local_path # include file_list = FileList() self.make_files(['a.py', 'b.txt', ml('d/c.py')]) file_list.process_template_line('include *.py') file_list.sort() assert file_list.files == ['a.py'] self.assertNoWarnings() file_list.process_template_line('include *.rb') file_list.sort() assert file_list.files == ['a.py'] self.assertWarnings()
def test_global_exclude(self): ml = make_local_path # global-exclude file_list = FileList() file_list.files = ['a.py', 'b.txt', ml('d/c.py')] file_list.process_template_line('global-exclude *.py') file_list.sort() assert file_list.files == ['b.txt'] self.assertNoWarnings() file_list.process_template_line('global-exclude *.rb') file_list.sort() assert file_list.files == ['b.txt'] self.assertWarnings()
def test_recursive_include(self): l = make_local_path # recursive-include file_list = FileList() self.make_files(['a.py', l('d/b.py'), l('d/c.txt'), l('d/d/e.py')]) file_list.process_template_line('recursive-include d *.py') file_list.sort() assert file_list.files == [l('d/b.py'), l('d/d/e.py')] self.assertNoWarnings() file_list.process_template_line('recursive-include e *.py') file_list.sort() assert file_list.files == [l('d/b.py'), l('d/d/e.py')] self.assertWarnings()
def test_graft(self): ml = make_local_path # graft file_list = FileList() self.make_files(['a.py', ml('d/b.py'), ml('d/d/e.py'), ml('f/f.py')]) file_list.process_template_line('graft d') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] self.assertNoWarnings() file_list.process_template_line('graft e') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] self.assertWarnings()
def test_recursive_exclude(self): ml = make_local_path # recursive-exclude file_list = FileList() file_list.files = ['a.py', ml('d/b.py'), ml('d/c.txt'), ml('d/d/e.py')] file_list.process_template_line('recursive-exclude d *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] self.assertNoWarnings() file_list.process_template_line('recursive-exclude e *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] self.assertWarnings()
def test_global_exclude(self): ml = make_local_path # global-exclude file_list = FileList() file_list.files = ['a.py', 'b.txt', ml('d/c.py')] file_list.process_template_line('global-exclude *.py') file_list.sort() assert file_list.files == ['b.txt'] self.assertNoWarnings() file_list.process_template_line('global-exclude *.rb') file_list.sort() assert file_list.files == ['b.txt'] self.assertWarnings()
def test_include(self): ml = make_local_path # include file_list = FileList() self.make_files(['a.py', 'b.txt', ml('d/c.py')]) file_list.process_template_line('include *.py') file_list.sort() assert file_list.files == ['a.py'] self.assertNoWarnings() file_list.process_template_line('include *.rb') file_list.sort() assert file_list.files == ['a.py'] self.assertWarnings()
def test_exclude_pattern(self): # return False if no match file_list = FileList() assert not file_list.exclude_pattern('*.py') # return True if files match file_list = FileList() file_list.files = ['a.py', 'b.py'] assert file_list.exclude_pattern('*.py') # test excludes file_list = FileList() file_list.files = ['a.py', 'a.txt'] file_list.exclude_pattern('*.py') file_list.sort() assert file_list.files == ['a.txt']
def test_exclude_pattern(self): # return False if no match file_list = FileList() assert not file_list.exclude_pattern('*.py') # return True if files match file_list = FileList() file_list.files = ['a.py', 'b.py'] assert file_list.exclude_pattern('*.py') # test excludes file_list = FileList() file_list.files = ['a.py', 'a.txt'] file_list.exclude_pattern('*.py') file_list.sort() assert file_list.files == ['a.txt']
def test_include_pattern(self): # return False if no match file_list = FileList() self.make_files([]) assert not file_list.include_pattern('*.py') # return True if files match file_list = FileList() self.make_files(['a.py', 'b.txt']) assert file_list.include_pattern('*.py') # test * matches all files file_list = FileList() self.make_files(['a.py', 'b.txt']) file_list.include_pattern('*') file_list.sort() assert file_list.files == ['a.py', 'b.txt']
def test_include_pattern(self): # return False if no match file_list = FileList() self.make_files([]) assert not file_list.include_pattern('*.py') # return True if files match file_list = FileList() self.make_files(['a.py', 'b.txt']) assert file_list.include_pattern('*.py') # test * matches all files file_list = FileList() self.make_files(['a.py', 'b.txt']) file_list.include_pattern('*') file_list.sort() assert file_list.files == ['a.py', 'b.txt']
class ManifestMaker(_ManifestMaker): """Generate a Manifest using Cythonized source files """ def run(self): """Run the command. """ self.filelist = FileList() if not os.path.exists(self.manifest): self.write_manifest() self.filelist.findall() self.add_defaults() if os.path.exists(self.template): self.read_template() self.prune_file_list() # Replace python with c files self.update_sources() self.filelist.sort() self.filelist.remove_duplicates() self.write_manifest() def update_sources(self): """Update the Python files with the C files using cdist options. """ cdist_cmd = self.get_finalized_command('cdist') old_filelist, self.filelist.files = self.filelist.files[:], [] for filename in old_filelist: for pattern in cdist_cmd.exclude_sources: if globstar_match(filename, pattern): self.filelist.append(filename) break else: root, ext = os.path.splitext(filename) if ext[1:] in cdist_cmd.source_extensions: original = filename filename = root + '.c' cdist_cmd.python_sources[original] = filename self.filelist.append(filename)