Skip to content

Commit

Permalink
uml 수정, 메타데이터 다운로드 방법 변경, 레퍼런스 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
laoraid committed May 21, 2020
1 parent e3ced39 commit 49918bf
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 66 deletions.
4 changes: 2 additions & 2 deletions KartRider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
getgameTypesDict, getKartsDict, getPetsDict, getTracksDict, getImagePath,
getCharacterName, getCharacterId, getFlyingPetId, getFlyingPetName,
getGameTypeId, getGameTypeName, getKartId, getKartName, getPetId,
getPetName, getTrackId, getTrackName)
getPetName, getTrackId, getTrackName, download_meta, downmeta_ifnotexist)

__all__ = ['Api', 'TooManyRequest', 'ForbiddenToken',
'InvalidToken', 'NotFound', 'UnknownStatusCode',
Expand All @@ -18,4 +18,4 @@
'getCharacterId', 'getFlyingPetId', 'getFlyingPetName',
'getGameTypeId', 'getGameTypeName', 'getKartId',
'getKartName', 'getPetId', 'getPetName', 'getTrackId',
'getTrackName']
'getTrackName', 'download_meta', 'downmeta_ifnotexist']
54 changes: 0 additions & 54 deletions KartRider/__main__.py

This file was deleted.

43 changes: 43 additions & 0 deletions KartRider/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import json
import os
import functools
from zipfile import ZipFile
from io import BytesIO
import requests
from . import utils

_path = ""
Expand Down Expand Up @@ -273,3 +276,43 @@ def getTrackId(name: str) -> str:
:rtype: str
"""
return _getId('track', name)


def download_meta(file_dir: str):
"""메타데이터를 다운로드 합니다.
:param file_dir: 메타데이터가 들어갈 폳더 경로
:type file_dir: str
"""
url = 'https://static.api.nexon.co.kr/kart/latest/metadata.zip'
res = requests.get(url)

zipfile = ZipFile(BytesIO(res.content))

zipfile.extractall(file_dir)
res.close()
zipfile.close()


def downmeta_ifnotexist(file_dir: str) -> bool:
"""메타데이터 폴더가 없으면 메타데이터를 다운로드 합니다.
:param file_dir: 메타데이터가 들어가거나 있는 폴더
:type file_dir: str
:return: 다운로드 했으면 True, 하지 않았으면 False 를 반환합니다.
:rtype: bool
"""
filenames = ['character', 'flyingPet', 'gameType', 'kart', 'pet', 'track']
images = ['character', 'kart', 'track']

for filename in filenames:
if not os.path.isfile(os.path.join(file_dir, filename + '.json')):
download_meta(file_dir)
return True

for image in images:
if not os.path.isdir(os.path.join(file_dir, image)):
download_meta(file_dir)
return True

return False
2 changes: 1 addition & 1 deletion __about__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '0.4.1'
__version__ = '0.5.0'
__author__ = 'Laoraid'
14 changes: 10 additions & 4 deletions docs/KartRider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ KartRider.py
::

> pip install KartRider
> python -m KartRider -d DOWNLOAD_DIR

경로를 지정해서 메타데이터를 다운로드 받으세요.

::

import KartRider
KartRider.download_meta(DOWNLOAD_DIR)
# or downmeta_ifnotexist(DOWNLOAD_DIR)
KartRider.set_metadatapath(DOWNLOAD_DIR)

위와 같이 메타데이터의 경로를 설정합니다.
위와 같이 메타데이터를 다운로드 받고 경로를 설정합니다.

::

Expand Down Expand Up @@ -68,12 +68,13 @@ API KEY는 공개적으로 저장하지 마세요.
가장 최근 매치의 상세 정보 불러오기
====================================
.. code-block:: python
import KartRider
KartRider.set_metadatapath(META_PATH)
api = KartRider.Api(API_KEY)
allmatches = api.getAllMatches(limit=10)
allmatches = api.getAllMatches(limit=1)
game = allmatches.mergeValues()[0]
Expand Down Expand Up @@ -121,6 +122,11 @@ Api 클래스
:undoc-members:
:show-inheritance:

.. automodule:: KartRider.basedata
:members:
:undoc-members:
:show-inheritance:

유저 데이터
==========================

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# -- Project information -----------------------------------------------------

project = 'KartRider'
copyright = '2019, Laoraid'
copyright = '2020, Laoraid'
author = __author__

# The full version, including alpha/beta/rc tags
Expand Down
Binary file modified docs/uml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
requests==2.22.0
tqdm==4.40.2
requests==2.22.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
keywords=['KartRider'],
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'License :: OSI Approved :: MIT License',
'Natural Language :: Korean',
'Topic :: Software Development :: Libraries :: Python Modules'
],
install_requires=['requests', 'tqdm'],
install_requires=['requests'],
python_requires='>=3.6'
)

0 comments on commit 49918bf

Please sign in to comment.