py/modio: Implement uio.resource_stream(package, resource_path).

The with semantics of this function is close to
pkg_resources.resource_stream() function from setuptools, which
is the canonical way to access non-source files belonging to a package
(resources), regardless of what medium the package uses (e.g. individual
source files vs zip archive). In the case of MicroPython, this function
allows to access resources which are frozen into the executable, besides
accessing resources in the file system.

This is initial stage of the implementation, which actually doesn't
implement "package" part of the semantics, just accesses frozen resources
from "root", or filesystem resource - from current dir.
This commit is contained in:
Paul Sokolovsky
2017-05-03 01:47:08 +03:00
parent 4c2fa83f2a
commit d7da2dba07
5 changed files with 59 additions and 6 deletions

View File

@@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
#include "py/lexer.h"
enum {
MP_FROZEN_NONE,
MP_FROZEN_STR,
@@ -31,4 +33,5 @@ enum {
};
int mp_find_frozen_module(const char *str, size_t len, void **data);
const char *mp_find_frozen_str(const char *str, size_t *len);
mp_import_stat_t mp_frozen_stat(const char *str);