mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Return helpers.TotalList instances on client.get_ methods
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Various helpers not related to the Telegram API itself"""
|
||||
import collections
|
||||
import os
|
||||
import struct
|
||||
from hashlib import sha1, sha256
|
||||
@@ -65,3 +66,25 @@ def get_password_hash(pw, current_salt):
|
||||
return sha256(pw_hash).digest()
|
||||
|
||||
# endregion
|
||||
|
||||
# region Custom Classes
|
||||
|
||||
class TotalList(list):
|
||||
"""
|
||||
A list with an extra `total` property, which may not match its `len`
|
||||
since the total represents the total amount of items *available*
|
||||
somewhere else, not the items *in this list*.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.total = 0
|
||||
|
||||
def __str__(self):
|
||||
return '[{}, total={}]'.format(
|
||||
', '.join(str(x) for x in self), self.total)
|
||||
|
||||
def __repr__(self):
|
||||
return '[{}, total={}]'.format(
|
||||
', '.join(repr(x) for x in self), self.total)
|
||||
|
||||
# endregion
|
||||
|
Reference in New Issue
Block a user