Professional Documents
Culture Documents
strasdf=str(list(bookings.keys()).index(asd)+1)
print()
print(strasdf,' ===>', 'Booking Made at', asd)
print()
print('=='*35)
x = bookings[asd]
p_c=x[len(x)-1]
print('=='*35)
print('Passenger Count:',p_c)
if p_c==1:
i=0
elif p_c > 1:
i=p_c-1
refer_e=['Booking cost: ', 'Flight Class: ','Departure City: ', 'Destination City:
','Gate: ','Flight ID: ','FlightTime: ']
booking_cost = x[1+i]
booking_class = x[2+i]
dept_city = x[3+i]
dest_city = x[4+i]
booking_gate = x[5+i]
flight_id = x[6+i]
flight_time=x[7+i]
for j in range(p_c):
print('=='*35)
print(list(x[j].keys()))
for k in list(x[j].keys()):
print(k,':',x[j][k])
print('=='*35)
counter=0
for bfk in range(p_c,len(x)-1):
print(refer_e[counter],x[bfk])
counter+=1
print('=='*35)
def menu():
global
db_cities,passengers,port_name,usa,spain,japan,brazil,australia,india,name,initial_city,ta
rget_city,ph_list,world_map,bookings
path1=pathlib.Path(__file__).parent/'damnson.json'
with open(path1) as f:
bookings=json.load(f)
# if json not allowed, delete above two lines and make a variable bookings={}
exit_loop=False
#print Title
print('\t\t\t\t',end='')
str2='◆◆◆◆◆◆◆◆◆◆'
for i in str2:
print(i, end='')
time.sleep(0.03)
print()
print('\t\t\t\t', end='')
str1=' '+' '+' '+' WherePort'
for i in str1:
print(i, end='')
time.sleep(0.03)
print()
print('\t\t\t\t',end='')
str3='◆◆◆◆◆◆◆◆◆◆'
for i in str2:
print(i, end='')
time.sleep(0.03)
print('\n')
print('Time:',time_12hr())
print()
ph_nst=[]
ph_list_nst={}
gate_to_move=False
name = ask('Question', 'What is your Name?')
#if tkinter not allow, take normal input
print('═'*40)
print('\t\t\t',' ',' ',' ','WΞLC♢MΣ',name,',\nᴡᴇ ᴀʀᴇ ᴡʜᴇʀᴇᴘᴏʀᴛ, ᴀ ʀᴀᴘɪᴅ ꜰʟɪɢʜᴛ
ᴛɪᴄᴋᴇᴛ ʙᴏᴏᴋɪɴɢ ᴄᴏᴍᴘᴀɴʏ...ᴀᴛ ʏᴏᴜʀ ꜱᴇʀᴠɪᴄᴇ.')
print('\t(っ◔◡◔)っ ♥ We sincerely thank you for using our CLI application ♥')
print('\t\t',' ',' ',' ',' ',' ',' ',' ',' ','~ƬΉΣ ЩΉΣЯΣPӨЯƬ ƬΣΛM')
print(' ',' ',' ',' ',' ',' ',' ',' ','𝙼𝚊𝚍𝚎 𝚠𝚒𝚝𝚑 𝚌𝚊𝚛𝚎 𝚋𝚢 𝙰𝚔𝚊𝚜𝚑( 𝙲𝙴𝙾), 𝙰𝚗𝚜𝚑𝚞𝚖𝚊𝚗(𝙲𝙾-
𝙲𝙴𝙾) 𝚊𝚗𝚍 𝙰𝚋𝚑𝚒𝚜𝚑𝚎𝚔(𝙲𝙾-𝙲𝙴𝙾))')
print('═'*40)
while exit_loop==False:
print()
print('Choose your service,',name,':\n1.Book a flight ticket\n2.Check scheduled
bookings\n3.Cancel existing booking\n4.Exit Command Line Application\n')
gahas=False
while gahas==False:
try:
inp_gt=int(input('Numerically, enter your choice: '))
if inp_gt!=1 and inp_gt!=2 and inp_gt!=3 and inp_gt!=4:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ :ᴇɴᴛᴇʀ ᴠᴀʟɪᴅ ɴᴜᴍʙᴇʀs ʟɪᴋᴇ ᴛʜɪꜱ: 1 ')
gahas=False
else:
gahas=True
except ValueError:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ :ᴇɴᴛᴇʀ ᴠᴀʟɪᴅ ɴᴜᴍʙᴇʀs ʟɪᴋᴇ ᴛʜɪꜱ: 1 ')
if inp_gt==4:
print('═'*40)
print('\t(っ◔◡◔)っ ♥ We sincerely thank you for using our CLI application ♥')
print('\t\t',' ',' ',' ',' ',' ',' ',' ',' ','~ƬΉΣ ЩΉΣЯΣPӨЯƬ ƬΣΛM')
print(' ',' ',' ',' ',' ',' ',' ',' ','𝙼𝚊𝚍𝚎 𝚠𝚒𝚝𝚑 𝚌𝚊𝚛𝚎 𝚋𝚢 𝙰𝚔𝚊𝚜𝚑( 𝙲𝙴𝙾),
𝙰𝚗𝚜𝚑𝚞𝚖𝚊𝚗(𝙲𝙾-𝙲𝙴𝙾) 𝚊𝚗𝚍 𝙰𝚋𝚑𝚒𝚜𝚑𝚎𝚔(𝙲𝙾-𝙲𝙴𝙾))')
with open(path1, 'w') as g:
json.dump(bookings,g)
print('═'*40)
return None
if inp_gt==1:
take_inp=None
take_inp_gate=False
choice=1
while take_inp_gate==False:
if choice==1:
print('═'*35)
print()
print('We operate in the following countries:')
print('1.United States Of
America\n2.Spain\n3.Japan\n4.Australia\n5.Brazil\n6.India')
gth234=False
cnt123=0
while gth234==False:
try:
print()
take_inp=list(input('ᴇɴᴛᴇʀ ɴᴜᴍʙᴇʀ ᴄᴏʀʀᴇꜱᴘᴏɴᴅɪɴɢ ᴛᴏ ᴛʜᴇ ᴄᴏᴜɴᴛʀY
ᴡʜᴏꜱᴇ ᴀɪʀᴘᴏʀᴛꜱ ᴀɴᴅ ᴄɪᴛɪᴇꜱ ʏᴏᴜ ᴡᴀɴɴᴀ ʙᴏᴏᴋ ꜰʀᴏᴍ. Leave blank to skip: '))
print()
if (('1' in take_inp or '2' in take_inp or '3' in take_inp or
'4' in take_inp or '5' in take_inp or '6' in take_inp) and len(take_inp)==1) or
len(take_inp)==0:
gth234=True
else:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ :ᴇɴᴛᴇʀ ᴠᴀʟɪᴅ ɴᴜᴍʙᴇʀs ʟɪᴋᴇ ᴛʜɪꜱ: 1 ᴏʀ 1
2.')
except ValueError:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ :ᴇɴᴛᴇʀ ᴀ ᴠᴀʟɪᴅ ɴᴜᴍʙᴇʀ ʟɪᴋᴇ ᴛʜɪꜱ 1 ᴏʀ 1 2.')
for c in take_inp:
if c=='1':
print('\t\t\t\tUnited States Of America')
print('\t\t\t\t','=======================')
print()
for i in usa:
if i!='United States Of America':
print(i, usa[i])
print()
elif c=='2':
print('\t\t\t\t',' ',' ',' ',' ','Spain')
print('\t\t\t\t',' ',' ',' ','=========')
print()
for i in spain:
if i!='Spain':
print(i, spain[i])
print()
elif c=='3':
print('\t\t\t\t',' ',' ',' ',' ','Japan')
print('\t\t\t\t',' ',' ',' ','=========')
print()
for i in japan:
if i!='Japan':
print(i, japan[i])
print()
elif c=='4':
print('\t\t\t\t',' ',' ',' ','Australia')
print('\t\t\t\t',' ',' ',' ','=========')
print()
for i in australia:
if i!='Australia':
print(i, australia[i])
print()
elif c=='5':
print('\t\t\t\t',' ',' ',' ',' ','Brazil')
print('\t\t\t\t',' ',' ',' ','=========')
print()
for i in brazil:
if i!='Brazil':
print(i, brazil[i])
print()
elif c=='6':
print('\t\t\t\t',' ',' ',' ',' ','India')
print('\t\t\t\t',' ',' ',' ','=========')
print()
for i in india:
if i!='India':
print(i, india[i])
print()
gate123456=False
while gate123456==False:
try:
print()
choice=int(input('Choose numerical option:\n1.Select another
country\n2.Move on to flight details\n\nEnter your choice: '))
print()
if choice!=1 and choice!=2:
print('Enter a valid Number')
gate123456=False
else:
gate123456=True
except ValueError:
print()
print('Enter a valid Number')
elif choice==2:
take_inp_gate=True
print('═'*35)
for i in range(len(db_cities)):
ph_list_nst["City"]=db_cities[i]
ph_list_nst["Airport"]=port_name[db_cities[i]]
ph_cont=None
for ab in world_map:
for gh in ab:
if db_cities[i]==gh:
ph_cont=ab[0]
ph_list_nst["Country"]=ph_cont
print('-'*45)
print(name,', ᴋɪɴᴅʟʏ ᴘʀᴏᴠɪᴅᴇ ᴄɪᴛʏ ᴅᴇᴛᴀɪʟꜱ')
print('-'*45)
gth=False
while gth==False:
try:
initial_city=input('ᴇɴᴛᴇʀ ᴅᴇᴘᴀʀᴛᴜʀᴇ ᴄɪᴛʏ:')
target_city=input('ᴇɴᴛᴇʀ ᴀʀʀɪᴠᴀʟ ᴄɪᴛʏ:')
ph_list=str(find_country(initial_city,target_city,world_map)[0] )+' to
'+ str(find_country(initial_city,target_city,world_map)[1])
gth=True
except IndexError:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ : ᴇɴᴛᴇʀ ᴀ ᴠᴀʟɪᴅ ɴᴀᴍᴇ, ᴄʜᴇᴄᴋ ꜰʀᴏᴍ ᴛʜᴇ ʟɪꜱᴛ ᴏꜰ ᴄɪɪᴇꜱ
ʏᴏᴜ ᴏᴘᴇɴᴇᴅ ᴀʙᴏᴠᴇ')
try:
tik_cost = cost[tuple(find_country(initial_city,target_city,world_map))]
except KeyError:
tik_cost=cost[tuple(reversed(find_country(initial_city,target_city,world_m
ap)))]
passengers.append((tik_cost*num_persons)+cost_adder)
passengers.append(choice_idk)
passengers.append(initial_city)
passengers.append(target_city)
for i in range(num_persons):
seat_num=random.randint(1,50)
seat_block=['A','B','C','D'][random.randint(0,3)]
seat=str(seat_num)+seat_block
passengers[i]['SeatBlock']=(seat_block)
passengers[i]['Seat']=(seat)
gate="Gate "+str(random.randint(1,10))
flight_str=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q
','R','S','T','U','V','W','X','Y','Z'][random.randint(0,25)]
flight_str=flight_str+['A','B','C','D','E','F','G','H','I','J','K','L','M','N'
,'O','P','Q','R','S','T','U','V','W','X','Y','Z'][random.randint(0,25)]
flight_str=flight_str+['A','B','C','D','E','F','G','H','I','J','K','L','M','N'
,'O','P','Q','R','S','T','U','V','W','X','Y','Z'][random.randint(0,25)]
flight_number=str(random.randint(1000,9999))
flight_str=flight_str+flight_number
passengers.append(gate)
passengers.append(flight_str)
passengers.append(timebruh)
passengers.append(num_persons)
print()
print('═'*35)
bookings[time_12hr()]=(passengers)
elif inp_gt==3:
print()
print('═'*35)
print()
if len(bookings)==0:
print('⚠ ɴᴏᴛɪᴄᴇ ⚠ : ʏᴏᴜ ʜᴀᴠᴇ ɴᴏ ʙᴏᴏᴋɪɴɢꜱ ꜱᴄʜᴇᴅᴜʟᴇᴅ.')
else:
print('ᴇxɪꜱᴛɪɴɢ ʙᴏᴏᴋɪɴɢꜱ:')
gt67=False
suggus_niggus()
def time_12hr():
'''This function parses the time from datetime module to a modern format(easy to
read)'''
month={1:'January',2:'February',3:'March',4:'April',5:'May',6:'June',7:'July',8:'Augus
t',9:'September',10:'October',11:'November',12:'December'}
time_now=datetime.datetime.now()
year=time_now.year
y=time_now.month
x=time_now.day
hour=time_now.hour
meridiem='AM'
if (x>3 and x<21) or (x>23 and x<31):
suffix='th'
elif x==1 or x==21:
suffix='st'
elif x==2 or x==22:
suffix='nd'
elif x==3 or x==33:
suffix='rd'
if hour>12:
hour-=12
meridiem='PM'
minute=time_now.minute
str1=' '+str(hour)+':'+str(minute)+''+meridiem+', '+str(x)+suffix+' '+month[y]+',
'+str(year)
return str1
def find_country(x,y,z):
''' This function will take initial city, target city and all countires as its
arguments and will return a
list [initial_country,target_country]'''
a=[]
for i in z:
for j in i:
if x==j:
a.append(i[0])
for i in z:
for j in i:
if y==j:
a.append(i[0])
return a
#main