Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify this code so that it give information of individuals who live in that location if location is found and the location i want is

Modify this code so that it give information of individuals who live in that location if location is found and the location i want is kansas city from xmlrpc.server import SimpleXMLRPCServer
import sys
import json
def load_data(group):
# Load data based on which portion it handles (am or nz)
file_path = f'data-{group}.json'
with open(file_path, 'r') as file:
data = json.load(file)
return data
class Worker:
def __init__(self, group):
self.data = load_data(group)
def getbyname(self, name):
result =[self.data.get(name,{})]
return {'error': False, 'result': result}
def getbylocation(self, location):
result =[]
for person in self.data.values():
if person["location"]== location:
result.append(person)
return {'error': False, 'result': result}
def getbyyear(self, location, year):
result =[record for record in self.data.values() if record['location']== location and record['year']== year]
return {'error': False, 'result': result}
def main():
if len(sys.argv)<3:
print('Usage: worker.py ')
sys.exit(0)
port = int(sys.argv[1])
group = sys.argv[2]
server = SimpleXMLRPCServer(("localhost", port))
print(f"Worker listening on port {port} for group {group}...")
# Register the Worker class instance
server.register_instance(Worker(group))
server.serve_forever()
if __name__=='__main__':
main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago