def map(self, line, **kwargs): section = self.getData('Parcelle1section', line).upper() if len(section) > 0: section = section[0] remaining_reference = '%s %s' % (self.getData( 'Parcelle1numero', line), self.getData('Parcelle1numerosuite', line)) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) division = '25111' if self.getData( 'AdresseTravauxVille', line) == 'Wauthier-Braine' else '25015' if not remaining_reference or not section or not abbreviations: return [] base_reference = parse_cadastral_reference(division + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) section2 = self.getData('Parcelle2section', line).upper() if section2: section2 = section2[0] remaining_reference2 = '%s %s' % (self.getData( 'Parcelle2numero', line), self.getData('Parcelle2numerosuite', line)) if not remaining_reference2: return [] abbreviations2 = identify_parcel_abbreviations( remaining_reference2) if not remaining_reference2 or not section2: return [] base_reference2 = parse_cadastral_reference(division + section2 + abbreviations2[0]) base_reference2 = CadastralReference(*base_reference2) for abbreviation2 in abbreviations2[1:]: new_parcel2 = guess_cadastral_reference( base_reference2, abbreviation2) parcels.append(new_parcel2) return parcels
def map(self, line, **kwargs): division = None section = self.getData('CADSEC', line).upper() remaining_reference = self.getData('CADNUM', line) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) if self.getData('CADDIV', line): division_map = self.getValueMapping('division_map') division = division_map.get(self.getData('CADDIV', line)) if not remaining_reference or not section or not division: return [] base_reference = parse_cadastral_reference(division + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) return parcels
def map(self, line, **kwargs): section = self.getSection(line) division = self.getDivision(line) remaining_reference = self.getData('Cadastre', line) remaining_reference_2 = self.getData('Cadastre_2', line) if remaining_reference_2: remaining_reference = remaining_reference + ',' + remaining_reference_2 chars_to_remove = ['.', ',', '?', ';', ':', '#'] for char in chars_to_remove: remaining_reference = remaining_reference.replace(char, '') if not remaining_reference: return [] if not division: division = '' if not section: section = '' abbreviations = identify_parcel_abbreviations(remaining_reference) base_reference = parse_cadastral_reference(division + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) return parcels
def get_parcels_from_filename(file_name, container): file_name = file_name.replace(" ", "") if file_name: split_name = list(split_text(file_name)) division = split_name[0] division_map = valuesmapping.VALUES_MAPS.get('division_map') if '0' == division[0] and len(division) > 1: division = division[1] division_code = division_map.get(division) if not division_code: section = '' num = '' with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" % (division, section, num) + "\n") return [] if len(split_name) > 1: section = split_name[1].upper() num = '' if len(split_name) >= 2: for x in split_name[2:]: num += x print(division_code, section, num) if not division_code or not section or not division or not num: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" % (division, section, num) + "\n") return [] abbreviations = identify_parcel_abbreviations(num) if not abbreviations: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" % (division, section, num) + "\n") base_reference = parse_cadastral_reference(division_code + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) if not base_reference: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" % (division, section, num) + "\n") parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) for parcel in parcels: create_parcel_in_notary_letter(parcel, container) else: return []
def map(self, line, **kwargs): raw_reference = self.getData('PRCL_PRC') reference = parse_cadastral_reference(raw_reference) cadastral_ref = CadastralReference(*reference) division_map = self.getValueMapping('division_map') if cadastral_ref.division: cadastral_ref.division = division_map[cadastral_ref.division] else: cadastral_ref = None return cadastral_ref
def get_parcels_from_filename(file_name, container): file_name = file_name.replace(" ", "") if file_name: split_name = list(split_text(file_name)) division = split_name[0] division_map = valuesmapping.VALUES_MAPS.get('division_map') if '0' == division[0] and len(division) > 1: division = division[1] division_code = division_map.get(division) if not division_code: section = '' num = '' with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" %(division, section, num) + "\n") return [] if len(split_name) > 1: section = split_name[1].upper() num = '' if len(split_name) >= 2: for x in split_name[2:]: num += x print(division_code, section, num) if not division_code or not section or not division or not num: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" %(division, section, num) + "\n") return [] abbreviations = identify_parcel_abbreviations(num) if not abbreviations: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" %(division, section, num) + "\n") base_reference = parse_cadastral_reference(division_code + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) if not base_reference: with open("notaryLettersMatchParcelsError.csv", "a") as file: file.write(file_name + ", division(%s) section(%s) num(%s)" %(division, section, num) + "\n") parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) for parcel in parcels: create_parcel_in_notary_letter(parcel, container) else: return []
def map(self, line, **kwargs): section = self.getData('Sect', line).upper() division_map = self.getValueMapping('division_map') division = division_map.get((self.getData('Div', line)).strip()) division_code_map = self.getValueMapping('division_code_map') division_code = division_code_map.get(division) remaining_reference = self.getData('num parcelle', line) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) if not division_code or not section or division_code == 'NA' or section == 'NA': return [] base_reference = parse_cadastral_reference(division_code + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) return parcels
def map(self, line, **kwargs): section = self.getSection(line) division = self.getDivision(line) remaining_reference = self.getData('Cadastre', line) remaining_reference_2 = self.getData('Cadastre_2', line) if remaining_reference_2: remaining_reference = remaining_reference + ',' + remaining_reference_2 if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) base_reference = parse_cadastral_reference(division + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) return parcels
def map(self, line, **kwargs): section = self.getData('Section', line).upper() division_map = self.getValueMapping('division_map') division = division_map.get((self.getData('Division', line)).strip()) if division: division_code_map = self.getValueMapping('division_code_map') division_code = division_code_map.get(division) remaining_reference = self.getData('Num parcelles', line) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) if not division or not section: return [] base_reference = parse_cadastral_reference(division_code + section + abbreviations[0]) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) return parcels
def create_parcel(parcelling, section1, num1, num1suite, division): division_label = division if len(section1) > 0: section1 = section1[0].upper() remaining_reference = '%s %s' % (num1, num1suite) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) division = '25111' if division == 'Wauthier-Braine' else '25015' if not remaining_reference or not section1: return [] abbrev = '' if len(abbreviations) == 0 else abbreviations[0] base_reference = parse_cadastral_reference(division + section1 + abbrev) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) # section2 = self.getData('Parcelle2section', line).upper() # if section2: # section2 = section2[0] # remaining_reference2 = '%s %s' % ( # self.getData('Parcelle2numero', line), self.getData('Parcelle2numerosuite', line)) # if not remaining_reference2: # return [] # # abbreviations2 = identify_parcel_abbreviations(remaining_reference2) # if not remaining_reference2 or not section2: # return [] # base_reference2 = parse_cadastral_reference(division + section2 + abbreviations2[0]) # # base_reference2 = CadastralReference(*base_reference2) # # for abbreviation2 in abbreviations2[1:]: # new_parcel2 = guess_cadastral_reference(base_reference2, abbreviation2) # parcels.append(new_parcel2) for parcel in parcels: searchview = api.portal.get().restrictedTraverse('searchparcels') #need to trick the search browser view about the args in its request parcel_args = parcel.to_dict() parcel_args.pop('partie') for k, v in parcel_args.iteritems(): searchview.context.REQUEST[k] = v #check if we can find a parcel in the db cadastre with these infos found = searchview.search_parcels_custom(**parcel_args) if not found: found = searchview.search_parcels_custom(old=True, **parcel_args) if len(found) == 1 and parcel.has_same_attribute_values(found[0]): parcel_args['divisionCode'] = parcel_args['division'] parcel_args['isOfficialParcel'] = True else: # api.portal.get().logError(api.portal.get(), None, 'Too much parcels found or not enough parcels found', {'args': parcel_args, 'search result': len(found)}) parcel_args['isOfficialParcel'] = False parcel_args['id'] = parcel.id parcel_args['partie'] = parcel.partie container = api.content.get(path='/urban/parcellings/' + parcelling) object_id = container.invokeFactory( 'PortionOut', title=parcel_args['id'], id=parcel_args['id'], isOfficialParcel=parcel_args['isOfficialParcel'], division=division_label, section=parcel_args['section'], puissance=parcel_args['puissance'], exposant=parcel_args['exposant'], radical=parcel_args['radical'], bis=parcel_args['bis'], divisionCode=parcel_args['division']) return object_id
def create_parcel(parcelling, section1, num1, num1suite, division): division_label = division if len(section1) > 0: section1 = section1[0].upper() remaining_reference = '%s %s' % (num1, num1suite) if not remaining_reference: return [] abbreviations = identify_parcel_abbreviations(remaining_reference) division = '2' if division == u'Wauthier-Braine' else '1' if not remaining_reference or not section1: return [] abbrev = '' if len(abbreviations) == 0 else abbreviations[0] base_reference = parse_cadastral_reference(division + section1 + abbrev) base_reference = CadastralReference(*base_reference) parcels = [base_reference] for abbreviation in abbreviations[1:]: new_parcel = guess_cadastral_reference(base_reference, abbreviation) parcels.append(new_parcel) # section2 = self.getData('Parcelle2section', line).upper() # if section2: # section2 = section2[0] # remaining_reference2 = '%s %s' % ( # self.getData('Parcelle2numero', line), self.getData('Parcelle2numerosuite', line)) # if not remaining_reference2: # return [] # # abbreviations2 = identify_parcel_abbreviations(remaining_reference2) # if not remaining_reference2 or not section2: # return [] # base_reference2 = parse_cadastral_reference(division + section2 + abbreviations2[0]) # # base_reference2 = CadastralReference(*base_reference2) # # for abbreviation2 in abbreviations2[1:]: # new_parcel2 = guess_cadastral_reference(base_reference2, abbreviation2) # parcels.append(new_parcel2) for parcel in parcels: searchview = api.portal.get().restrictedTraverse('searchparcels') #need to trick the search browser view about the args in its request parcel_args = parcel.to_dict() parcel_args.pop('partie') for k, v in parcel_args.iteritems(): searchview.context.REQUEST[k] = v #check if we can find a parcel in the db cadastre with these infos found = searchview.findParcel(**parcel_args) if not found: found = searchview.findParcel(browseoldparcels=True, **parcel_args) if len(found) == 1 and parcel.has_same_attribute_values(found[0]): parcel_args['divisionCode'] = parcel_args['division'] parcel_args['isOfficialParcel'] = True else: # api.portal.get().logError(api.portal.get(), None, 'Too much parcels found or not enough parcels found', {'args': parcel_args, 'search result': len(found)}) parcel_args['isOfficialParcel'] = False parcel_args['id'] = parcel.id parcel_args['partie'] = parcel.partie container = api.content.get(path='/urban/parcellings/' + parcelling) object_id = container.invokeFactory('PortionOut', title=parcel_args['id'], id=parcel_args['id'], isOfficialParcel=parcel_args['isOfficialParcel'], division=division_label, section=parcel_args['section'], puissance=parcel_args['puissance'], exposant=parcel_args['exposant'], radical=parcel_args['radical'], bis=parcel_args['bis'], divisionCode=parcel_args['division']) return object_id