habitipy.util

habitipy - tools and library for Habitica restful API utility functions

progressed_bar

progressed_bar(count, total=100, status=None, suffix=None, bar_len=10)

render a progressed.io like progress bar

progressed

progressed(string)

helper function to replace all links to progressed.io with progress bars

Example

from habitipy.util import progressed
text_from_habitica = 'Write thesis ![progress](http://progressed.io/bar/0 "progress")'
print(progressed(text_from_habitica))
Write thesis ██████████0%

prettify

prettify(string)

replace markup emoji and progressbars with actual things

Example

from habitipy.util import prettify
print(prettify('Write thesis :book: ![progress](http://progressed.io/bar/0 "progress")'))
Write thesis 📖 ██████████0%

umask

umask(mask)

temporarily change umask

Arguments

  • mask : a umask (invese of chmod argument)

Example

with umask(0o077), open('yay.txt') as f:
    f.write('nyaroo~n')

yay.txt will be written with 600 file mode

is_secure_file

is_secure_file(fn)

checks if a file can be accessed only by the owner

SecurityError

SecurityError(self, /, *args, **kwargs)

Error fired when a secure file is stored in an insecure manner

assert_secure_file

assert_secure_file(file)

checks if a file is stored securely

get_translation_for

get_translation_for(package_name: str) -> gettext.NullTranslations

find and return gettext translation for package

get_translation_functions

get_translation_functions(package_name: str, names: Tuple[str, ...] = ('gettext',))

finds and installs translation functions for package