Skip to content

Commit 825925e

Browse files
committed
Segregate I/O, Files, and Filesystem builtins
1 parent f2597b9 commit 825925e

8 files changed

Lines changed: 17 additions & 9 deletions

File tree

mathics/builtin/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,25 @@ def is_builtin(var):
116116

117117

118118
# FIXME: redo using importlib since that is probably less fragile.
119-
exclude_files = set(("files", "codetables", "base", "importexport", "colors"))
119+
exclude_files = set(("codetables", "base"))
120120
module_names = [
121121
f for f in __py_files__ if re.match("^[a-z0-9]+$", f) if f not in exclude_files
122122
]
123123

124-
if ENABLE_FILES_MODULE:
125-
module_names += ["files", "importexport"]
126-
127124
modules = []
128125
import_builtins(module_names)
129126

130127
_builtins = []
131128
builtins_by_module = {}
132129

133-
for subdir in ("drawing", "numbers", "specialfns",):
130+
disable_file_module_names = ["files_io.files", "files_io.importexport"] if ENABLE_FILES_MODULE else []
131+
132+
for subdir in ("drawing", "files_io", "numbers", "specialfns",):
134133
import_name = f"{__name__}.{subdir}"
134+
135+
if import_name in disable_file_module_names:
136+
continue
137+
135138
builtin_module = importlib.import_module(import_name)
136139
submodule_names = [
137140
modname
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Input/Output, Files, and Filesystem
3+
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
)
3838

3939
from mathics.builtin.base import Builtin, Predefined
40-
from mathics.builtin.files import (
40+
from mathics.builtin.files_io.files import (
4141
DIRECTORY_STACK,
4242
INITIAL_DIR, # noqa is used via global
4343
mathics_open
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
get_option,
2828
)
2929

30-
from .pymimesniffer import magic
30+
from mathics.builtin.pymimesniffer import magic
3131
import mimetypes
3232
import sys
3333
from itertools import chain
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
The Main Loop
3+
Main Loop I/O Hooks
44
"""
55

66
from mathics.version import __version__ # noqa used in loading to check consistency.
7+
78
from mathics.builtin.base import Builtin
89

910

mathics/builtin/xmlformat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from mathics.version import __version__ # noqa used in loading to check consistency.
99

1010
from mathics.builtin.base import Builtin
11-
from mathics.builtin.files import mathics_open
11+
from mathics.builtin.files_io.files import mathics_open
1212
from mathics.core.expression import (
1313
Expression,
1414
String,

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def subdirs(root, file="*.*", depth=10):
124124
"mathics.builtin",
125125
"mathics.builtin.compile",
126126
"mathics.builtin.drawing",
127+
"mathics.builtin.files_io",
127128
"mathics.builtin.numbers",
128129
"mathics.builtin.numpy_utils",
129130
"mathics.builtin.pymimesniffer",

0 commit comments

Comments
 (0)