Skip to content

Commit

Permalink
feat(devtools): move the 4 local courses to the configuration file, s…
Browse files Browse the repository at this point in the history
…implify code generating dev pages
  • Loading branch information
szabgab committed Jan 15, 2022
1 parent 27723a3 commit d64da8b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
48 changes: 18 additions & 30 deletions apps/tools/librelingo_tools/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,45 +96,33 @@ def main():
links = []
courses_data = {}

for course in courses:
download_course(course["url"], tempdir)
sdir = os.path.join(tempdir.name, course["sdir"])
generate_course(
links=links,
courses_data=courses_data,
sdir=sdir,
reldir="course",
outdir=outdir,
tdir=course["tdir"],
course_dir=os.path.join(sdir, "course"),
)

root = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
)

generate_course(
links=links,
courses_data=courses_data,
sdir=root,
reldir="course",
outdir=outdir,
tdir="basque-from-english",
course_dir=os.path.join(root, "courses", "basque-from-english"),
)
for course in courses:
if "url" in course:
download_course(course["url"], tempdir)
sdir = os.path.join(tempdir.name, course["sdir"])
else:
sdir = root

reldir = "course"
if "reldir" in course:
reldir = course["reldir"]

course_dir = os.path.join(sdir, "course")
if "course_dir" in course:
course_dir = os.path.join(root, course["course_dir"])

courses_dir = os.path.join(root, "temporarily_inactive_courses")
for tdir in os.listdir(courses_dir):
if tdir == "basque-from-english":
continue
generate_course(
links=links,
courses_data=courses_data,
sdir=root,
reldir=os.path.join("temporarily_inactive_courses", tdir),
sdir=sdir,
reldir=reldir,
outdir=outdir,
tdir=tdir,
course_dir=os.path.join(courses_dir, tdir),
tdir=course["tdir"],
course_dir=course_dir,
)

end_time = datetime.datetime.now()
Expand Down
19 changes: 19 additions & 0 deletions config/courses.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,24 @@
"url": "https://codeberg.org/Lamdarer/LibreLingo-DE-from-EN/archive/main.zip",
"sdir": "librelingo-de-from-en",
"tdir": "german-from-english"
},
{
"tdir": "basque-from-english",
"course_dir": "courses/basque-from-english"
},
{
"tdir": "bangla-from-english",
"reldir": "temporarily_inactive_courses/bangla-from-english",
"course_dir": "temporarily_inactive_courses/bangla-from-english"
},
{
"tdir": "french-from-english",
"reldir": "temporarily_inactive_courses/french-from-english",
"course_dir": "temporarily_inactive_courses/french-from-english"
},
{
"tdir": "parsig-from-english",
"reldir": "temporarily_inactive_courses/parsig-from-english",
"course_dir": "temporarily_inactive_courses/parsig-from-english"
}
]

1 comment on commit d64da8b

@vercel
Copy link

@vercel vercel bot commented on d64da8b Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.