python-snippets/examples.py
2024-07-17 22:59:13 +01:00

38 lines
1.3 KiB
Python

from pseudodb import pseudodb
from utils.file_utils import search_path
from utils.str_utils import obscure, unobscure, get_random_string, get_dash_suffix
from utils.misc_utils import immutable_to_list
if __name__ == '__main__':
db = pseudodb.PseudoDB('pseudodb.default.data')
data_collections = db.get_collections()
print("Collections in Pseudodb: "+str(data_collections))
for collection in data_collections:
print("Collection: "+collection)
for key in db.get_keys(collection):
print("\t"+key+": "+str(db.get_values(collection, key)))
print()
immutable_list = ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine')
print("Immutable: "+str(immutable_list))
shuffled_list = immutable_to_list(immutable_list, scramble=True)
print("Shuffled Mutable: "+str(shuffled_list))
files = search_path("./utils", "misc")
print("Search Results: "+str(files))
rando_string = get_random_string(30, caps=True, numbers=True, specials=True)
print("Random: "+rando_string)
obscured = obscure(rando_string)
print("Obscured: "+str(obscured))
unobscured = unobscure(obscured)
print("Unobscured: "+unobscured)
dash_suffix = get_dash_suffix("example-silly-string-with-dashes-"+get_random_string(10))
print("Suffix found: "+dash_suffix)