Skip to main content

An id tool for League of Legends with fuzzy string matching, nicknames, multiple locales, automatic updates, and translation.

Project description

lol_id_tools

An id tool for League of Legends with fuzzy string matching, nicknames, multiple locales, automatic updates, and translation.

The package relies on rapidfuzz for string matching. Nicknames are on github, please make a pull requests to add new ones!

Installation

Get lit with pip install lol-id-tools

Usage

Initialisation

import lol_id_tools

# lit will always reload existing locales, and try to add any supplied as arguments.
lit = lol_id_tools.LolIdTools('en_US', 'ko_KR')

Get id from name

# When the name is typed properly, matching is instant.
lit.get_id('Miss Fortune')

21

# Standard nicknames are loaded from https://github.com/mrtolkien/lol_id_tools/blob/master/data/nicknames.json.
lit.get_id('MF')

21

# Any loaded locale will work
lit.get_id('미스 포츈')

21

# Even very inaccurate strings can match properly, but the package will raise a warning if its confidence is low.
lit.get_id('misfo')

WARNING:root: Very low confidence matching from misfo to Miss Fortune.

Type: champion, Locale: en_US, Precision ratio: 59

21


lit.get_id('Maw of Malmortius')

3156

# This matches to Kog'Maw because of our calculation method and is an unwanted result.
lit.get_id('Maw of Malmo')

96

# When we know the type of object we are looking for, we can improve accuracy by providing input_type
lit.get_id('Maw of Malmo', input_type='item')

3156

Get name from ID

On patch 10.5 no champion, item, or rune shares an ID. If they do in the future, the package will need to be updated accordingly.

lit.get_name(11)

'Master Yi'

# If a locale needed for output is not loaded, it will automatically add it to the package.
lit.get_name(11, 'fr_FR')

'Maître Yi'

Get translation

# Default output is 'en_US'
lit.get_translation('미스 포츈')

'Miss Fortune'

# If you haven’t loaded the input locale yet, you can supply it as a parameter
lit.get_translation('ミス・フォーチュン', 'zh_CN', input_locale='ja_JP')

'赏金猎人'

# If get_translation() is called on an existing locale, it can help get the "clean" object name
lit.get_translationn('Misfo')

WARNING:root: Very low confidence matching from Misfo to Miss Fortune.

Type: champion, Locale: en_US, Precision ratio: 59

'Miss Fortune'

Handling locales

# Adds Polish language information
lit.add_locale('pl_PL')
# Forces reloading of all existing locales
lit.reload_app_data()
# Reloads and saves data with only the specified locales
lit.reload_app_data('en_US', 'ja_JP')

Tests

You can take a look at the tests suit for more code examples.

Notes

Package data is saved in ~/.config/lol_id_tools for offline usage and faster startup after first use. If loading all 27 LoL locales, dump size is 205kbs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lol_id_tools-0.4.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lol_id_tools-0.4.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file lol_id_tools-0.4.1.tar.gz.

File metadata

  • Download URL: lol_id_tools-0.4.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for lol_id_tools-0.4.1.tar.gz
Algorithm Hash digest
SHA256 034c4bfafd6176a938d68b5b2eb1a0e1ad0039f399624ff4d01a844bc1381659
MD5 cd40b189a0464f89476764d1d23dbc8b
BLAKE2b-256 b48a316d70aecb8486e5a518a36acf2078f330145bef1a0e9c06250ebcfdfc08

See more details on using hashes here.

File details

Details for the file lol_id_tools-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: lol_id_tools-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for lol_id_tools-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3eedab3ca2e7c62711e15800f607373095bbb230f815568047d5f28605aa1a16
MD5 47d754c998ccaef4c9e94a70cdf97e87
BLAKE2b-256 972764386feac74f875f3c88e66fc51f6bba85f8885d6825b6f1d48277a29eec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page