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

make r2ai-plugin work r2pm #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion main.py

This file was deleted.

1 change: 1 addition & 0 deletions r2ai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def run_rcfile_once(ai):
def main(args, commands, dorepl=True):

os.environ["TOKENIZERS_PARALLELISM"] = "false"
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"

try:
r2aihome = os.path.dirname(os.path.realpath(__file__))
Expand Down
17 changes: 16 additions & 1 deletion r2ai/plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
"""Entrypoint for the r2ai plugin and repl."""

import sys
import os
import builtins
import traceback

current_dir = os.path.dirname(os.path.realpath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
try:
venv_dir = os.path.join(parent_dir, 'venv')
if os.path.exists(venv_dir):
site_packages = os.path.join(venv_dir, 'lib', 'python{}.{}'.format(*sys.version_info[:2]), 'site-packages')
if os.path.exists(site_packages):
sys.path.insert(0, site_packages)
except Exception:
pass

import r2lang
from r2ai.main import r2ai_singleton, run_rcfile_once, runline, help_message

Expand Down
17 changes: 10 additions & 7 deletions r2ai/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ def tab_init():
pass
except Exception:
pass
readline.set_completer(completer.complete)
readline.set_completer_delims('\t\n;')
readline.set_completion_display_matches_hook(completer.display_matches)
if readline.__doc__.find("GNU") != -1:
readline.parse_and_bind('tab: complete')
else:
readline.parse_and_bind("bind ^I rl_complete")
try:
readline.set_completer(completer.complete)
readline.set_completer_delims('\t\n;')
readline.set_completion_display_matches_hook(completer.display_matches)
if readline.__doc__.find("GNU") != -1:
readline.parse_and_bind('tab: complete')
else:
readline.parse_and_bind("bind ^I rl_complete")
except Exception as e:
pass