osc-vitap / OpenSource101

This is a starter repository made specifically so we can help you get your first pull request and learn the basics of Git and GitHub.
https://opensource101.oscvitap.org/
GNU General Public License v3.0
85 stars 109 forks source link

Optimized Data Unification and Directory Handling #110

Closed PB2204 closed 1 year ago

PB2204 commented 1 year ago

About Me

Full-Stack Web Developer & AI-ML Enthusiast With Some Knowledge Of Block-Chain Technology. A Very Ordinary Man Who Knows To Interact With The Dumb Computers.

Name : Pabitra Banerjee

Tick the check boxes below if true :

On a scale of 1 - 10, 1 being very easy and 10 being hard, how difficult did you find it to create a pull request ? : 1



Make sure you fill in this form before sending a pull request.

Certainly! Here's a beautifully crafted pull request description based on the changes made to your code:


Pull Request: Optimized Data Unification and Directory Handling

Description: This pull request enhances the existing code for unifying data from multiple JSON files and storing it in a single JSON file while improving code structure and handling directory-related issues.

Changes Made:

  1. Improved Directory Handling:

    • Utilized a context manager (with) for changing directories to ensure that the working directory is always restored to its original state.
    • Defined the current_dir variable to store the current working directory and used it for returning to the original directory after processing the JSON files.
  2. File Type Check:

    • Added a check to ensure that only JSON files with the ".json" extension are opened. This avoids potential issues when there are other non-JSON files in the "contributors" directory.
  3. Target Directory Handling:

    • Defined the target_directory variable to specify the location for the output file.
    • Created the target_directory using os.makedirs with exist_ok=True to ensure it exists and is ready for the output file.
  4. Path Construction:

    • Utilized os.path.join to construct the full path to the output file. This ensures cross-platform compatibility for specifying the file path.
  5. JSON Output Formatting:

    • Added an indent parameter when writing the JSON data, resulting in a more human-readable output file.

Testing:

Closing Notes: This pull request aims to improve the code's readability, maintainability, and robustness while handling potential issues that may arise during directory operations. Your review and feedback on the changes made are highly appreciated.