grail.pyz Module

Version: 16.2

New in version 5.10.

Table of Contents

Overview

This module is designed to provide a common helper function when working with (or within) PYZ modules.

Functions

get_data(_name_, _file_, rel_path):

Supply the built-in __name__ and __file__, as well as the "relative path" that wish to load. This will return the data as a binary string (meaning no CRLF changes for text files).

As an example, if you had a script called script.py, and

mylogo = pyz.get_data(__name__, __file__, "mylogo.png")

and mylogo will contain the binary data of that file as a binary string. This function doesn't care if you are a packaged or unpackaged module.

The purpose of this function is to let you abstract out all the ideas involved in loading resource files. If your module is a package residing in memory, the data will also be loaded from memory.