Skip to content

Commit

Permalink
Added std library
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-balades committed May 24, 2024
1 parent f0df605 commit 1b7df0b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 68 deletions.
51 changes: 25 additions & 26 deletions check_packages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import os
import json
import tomllib

has_error = False

Expand Down Expand Up @@ -36,39 +35,39 @@
print(GREEN + "OK" + RESET)

# See if the package has a "sn.toml" file
print(" PACKAGE CONFIG: ...", end=' ')
if os.path.isfile(".temp/sn.toml"):
print(" PACKAGE DEPS: ...", end=' ')
if os.path.isfile(".temp/deps.reky"):
# If it does, then it's a valid package
print(GREEN + "OK" + RESET)

# Load the "sn.toml" file
with open(".temp/sn.toml", "r") as sn_toml_file:
# Load the "sn.toml" file
sn_toml_data = tomllib.loads(sn_toml_file.read())

print(" ENTRY EXISTENCE: ...", end=' ')
# See if the package has an entry
if "main" in sn_toml_data["package"]:
entry = sn_toml_data["package"]["main"]
with open(f".temp/{entry}", "r") as entry_file:
print(GREEN + "OK" + RESET)
else:
# If it doesn't, then it's an invalid package
content = open(".temp/deps.reky", "r").read()
for dep in content.splitlines():
if dep.startswith("#"):
continue
line = dep.strip()
if line == "":
continue
split = line.split("==")
if len(split) != 2:
print(RED + "INVALID" + RESET)
has_error = True

print(" DEPENDENCIES EXISTENCE: ...", end=' ')
# See if the package has dependencies
if "dependencies" in sn_toml_data:
dependencies = sn_toml_data["dependencies"]
for dependency in dependencies:
# only check if the dependency exists in the pkgs folder
if os.path.isfile(f"pkgs/{dependency}.json"):
break
dep_name = split[0]
dep_version = split[1]
print(" " + dep_name + " " + dep_version + ": ...", end=' ')
try:
# Check if the dependency exists
with open("pkgs/" + dep_name + ".json", "r") as dep_file:
dep_data = json.load(dep_file)
if dep_version in dep_data["versions"]:
print(GREEN + "OK" + RESET)
else:
print(RED + "INVALID" + RESET)
has_error = True
else: print(GREEN + "OK" + RESET)
except Exception as e:
print(RED + "ERROR" + RESET)
print(e)
has_error = True

else:
# If it doesn't, then it's an invalid package
print(RESET + "INVALID" + RESET)
Expand Down
14 changes: 0 additions & 14 deletions pkgs/is_even.json

This file was deleted.

14 changes: 0 additions & 14 deletions pkgs/is_odd.json

This file was deleted.

14 changes: 0 additions & 14 deletions pkgs/rgb.json

This file was deleted.

17 changes: 17 additions & 0 deletions pkgs/std.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "std",
"download_url": "https://github.com/snowball-lang/std.git",
"tags": [
"snowball",
"standard-library",
"stdlib",
"std",
"core"
],
"versions": [
"0.0.1"
],
"description": "Standard library for the Snowball programming language",
"license": "MIT",
"web": "https://github.com/snowball-lang/std"
}

0 comments on commit 1b7df0b

Please sign in to comment.