Add ability to import modules with dashes or spaces

Any module with underscores in it will now attempt to look for 3 files,
first the original, then with dashes, then with spaces, ie:
import addressbook_v_2_capnp
will search for 'addressbook_v_2.capnp', 'addressbook-v-2.capnp', and
'addressbook v 2.capnp'.
This commit is contained in:
Jason Paryani
2014-06-12 16:37:06 -07:00
parent c77b5fa132
commit db63fd1880
4 changed files with 96 additions and 0 deletions

View File

@@ -58,6 +58,12 @@ def test_failed_import():
def test_defualt_import_hook():
import addressbook_capnp
def test_dash_import():
import addressbook_with_dashes_capnp
def test_spaces_import():
import addressbook_with_spaces_capnp
def test_add_import_hook():
capnp.add_import_hook([this_dir])