Skip to content

Commit e32b90d

Browse files
authored
Update README.md
1 parent fa20cd9 commit e32b90d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
# PyCaptionCompiler
22
A rewritten caption compiler for Source File games in Python
3+
4+
### Run with -h to get information on how to use this program.
5+
6+
## This repository is also houses the main library.
7+
This library is used to compile captions natively in Python without calling a separate executable. In order to use this library you have to install it via pip, or add it to requirements.txt:
8+
`pip install git+https://github.com/Project-Collapse-Studios/PyCaptionCompiler.git`
9+
10+
Then you can use this library as such:
11+
```py
12+
from pycaptioncompiler import Subtitles # Subtitles is the compiler class
13+
14+
subs = Subtitles.from_path("C:/path/to/file/file.txt") # Will open the file and handle encoding, this is the recommended option
15+
subs = Subtitles.from_file(file) # An already opened file
16+
subs = Subtitles.from_keyvalues(<srctools.KeyValues>) # From an already parsed file with srctools.KeyValues
17+
18+
with open("C:/subtitles_out.dat", "wb") as f:
19+
f.write(subs.serialize()) # Calling serialize actually compiles the file and serializes it, returning it.
20+
```

0 commit comments

Comments
 (0)