Skip to content

Commit

Permalink
Spin out part of hy.I into slashes2dots
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodiologist committed Nov 6, 2023
1 parent cc5ca79 commit 46fca11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions hy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ def __call__(self, module_name):
import importlib
return importlib.import_module(module_name)
def __getattr__(self, s):
import re
return self(hy.mangle(re.sub(
r'/(-*)',
lambda m: '.' + '_' * len(m.group(1)),
hy.unmangle(s))))
from hy.reader.mangling import slashes2dots
return self(slashes2dots(s))
I = I()


Expand Down
8 changes: 8 additions & 0 deletions hy/reader/mangling.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,11 @@ def unmangle(s):
s = s.replace("_", "-")

return prefix + s + suffix


def slashes2dots(s):
'Interpret forward slashes as a substitute for periods.'
return mangle(re.sub(
r'/(-*)',
lambda m: '.' + '_' * len(m.group(1)),
unmangle(s)))

0 comments on commit 46fca11

Please sign in to comment.