https://github.com/slashscreen/cowboy-file-reader
https://github.com/slashscreen/cowboy-file-reader
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/slashscreen/cowboy-file-reader
- Owner: SlashScreen
- Created: 2018-06-08T05:42:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-09T05:53:30.000Z (about 8 years ago)
- Last Synced: 2025-02-09T19:36:32.635Z (over 1 year ago)
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cowboy-file-reader
This is the read/writer for my filetype, .cowboy, I made as a multi-purpose sort of file I would use for config, dialog, savegame, etc.
The two .cowboy files are to test reading and writing
cowboytestdemo.py is a demonstration piece on how to use the module
readcowboy.py is the module itself, and doesn't do anything on its own
# Module Documentation
`read(path)`
reads the file specified at *path*. **The .cowboy extension is added at the end automatically.**
`write(name,doctype,data)`
writes to a new file, and creates one if there isn't one already there.
*name* is the filename (again, automatically adds extension)
*doctype* is the document type. Refer to style guide.
*data* is an array or whatever of data that can be put into text form.
# .cowboy Style Guide
.cowboy files aren't super forgiving. it goes as follows:
```python
document_type
dataA:1
dataB:Ralph
dataC:5.0
```
`document_type`: all lowercase, can be 1 of several types that are more or less handled differently: "testdoc", "savegame", "text"
`data`: this reads sorta like JSON, in that instead of an = there is a :, because it looks cooler. there are syntax requirements, however, that are listed below.
1. Each data point must be on a new line (no minification, sorry!)
2. Data points can be as far away from eachother as you like, as long as they are on the same line. Ex. "a : 5.3"
3. Data point can only equal 1 value. you can't do "a:3:6" because it will ignore everything past the second colon.
4. Numbers are always detected and converted automatically to floats. Ex. "a:3" will be converted "a:3.0" either in memory when the file is read or in the file itself if it is writing.
text: all you need to do for this is have 'text' as the first line of your document, and then put in anything afterwards