Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: practice Python programming with string processing, collections, and file I/O Understanding a large program usually requires knowledge of the calling relationships between functions or

Objective: practice Python programming with string processing, collections, and file I/O

Understanding a large program usually requires knowledge of the calling relationships between functions or methods as well as dependencies between their larger units of modularization, such as classes. Oftentimes, when we're trying to study function FA, we need to know which other functions call it. And if there are numerous calling functions, we sometimes just need to know which classes they belong to, for future investigation.

In this programming assignment, the input is a text file with the following format:

C1.f1 calls C1.f2 C1.f3 calls C1.f2 C2.f4 calls C1.f3 C2.f4 calls C2.f5 C2.f4 calls C3.f1 C1.f1 calls C1.f1 C2.f5 calls C3.f1

That is, each line tells you which function calls which other function, as qualified by their class name. Similar to Java, functions in different classes may have the same names, hence the class qualifier. Note that, as in the second to last line, a function might call itself. For the purpose of this project, assume that all lines will be of this format: ClassA.functionB calls ClassX.functionY, that is, each function listed is part of a class.

Requirements:

Your program will read the file and store the relationships in a collection structure. It is up to you to determine the proper collection(s) to use.

Next, your program will output the following reports to standard output:

Called by relationships - list which functions call a given function, in a format like this:

Called by relationships: C1.f1 is called by C1.f1 C1.f2 is called by C1.f1,C1.f3 C1.f3 is called by C2.f4 C2.f4 is not called by any function C2.f5 is called by C2.f4 C3.f1 is called by C2.f4,C2.f5

If a function is called from multiple functions, each of those calling functions are listed in a comma-separated format. Note that this output should be sorted alphabetically.Class dependencies - list which class uses functions from which other class, like this:

Class dependencies: C2 uses C1,C3

If a class uses multiple classes, each of those are listed in a comma-separated format. Note that self relationships are excluded from this list (so you won't see C1 uses C1 or C2 uses C1, C2, C3 and so on) since that is nearly true with every class usually having functions that call other functions inside it.Class reverse dependencies - this is the reverse relationship from the previous output. List which class are used by other classes, like this:

Class reverse dependencies: C1 is used by C2 C3 is used by C1

As in the previous output, self relationships (e.g., C2 is used by C2) are excluded from this list. If a class is used by multiple classes, each of those are listed in a comma-separated format.

Additional Requirements

Handle exceptions for incorrect input format. For example, the following lines should be flagged:

C1 calls C2.f2 # C1 is missing a function C1.f1 # does not call anything C1.f1.f2 calls C3.f3 # multiple qualifiers on f2

Just print the error as incorrect input line with the line itself and ignore the line in subsequent processing.

There should be at least 2 classes, a DataExtractor class that includes responsibilities for reading the file and putting the inputs into an appropriate collection, and a GraphAnalysis class that performs the necessary analysis of the input data and produces the 3 outputs outlined above. Optionally, the actual generation of outputs can also be separated into its own class. You can define more classes than these according to your design preference.

Include a docstring for each major function you create explaining what its responsibilities are.

Submit one Python file for each class as well as a separate Python file that calls these, and your own test data file with at least 10 valid lines.

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions