Skip to content

Commit

Permalink
titles now in txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
JibrilExe committed May 3, 2024
1 parent d65cb7d commit c20d320
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 213 deletions.
211 changes: 0 additions & 211 deletions backend/seeder/elements.py

This file was deleted.

13 changes: 11 additions & 2 deletions backend/seeder/seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy_utils import register_composites

from elements import course_titles
from project.models.course import Course
from project.models.course_relation import CourseAdmin, CourseStudent
from project.models.project import Project
Expand All @@ -25,9 +24,19 @@

fake = Faker()

# Get the directory of the current script
script_dir = os.path.dirname(os.path.realpath(__file__))

# Construct the path to titles.txt relative to the script directory
titles_path = os.path.join(script_dir, 'titles.txt')

with open(titles_path, 'r', encoding='utf-8') as file:
# Read the lines of the file and strip newline characters
titles = [line.strip() for line in file]

course_title_provider = DynamicProvider( # Custom course titles.
provider_name="course_titles",
elements=course_titles,
elements=titles,
)
fake.add_provider(course_title_provider)

Expand Down
Loading

0 comments on commit c20d320

Please sign in to comment.