@@ -22,45 +22,19 @@ python setup.py install
2222```
2323
2424## Usage
25-
26- ### Reading a USF file
2725``` python
2826import usf
2927
30- # Initialize the USF Parser with the file path
31- parser = usf.USFParser(" schedule.usf" )
32-
33- # Get subjects from the parsed data
34- subjects = parser.get_subjects()
35- print (subjects)
36-
37- # Get periods
38- periods = parser.get_periods()
39- print (periods)
40-
41- # Get the timetable
42- timetable = parser.get_timetable()
43- print (timetable)
44- ```
45-
46- ### Validating a USF file
47- ``` python
48- import usf
49-
50- # Initialize the USF Validator with a schema file
51- validator = usf.USFValidator(" schema.json" )
52-
53- # Validate the parsed data
54- if validator.validate(data):
55- print (" Valid USF data" )
28+ # Reading a USF file
29+ data = usf.read(" schedule.usf" )
30+ if usf.is_valid(data):
31+ print (" Valid USF file" )
32+ subjects = usf.get_subjects(data)
33+ print (subjects)
5634else :
57- print (" Invalid USF data" )
58- ```
59-
60- ### Creating a USF file
61- ···python
62- import usf
35+ print (" Invalid USF file" )
6336
37+ # Creating a USF file
6438# Initialize the USF Generator (version 1 by default)
6539usf_generator = usf.USFGenerator()
6640
@@ -78,45 +52,27 @@ usf_generator.add_schedule(day=2, week_type="odd", subject="Physics", period_ind
7852
7953# Generate the USF data and save it to a file
8054usf_generator.save_to_file(" schedule.usf" )
81- ···
82-
83- ### Adding a Course to an Existing USF File
84- ``` python
85- import usf
8655
87- # Initialize the USF Parser
56+ # Adding a Course to an Existing USF File
8857data = usf.read(" schedule.usf" )
89-
90- # Add a new subject
9158usf.add_subject(data, {
9259 " name" : " Physics" ,
9360 " teacher" : " Prof. Johnson" ,
9461 " location" : " Room 203" ,
9562 " time" : [3 , 4 ],
9663 " week" : " odd"
9764})
98-
99- # Save the updated schedule
10065usf.save(data, " updated_schedule.usf" )
101- ```
102-
103- ### Generating a USF File from Scratch
104- ``` python
105- import usf
10666
107- # Initialize the USF Generator
67+ # Generating a USF File from Scratch
10868schedule = usf.create()
109-
110- # Add a subject
11169usf.add_subject(schedule, {
11270 " name" : " Computer Science" ,
11371 " teacher" : " Ms. Lee" ,
11472 " location" : " Lab 2" ,
11573 " time" : [5 , 6 ],
11674 " week" : " even"
11775})
118-
119- # Save the new schedule
12076usf.save(schedule, " new_schedule.usf" )
12177```
12278
0 commit comments