python-snippets/examples.py

35 lines
1.3 KiB
Python
Raw Normal View History

2024-07-17 21:30:12 +00:00
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')
print("Collections in Pseudodb: "+str(db.data_list()))
for collection in db.data_list():
print("Collection: "+collection)
for key in db.get_keys(collection):
print(key+": "+str(db.get_values(collection, key)))
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)