Skip to content

Commit d82ecf0

Browse files
committed
Remove non-python files
1 parent 18b3ca1 commit d82ecf0

File tree

5 files changed

+70
-63
lines changed

5 files changed

+70
-63
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## Include
22
include README.md COPYING COPYING.lesser NOTICE requirements.txt
33
recursive-include compiler *.py *.tl *.tsv *.txt
4-
recursive-include pyrogram mime.types schema.sql
54

65
## Exclude
76
prune pyrogram/errors/exceptions
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2020 Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
# From https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types.
20+
# Extended with extra mime types specific to Telegram.
21+
mime_types = """
122
# This file maps Internet media types to unique file extension(s).
223
# Although created for httpd, this file is used by many software systems
324
# and has been placed in the public domain for unlimited redistribution.
@@ -1855,4 +1876,6 @@
18551876
x-conference/x-cooltalk ice
18561877
18571878
# Telegram animated stickers
1858-
application/x-tgsticker tgs
1879+
application/x-bad-tgsticker tgs
1880+
application/x-tgsticker tgs
1881+
"""

pyrogram/scaffold.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import platform
2222
import re
2323
import sys
24+
from io import StringIO
2425
from mimetypes import MimeTypes
2526
from pathlib import Path
2627

2728
import pyrogram
2829
from pyrogram import __version__
2930
from pyrogram.parser import Parser
3031
from pyrogram.session.internals import MsgId
32+
from .mime_types import mime_types
3133

3234

3335
class Scaffold:
@@ -46,7 +48,8 @@ class Scaffold:
4648

4749
PARSE_MODES = ["combined", "markdown", "md", "html", None]
4850

49-
mimetypes = MimeTypes((f"{os.path.dirname(__file__)}/mime.types",))
51+
mimetypes = MimeTypes()
52+
mimetypes.readfp(StringIO(mime_types))
5053

5154
def __init__(self):
5255
try:

pyrogram/storage/schema.sql

Lines changed: 0 additions & 57 deletions
This file was deleted.

pyrogram/storage/sqlite_storage.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,54 @@
1919
import inspect
2020
import sqlite3
2121
import time
22-
from pathlib import Path
2322
from threading import Lock
2423
from typing import List, Tuple, Any
2524

2625
from pyrogram import raw
2726
from .storage import Storage
2827
from .. import utils
2928

29+
# language=SQLite
30+
SCHEMA = """
31+
CREATE TABLE sessions
32+
(
33+
dc_id INTEGER PRIMARY KEY,
34+
test_mode INTEGER,
35+
auth_key BLOB,
36+
date INTEGER NOT NULL,
37+
user_id INTEGER,
38+
is_bot INTEGER
39+
);
40+
41+
CREATE TABLE peers
42+
(
43+
id INTEGER PRIMARY KEY,
44+
access_hash INTEGER,
45+
type INTEGER NOT NULL,
46+
username TEXT,
47+
phone_number TEXT,
48+
last_update_on INTEGER NOT NULL DEFAULT (CAST(STRFTIME('%s', 'now') AS INTEGER))
49+
);
50+
51+
CREATE TABLE version
52+
(
53+
number INTEGER PRIMARY KEY
54+
);
55+
56+
CREATE INDEX idx_peers_id ON peers (id);
57+
CREATE INDEX idx_peers_username ON peers (username);
58+
CREATE INDEX idx_peers_phone_number ON peers (phone_number);
59+
60+
CREATE TRIGGER trg_peers_last_update_on
61+
AFTER UPDATE
62+
ON peers
63+
BEGIN
64+
UPDATE peers
65+
SET last_update_on = CAST(STRFTIME('%s', 'now') AS INTEGER)
66+
WHERE id = NEW.id;
67+
END;
68+
"""
69+
3070

3171
def get_input_peer(peer_id: int, access_hash: int, peer_type: str):
3272
if peer_type in ["user", "bot"]:
@@ -61,8 +101,7 @@ def __init__(self, name: str):
61101

62102
def create(self):
63103
with self.lock, self.conn:
64-
with open(str(Path(__file__).parent / "schema.sql"), "r") as schema:
65-
self.conn.executescript(schema.read())
104+
self.conn.executescript(SCHEMA)
66105

67106
self.conn.execute(
68107
"INSERT INTO version VALUES (?)",

0 commit comments

Comments
 (0)