示例#1
0
def package (project, logger):
    globs = project.get_mandatory_property("copy_resources_glob")
    if not globs:
        logger.warn("No resources to copy configured. Consider removing plugin.")
        return
    
    source = project.basedir
    target = project.expand_path("$copy_resources_target")
    logger.info("Copying resources matching '%s' from %s to %s", " ".join(globs), source, target)
    
    apply_on_files(source, copy_resource, globs, target, logger)
示例#2
0
 def test_should_apply_callback_to_one_file_when_expression_matches_one_file (self):
     when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])
     
     called_on_file = []
     
     def callback (absolute_file_name, relative_file_name):
         called_on_file.append(absolute_file_name)
     
     apply_on_files("spam", callback, "a")
     self.assertEquals(["spam/a"], called_on_file)
     
     verify(os).walk("spam")
def filter_resources (project, logger):
    globs = project.get_mandatory_property("filter_resources_glob")
    if not globs:
        logger.warn("No resources to filter configured. Consider removing plugin.")
        return
    
    target = project.expand_path("$filter_resources_target")
    logger.info("Filter resources matching %s in %s", " ".join(globs), target)
    
    project_dict_wrapper = ProjectDictWrapper(project)
    
    apply_on_files(target, filter_resource, globs, project_dict_wrapper, logger)
示例#4
0
 def test_should_pass_additional_arguments_to_closure (self):
     when(os).walk("spam").thenReturn([("spam", [], ["a"])])
     
     called_on_file = []
     
     def callback (absolute_file_name, relative_file_name, additional_argument):
         self.assertEquals("additional argument", additional_argument)
         called_on_file.append(absolute_file_name)
     
     apply_on_files("spam", callback, "a", "additional argument")
     self.assertEquals(["spam/a"], called_on_file)
     
     verify(os).walk("spam")
示例#5
0
 def test_should_apply_callback_to_all_files_when_expression_matches_all_files (self):
     when(os).walk("spam").thenReturn([("spam", [], ["a", "b", "c"])])
     
     absolute_file_names = []
     relative_file_names = []
     
     def callback (absolute_file_name, relative_file_name):
         absolute_file_names.append(absolute_file_name)
         relative_file_names.append(relative_file_name)
     
     apply_on_files("spam", callback, "*")
     self.assertEquals(["spam/a", "spam/b", "spam/c"], absolute_file_names)
     self.assertEquals(["a", "b", "c"], relative_file_names)
     
     verify(os).walk("spam")