Skip to content

Commit a23a58a

Browse files
Update README.md
1 parent a5588ec commit a23a58a

File tree

1 file changed

+10
-54
lines changed

1 file changed

+10
-54
lines changed

README.md

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,19 @@ python setup.py install
2222
```
2323

2424
## Usage
25-
26-
### Reading a USF file
2725
```python
2826
import 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)
5634
else:
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)
6539
usf_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
8054
usf_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
8857
data = usf.read("schedule.usf")
89-
90-
# Add a new subject
9158
usf.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
10065
usf.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
10868
schedule = usf.create()
109-
110-
# Add a subject
11169
usf.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
12076
usf.save(schedule, "new_schedule.usf")
12177
```
12278

0 commit comments

Comments
 (0)