mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	integrations: Extend screenshot tool for more flexibility.
This allows the user to skip generating screenshots up to certain integration when working through generating screenshots for all integrations. This also allow the user to select a number of integrations to selectively generate screenshots for.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							e8a6f6a313
						
					
				
				
					commit
					d1455d81f2
				
			@@ -252,7 +252,11 @@ def generate_screenshot_from_config(
 | 
			
		||||
parser = argparse.ArgumentParser()
 | 
			
		||||
group = parser.add_mutually_exclusive_group(required=True)
 | 
			
		||||
group.add_argument("--all", action="store_true")
 | 
			
		||||
group.add_argument("--integration", help="Name of the integration")
 | 
			
		||||
group.add_argument(
 | 
			
		||||
    "--skip-until", help="Name of the integration whose predecessor are skipped. Similar to --all"
 | 
			
		||||
)
 | 
			
		||||
group.add_argument("--integration", nargs="+", help="Names of the integrations")
 | 
			
		||||
fixture_group = parser.add_argument_group("integration")
 | 
			
		||||
parser.add_argument("--fixture", help="Name of the fixture file to use")
 | 
			
		||||
parser.add_argument("--image-name", help="Name for the screenshot image")
 | 
			
		||||
parser.add_argument("--image-dir", help="Directory name where to save the screenshot image")
 | 
			
		||||
@@ -281,11 +285,32 @@ if options.all:
 | 
			
		||||
    for key, value in vars(options).items():
 | 
			
		||||
        if key != "all" and value:
 | 
			
		||||
            print("Generating screenshots for all integrations. Ignoring all command-line options")
 | 
			
		||||
            break
 | 
			
		||||
    for integration_name, screenshot_configs in DOC_SCREENSHOT_CONFIG.items():
 | 
			
		||||
        for screenshot_config in screenshot_configs:
 | 
			
		||||
            generate_screenshot_from_config(integration_name, screenshot_config)
 | 
			
		||||
 | 
			
		||||
elif options.skip_until:
 | 
			
		||||
    for key, value in vars(options).items():
 | 
			
		||||
        if key != "skip_until" and value:
 | 
			
		||||
            print(
 | 
			
		||||
                f"Generating screenshots for all integrations skipping until {options.skip_until}. Ignoring all command-line options"
 | 
			
		||||
            )
 | 
			
		||||
            break
 | 
			
		||||
    skip = True
 | 
			
		||||
    for integration_name, screenshot_configs in DOC_SCREENSHOT_CONFIG.items():
 | 
			
		||||
        if integration_name == options.skip_until:
 | 
			
		||||
            skip = False
 | 
			
		||||
        if skip:
 | 
			
		||||
            continue
 | 
			
		||||
        for screenshot_config in screenshot_configs:
 | 
			
		||||
            generate_screenshot_from_config(integration_name, screenshot_config)
 | 
			
		||||
 | 
			
		||||
elif options.fixture:
 | 
			
		||||
    if len(options.integration) != 1:
 | 
			
		||||
        parser.error(
 | 
			
		||||
            "Exactly one integration should be specified for --integration when --fixture is provided"
 | 
			
		||||
        )
 | 
			
		||||
    config = dict(
 | 
			
		||||
        fixture_name=options.fixture,
 | 
			
		||||
        use_basic_auth=options.use_basic_auth,
 | 
			
		||||
@@ -301,12 +326,14 @@ elif options.fixture:
 | 
			
		||||
    if options.payload_param_name:
 | 
			
		||||
        config["payload_param_name"] = options.payload_param_name
 | 
			
		||||
    screenshot_config = ScreenshotConfig(**config)
 | 
			
		||||
    generate_screenshot_from_config(options.integration, screenshot_config)
 | 
			
		||||
    generate_screenshot_from_config(options.integration[0], screenshot_config)
 | 
			
		||||
 | 
			
		||||
elif options.integration in DOC_SCREENSHOT_CONFIG:
 | 
			
		||||
    configs = DOC_SCREENSHOT_CONFIG[options.integration]
 | 
			
		||||
elif options.integration:
 | 
			
		||||
    for integration in options.integration:
 | 
			
		||||
        assert integration in DOC_SCREENSHOT_CONFIG
 | 
			
		||||
        configs = DOC_SCREENSHOT_CONFIG[integration]
 | 
			
		||||
        for screenshot_config in configs:
 | 
			
		||||
        generate_screenshot_from_config(options.integration, screenshot_config)
 | 
			
		||||
            generate_screenshot_from_config(integration, screenshot_config)
 | 
			
		||||
 | 
			
		||||
else:
 | 
			
		||||
    parser.error(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user