def test_make_project_survey_label_from_path(self): prj = BaseProject(projects_folder=None) survey_label = prj.make_survey_label_from_path("fake/H012345") self.assertTrue(len(survey_label) != 0) self.assertTrue(len(survey_label) == 6) self.assertEqual(survey_label, "H01234")
def _bag_checks_v1(self, grid_file: str, idx: int, total: int) -> bool: quantum = 100.0 / total cur_quantum = quantum * idx self.progress.update(value=cur_quantum + quantum * 0.05, text="[%d/%d] File opening" % (idx + 1, total)) # we want to be sure that the label is based on the name of the new file input self._survey = BaseProject.make_survey_label_from_path(grid_file) self._grid_basename = os.path.basename(grid_file) # skip CSAR if not bag.BAGFile.is_bag(bag_path=grid_file): # skip CSAR logger.debug('not a BAG file: %s' % grid_file) return False self._is_vr = bag.BAGFile.is_vr(bag_path=grid_file) if self._is_vr: logger.debug('detected VR BAG') self._bc_report = Report(lib_name=lib_name, lib_version=lib_version) self.progress.update(value=cur_quantum + quantum * 0.15, text="[%d/%d] Structure checking" % (idx + 1, total)) self._bag_checks_v1_structure(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.3, text="[%d/%d] Metadata checking" % (idx + 1, total)) self._bag_checks_v1_metadata(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.5, text="[%d/%d] Elevation checking" % (idx + 1, total)) self._bag_checks_v1_elevation(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.7, text="[%d/%d] Uncertainty checking" % (idx + 1, total)) self._bag_checks_v1_uncertainty(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.85, text="[%d/%d] Tracking list checking" % (idx + 1, total)) self._bag_checks_v1_tracking_list(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.95, text="[%d/%d] Summary" % (idx + 1, total)) self._bag_checks_v1_summary() output_pdf = os.path.join( self.bagchecks_output_folder, "%s.BCv1.%s.pdf" % (self._grid_basename, datetime.now().strftime("%Y%m%d.%H%M%S"))) if self._noaa_nbs_profile: title_pdf = "BAG Checks v1 - Tests against NOAA OCS Profile" else: title_pdf = "BAG Checks v1 - Tests against General Profile" if self._bc_report.generate_pdf(output_pdf, title_pdf, use_colors=True): self._bc_pdf = output_pdf return True