Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with IPython #79

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions erppeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Author: Florent Xicluna
(derived from a script by Alan Bell)
"""
import _ast
import atexit
import csv
import functools
Expand All @@ -16,6 +15,15 @@
import sys
import time
import traceback

import _ast

try:
from ptpython.repl import embed
PTPYTHON = True
except ImportError:
PTPYTHON = False

try: # Python 3
import configparser
from threading import current_thread
Expand Down Expand Up @@ -155,7 +163,7 @@ def literal_eval(expression, _octal_digits=frozenset('01234567')):
raise SyntaxError('unsupported octal notation')
value = _convert(node.body)
if isinstance(value, int_types) and not MININT <= value <= MAXINT:
raise ValueError('overflow, int exceeds XML-RPC limits')
raise ValueError('overflow, int exceeds XML-RPC limits')
return value


Expand Down Expand Up @@ -1367,6 +1375,7 @@ class Record(object):
The attributes are evaluated lazily, and they are cached in the record.
The Record's cache is invalidated if any attribute is changed.
"""

def __init__(self, res_model, res_id, context=None):
if isinstance(res_id, (list, tuple)):
(res_id, res_name) = res_id
Expand Down Expand Up @@ -1577,7 +1586,8 @@ def displayhook(value, _printer=pprint.pprint, _builtins=builtins):
class Usage(object):
def __call__(self):
print(usage)
__repr__ = lambda s: usage

def __repr__(s): return usage
builtins.usage = Usage()

try:
Expand Down Expand Up @@ -1688,7 +1698,11 @@ def main(interact=_interact):
if not client.user:
client.connect()
# Enter interactive mode
return interact(global_vars) if interact else global_vars
if PTPYTHON:
embed(global_vars, locals(), vi_mode=False)
else:
return interact(global_vars) if interact else global_vars


if __name__ == '__main__':
main()