Browse Source

Python3 only

- added UUID cleanup
master
clerie 2 years ago
parent
commit
6c134927d5
5 changed files with 48 additions and 5 deletions
  1. +39
    -0
      README.md
  2. +2
    -2
      mcuuid/api.py
  3. +5
    -0
      mcuuid/tools.py
  4. +1
    -2
      setup.py
  5. +1
    -1
      test.py

+ 39
- 0
README.md View File

@ -49,6 +49,45 @@ if is_valid_mojang_uuid('a2080281c2784181b961d99ed2f3347c'):
print('Valid')
```
## Documentation
### Module `mcuuid.api`
#### Class `GetPlayerData(indentifier, timestamp=None)`
##### Parameters
- `identifier`: string - a Minecraft username or Mojang UUID
- `timestamp`: int - a unix timestamp
##### Returns
`player` object
#### Object `player`
##### Value `player.uuid`
Mojang UUID
##### Value `player.username`
Minecraft username
### Module `mcuuid.tools`
#### Function `is_valid_minecraft_username(username)`
##### Parameters
- `username`: string - a Minecraft username
##### Returns
`True` or `False`
#### Function `is_valid_mojang_uuid(uuid)`
##### Parameters
- `uuid`: string - a Mojang UUID
##### Returns
`True` or `False`
#### Function `cleanup_uuid(uuid)`
##### Parameters
- `uuid`: string - a Mojang UUID
##### Returns
`uuid` as string, lowered. Without dashes
## Test file
Usage
```


+ 2
- 2
mcuuid/api.py View File

@ -7,8 +7,8 @@ Uses the official Mojang API to fetch player data.
### Import necessary modules
import http.client
import json
from tools import is_valid_minecraft_username
from tools import is_valid_mojang_uuid
from mcuuid.tools import is_valid_minecraft_username
from mcuuid.tools import is_valid_mojang_uuid
### Main class
class GetPlayerData:


+ 5
- 0
mcuuid/tools.py View File

@ -29,3 +29,8 @@ def is_valid_mojang_uuid(uuid):
return False
return True
def cleanup_uuid(uuid):
uuid = uuid.lower()
uuid = uuid.replace('-', '')
return uuid

+ 1
- 2
setup.py View File

@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="mcuuid",
version="0.2",
version="0.3",
author="Clemens Riese",
author_email="hallo@clerie.de",
description="Getting Minecraft Player Information from Mojang API.",
@ -15,7 +15,6 @@ setuptools.setup(
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 2",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],


+ 1
- 1
test.py View File

@ -20,7 +20,7 @@ if len(sys.argv) > 1:
# Else, ask for a identifier by userinput
else:
print("Please enter a username or UUID: ")
identifier = raw_input()
identifier = input()
### Is the identifier a valid value?
if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(identifier):


Loading…
Cancel
Save