summaryrefslogtreecommitdiff
path: root/src/pyinterp.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-11 16:03:50 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-11 17:02:25 -0400
commitdea2aed0b509734ec4e1cd163ac2a4f013000da2 (patch)
tree7908da76c67ae5172882306a319bf26df81b73b4 /src/pyinterp.cc
parentd580079df892c30d023b3211d6c4611c17b11f8f (diff)
downloadfork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.gz
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.tar.bz2
fork-ledger-dea2aed0b509734ec4e1cd163ac2a4f013000da2.zip
Untabified all source files
Diffstat (limited to 'src/pyinterp.cc')
-rw-r--r--src/pyinterp.cc108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index 1330fc5c..76fc0561 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -80,10 +80,10 @@ struct python_run
object result;
python_run(python_interpreter_t * intepreter,
- const string& str, int input_mode)
+ const string& str, int input_mode)
: result(handle<>(borrowed(PyRun_String(str.c_str(), input_mode,
- intepreter->main_nspace.ptr(),
- intepreter->main_nspace.ptr())))) {}
+ intepreter->main_nspace.ptr(),
+ intepreter->main_nspace.ptr())))) {}
operator object() {
return result;
}
@@ -104,12 +104,12 @@ void python_interpreter_t::initialize()
object main_module = python::import("__main__");
if (! main_module)
throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find __main__)"));
+ _("Python failed to initialize (couldn't find __main__)"));
main_nspace = extract<dict>(main_module.attr("__dict__"));
if (! main_nspace)
throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find __dict__)"));
+ _("Python failed to initialize (couldn't find __dict__)"));
python::detail::init_module("ledger", &initialize_for_python);
@@ -142,17 +142,17 @@ void python_interpreter_t::hack_system_paths()
if (exists(pathname / "ledger" / "__init__.py")) {
if (python::object module_ledger = python::import("ledger")) {
- DEBUG("python.interp",
- "Setting ledger.__path__ = " << (pathname / "ledger"));
+ DEBUG("python.interp",
+ "Setting ledger.__path__ = " << (pathname / "ledger"));
- python::object ledger_dict = module_ledger.attr("__dict__");
- python::list temp_list;
- temp_list.append((pathname / "ledger").string());
+ python::object ledger_dict = module_ledger.attr("__dict__");
+ python::list temp_list;
+ temp_list.append((pathname / "ledger").string());
- ledger_dict["__path__"] = temp_list;
+ ledger_dict["__path__"] = temp_list;
} else {
- throw_(std::runtime_error,
- _("Python failed to initialize (couldn't find ledger)"));
+ throw_(std::runtime_error,
+ _("Python failed to initialize (couldn't find ledger)"));
}
#if defined(DEBUG_ON)
path_initialized = true;
@@ -163,7 +163,7 @@ void python_interpreter_t::hack_system_paths()
#if defined(DEBUG_ON)
if (! path_initialized)
DEBUG("python.init",
- "Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH");
+ "Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH");
#endif
}
@@ -176,7 +176,7 @@ object python_interpreter_t::import_into_main(const string& str)
object mod = python::import(str.c_str());
if (! mod)
throw_(std::runtime_error,
- _("Failed to import Python module %1") << str);
+ _("Failed to import Python module %1") << str);
// Import all top-level entries directly into the main namespace
main_nspace.update(mod.attr("__dict__"));
@@ -217,7 +217,7 @@ object python_interpreter_t::import_option(const string& str)
object python_interpreter_t::eval(std::istream& in, py_eval_mode_t mode)
{
- bool first = true;
+ bool first = true;
string buffer;
buffer.reserve(4096);
@@ -328,12 +328,12 @@ value_t python_interpreter_t::server_command(call_scope_t& args)
server_module = python::import("ledger.server");
if (! server_module)
throw_(std::runtime_error,
- _("Could not import ledger.server; please check your PYTHONPATH"));
+ _("Could not import ledger.server; please check your PYTHONPATH"));
}
catch (const error_already_set&) {
PyErr_Print();
throw_(std::runtime_error,
- _("Could not import ledger.server; please check your PYTHONPATH"));
+ _("Could not import ledger.server; please check your PYTHONPATH"));
}
if (python::object main_function = server_module.attr("main")) {
@@ -344,12 +344,12 @@ value_t python_interpreter_t::server_command(call_scope_t& args)
catch (const error_already_set&) {
PyErr_Print();
throw_(std::runtime_error,
- _("Error while invoking ledger.server's main() function"));
+ _("Error while invoking ledger.server's main() function"));
}
return true;
} else {
throw_(std::runtime_error,
- _("The ledger.server module is missing its main() function!"));
+ _("The ledger.server module is missing its main() function!"));
}
return false;
@@ -367,7 +367,7 @@ python_interpreter_t::lookup_option(const char * p)
}
expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
- const string& name)
+ const string& name)
{
// Give our superclass first dibs on symbol definitions
if (expr_t::ptr_op_t op = session_t::lookup(kind, name))
@@ -382,7 +382,7 @@ expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
DEBUG("python.interp", "Python lookup: " << name);
if (python::object obj = main_nspace.get(name.c_str()))
- return WRAP_FUNCTOR(functor_t(obj, name));
+ return WRAP_FUNCTOR(functor_t(obj, name));
}
break;
@@ -396,12 +396,12 @@ expr_t::ptr_op_t python_interpreter_t::lookup(const symbol_t::kind_t kind,
switch (*p) {
case 'p':
if (is_eq(p, "python"))
- return MAKE_FUNCTOR(python_interpreter_t::python_command);
+ return MAKE_FUNCTOR(python_interpreter_t::python_command);
break;
case 's':
if (is_eq(p, "server"))
- return MAKE_FUNCTOR(python_interpreter_t::server_command);
+ return MAKE_FUNCTOR(python_interpreter_t::server_command);
break;
}
}
@@ -419,21 +419,21 @@ namespace {
if (value.is_scope()) {
const scope_t * scope = value.as_scope();
if (const post_t * post = dynamic_cast<const post_t *>(scope))
- lst.append(ptr(post));
+ lst.append(ptr(post));
else if (const xact_t * xact = dynamic_cast<const xact_t *>(scope))
- lst.append(ptr(xact));
+ lst.append(ptr(xact));
else if (const account_t * account =
- dynamic_cast<const account_t *>(scope))
- lst.append(ptr(account));
+ dynamic_cast<const account_t *>(scope))
+ lst.append(ptr(account));
else if (const period_xact_t * period_xact =
- dynamic_cast<const period_xact_t *>(scope))
- lst.append(ptr(period_xact));
+ dynamic_cast<const period_xact_t *>(scope))
+ lst.append(ptr(period_xact));
else if (const auto_xact_t * auto_xact =
- dynamic_cast<const auto_xact_t *>(scope))
- lst.append(ptr(auto_xact));
+ dynamic_cast<const auto_xact_t *>(scope))
+ lst.append(ptr(auto_xact));
else
- throw_(std::logic_error,
- _("Cannot downcast scoped object to specific type"));
+ throw_(std::logic_error,
+ _("Cannot downcast scoped object to specific type"));
} else {
lst.append(value);
}
@@ -449,7 +449,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
extract<value_t> val(func);
std::signal(SIGINT, sigint_handler);
if (val.check())
- return val();
+ return val();
return NULL_VALUE;
}
else if (args.size() > 0) {
@@ -457,31 +457,31 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
// jww (2009-11-05): What about a single argument which is a sequence,
// rather than a sequence of arguments?
if (args.value().is_sequence())
- foreach (const value_t& value, args.value().as_sequence())
- append_value(arglist, value);
+ foreach (const value_t& value, args.value().as_sequence())
+ append_value(arglist, value);
else
- append_value(arglist, args.value());
+ append_value(arglist, args.value());
if (PyObject * val =
- PyObject_CallObject(func.ptr(), python::tuple(arglist).ptr())) {
- extract<value_t> xval(val);
- value_t result;
- if (xval.check()) {
- result = xval();
- Py_DECREF(val);
- } else {
- Py_DECREF(val);
- throw_(calc_error,
- _("Could not evaluate Python variable '%1'") << name);
- }
- std::signal(SIGINT, sigint_handler);
- return result;
+ PyObject_CallObject(func.ptr(), python::tuple(arglist).ptr())) {
+ extract<value_t> xval(val);
+ value_t result;
+ if (xval.check()) {
+ result = xval();
+ Py_DECREF(val);
+ } else {
+ Py_DECREF(val);
+ throw_(calc_error,
+ _("Could not evaluate Python variable '%1'") << name);
+ }
+ std::signal(SIGINT, sigint_handler);
+ return result;
}
else if (PyErr_Occurred()) {
- PyErr_Print();
- throw_(calc_error, _("Failed call to Python function '%1'") << name);
+ PyErr_Print();
+ throw_(calc_error, _("Failed call to Python function '%1'") << name);
} else {
- assert(false);
+ assert(false);
}
}
else {