Skip to main content

Type Language Object

Reader of binary serialized Type Language Schema

Example of result in the end of reading TLO

demo

Declaimer

This code has not been tested sufficiently. It's a rewritten version of original reader in C++. If you are going to use this for code generation, please do additional tests. Recheck my implementation for errors and so on.

Context

The Type Language (TL) was invented many years ago. It was originally used in VK, and now in Telegram. The creators of this language invented and wrote all the necessary tools to work with it. For example, a parser of the language and its binary format for serialization was developed.

What is this for?

To work with TL Schemes using OOP. To generate the client MTProto code using official TL parsers and binary formats.

Many Open Source MTProto client use their own implementation of parsers, which are not ultimatum. They are hardcoded for their minimal task.

Hardcode is not the way of Telegram. Official Telegram's Open Source projects take the right approach. So, for example, tdlib generates several interfaces for different languages and this is how it looks:

Raw TL Schema -> Tl Parser -> binary TL Object -> TLO reader -> code generator.

Step name Description
Raw TL Schema Can be founded here and in official Telegram repositories of client (tdesktop/Telegram/Resources/tl, tdlib/generate/scheme).
Tl Parser Official TL parser written in C++. Now it's a part of tdlib/td/generate/tl-parser. In the input it takes raw TL schema file. The output is TLO file.
binary TL Object The output of Tl Parser.
TLO reader This repository contains implementation of it in Python and JavaScript. Reader of binary file. Provide access to combinators, types, functions, arguments and so on via Object Oriented Programming.
code generator Any code generator. In tdlib/td/generate there is generator for C++, JNI, .NET and JSON interfaces.

Installing

For Python

pip install tlo

For JavaScript Work in progress

npm install tlo

Usage

You can find TLO files for tests here.

Python (3.6+)

from tlo import read_tl_config_from_file, read_tl_config


# use read_tl_config(data) to pass bytes directly
config = read_tl_config_from_file('td_api.tlo')

JavaScript Work in progress

import {read_tl_config_from_file, read_tl_config} from 'tlo';


// use read_tl_config(data) to pass bytes directly
const config = read_tl_config_from_file('td_api.tlo')

Licence

MIT License

Release files for tlo 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tlo 1.0.1
File Size Uploaded
tlo-1.0.1.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tlo 1.0.1
File Interpreter ABI Platform
tlo-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / tlo-1.0.1.tar.gz

Download URL tlo-1.0.1.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9099f13300eafbb56ddd770b7661722ffa87515aa84ee508b51c88c53249434f
BLAKE2b-256 checksum
How to use checksums
7dbb60f02d7f80e9cdaeb2e95ea3c77afabc165faebbef6294a9bc6896fa7c27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.2 Darwin/20.6.0

Release files / tlo-1.0.1-py3-none-any.whl

Download URL tlo-1.0.1-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b9604688809ff972835ecd8fd50f9a794a2f0b19cdfe246392058486e966772
BLAKE2b-256 checksum
How to use checksums
ab15eebe66f45fc303f9880f9bba5acc6cb229f3931cedc27fdb49f2c83a95d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.2 Darwin/20.6.0

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page