@@ -11,56 +11,56 @@ Pyben Enables fast and easy encoding and decoding of bencoded data.
1111
1212## Prerequisites
1313
14- * Python3 installed and enabled
14+ * Python3 installed and enabled
1515
1616## Installing PyBen
1717
1818To install PyBen, follow these steps:
1919
2020Using pip:
2121
22- ``` bash
23- pip install pyben
24- ```
22+ ```bash
23+ pip install pyben
24+ ```
2525
2626Using git:
2727
28- ``` cmd
29- git clone https://github.com/alexpdev/pyben.git
30- ```
28+ ```cmd
29+ git clone https://github.com/alexpdev/pyben.git
30+ ```
3131
3232## Using PyBen
3333
3434The API is intentionally designed to mimic Python's json module.
3535
36- ``` python
37- >> > fd = " path/to/file"
38- >> > data = {" item1" : [" item2" , 3 , [4 ], {5 : " item6" }]}
39- >> > encoded = pyben.dumps(data)
40- >> > encoded
41- b ' d5:item1l5:item2i3eli4eedi5e5:item6eee'
42- >> > decoded = pyben.loads(encoded)
43- {' item1' : [' item2' , 3 , [4 ], {5 : ' item6' }]}
44- ```
36+ ```python
37+ >>> fd = "path/to/file"
38+ >>> data = {"item1": ["item2", 3, [4], {5: "item6"}]}
39+ >>> encoded = pyben.dumps(data)
40+ >>> encoded
41+ b'd5:item1l5:item2i3eli4eedi5e5:item6eee'
42+ >>> decoded = pyben.loads(encoded)
43+ {'item1': ['item2', 3, [4], {5: 'item6'}]}
44+ ```
4545
4646One key difference is that the 'load' and 'dump' methods accept as arguments,
4747string paths or path objects as well as open iobuffer.
4848
4949For Example this:
5050
51- ``` python
52- >> with open (" encoded.file" , " wb" ) as fd:
53- ... pyben.dump(data, fd)
54- >> with open (" encoded.file" , " rb" ) as fd:
55- ... decoded = pyben.load(fd)
56- ```
51+ ```python
52+ >> with open("encoded.file", "wb") as fd:
53+ ... pyben.dump(data, fd)
54+ >> with open("encoded.file", "rb") as fd:
55+ ... decoded = pyben.load(fd)
56+ ```
5757
5858is the same as doing following.
5959
60- ``` python
61- >> > pyben.dump(data, " encoded.file" )
62- >> > decoded = pyben.load(" encoded.file" )
63- ```
60+ ```python
61+ >>> pyben.dump(data, "encoded.file")
62+ >>> decoded = pyben.load("encoded.file")
63+ ```
6464
6565The full API includes many other functions and classes as well.
6666See docs for more full API.
0 commit comments