Spaces:
Sleeping
Sleeping
Gemini CLI commited on
Commit ·
2706875
1
Parent(s): 8116bfc
Swap Iraqi and Fly Dubai templates and fix date formats as requested
Browse files- src/formats.py +40 -43
src/formats.py
CHANGED
|
@@ -69,43 +69,8 @@ def _to_ddmmmyy(date_str):
|
|
| 69 |
|
| 70 |
def format_fly_dubai(data_list):
|
| 71 |
"""
|
| 72 |
-
Formats data for Fly Dubai template.
|
| 73 |
-
|
| 74 |
-
Example: Adult MR FirstNameOne LastNameOne 13NOV84 Male
|
| 75 |
-
"""
|
| 76 |
-
formatted_rows = []
|
| 77 |
-
|
| 78 |
-
for item in data_list:
|
| 79 |
-
sex = item.get('sex', '').upper()
|
| 80 |
-
gender_full = "Male" if sex == 'M' else "Female"
|
| 81 |
-
title = "MR" if sex == 'M' else "MRS"
|
| 82 |
-
|
| 83 |
-
# Get and format dates
|
| 84 |
-
raw_dob = item.get('date_of_birth', '')
|
| 85 |
-
ddmmyyyy_dob = _format_mrz_date(raw_dob)
|
| 86 |
-
|
| 87 |
-
# Calculate passenger type based on age
|
| 88 |
-
passenger_type, _ = calculate_passenger_type(ddmmyyyy_dob)
|
| 89 |
-
|
| 90 |
-
# Dubai uses DDMMMYY format
|
| 91 |
-
dob_dubai = _to_ddmmmyy(ddmmyyyy_dob)
|
| 92 |
-
|
| 93 |
-
row = {
|
| 94 |
-
"TYPE": passenger_type,
|
| 95 |
-
"TITLE": title,
|
| 96 |
-
"FIRST NAME": item.get('name', ''),
|
| 97 |
-
"LAST NAME": item.get('surname', ''),
|
| 98 |
-
"DOB (DDMMMYY)": dob_dubai,
|
| 99 |
-
"GENDER": gender_full
|
| 100 |
-
}
|
| 101 |
-
formatted_rows.append(row)
|
| 102 |
-
|
| 103 |
-
return pd.DataFrame(formatted_rows)
|
| 104 |
-
|
| 105 |
-
def format_iraqi(data_list):
|
| 106 |
-
"""
|
| 107 |
-
Formats data for Iraqi template.
|
| 108 |
-
- Dates: DD/MM/YYYY (e.g., 20/03/2018)
|
| 109 |
"""
|
| 110 |
formatted_rows = []
|
| 111 |
|
|
@@ -115,14 +80,14 @@ def format_iraqi(data_list):
|
|
| 115 |
|
| 116 |
first_middle = item.get('name', '')
|
| 117 |
|
| 118 |
-
# Get and format dates to
|
| 119 |
raw_dob = item.get('date_of_birth', '')
|
| 120 |
raw_expiry = item.get('expiration_date', '')
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
|
| 125 |
-
_, ptc_code = calculate_passenger_type(
|
| 126 |
|
| 127 |
row = {
|
| 128 |
"Last Name": item.get('surname', ''),
|
|
@@ -130,14 +95,14 @@ def format_iraqi(data_list):
|
|
| 130 |
"Title": title,
|
| 131 |
"PTC": ptc_code,
|
| 132 |
"Gender": sex,
|
| 133 |
-
"Date of Birth":
|
| 134 |
"Passport Last Name": item.get('surname', ''),
|
| 135 |
"Passport First Name": first_middle,
|
| 136 |
"Passport Middle Name": "",
|
| 137 |
"Passport Number": item.get('passport_number', ''),
|
| 138 |
"Passport Nationality": item.get('nationality', '')[:3].upper(),
|
| 139 |
"Passport Issue Country": item.get('country', '')[:3].upper(),
|
| 140 |
-
"Passport Expiry Date":
|
| 141 |
"Visa Number": "", "Visa Type": "", "Visa Issue Date": "", "Place of Birth": "",
|
| 142 |
"Visa Place of Issue": "", "Visa Country of Application": "", "Address Type": "",
|
| 143 |
"Address Country": "", "Address Details": "", "Address City": "",
|
|
@@ -147,6 +112,38 @@ def format_iraqi(data_list):
|
|
| 147 |
|
| 148 |
return pd.DataFrame(formatted_rows)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
def format_fly_baghdad(data_list):
|
| 151 |
"""
|
| 152 |
Formats data for Fly Baghdad template.
|
|
|
|
| 69 |
|
| 70 |
def format_fly_dubai(data_list):
|
| 71 |
"""
|
| 72 |
+
Formats data for Fly Dubai template (Full details).
|
| 73 |
+
- Dates: DDMMMYY (e.g., 18NOV16)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
"""
|
| 75 |
formatted_rows = []
|
| 76 |
|
|
|
|
| 80 |
|
| 81 |
first_middle = item.get('name', '')
|
| 82 |
|
| 83 |
+
# Get and format dates to DDMMMYY
|
| 84 |
raw_dob = item.get('date_of_birth', '')
|
| 85 |
raw_expiry = item.get('expiration_date', '')
|
| 86 |
|
| 87 |
+
dob_dubai = _to_ddmmmyy(_format_mrz_date(raw_dob))
|
| 88 |
+
expiry_dubai = _to_ddmmmyy(_format_mrz_date(raw_expiry))
|
| 89 |
|
| 90 |
+
_, ptc_code = calculate_passenger_type(_format_mrz_date(raw_dob))
|
| 91 |
|
| 92 |
row = {
|
| 93 |
"Last Name": item.get('surname', ''),
|
|
|
|
| 95 |
"Title": title,
|
| 96 |
"PTC": ptc_code,
|
| 97 |
"Gender": sex,
|
| 98 |
+
"Date of Birth": dob_dubai,
|
| 99 |
"Passport Last Name": item.get('surname', ''),
|
| 100 |
"Passport First Name": first_middle,
|
| 101 |
"Passport Middle Name": "",
|
| 102 |
"Passport Number": item.get('passport_number', ''),
|
| 103 |
"Passport Nationality": item.get('nationality', '')[:3].upper(),
|
| 104 |
"Passport Issue Country": item.get('country', '')[:3].upper(),
|
| 105 |
+
"Passport Expiry Date": expiry_dubai,
|
| 106 |
"Visa Number": "", "Visa Type": "", "Visa Issue Date": "", "Place of Birth": "",
|
| 107 |
"Visa Place of Issue": "", "Visa Country of Application": "", "Address Type": "",
|
| 108 |
"Address Country": "", "Address Details": "", "Address City": "",
|
|
|
|
| 112 |
|
| 113 |
return pd.DataFrame(formatted_rows)
|
| 114 |
|
| 115 |
+
def format_iraqi(data_list):
|
| 116 |
+
"""
|
| 117 |
+
Formats data for Iraqi template.
|
| 118 |
+
Columns: TYPE, TITLE, FIRST NAME, LAST NAME, DOB (DD/MM/YYYY), GENDER
|
| 119 |
+
Example: Adult MR FirstNameOne LastNameOne 20/03/2018 Male
|
| 120 |
+
"""
|
| 121 |
+
formatted_rows = []
|
| 122 |
+
|
| 123 |
+
for item in data_list:
|
| 124 |
+
sex = item.get('sex', '').upper()
|
| 125 |
+
gender_full = "Male" if sex == 'M' else "Female"
|
| 126 |
+
title = "MR" if sex == 'M' else "MRS"
|
| 127 |
+
|
| 128 |
+
# Get and format dates
|
| 129 |
+
raw_dob = item.get('date_of_birth', '')
|
| 130 |
+
ddmmyyyy_dob = _format_mrz_date(raw_dob)
|
| 131 |
+
|
| 132 |
+
# Calculate passenger type based on age
|
| 133 |
+
passenger_type, _ = calculate_passenger_type(ddmmyyyy_dob)
|
| 134 |
+
|
| 135 |
+
row = {
|
| 136 |
+
"TYPE": passenger_type,
|
| 137 |
+
"TITLE": title,
|
| 138 |
+
"FIRST NAME": item.get('name', ''),
|
| 139 |
+
"LAST NAME": item.get('surname', ''),
|
| 140 |
+
"DOB (DD/MM/YYYY)": ddmmyyyy_dob,
|
| 141 |
+
"GENDER": gender_full
|
| 142 |
+
}
|
| 143 |
+
formatted_rows.append(row)
|
| 144 |
+
|
| 145 |
+
return pd.DataFrame(formatted_rows)
|
| 146 |
+
|
| 147 |
def format_fly_baghdad(data_list):
|
| 148 |
"""
|
| 149 |
Formats data for Fly Baghdad template.
|