-
-
Notifications
You must be signed in to change notification settings - Fork 0
Initial python script to read json files #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maitecr
wants to merge
7
commits into
main
Choose a base branch
from
feat/readjson
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e073eea
Initial python script to read json files
maitecr b88dba7
Creating dict by json files
maitecr 7e43d82
create csv file
maitecr 25e87a4
Update scripts/generate_csv.py
maitecr a95ecc0
modules created and updated workflow pathes
maitecr 0212b60
try to add a new folder
maitecr 71ddd36
remove create folder line
maitecr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 212 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 552 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"health_percentage":75,"description":"Linguagem de programação 100% em português baseada em TypeScript, independente de sistema operacional e dispositivo, e suporte a múltiplos dialetos.","documentation":"https://designliquido.github.io/delegua/","files":{"code_of_conduct":null,"code_of_conduct_file":null,"contributing":{"url":"https://api.github.com/repos/DesignLiquido/delegua/contents/CONTRIBUTING.md","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/CONTRIBUTING.md"},"issue_template":null,"pull_request_template":null,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/LICENSE"},"readme":{"url":"https://api.github.com/repos/DesignLiquido/delegua/contents/README.md","html_url":"https://github.com/DesignLiquido/delegua/blob/principal/README.md"}},"updated_at":"2025-07-16T17:00:12Z","content_reports_enabled":true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"forkCount":26} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"name":"0.48.2","publishedAt":"2025-08-02T20:40:49Z","tagName":"0.48.2","url":"https://github.com/DesignLiquido/delegua/releases/tag/0.48.2"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"isSecurityPolicyEnabled":true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"stargazerCount":332} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"watchers":{"totalCount":6}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| stars_count,watchers_count,fork_count,last_release_name,last_release_date,contributors_count,open_issues_count,closed_issues_count,open_prs_count,closed_prs_count,community_stardards_description,community_stardards_readme,community_stardards_code_of_conduct,community_stardards_contributing,community_stardards_license,community_stardards_security_policy,community_stardards_issues_templates,community_stardards_pr_template,community_stardards_content_reports_enabled | ||
| 332,6,26,0.48.2,2025-08-02T20:40:49Z,16,8,212,1,552,True,True,False,True,True,True,False,False,True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import json, csv | ||
|
|
||
| # --- OPEN JSON FILES --- # | ||
| # Star count | ||
| with open('./files/stargazerCount.json') as star_count_json: | ||
| star_count_data = json.load(star_count_json) | ||
| # print('Star count: ', star_count_data,'\n') | ||
|
|
||
| # Watchers count | ||
| with open('./files/watchersCount.json') as watchers_count_json: | ||
| watchers_count_data = json.load(watchers_count_json) | ||
| # print('Watchers count: ', watchers_count_data,'\n') | ||
|
|
||
| # Fork count | ||
| with open('./files/forkCount.json') as fork_count_json: | ||
| fork_count_data = json.load(fork_count_json) | ||
| # print('Fork count: ', fork_count_data) | ||
|
|
||
| # Last Release | ||
| with open('./files/lastReleaseData.json') as last_release_json: | ||
| last_release_data = json.load(last_release_json) | ||
| # print('Last release: ', last_release_data) | ||
| '' | ||
| # Contributors Count | ||
| with open('./files/contributorsCount.json') as contributors_count_json: | ||
| contributors_count_data = json.load(contributors_count_json) | ||
| # print('Conbributors count: ', contributors_count_data) | ||
|
|
||
| # Open Issues | ||
| with open ('./files/openIssuesCount.json') as open_issues_count_json: | ||
| open_issues_count_data = json.load(open_issues_count_json) | ||
| # print('Open ISSUES: ', open_issues_count_data) | ||
|
|
||
| # Closed Issues | ||
| with open('./files/closedIssuesCount.json') as closed_issues_count_json: | ||
| closed_issues_count_data = json.load(closed_issues_count_json) | ||
| # print('Closed ISSUES: ', closed_issues_count_data) | ||
|
|
||
| # Open PRs Count | ||
| with open('./files/openPRsCount.json') as open_prs_count_json: | ||
| open_prs_count_data = json.load(open_prs_count_json) | ||
| # print('Open PRs: ', open_prs_count_data) | ||
|
|
||
| # Closed PRs Count | ||
| with open('./files/closedPRsCount.json') as closed_prs_count_json: | ||
| closed_prs_count_data = json.load(closed_prs_count_json) | ||
| # print('Closed PRs: ', closed_prs_count_data) | ||
|
|
||
| # Community Standards | ||
| with open('./files/communityStandards.json') as community_standards_json: | ||
| community_standards_data = json.load(community_standards_json) | ||
| # print('Community Standards: ', community_standards_data) | ||
|
|
||
| # Security Data | ||
| with open('./files/security.json', 'r') as security_json: | ||
| secutiry_data = json.load(security_json) | ||
|
maitecr marked this conversation as resolved.
Outdated
|
||
| # print('Secutiry enabled: ', secutiry_data) | ||
|
|
||
|
|
||
| print('TESTS: generating dicts') | ||
|
|
||
| repo_data_dict = { | ||
|
maitecr marked this conversation as resolved.
Outdated
|
||
| 'stars_count': star_count_data['stargazerCount'], | ||
| 'watchers_count': watchers_count_data['watchers']['totalCount'], | ||
| 'fork_count': fork_count_data['forkCount'], | ||
| 'last_release_name': last_release_data['name'], | ||
| 'last_release_date': last_release_data['publishedAt'], | ||
| 'contributors_count': contributors_count_data, | ||
| 'open_issues_count': open_issues_count_data, | ||
| 'closed_issues_count': closed_issues_count_data, | ||
| 'open_prs_count': open_prs_count_data, | ||
| 'closed_prs_count': closed_prs_count_data, | ||
| 'community_stardards_description': True if community_standards_data.get('description') else False, | ||
|
maitecr marked this conversation as resolved.
Outdated
|
||
| 'community_stardards_readme': True if community_standards_data.get('files', {}).get('readme') is not None else False , | ||
| 'community_stardards_code_of_conduct': True if community_standards_data.get('files', {}).get('code_of_conduct') is not None else False, | ||
| 'community_stardards_contributing': True if community_standards_data.get('files', {}).get('contributing', {}).get('url') is not None else False, | ||
| 'community_stardards_license': True if community_standards_data.get('files', {}).get('license', {}.get('name')) is not None else False, | ||
|
maitecr marked this conversation as resolved.
Outdated
|
||
| 'community_stardards_security_policy': secutiry_data['isSecurityPolicyEnabled'], | ||
| 'community_stardards_issues_templates': True if community_standards_data.get('files', {}).get('issue_template') is not None else False, | ||
| 'community_stardards_pr_template': True if community_standards_data.get('files', {}).get('pull_request_template') is not None else False, | ||
| 'community_stardards_content_reports_enabled': community_standards_data.get('content_reports_enabled') | ||
|
maitecr marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| with open("repo_health_data.csv", "w", newline="", encoding="utf-8") as repo_health_data: | ||
| writer = csv.DictWriter(repo_health_data, fieldnames=repo_data_dict.keys()) | ||
| writer.writeheader() | ||
| writer.writerow(repo_data_dict) | ||
|
|
||
| print(repo_data_dict) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a suggestion to improve the maintainability and readability of this script: consider refactoring the repeated code blocks for loading JSON files and building the data dictionary into functions. This would help avoid repetition, make the code easier to update, and simplify testing in the future. One idea of how it could look like:
You can also create methods to get the nested attributes in a dict, to evaluate if the key is inside the dict... so then you can reuse them and make things easier to read and test.