@@ -22,45 +22,19 @@ python setup.py install
22
22
```
23
23
24
24
## Usage
25
-
26
- ### Reading a USF file
27
25
``` python
28
26
import usf
29
27
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)
56
34
else :
57
- print (" Invalid USF data" )
58
- ```
59
-
60
- ### Creating a USF file
61
- ···python
62
- import usf
35
+ print (" Invalid USF file" )
63
36
37
+ # Creating a USF file
64
38
# Initialize the USF Generator (version 1 by default)
65
39
usf_generator = usf.USFGenerator()
66
40
@@ -78,45 +52,27 @@ usf_generator.add_schedule(day=2, week_type="odd", subject="Physics", period_ind
78
52
79
53
# Generate the USF data and save it to a file
80
54
usf_generator.save_to_file(" schedule.usf" )
81
- ···
82
-
83
- ### Adding a Course to an Existing USF File
84
- ``` python
85
- import usf
86
55
87
- # Initialize the USF Parser
56
+ # Adding a Course to an Existing USF File
88
57
data = usf.read(" schedule.usf" )
89
-
90
- # Add a new subject
91
58
usf.add_subject(data, {
92
59
" name" : " Physics" ,
93
60
" teacher" : " Prof. Johnson" ,
94
61
" location" : " Room 203" ,
95
62
" time" : [3 , 4 ],
96
63
" week" : " odd"
97
64
})
98
-
99
- # Save the updated schedule
100
65
usf.save(data, " updated_schedule.usf" )
101
- ```
102
-
103
- ### Generating a USF File from Scratch
104
- ``` python
105
- import usf
106
66
107
- # Initialize the USF Generator
67
+ # Generating a USF File from Scratch
108
68
schedule = usf.create()
109
-
110
- # Add a subject
111
69
usf.add_subject(schedule, {
112
70
" name" : " Computer Science" ,
113
71
" teacher" : " Ms. Lee" ,
114
72
" location" : " Lab 2" ,
115
73
" time" : [5 , 6 ],
116
74
" week" : " even"
117
75
})
118
-
119
- # Save the new schedule
120
76
usf.save(schedule, " new_schedule.usf" )
121
77
```
122
78
0 commit comments