GithubHelp home page GithubHelp logo

idanpa / calcpy Goto Github PK

View Code? Open in Web Editor NEW
72.0 2.0 1.0 231 KB

Terminal calculator and advanced math solver using Python, IPython and SymPy

License: MIT License

Python 100.00%
calculator cli programmer-calculator console-application ipython sympy console-calculator terminal-calculator python-calculator scientific-calculator

calcpy's People

Contributors

dogeystamp avatar idanpa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

calcpy's Issues

Publish to PyPi

I would like to publish this package to PyPi.
@ZhiqingXiao I see you own calcpy, but the package is actually empty, and the github repo is empty too.
Do you have plans for using calcpy? if no, could you kindly remove this package?
Thanks

Enabling IPython vi mode crashes calcpy on startup

Hi, thank you for writing calcpy, it's a great tool.

I tried to add this line to my IPython config file .config/ipython/profile_calcpy/ipython_config.py:

c.TerminalInteractiveShell.editing_mode = "vi"

I then ran python3 calcpy_cli and got this error:

Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3.11/pathlib.py", line 1250, in is_dir
    return S_ISDIR(self.stat().st_mode)
                   ^^^^^^^^^
AttributeError: 'str' object has no attribute 'stat'

Original exception was:
Traceback (most recent call last):
  File "/home/dogeystamp/.local/bin/calcpy/calcpy_cli.py", line 109, in <module>
    main()
  File "/home/dogeystamp/.local/bin/calcpy/calcpy_cli.py", line 106, in main
    IPython.start_ipython(ipython_args)
  File "/usr/lib/python3.11/site-packages/IPython/__init__.py", line 129, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/traitlets/config/application.py", line 1043, in launch_instance
    app.start()
  File "/usr/lib/python3.11/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 888, in mainloop
    self.interact()
  File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 873, in interact
    code = self.prompt_for_code()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 812, in prompt_for_code
    text = self.pt_app.prompt(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1035, in prompt
    return self.app.run(
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 961, in run
    return loop.run_until_complete(coro)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 875, in run_async
    return await _run_async(f)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 676, in _run_async
    self.reset()
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/application/application.py", line 432, in reset
    self.vi_state.reset()
  File "/usr/lib/python3.11/site-packages/prompt_toolkit/key_binding/vi_state.py", line 99, in reset
    self.input_mode = InputMode.INSERT
    ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/IPython/terminal/shortcuts/__init__.py", line 370, in set_input_mode
    sys.stdout.write(cursor)
TypeError: no_asyncio_write() missing 1 required positional argument: 'data'

It seems like the source of the error is this code from calcpy_cli.py:

    # monkey patch prompt_toolkit to avoid printin from background for preview
    # TODO: need a better fix
    prompt_toolkit.patch_stdout.StdoutProxy.write = \
        partial(no_asyncio_write, prompt_toolkit.patch_stdout.StdoutProxy.write)

I patched no_asyncio_write like this:

def no_asyncio_write(write, self, data=None):
    if data is None:
        return
    if not threading.currentThread().name.startswith('asyncio'):
        write(self, data)

and it seemed to fix the crash.

Completely removing the monkey patch also fixes the crash.

I'm not quite sure what the purpose of your code is here, so I do not know if these fixes break any functionality of calcpy.

EDIT: the above no_asyncio_write patch is just a workaround because it fails to actually write the data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.