summaryrefslogtreecommitdiff
path: root/src/pyinterp.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-10 14:16:40 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-10 14:16:40 -0500
commit91e8378f04d33137f8e6281928ae70af12be3b2b (patch)
tree1fe03ea8d7eeb21aa4f923373fbbd8c06f536d75 /src/pyinterp.h
parent5ffa987daf4d97c52066e4c28733d826d3726297 (diff)
downloadfork-ledger-91e8378f04d33137f8e6281928ae70af12be3b2b.tar.gz
fork-ledger-91e8378f04d33137f8e6281928ae70af12be3b2b.tar.bz2
fork-ledger-91e8378f04d33137f8e6281928ae70af12be3b2b.zip
Fixes to Python importing; removed "hello" precommand
Diffstat (limited to 'src/pyinterp.h')
-rw-r--r--src/pyinterp.h50
1 files changed, 11 insertions, 39 deletions
diff --git a/src/pyinterp.h b/src/pyinterp.h
index 002e8af1..f2d7b760 100644
--- a/src/pyinterp.h
+++ b/src/pyinterp.h
@@ -57,8 +57,10 @@ public:
}
void initialize();
+ void hack_system_paths();
- python::object import(const string& name);
+ python::object import_into_main(const string& name);
+ python::object import_option(const string& name);
enum py_eval_mode_t {
PY_EVAL_EXPR,
@@ -67,16 +69,17 @@ public:
};
python::object eval(std::istream& in,
- py_eval_mode_t mode = PY_EVAL_EXPR);
+ py_eval_mode_t mode = PY_EVAL_EXPR);
python::object eval(const string& str,
- py_eval_mode_t mode = PY_EVAL_EXPR);
+ py_eval_mode_t mode = PY_EVAL_EXPR);
python::object eval(const char * c_str,
- py_eval_mode_t mode = PY_EVAL_EXPR) {
+ py_eval_mode_t mode = PY_EVAL_EXPR) {
string str(c_str);
return eval(str, mode);
}
value_t python_command(call_scope_t& scope);
+ value_t server_command(call_scope_t& args);
class functor_t {
functor_t();
@@ -87,9 +90,9 @@ public:
public:
string name;
- functor_t(const string& _name, python::object _func)
+ functor_t(python::object _func, const string& _name)
: func(_func), name(_name) {
- TRACE_CTOR(functor_t, "const string&, python::object");
+ TRACE_CTOR(functor_t, "python::object, const string&");
}
functor_t(const functor_t& other)
: func(other.func), name(other.name) {
@@ -106,41 +109,10 @@ public:
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
const string& name);
-#if BOOST_VERSION >= 103700
OPTION_(python_interpreter_t, import_, DO_(scope) {
- interactive_t args(scope, "s");
-
- path file(args.get<string>(0));
-
- python::object module_sys = parent->import("sys");
- python::object sys_dict = module_sys.attr("__dict__");
-
- python::list paths(sys_dict["path"]);
- paths.insert(0, file.parent_path().string());
- sys_dict["path"] = paths;
-
- string name = file.filename();
- if (contains(name, ".py"))
- parent->import(file.stem());
- else
- parent->import(name);
- });
-#else // BOOST_VERSION >= 103700
- OPTION_(python_interpreter_t, import_, DO_(scope) {
- interactive_t args(scope, "s");
-
- path file(args.get<string>(0));
-
- python::object module_sys = parent->import("sys");
- python::object sys_dict = module_sys.attr("__dict__");
-
- python::list paths(sys_dict["path"]);
- paths.insert(0, file.branch_path().string());
- sys_dict["path"] = paths;
-
- parent->import(file.leaf());
+ interactive_t args(scope, "ss");
+ parent->import_option(args.get<string>(1));
});
-#endif // BOOST_VERSION >= 103700
};
extern shared_ptr<python_interpreter_t> python_session;