def set_custom_affiliated_file(self): custom_affiliated_file_list = self.get_custom_affiliated_file_character( ) if len(custom_affiliated_file_list) > 0: for affiliated_file_info in custom_affiliated_file_list: affiliated_file_path = CUtils.dict_value_by_name( affiliated_file_info, self.Name_FilePath, None) regex_match = CUtils.dict_value_by_name( affiliated_file_info, self.Name_RegularExpression, None) no_match = CUtils.dict_value_by_name( affiliated_file_info, self.Name_No_Match_RegularExpression, None) if (affiliated_file_path is not None) and (regex_match is not None): affiliated_file_name_list = CFile.file_or_dir_fullname_of_path( affiliated_file_path, False, regex_match, CFile.MatchType_Regex) # 模糊匹配文件列表 if len(affiliated_file_name_list) > 0: for affiliated_file_name in affiliated_file_name_list: if no_match is None: self._object_detail_file_full_name_list.append( affiliated_file_name) else: if not CUtils.text_match_re( CFile.file_name(affiliated_file_name), no_match): self._object_detail_file_full_name_list.append( affiliated_file_name)
def add_file_to_detail_list(self, match_name): """ 设定国土行业数据国情的附属文件的验证规则(镶嵌影像) 完成 负责人 王学谦 在这里检验国情的附属文件 :return: """ file_main_name = self._object_name file_path = self.file_info.file_path # 正则匹配附属文件 if not CUtils.equal_ignore_case(file_path, ''): match_str = '{0}*.*'.format(match_name) match_file_list = CFile.file_or_dir_fullname_of_path( file_path, False, match_str, CFile.MatchType_Common) match_str_main_name = r'(?i)^{0}[FMP]$'.format(match_name) # 主附属 ext_list = [ 'rar', 'zip', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'xml' ] for file_with_path in match_file_list: if CUtils.equal_ignore_case( CFile.file_main_name(file_with_path), file_main_name): # 去除自身与同名文件 pass elif CUtils.text_match_re(CFile.file_main_name(file_with_path), match_str_main_name): self.add_file_to_details(file_with_path) # 将文件加入到附属文件列表中 elif CFile.file_ext(file_with_path).lower() in ext_list: self.add_file_to_details(file_with_path) else: pass
def add_file_to_detail_list(self, match_name): """ 设定国土行业数据三调的附属文件的验证规则(镶嵌影像) 完成 负责人 王学谦 在这里检验三调的附属文件 :return: """ file_main_name = self._object_name file_path = self.file_info.file_path # 模糊匹配附属文件 if not CUtils.equal_ignore_case(file_path, ''): match_str = '{0}*xq.*'.format(match_name) match_file_list = CFile.file_or_dir_fullname_of_path( file_path, False, match_str, CFile.MatchType_Common) for file_with_path in match_file_list: if not CUtils.equal_ignore_case( CFile.file_main_name(file_with_path), file_main_name): # 去除自身与同名文件 self.add_file_to_details(file_with_path) # 将文件加入到附属文件列表中 try: db = CFactory().give_me_db(self.file_info.db_server_id) metadata_name_before_six_name = db.one_row("select gdstitle from ro_global_dim_space " "where gdsid = '{0}'".format(match_name)) \ .value_by_name(0, 'gdstitle', None) metadata_file_name = '{0}{1}.mdb'.format( match_name, metadata_name_before_six_name) metadata_file_name_with_path = CFile.join_file( file_path, metadata_file_name) if CFile.file_or_path_exist(metadata_file_name_with_path): self.add_file_to_details(metadata_file_name_with_path) except: pass
def process(self) -> str: """ 在这里处理将__file_info__中记录的对象所对应的文件或目录信息, 根据__detail_*变量的定义, 进行目录扫描, 记录到dm2_storage_object_detail中 :return: """ self._before_process() if self._only_stat_file: result = self.__stat_object_detail_of_schema() if not CResult.result_success(result): return result else: if not CUtils.equal_ignore_case(self.__detail_file_path__, ''): list_file_fullname = CFile.file_or_dir_fullname_of_path( self.__detail_file_path__, self.__detail_file_recurse__, self.__detail_file_match_text__, self.__detail_file_match_type__) result = self.__inbound_object_detail_of_schema( list_file_fullname) if not CResult.result_success(result): return result if len(self._file_custom_list) > 0: return self.inbound_object_detail_of_custom(self._file_custom_list) else: return CResult.merge_result(self.Success, '对象附属文件处理成功结束!')
def add_file_to_detail_list(self): """ 设定国土行业数据mosaic的附属文件的验证规则(镶嵌影像) 完成 负责人 李宪 在这里检验mosaic的附属文件的识别规则 :return: """ file_detail_xml = '{0}_21at.xml'.format( self.file_info.file_main_name_with_full_path) self.add_file_to_details(file_detail_xml) # 将文件加入到附属文件列表中 file_detail_xq = '{0}xq.*'.format(self.file_info.file_main_name) if not CUtils.equal_ignore_case(self.file_info.file_path, ''): list_file_fullname_xq = CFile.file_or_dir_fullname_of_path( self.file_info.file_path, False, file_detail_xq, CFile.MatchType_Common) # 模糊匹配文件列表 for list_file_fullname in list_file_fullname_xq: self.add_file_to_details(list_file_fullname) # 将文件加入到附属文件列表中
def classified(self): """ 关键字识别 """ super().classified() # 预获取需要的参数 file_path = self.file_info.file_path file_main_name = self.file_info.file_main_name file_ext = self.file_info.file_ext # 预定义逻辑参数 数据文件匹配 object_file_name_flag = False object_file_path_flag = False object_file_ext_flag = False object_affiliated_file_main_flag = False object_file_affiliated_flag = False object_keyword_list = self.get_classified_character_of_object_keyword() if len(object_keyword_list) > 0: for keyword_info in object_keyword_list: keyword_id = CUtils.dict_value_by_name(keyword_info, self.Name_ID, None) regex_match = CUtils.dict_value_by_name( keyword_info, self.Name_RegularExpression, '.*') if regex_match is None: regex_match = '.*' if CUtils.equal_ignore_case(keyword_id, self.Name_FileName): if CUtils.text_match_re(file_main_name, regex_match): object_file_name_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FilePath): if CUtils.text_match_re(file_path, regex_match): object_file_path_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FileExt): if CUtils.text_match_re(file_ext, regex_match): object_file_ext_flag = True else: same_name_file_list = CFile.file_or_dir_fullname_of_path( file_path, False, '(?i)^' + file_main_name + '[.].*$', CFile.MatchType_Regex) if len(same_name_file_list) > 0: for same_name_file in same_name_file_list: same_name_file_ext = CFile.file_ext( same_name_file) if CUtils.text_match_re( same_name_file_ext, regex_match): object_affiliated_file_main_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FileAffiliated): affiliated_file_path = CUtils.dict_value_by_name( keyword_info, self.Name_FilePath, None) if affiliated_file_path is not None: if CFile.find_file_or_subpath_of_path( affiliated_file_path, regex_match, CFile.MatchType_Regex): object_file_affiliated_flag = True else: object_file_affiliated_flag = True # 预定义逻辑参数 附属文件匹配 affiliated_file_name_flag = False affiliated_file_path_flag = False affiliated_file_ext_flag = False affiliated_file_main_flag = False affiliated_keyword_list = self.get_classified_character_of_affiliated_keyword( ) if len(affiliated_keyword_list) > 0: for keyword_info in affiliated_keyword_list: keyword_id = CUtils.dict_value_by_name(keyword_info, self.Name_ID, None) regex_match = CUtils.dict_value_by_name( keyword_info, self.Name_RegularExpression, '.*') if regex_match is None: regex_match = '.*' if CUtils.equal_ignore_case(keyword_id, self.Name_FileName): if CUtils.text_match_re(file_main_name, regex_match): affiliated_file_name_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FilePath): if CUtils.text_match_re(file_path, regex_match): affiliated_file_path_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FileExt): if CUtils.text_match_re(file_ext, regex_match): affiliated_file_ext_flag = True elif CUtils.equal_ignore_case(keyword_id, self.Name_FileMain): affiliated_file_path = CUtils.dict_value_by_name( keyword_info, self.Name_FilePath, None) if affiliated_file_path is not None: if CFile.find_file_or_subpath_of_path( affiliated_file_path, regex_match, CFile.MatchType_Regex): affiliated_file_main_flag = True if object_file_name_flag and object_file_path_flag and \ object_file_ext_flag and object_file_affiliated_flag: self._object_confirm = self.Object_Confirm_IKnown self._object_name = file_main_name self.set_custom_affiliated_file() elif affiliated_file_name_flag and affiliated_file_path_flag and \ affiliated_file_ext_flag and affiliated_file_main_flag: self._object_confirm = self.Object_Confirm_IKnown_Not self._object_name = None elif object_file_name_flag and object_file_path_flag and object_affiliated_file_main_flag: self._object_confirm = self.Object_Confirm_IKnown_Not self._object_name = None else: self._object_confirm = self.Object_Confirm_IUnKnown self._object_name = None return self._object_confirm, self._object_name
def process_ndi_table(self): object_table_id = self._obj_id # 获取oid metadata_bus_dict = self.get_metadata_bus_dict() ndi_table_name = CUtils.dict_value_by_name(self.information(), 'ndi_table_name', 'ap_product_ndi') ndi_table = CTable() ndi_table.load_info(self._db_id, ndi_table_name) ndi_table.column_list.column_by_name('id').set_value(object_table_id) productname = CUtils.dict_value_by_name(metadata_bus_dict, 'productname', None) if CUtils.equal_ignore_case(productname, ''): productname = self._dataset.value_by_name(0, 'dsoobjectname', None) ndi_table.column_list.column_by_name('rid').set_value(productname) ndi_table.column_list.column_by_name('fid').set_value(object_table_id) ndi_table.column_list.column_by_name('satelliteid').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'satelliteid', None)) ndi_table.column_list.column_by_name('sensorid').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'sensorid', None)) ndi_table.column_list.column_by_name('topleftlatitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'topleftlatitude', None)) ndi_table.column_list.column_by_name('topleftlongitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'topleftlongitude', None)) ndi_table.column_list.column_by_name('toprightlatitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'toprightlatitude', None)) ndi_table.column_list.column_by_name('toprightlongitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'toprightlongitude', None)) ndi_table.column_list.column_by_name('bottomrightlatitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'bottomrightlatitude', None)) ndi_table.column_list.column_by_name('bottomrightlongitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'bottomrightlongitude', None)) ndi_table.column_list.column_by_name('bottomleftlatitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'bottomleftlatitude', None)) ndi_table.column_list.column_by_name('bottomleftlongitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'bottomleftlongitude', None)) ndi_table.column_list.column_by_name('centerlatitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'centerlatitude', None)) ndi_table.column_list.column_by_name('centerlongitude').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'centerlongitude', None)) transformimg = CUtils.dict_value_by_name(metadata_bus_dict, 'transformimg', None) if not CUtils.equal_ignore_case(transformimg, ''): view_path = settings.application.xpath_one( self.Path_Setting_MetaData_Dir_View, None) browser_path = CFile.file_path( self._dataset.value_by_name(0, 'dso_browser', None)) file_list = CFile.file_or_dir_fullname_of_path( CFile.join_file(view_path, browser_path), False, transformimg, CFile.MatchType_Regex) if len(file_list) > 0: ndi_table.column_list.column_by_name('transformimg').set_value( '{0}{1}'.format( CFile.sep(), CFile.join_file(browser_path, CFile.file_name(file_list[0])))) ndi_table.column_list.column_by_name('filesize').set_sql(''' (select sum(dodfilesize) from dm2_storage_obj_detail where dodobjectid='{0}') '''.format(object_table_id)) ndi_table.column_list.column_by_name('dataexist').set_value(0) ndi_table.column_list.column_by_name('centertime').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'centertime', None)) resolution = CUtils.dict_value_by_name(metadata_bus_dict, 'resolution', None) if not CUtils.equal_ignore_case(resolution, ''): ndi_table.column_list.column_by_name('resolution').set_value( resolution) else: ndi_table.column_list.column_by_name('resolution').set_value(0) rollangle = CUtils.dict_value_by_name(metadata_bus_dict, 'rollangle', 0) if CUtils.equal_ignore_case(rollangle, ''): rollangle = 0 ndi_table.column_list.column_by_name('rollangle').set_value(rollangle) cloudpercent = CUtils.dict_value_by_name(metadata_bus_dict, 'cloudpercent', 0) if CUtils.equal_ignore_case(cloudpercent, ''): cloudpercent = 0 ndi_table.column_list.column_by_name('cloudpercent').set_value( cloudpercent) ndi_table.column_list.column_by_name('dataum').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'dataum', None)) ndi_table.column_list.column_by_name('acquisition_id').set_value( CUtils.dict_value_by_name(metadata_bus_dict, 'acquisition_id', None)) result = ndi_table.save_data() return result