mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/__init__.py
This commit is contained in:
commit
00f0051bd6
@ -31,7 +31,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance
|
||||
"e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
|
||||
)
|
||||
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
|
||||
__version__ = "0.8.0async1"
|
||||
__version__ = "0.8.0.async1"
|
||||
|
||||
from .api.errors import Error
|
||||
from .client.types import (
|
||||
|
@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
@ -23,13 +24,23 @@ from json import JSONEncoder, dumps
|
||||
|
||||
from ..all import objects
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Object:
|
||||
all = {}
|
||||
|
||||
@staticmethod
|
||||
def read(b: BytesIO, *args):
|
||||
return Object.all[int.from_bytes(b.read(4), "little")].read(b, *args)
|
||||
constructor_id = int.from_bytes(b.read(4), "little")
|
||||
|
||||
try:
|
||||
return Object.all[constructor_id].read(b, *args)
|
||||
except KeyError:
|
||||
log.error("Unknown constructor found: {}. Full data: {}".format(
|
||||
hex(constructor_id),
|
||||
b.getvalue().hex())
|
||||
)
|
||||
|
||||
def write(self, *args) -> bytes:
|
||||
pass
|
||||
|
@ -26,9 +26,9 @@ class MessageEntity(Object):
|
||||
Args:
|
||||
type (``str``):
|
||||
Type of the entity.
|
||||
Can be "mention" (@username), "hashtag", "cashtag", "bot_command", "url", "email", "bold" (bold text),
|
||||
italic (italic text), "code" (monowidth string), "pre" (monowidth block), "text_link" (for clickable text
|
||||
URLs), "text_mention" (for users without usernames).
|
||||
Can be "mention" (@username), "hashtag", "cashtag", "bot_command", "url", "email", "phone_number", "bold"
|
||||
(bold text), italic (italic text), "code" (monowidth string), "pre" (monowidth block), "text_link"
|
||||
(for clickable text URLs), "text_mention" (for users without usernames).
|
||||
|
||||
offset (``int``):
|
||||
Offset in UTF-16 code units to the start of the entity.
|
||||
|
137
setup.py
137
setup.py
@ -16,10 +16,12 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from sys import argv
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools import setup, find_packages, Command
|
||||
|
||||
from compiler.api import compiler as api_compiler
|
||||
from compiler.docs import compiler as docs_compiler
|
||||
@ -31,24 +33,125 @@ def read(file: str) -> list:
|
||||
return [i.strip() for i in r]
|
||||
|
||||
|
||||
if len(argv) > 1 and argv[1] != "sdist":
|
||||
api_compiler.start()
|
||||
docs_compiler.start()
|
||||
def get_version():
|
||||
with open("pyrogram/__init__.py", encoding="utf-8") as f:
|
||||
return re.findall(r"__version__ = \"(.+)\"", f.read())[0]
|
||||
|
||||
|
||||
def get_readme():
|
||||
# PyPI doesn"t like raw html
|
||||
with open("README.rst", encoding="utf-8") as f:
|
||||
readme = re.sub(r"\.\. \|.+\| raw:: html(?:\s{4}.+)+\n\n", "", f.read())
|
||||
return re.sub(r"\|header\|", "|logo|\n\n|description|\n\n|scheme| |tgcrypto|", readme)
|
||||
|
||||
|
||||
class Clean(Command):
|
||||
DIST = [
|
||||
"./build",
|
||||
"./dist",
|
||||
"./Pyrogram.egg-info"
|
||||
]
|
||||
|
||||
API = [
|
||||
"pyrogram/api/errors/exceptions",
|
||||
"pyrogram/api/functions",
|
||||
"pyrogram/api/types",
|
||||
"pyrogram/api/all.py",
|
||||
]
|
||||
|
||||
DOCS = [
|
||||
"docs/source/functions",
|
||||
"docs/source/types",
|
||||
"docs/build"
|
||||
]
|
||||
|
||||
ALL = DIST + API + DOCS
|
||||
|
||||
description = "Clean generated files"
|
||||
|
||||
user_options = [
|
||||
("dist", None, "Clean distribution files"),
|
||||
("api", None, "Clean generated API files"),
|
||||
("docs", None, "Clean generated docs files"),
|
||||
("all", None, "Clean all generated files"),
|
||||
]
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
super().__init__(dist, **kw)
|
||||
|
||||
self.dist = None
|
||||
self.api = None
|
||||
self.docs = None
|
||||
self.all = None
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
paths = set()
|
||||
|
||||
if self.dist:
|
||||
paths.update(Clean.DIST)
|
||||
|
||||
if self.api:
|
||||
paths.update(Clean.API)
|
||||
|
||||
if self.docs:
|
||||
paths.update(Clean.DOCS)
|
||||
|
||||
if self.all:
|
||||
paths.update(Clean.ALL)
|
||||
|
||||
for path in sorted(list(paths)):
|
||||
try:
|
||||
shutil.rmtree(path) if os.path.isdir(path) else os.remove(path)
|
||||
except OSError:
|
||||
print("skipping {}".format(path))
|
||||
else:
|
||||
print("removing {}".format(path))
|
||||
|
||||
|
||||
class Build(Command):
|
||||
description = "Build Pyrogram files"
|
||||
|
||||
user_options = [
|
||||
("api", None, "Build API files"),
|
||||
("docs", None, "Build docs files"),
|
||||
]
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
super().__init__(dist, **kw)
|
||||
|
||||
self.api = None
|
||||
self.docs = None
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
if self.api:
|
||||
error_compiler.start()
|
||||
api_compiler.start()
|
||||
|
||||
if self.docs:
|
||||
docs_compiler.start()
|
||||
|
||||
|
||||
if len(argv) > 1 and argv[1] in ["bdist_wheel", "install"]:
|
||||
error_compiler.start()
|
||||
|
||||
with open("pyrogram/__init__.py", encoding="utf-8") as f:
|
||||
version = re.findall(r"__version__ = \"(.+)\"", f.read())[0]
|
||||
|
||||
# PyPI doesn't like raw html
|
||||
with open("README.rst", encoding="utf-8") as f:
|
||||
readme = re.sub(r"\.\. \|.+\| raw:: html(?:\s{4}.+)+\n\n", "", f.read())
|
||||
readme = re.sub(r"\|header\|", "|logo|\n\n|description|\n\n|scheme| |tgcrypto|", readme)
|
||||
api_compiler.start()
|
||||
|
||||
setup(
|
||||
name="Pyrogram",
|
||||
version=version,
|
||||
version=get_version(),
|
||||
description="Telegram MTProto API Client Library for Python",
|
||||
long_description=readme,
|
||||
long_description=get_readme(),
|
||||
url="https://github.com/pyrogram",
|
||||
download_url="https://github.com/pyrogram/pyrogram/releases/latest",
|
||||
author="Dan Tès",
|
||||
@ -85,5 +188,9 @@ setup(
|
||||
packages=find_packages(exclude=["compiler*"]),
|
||||
zip_safe=False,
|
||||
install_requires=read("requirements.txt"),
|
||||
extras_require={"tgcrypto": ["tgcrypto>=1.0.4"]}
|
||||
extras_require={"tgcrypto": ["tgcrypto>=1.0.4"]},
|
||||
cmdclass={
|
||||
"clean": Clean,
|
||||
"build": Build,
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user