@shaun-h , hey are you ok to receive comments about improving this lib? Maybe it just works as you like it and you don't want to spend any extra time on it. If that's the case I understand.
But I have stored a few things now. For me it needs more.
This is one thing I stored, but I would like to have notes, as well as tags and a field for the origin as I copied it. Also I commented out a line and replaced with my own idea. Also a count of how many times I have copied it from the database, so later the entries could be also sorted by most recent, most popular etc... Just saying, would be nice additions.
But one reason, I looked away from SQLite. I was looking for something that could adapt easily. But not wanting to become a SQL programmer as took me in that direction. Even SqlAlcemy (excuse the spelling) is not that easy unless you are doing it all the time.
Anyway, my 2cents worth
def sizeof_fmt(self, num, suffix='B'):
# copied from -
# http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
#for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
for unit in ['','K','M','G','T','P','E','Z']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Yi', suffix)