Vergil
KEEP IT CLEAN!
Vergil is a simple Pure Python library to help keep your JSON files clean and sporty! Vergil maintains your JSON files so you don't have to.
Why is this a thing?
Vergil was made as an annoynance of mine with constantly maintaining old, rubbish JSON files. Vergil aims to keep the JSON polished and fine!
This is cool, but how do I get it?
- Use pip
sudo pip3 install vergil
- Download the source code and do a quick install.
git clone https://github.com/KuanHulio/Vergil.git
cd Vergil
python setup.py install
Documentation?
I run my documentations like FAQ's. Instead of having multiple, tiring searches for docs and comments, you can refer to a question.
Q: How do I even start the library?
Simple.
from vergil.manager import Vergil
manager = Vergil("path/to/store/dbs")
Q: How do I actually do anything now?
Vergil's main class is nothing more than a Get and Set. Main file operations are subclassed into list, create, drop, check
for simple syntax. If I wanted a list of all DB's inside the path, I would do this:
from vergil.manager import Vergil
manager = Vergil("path/to/store/dbs")
list_of_files = manager.list().dbs()
If I wanted to create a new DB, table, and record, I would do this:
from vergil.manager import Vergil, VergilException
manager = Vergil("path/to/store/dbs")
try:
manager.create().db("this_thing")
manager.create().table("this_thing", "table_thing")
manager.create().record("this_thing", "table_thing", {"file": "blah"}
except VergilException as e:
print(e) # Either a database or table already existed.
If I wanted to drop a DB, table, and all records, I would do this:
from vergil.manager import Vergil, VergilException
manager = Vergil("path/to/store/dbs")
try:
manager.drop().all_records("this_thing", "table_thing")
manager.drop().table("this_thing", "table_thing")
manager.drop().db("this_thing")
except VergilException as e:
print(e) # Either a database or table never existed.
Also, take note that drop()
has functions to drop all DB's, tables, and records.
Those have a corresponding .all_dbs()
, .all_tables()
, and .all_records()
.
Q. Wait a minute, how do I list records in a table if list doesn't have a function for records?
list().tables()
will give a list of tuples like so:
from vergil.manager import Vergil, VergilException
manager = Vergil("path/to/store/dbs")
list_of_tuples = manager.list().tables("this_thing")
print(list_of_tuples) # Assuming we didn't drop the tables
# [(table_thing, {"file": "path"})]
print(list_of_tuples[0][1]["file"])
# "path"
Q: Is there password protection?
I'm still working on that, but version 1.0.5 doesn't have that.
Q: Is it possible to have an API wrapper around this?
Yes! I'm currently writing a JSON API for this right now! Nearly all languages can take advantage of this package and API!