Question: import copy # needed in examples of functions that modify input dict from typing import TextIO from constants import ( ID , HEADLINE, LISTED, FEATURES,
import copy # needed in examples of functions that modify input dict
from typing import TextIO
from constants import ID HEADLINE, LISTED, FEATURES, LOC, DESC, END, SEP,
LocType, ListingValueType, ListingType, BookSysType
EXAMPLEBOOKSYS
:
'identifier':
'headline': 'Beautiful bedroom home on lakeside',
'listed':
'features': bedroom', bath', 'Pool'
'location': New York', 'USA'
'description': This is a beautiful bedroom, bath detached house
with an outdoor pool.
:
'identifier':
'headline': 'House',
'listed': None,
'features': clean
'location': Hamilton 'Canada'
'description': None
:
'identifier':
'headline': 'Stunning lakeside cottage
'listed':
'features':
'location': OxfordUK
'description': 'This is lakeside!
EXAMPLEBYCOUNTRY
'USA':
'Canada':
UK:
# We provide the header and docstring for this function to get you
# started and to demonstrate that there are no docstring examples in
# functions that read from files.
def readbooksysfilebooksysfile: TextIO BookSysType:
Return a dict containing all booking system info in 'booksysfile'.
Precondition: 'booksysfile' is open for reading
'booksysfile' is in the format described in the handout
pass
# We provide the header and PART of a docstring for this function to
# get you started and to demonstrate the use of example data.
def makecountrytolistings
booksys: BookSysType dictstr liststr:
Return a dict that maps each country to a list of IDs of listings in
that country based on the information in booking system data 'booksys
makecountrytolistingsEXAMPLEBOOKSYS EXAMPLEBYCOUNTRY
True
pass
# We provide the header and PART of a docstring for this function to
# get you started and to demonstrate the use of function deepcopy in
# examples that modify input data.
def keepcompletelistingsbooksys: BookSysType None:
Update the booking system data 'booksys so that it only contains
listings that are not missing any information.
booksyscopy copy.deepcopyEXAMPLEBOOKSYS
keepcompletelistingsbooksyscopy
booksyscopy : EXAMPLEBOOKSYS
True
pass
if namemain:
import doctest
doctest.testmod
# uncomment to test with example data files
# with openexampledata.txt as exampledata:
# RESULT readbooksysfileexampledata
# printDid we produce a correct dict? RESULT EXAMPLEBOOKSYS
# uncomment to work with a larger data set
# with opendatatxt as datatxt:
# EXAMPLE readbooksysfiledatatxt
# EXAMPLECOUNTRYTOLISTING makecountrytolistingsEXAMPLE
# EXAMPLEMOSTPOPULARCOUNTRIES getmostpopularcountriesEXAMPLE
# printEXAMPLEMOSTPOPULARCOUNTRIES
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
