Giter Club home page Giter Club logo

aiograph's Introduction

AIOGraph

PyPI PyPi status Travis-CI Codecov MIT License

aiograph - asynchronous Python Telegra.ph API wrapper.

Annotations

The Telegraph class (aiograph.Telegraph) encapsulates all API calls in a single class. It provides functions such as create_page, get_views and other's methods described at Telegra.ph/api page

All data types stored In the package aiograph.types.

All methods are named following the PEP-8 instructions for example create_account for createAccount method and etc. All API methods are awaitable and can be called only inside Event-loop.

Also if you want to upload the file to Telegra.ph service use upload method from the instance of Telegraph class.

By the end of all actions you will need to close HTTP connections by calling the close() method (is awaitable).

Installation

Using PIP

$ pip install -U aiograph

From sources

$ git clone https://github.com/aiogram/aiograph.git
$ cd aiograph
$ python setup.py install

Usage examples

Basics

import asyncio

from aiograph import Telegraph

loop = asyncio.get_event_loop()
telegraph = Telegraph()


async def main():
    await telegraph.create_account('aiograph-demo')
    page = await telegraph.create_page('Demo', '<p><strong>Hello, world!</strong></p>')
    print('Created page:', page.url)


if __name__ == '__main__':
    try:
        loop.run_until_complete(main())
    except (KeyboardInterrupt, SystemExit):
        pass
    finally:
        loop.run_until_complete(telegraph.close())  # Close the aiohttp.ClientSession

aiograph's People

Contributors

gabbhack avatar jrootjunior avatar yyonging avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aiograph's Issues

Получаю ошибку | TypeError: attrib() got an unexpected keyword argument 'convert'

изображение

C:\Users\Poool\PycharmProjects\anixartAPI-async\venv39\Scripts\python.exe C:/Users/Poool/PycharmProjects/testproj/main.py
Traceback (most recent call last):
  File "C:\Users\Poool\PycharmProjects\testproj\main.py", line 1, in <module>
    from aiograph import Telegraph
  File "C:\Users\Poool\PycharmProjects\anixartAPI-async\venv39\lib\site-packages\aiograph\__init__.py", line 1, in <module>
    from . import types
  File "C:\Users\Poool\PycharmProjects\anixartAPI-async\venv39\lib\site-packages\aiograph\types\__init__.py", line 6, in <module>
    from .page_list import PageList
  File "C:\Users\Poool\PycharmProjects\anixartAPI-async\venv39\lib\site-packages\aiograph\types\page_list.py", line 13, in <module>
    class PageList(TelegraphObject):
  File "C:\Users\Poool\PycharmProjects\anixartAPI-async\venv39\lib\site-packages\aiograph\types\page_list.py", line 21, in PageList
    pages: List[Page] = ib(factory=list, convert=pages_converter)
TypeError: attrib() got an unexpected keyword argument 'convert'

Process finished with exit code 1

Python 3.9
Aiograph 1.0-2.0

Вы хотели переписать типы в 2020м году.

can't install aiograph with poetry

i am trying to install from git but i get a error.
here is my pyproject.toml

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing aiograph (0.2 a00aace)

  CalledProcessError

  Command 'C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\Scripts\python.exe -m pip install --use-pep517 --disable-pip-version-check --prefix C:\Users\
bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10 --upgrade --no-deps C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\src\aiograph' returned non-zero exit status 1.

  at C:\Program Files\Python311\Lib\subprocess.py:569 in run
       565│             # We don't call process.wait() as .__exit__ does that for us.
       566│             raise
       567│         retcode = process.poll()
       568│         if check and retcode:
    →  569│             raise CalledProcessError(retcode, process.args,
       570│                                      output=stdout, stderr=stderr)
       571│     return CompletedProcess(process.args, retcode, stdout, stderr)
       572│
       573│

The following error occurred when trying to handle this error:


  EnvCommandError

  Command C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\Scripts\python.exe -m pip install --use-pep517 --disable-pip-version-check --prefix C:\Users\b
omzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10 --upgrade --no-deps C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\src\aiograph errored with the following return code 1, and output:
  Processing c:\users\bomzh\appdata\local\pypoetry\cache\virtualenvs\shvatka-esq-9bns-py3.10\src\aiograph
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error

    Getting requirements to build wheel did not run successfully.
    exit code: 1

    [23 lines of output]
    Traceback (most recent call last):
      File "<string>", line 12, in <module>
    ModuleNotFoundError: No module named 'pip'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>      
        main()
      File "C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "C:\Users\bomzh\AppData\Local\pypoetry\Cache\virtualenvs\shvatka-ESq-9BnS-py3.10\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 118, in get_requires_for_build_wheel
        return hook(config_settings)
      File "C:\Users\bomzh\AppData\Local\Temp\pip-build-env-_ir94xd_\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in get_requires_for_build_wheel
        return self._get_build_requires(config_settings, requirements=['wheel'])
      File "C:\Users\bomzh\AppData\Local\Temp\pip-build-env-_ir94xd_\overlay\Lib\site-packages\setuptools\build_meta.py", line 320, in _get_build_requires
        self.run_setup()
      File "C:\Users\bomzh\AppData\Local\Temp\pip-build-env-_ir94xd_\overlay\Lib\site-packages\setuptools\build_meta.py", line 483, in run_setup
        super(_BuildMetaLegacyBackend,
      File "C:\Users\bomzh\AppData\Local\Temp\pip-build-env-_ir94xd_\overlay\Lib\site-packages\setuptools\build_meta.py", line 335, in run_setup
        exec(code, locals())
      File "<string>", line 14, in <module>
    ModuleNotFoundError: No module named 'pip'
    [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error

  Getting requirements to build wheel did not run successfully.
  exit code: 1

  See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.


  at ~\AppData\Roaming\pypoetry\venv\Lib\site-packages\poetry\utils\env.py:1476 in _run
      1472│                 output = subprocess.check_output(
      1473│                     command, stderr=subprocess.STDOUT, env=env, **kwargs
      1474│                 )
      1475│         except CalledProcessError as e:
    → 1476│             raise EnvCommandError(e, input=input_)
      1477│
      1478│         return decode(output)
      1479│
      1480│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

The following error occurred when trying to handle this error:


  PoetryException

  Failed to install C:/Users/bomzh/AppData/Local/pypoetry/Cache/virtualenvs/shvatka-ESq-9BnS-py3.10/src/aiograph

  at ~\AppData\Roaming\pypoetry\venv\Lib\site-packages\poetry\utils\pip.py:51 in pip_install
       47│
       48│     try:
       49│         return environment.run_pip(*args)
       50│     except EnvCommandError as e:
    →  51│         raise PoetryException(f"Failed to install {path.as_posix()}") from e
       52│

same error on GitHub actions

Немогу запустить код из примера

При запуске кода из примера выдает ошибку:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/test.py", line 3, in <module>
    from aiograph import Telegraph
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/aiograph/__init__.py", line 1, in <module>
    from . import types
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/aiograph/types/__init__.py", line 6, in <module>
    from .page_list import PageList
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/aiograph/types/page_list.py", line 13, in <module>
    class PageList(TelegraphObject):
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/aiograph/types/page_list.py", line 21, in PageList
    pages: List[Page] = ib(factory=list, convert=pages_converter)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: attrib() got an unexpected keyword argument 'convert'```

Fix bug please

venv/lib/python3.7/site-packages/aiograph/types/page_list.py:21

pages: List[Page] = ib(factory=list, converter=pages_converter)

images uploading incorrect

image
Hi, when im uploading in telegraph content its uploading incorrect, the first image setting in the end, sometimes may upload reversed list images...., but give images in correct order
For example: article which im getting it`s https://telegra.ph/Tajna-otelya-i-razoblachayushchij-vizit-11-17

article which i got
reversed example: https://telegra.ph/Tajna-otelya-i-razoblachayushchij-vizit-02-03-13

unreversed, first image in the end!!!: https://telegra.ph/Tajna-otelya-i-razoblachayushchij-vizit-02-03

Problem with connection via proxy

There is problem with connection via proxy. I use 'aiograph/examples/basics.py'
with 'telegraph = Telegraph(proxy ='my_proxy', proxy_auth='my_data')'
(this credentials work correctly with aiogram) and get error:
'aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegra.ph:443 ssl:default [The semaphore timeout period has expired]'

How to change the content in exist telegraph page?

I have a telegraph page generated through your library. It works great.
Whose a way to make changes to an existing page don't recreating content or how to get the "old" content and changing it before load to telegraph?

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.