# Read in file. # Parse JSON, extract current weather. # # Print the weather out to the user, nicely formatted. # # If file cannot be opened, or invalid JSON is detected, # prints an error message and exits. # def read_weather(filename): # Open file # Read until opening curly-bracket read_until_curly_bracket() # Handle errors returned by curly-bracket method. read_next_field_name() # Handle errors returned by method # # Read white-space up to first curly-bracket. # # Returns true if found, false if characters other than curly-bracket and white-space are found. # def read_until_curly_bracket(file): # Loop, reading whitespace or curly-bracket until curly-bracket found. # # Reads in a field name (surrounded by quotes), up to the next colon. # If quote is not next character read from file, returns false # def read_next_field_name(): # Read quote. Error if not quote.