Skip to content

Commit

Permalink
Fix updating the list of languages, and add Inko back to the list (al…
Browse files Browse the repository at this point in the history
…illeybrinker#50)

* Fix updating the list of languages

The old approach of updating languages would produce inconsistent
results in the JSON file. For example, when adding Inko and running
update.py, Inko would be removed from the list while Dyon would exist
twice.

This commit changes this by simply appending data to a new list, instead
of modifying the old list in-place.

* Add Inko back to the list of languages
  • Loading branch information
yorickpeterse authored Jul 1, 2022
1 parent 7e60b98 commit 59ab775
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Then it can be included in this list!
| [Orion] | 225 | ☀️ Active | A high level, purely functional programming language with a LISP based syntax. |
| [EndBASIC] | 205 | ☀️ Active | BASIC environment with a REPL, a web interface, and RPi support written in Rust. |
| [Eldiro] | 181 | ☀️ Active | A programming language to teach how to implement languages in Rust. |
| [Inko] | 170 | ☀️ Active | Inko is a statically-typed, safe, object-oriented programming language for writing concurrent programs. |
| [Sway] | 133 | ☀️ Active | Sway is a language developed for the Fuel blockchain. |
| [atto] | 131 | ☀️ Active | A simple self-hosted functional programming language. |
| [Butter] | 106 | ☀️ Active | A tasty language for building efficient software. |
Expand Down Expand Up @@ -208,3 +209,4 @@ broader than a programming language project.
[Chili]: https://github.com/r0nsha/chili
[Foolang]: https://github.com/nikodemus/foolang
[Rust]: https://github.com/rust-lang/rust
[Inko]: https://github.com/YorickPeterse/inko
9 changes: 8 additions & 1 deletion languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,5 +656,12 @@
"url": "https://github.com/rust-lang/rust",
"stars": 67593,
"active": true
},
{
"name": "Inko",
"description": "Inko is a statically-typed, safe, object-oriented programming language for writing concurrent programs.",
"url": "https://github.com/YorickPeterse/inko",
"stars": 170,
"active": true
}
]
]
21 changes: 12 additions & 9 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ def api_request(token):
with open("languages.json", "r+", encoding="utf-8") as file:
# Read the current state of the file.
languages = json.load(file)
new_data = []

for count, lang in enumerate(languages):
for lang in languages:
# TODO: Also support requests to other APIs like GitLab to get this info.
if "github.com" in lang["url"]:
# Get the URL for the proper API request.
Expand All @@ -124,17 +125,19 @@ def api_request(token):

# Get the latest data and update the list.
data = response.json()
languages[count - 1] = {
"name": lang["name"],
"description": lang["description"],
"url": lang["url"],
"stars": data["stargazers_count"],
"active": is_active(data["updated_at"]),
}
new_data.append(
{
"name": lang["name"],
"description": lang["description"],
"url": lang["url"],
"stars": data["stargazers_count"],
"active": is_active(data["updated_at"]),
}
)

# Update the file.
file.seek(0)
json.dump(languages, file, indent=4)
json.dump(new_data, file, indent=4)
file.truncate()


Expand Down

0 comments on commit 59ab775

Please sign in to comment.