Search paths properly on import and execute __init__.py if it exists.

This commit is contained in:
Damien George
2014-02-05 23:57:48 +00:00
parent cdcb4906d4
commit e09ffa1400
6 changed files with 154 additions and 41 deletions

View File

@@ -334,3 +334,17 @@ int main(int argc, char **argv) {
machine_float_t machine_sqrt(machine_float_t x) {
return sqrt(x);
}
#include <sys/stat.h>
uint mp_import_stat(const char *path) {
struct stat st;
if (stat(path, &st) == 0) {
if (S_ISDIR(st.st_mode)) {
return MP_IMPORT_STAT_DIR;
} else if (S_ISREG(st.st_mode)) {
return MP_IMPORT_STAT_FILE;
}
}
return MP_IMPORT_STAT_NO_EXIST;
}