Best Python code snippet using avocado_python
insar.py
Source:insar.py  
...37                files.append(output)38        return files39    def create_readme(self) -> Path:40        reference_file = self.product_dir / f'{self.product_name}_amp.tif'41        return self.create_metadata_file(self.payload, 'insar/readme.md.txt.j2', reference_file,42                                         out_ext='README.md.txt',43                                         strip_ext=True, name_only=True)44    def create_amp_xml(self) -> Path:45        reference_file = self.product_dir / f'{self.product_name}_amp.tif'46        return self.create_metadata_file(self.payload, 'insar/amp_tif.xml.j2', reference_file)47    def create_coherence_xml(self) -> Path:48        reference_file = self.product_dir / f'{self.product_name}_corr.tif'49        return self.create_metadata_file(self.payload, 'insar/corr_tif.xml.j2', reference_file)50    def create_dem_tif_xml(self) -> Path:51        reference_file = self.product_dir / f'{self.product_name}_dem.tif'52        return self.create_metadata_file(self.payload, 'insar/dem.xml.j2', reference_file)53    def create_los_displacement_xml(self) -> Path:54        reference_file = self.product_dir / f'{self.product_name}_los_disp.tif'55        return self.create_metadata_file(self.payload, 'insar/los_disp_tif.xml.j2', reference_file)56    def create_look_vector_xmls(self) -> List[Path]:57        reference_file_phi = self.product_dir / f'{self.product_name}_lv_phi.tif'58        reference_file_theta = self.product_dir / f'{self.product_name}_lv_theta.tif'59        output_files = [60            self.create_metadata_file(self.payload, 'insar/lv_phi_tif.xml.j2', reference_file_phi),61            self.create_metadata_file(self.payload, 'insar/lv_theta_tif.xml.j2', reference_file_theta),62        ]63        return output_files64    def create_browse_xmls(self) -> List[Path]:65        reference_file_col = self.product_dir / f'{self.product_name}_color_phase.png'66        reference_file_unw = self.product_dir / f'{self.product_name}_unw_phase.png'67        output_files = [68            self.create_metadata_file(self.payload, 'insar/color_phase_png.xml.j2', reference_file_col),69            self.create_metadata_file(self.payload, 'insar/unw_phase_png.xml.j2', reference_file_unw),70        ]71        return output_files72    def create_unwrapped_phase_xml(self) -> Path:73        reference_file = self.product_dir / f'{self.product_name}_unw_phase.tif'74        return self.create_metadata_file(self.payload, 'insar/unw_phase_tif.xml.j2', reference_file)75    def create_vertical_displacement_xml(self) -> Path:76        reference_file = self.product_dir / f'{self.product_name}_vert_disp.tif'77        return self.create_metadata_file(self.payload, 'insar/vert_disp_tif.xml.j2', reference_file)78    def create_wrapped_phase_xml(self) -> Path:79        reference_file = self.product_dir / f'{self.product_name}_wrapped_phase.tif'80        return self.create_metadata_file(self.payload, 'insar/wrapped_phase_tif.xml.j2', reference_file)81    def create_inc_map_xml(self) -> Path:82        reference_file = self.product_dir / f'{self.product_name}_inc_map.tif'83        return self.create_metadata_file(self.payload, 'insar/inc_map_tif.xml.j2', reference_file)84    def create_inc_map_ell_xml(self) -> Path:85        reference_file = self.product_dir / f'{self.product_name}_inc_map_ell.tif'86        return self.create_metadata_file(self.payload, 'insar/inc_map_ell_tif.xml.j2', reference_file)87    def create_water_mask_xml(self) -> Path:88        reference_file = self.product_dir / f'{self.product_name}_water_mask.tif'89        return self.create_metadata_file(self.payload, 'insar/water_mask_tif.xml.j2', reference_file)90    @classmethod91    def create_metadata_file(cls, payload: dict, template: str, reference_file: Path, out_ext: str = 'xml',92                             strip_ext: bool = False, name_only=False) -> Optional[Path]:93        if not reference_file.exists():94            return None95        payload = deepcopy(payload)96        info = gdal.Info(str(reference_file), format='json')97        payload['reference_file'] = reference_file.name98        payload['pixel_spacing'] = info['geoTransform'][1]99        payload['projection'] = util.get_projection(info['coordinateSystem']['wkt'])100        if reference_file.suffix == '.png':101            payload['thumbnail_encoded_string'] = util.get_thumbnail_encoded_string(reference_file)102        else:103            payload['thumbnail_encoded_string'] = ''104        content = util.render_template(template, payload)105        out_name = reference_file.name if not strip_ext else reference_file.stem...rtc.py
Source:rtc.py  
...32        return files33    def create_readme(self) -> Path:34        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_' \35                                                       f'{self.payload["polarizations"][0]}.tif'36        return self.create_metadata_file(self.payload, 'rtc/readme.md.txt.j2', reference_file, out_ext='README.md.txt',37                                         strip_ext=True, strip_pol=True38                                         )39    def create_product_xmls(self) -> List[Path]:40        payload = deepcopy(self.payload)41        output_files = []42        for pol in payload['polarizations']:43            payload['pol'] = pol44            reference_file = payload['product_dir'] / f'{payload["product_dir"].name}_{pol}.tif'45            output_files.append(46                self.create_metadata_file(payload, 'rtc/product.xml.j2', reference_file)47            )48        return output_files49    def create_dem_xml(self) -> Path:50        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_dem.tif'51        dem_template_id = get_dem_template_id(self.payload['dem_name'])52        if dem_template_id is not None:53            return self.create_metadata_file(self.payload, f'dem/dem-{dem_template_id}.xml.j2', reference_file)54    def create_browse_xmls(self) -> List[Path]:55        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}.png'56        output_files = [57            self.create_metadata_file(self.payload, 'browse/browse-greyscale.xml.j2', reference_file),58        ]59        rgb_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_rgb.png'60        if rgb_file.exists():61            output_files.append(62                self.create_metadata_file(self.payload, 'browse/browse-color.xml.j2', rgb_file)63            )64        return output_files65    def create_inc_map_xml(self) -> Path:66        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_inc_map.tif'67        return self.create_metadata_file(self.payload, 'rtc/inc_map.xml.j2', reference_file)68    def create_ls_map_xml(self) -> Path:69        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_ls_map.tif'70        return self.create_metadata_file(self.payload, 'rtc/ls_map.xml.j2', reference_file)71    def create_area_xml(self) -> Path:72        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_area.tif'73        return self.create_metadata_file(self.payload, 'rtc/area.xml.j2', reference_file)74    def create_rgb_xml(self) -> Path:75        reference_file = self.payload['product_dir'] / f'{self.payload["product_dir"].name}_rgb.tif'76        return self.create_metadata_file(self.payload, 'rtc/rgb.xml.j2', reference_file)77    @classmethod78    def create_metadata_file(cls, payload: dict, template: str, reference_file: Path, out_ext: str = 'xml',79                             strip_ext: bool = False, strip_pol: bool = False) -> Optional[Path]:80        if not reference_file.exists():81            return None82        payload = deepcopy(payload)83        info = gdal.Info(str(reference_file), format='json')84        payload['reference_file'] = reference_file.name85        payload['pixel_spacing'] = info['geoTransform'][1]86        payload['projection'] = util.get_projection(info['coordinateSystem']['wkt'])87        browse_file = reference_file.with_suffix('.png')88        browse_file = browse_file.parent / util.strip_polarization(browse_file.name)89        payload['thumbnail_encoded_string'] = util.get_thumbnail_encoded_string(browse_file)90        content = util.render_template(template, payload)91        out_name = reference_file.name if not strip_ext else reference_file.stem92        if strip_pol:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
