Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # méthode de création d'un objet de type "Course" à partir de données d'entrées
- def createCourse(self, id_course, course):
- course = conversion_accents(course)
- course = re.sub(regex_special_chars, ' ', course)
- #print(course)
- # template = "09H20 - (POTEZ JUSTINE (ADO)) Saint-Laurent-du-Var - 591 Avenue Jean Aicard - RESIDENCE ST MARC BAT 7 - 06 73 80 48 45 - 06 25 18 28 24 PERE DEST Nice 2 Rue Raynardi / CPJA <<EXO OUI BT SERIE SI HOMME PRENDS COURSE, NE PAS PARLER A JUSTINE"
- tab_1 = course.split("<<")
- #print(tab_1)
- # payment info -> EXO OUI BT SERIE SI HOMME PRENDS COURSE, NE PAS PARLER A JUSTINE"
- payment_info = tab_1[1].strip()
- #print("PROUT", payment_info)
- #payment_info = tab_1
- # tab_2 -> template = "09H20 - (POTEZ JUSTINE (ADO)) Saint-Laurent-du-Var - 591 Avenue Jean Aicard - RESIDENCE ST MARC BAT 7 - 06 73 80 48 45 - 06 25 18 28 24 PERE DEST Nice 2 Rue Raynardi / CPJA
- tab_2 = tab_1[0]
- tab_3 = tab_2.split(" DEST ")
- # Extraction adresse destination de la course
- # tab_4 -> template = "Nice 2 Rue Raynardi / CPJA "
- # tab_4 -> template = "S20 Nice CYCLOTRON - CAL - 227 Avenue de la Lanterne "
- tab_4 = tab_3[1]
- tab_4_tmp = tab_4.split(" ")
- is_sector_code = True if re.match(regex_code_secteur, tab_4_tmp[0]) else False
- sector_code = tab_4_tmp[0].strip() if is_sector_code else ""
- to_city = tab_4_tmp[1] if is_sector_code else tab_4_tmp[0]
- to_street = " ".join(tab_4_tmp[2:len(tab_4_tmp)]).strip() if sector_code else " ".join(tab_4_tmp[1:len(tab_4_tmp)])
- to_street = to_street.split("/")[0].strip()
- to_postal_address = to_street.strip() + " " + to_city.strip()
- # Extraction informations client, heure et adresse de ramassage
- # tab_5 -> template = "09H20 - (POTEZ JUSTINE (ADO)) Saint-Laurent-du-Var - 591 Avenue Jean Aicard - RESIDENCE ST MARC BAT 7 - 06 73 80 48 45 - 06 25 18 28 24 PERE
- # tab_5 -> template = "09H15 - (ROBBE CLAUDE) NICE - 12 RUE DES PONCHETTES - MAISON EN FACE DE L ARCHE- PRES DU COURS SALEYA - 06 82 56 88 06 - 04 93 13 08 28 "
- # tab_5 -> template = "09H00 - (CARBONI EDMON - BASTIA) NICE - NICE AEROPORT 2 - BASTIA - 06 45 27 30 75 DEST S22 NICE HOPITAL ARCHET 1"
- tab_5 = tab_3[0]
- #tab_5 = re.sub('(.')
- tab_6 = tab_5.split(" - ")
- #print("Phone 1", tab_6)
- time = tab_6[0].strip()
- # Nom contact et ville
- # template = "(POTEZ JUSTINE (ADO)) Saint-Laurent-du-Var "
- # template = "(CARBONI EDMON - BASTIA) NICE"
- tab_field_2 = tab_6[1].strip()
- tab_field_2_tmp = tab_field_2.strip().split(" ")
- from_city = tab_field_2_tmp[-1]
- contact_name_tmp = " ".join(tab_field_2_tmp[0:len(tab_field_2_tmp) - 1])
- contact_name = contact_name_tmp[1:len(contact_name_tmp) - 1].strip()
- # Adresse et complément d'adresse
- from_street = tab_6[2]
- from_postal_address = from_street.strip() + " " + from_city.strip()
- # Numéros de tél de contact
- phone_list = []
- #print("Phone", tab_6)
- for field in tab_6:
- if re.match(regex_phone_number, field):
- phone_number = re.sub('[a-zA-Z]', '', field)
- phone_list.append(phone_number)
- first_phone_no = phone_list[0]
- second_phone_no = phone_list[1] if len(phone_list) == 2 else ""
- position_fin_adresse = len(tab_6) - len(phone_list)
- from_address_info = " - ".join(tab_6[3:position_fin_adresse])
- from_location_id = self.getLocationId(from_postal_address, sector_code, 'P')
- print(from_location_id)
- to_location_id = self.getLocationId(to_postal_address, sector_code, 'D')
- course_Object = Course(id_course, time, from_location_id, to_location_id, contact_name, first_phone_no, second_phone_no, payment_info)
- return course_Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement