From 1b705badd236207c54022ca4e9e1b1504bd17492 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 28 May 2014 03:42:44 +0000 Subject: [PATCH] Fixed up docs --- README.md | 8 ++++++-- simport/__init__.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b3e2f1d..16fce15 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,14 @@ Using Simport # For modules already in the Python Path function = simport.load('mymodule.myfunction') class_method = simport.load('mymodule:MyClass.mymethod') + klass = simport.load('mymodule:MyClass') # uninstanstiated. # For modules not in the Python Path - function = simport.load('/path/to/file|module_name:myfunction') - class_method = simport.load('/path/to/module|module_name:MyClass.mymethod') + function = simport.load('/path/to/dir|module_name:myfunction') + class_method = simport.load('/path/to/dir|module_name:MyClass.mymethod') + +Look at the tests for some interesting naming conventions for +specifying relative modules, etc. Running Tests ============= diff --git a/simport/__init__.py b/simport/__init__.py index de3a7a9..eae2822 100644 --- a/simport/__init__.py +++ b/simport/__init__.py @@ -44,15 +44,19 @@ def _get_module(target): Accepts these formats: ".../file/path|module_name:Class.method" + ".../file/path|module_name:Class" ".../file/path|module_name:function" + "module_name:Class" + "module_name:function" + "module_name:Class.function" - If a fully qualified file is specified, it implies the - file is not already on the Python Path, in which case + If a fully qualified directory is specified, it implies the + directory is not already on the Python Path, in which case it will be added. - For example, if I import /home/foo/my_code.py (and + For example, if I import /home/foo (and /home/foo is not in the python path) as - "/home/foo/my_code.py|mycode:MyClass.mymethod" + "/home/foo|mycode:MyClass.mymethod" then /home/foo will be added to the python path and the module loaded as normal. """