Added to readme and bugfix in import hook

This commit is contained in:
Veit Heller
2014-10-13 15:41:46 +02:00
parent 1cf2f7a573
commit d4331273b9
2 changed files with 5 additions and 2 deletions

View File

@@ -29,6 +29,9 @@ As in mames' original version, you can create such a __script__ easily:
If you have a file containing _ code, you can import it after importing
_. Cool, huh?
Please note that the file you are importing is either an `.us` file or import
it by the fully qualified name(e.g. `import \_.py`).
The idea behind it is using Pythons import hooks to achieve something similar
to mames' original script, only that it works the opposite way.

View File

@@ -91,8 +91,8 @@ class Finder:
filename = os.path.join(dirname, fullname)
if os.path.exists(filename):
return UnderScoreLoader(filename)
else if os.path.exists(filename + ".py"):
return UnderScoreLoader(filename + ".py")
else if os.path.exists(filename + ".us"):
return UnderScoreLoader(filename + ".us")
class UnderScoreLoader:
"""Custom module loader for _ files."""