From df8fa43344d33f99e44ea76fcfcb30acd84f762c Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Fri, 6 Sep 2019 01:33:11 +0300 Subject: [PATCH] readme & license --- LICENSE | 29 ++++++++ README.md | 99 ++++++++++++++++++++++++++ TODO.md | 2 + src/service/api/json.py | 8 +++ src/service/api/routes.py | 8 +++ src/service/api/utils.py | 8 +++ src/service/api/views/bis.py | 21 +++--- src/service/api/views/loot.py | 9 ++- src/service/api/views/player.py | 8 +++ src/service/api/web.py | 8 +++ src/service/application/application.py | 8 +++ src/service/application/core.py | 8 +++ src/service/core/ariyala_parser.py | 8 +++ src/service/core/config.py | 8 +++ src/service/core/database.py | 8 +++ src/service/core/exceptions.py | 8 +++ src/service/core/loot_selector.py | 8 +++ src/service/core/party.py | 8 +++ src/service/core/sqlite.py | 8 +++ src/service/core/sqlite_helper.py | 8 +++ src/service/core/version.py | 8 +++ src/service/models/bis.py | 8 +++ src/service/models/job.py | 8 +++ src/service/models/loot.py | 8 +++ src/service/models/piece.py | 8 +++ src/service/models/player.py | 8 +++ src/service/models/upgrade.py | 8 +++ 27 files changed, 324 insertions(+), 12 deletions(-) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 TODO.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6d70198 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ + + Copyright (c) 2019, Evgeniy Alekseev + + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ffxivbis nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0e242a --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +# FFXIV BiS + +Service which allows to manage savage loot distribution easy. + +## REST API + +### Party API + +* `GET /api/v1/party` + + Get party list. Parameters: + + * `nick`: player full nickname to filter, string, optional. + +* `POST /api/v1/party` + + Add or remove party member. Parameters: + + * `action`: action to do, string, required. One of `add`, `remove`. + * `job`: player job name, string, required. + * `nick`: player nickname, string, required. + * `link`: link to ariyala set to parse BiS, string, optional. + +### BiS API + +* `GET /api/v1/party/bis` + + Get party/player BiS. Parameters: + + * `nick`: player full nickname to filter, string, optional. + +* `POST /api/v1/party/bis` + + Add or remove item to/from BiS. Parameters: + + * `action`: action to do, string, required. One of `add`, `remove`. + * `job`: player job name, string, required. + * `nick`: player nickname, string, required. + * `is_tome`: is item tome gear or not, bool, required. + * `piece`: item name, string, required. + +* `PUT /api/v1/party/bis` + + Create BiS from ariyala link. Parameters: + + * `job`: player job name, string, required. + * `nick`: player nickname, string, required. + * `link`: link to ariyala set to parse BiS, string, required. + +### Loot API + +* `GET /api/v1/party/loot` + + Get party/player loot. Parameters: + + * `nick`: player full nickname to filter, string, optional. + +* `POST /api/v1/party/loot` + + Add or remove item to/from loot list. Parameters: + + * `action`: action to do, string, required. One of `add`, `remove`. + * `job`: player job name, string, required. + * `nick`: player nickname, string, required. + * `is_tome`: is item tome gear or not, bool, required. + * `piece`: item name, string, required. + +* `PUT /api/v1/party/loot` + + Suggest players to get loot. Parameters: + + * `is_tome`: is item tome gear or not, bool, required. + * `piece`: item name, string, required. + + +## Configuration + +* `settings` section + + General project settings. + + * `include`: path to include configuration directory, string, optional. + * `logging`: path to logging configuration, see `logging.ini` for reference, string, optional. + * `database`: database provide name, string, required. Allowed values: `sqlite`. + * `priority`: methods of `Player` class which will be called to sort players for loot priority, space separated list of strings, required. + +* `web` section + + Web server related settings. + + * `host`: address to bind, string, required. + * `port`: port to bind, int, required. + +* `sqlite` section + + Database settings for `sqlite` provider. + + * `database_path`: path to sqlite database, string, required. + * `migrations_path`: path to database migrations, string, required. \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..7360943 --- /dev/null +++ b/TODO.md @@ -0,0 +1,2 @@ +[ ] postgres support +[ ] pretty UI \ No newline at end of file diff --git a/src/service/api/json.py b/src/service/api/json.py index a3b6e40..b8b3137 100644 --- a/src/service/api/json.py +++ b/src/service/api/json.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from enum import Enum from json import JSONEncoder from typing import Any diff --git a/src/service/api/routes.py b/src/service/api/routes.py index b3b3bb3..a1452f4 100644 --- a/src/service/api/routes.py +++ b/src/service/api/routes.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from aiohttp.web import Application from .views.bis import BiSView diff --git a/src/service/api/utils.py b/src/service/api/utils.py index be59f4d..e7efeec 100644 --- a/src/service/api/utils.py +++ b/src/service/api/utils.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import json from aiohttp.web import Response diff --git a/src/service/api/views/bis.py b/src/service/api/views/bis.py index f892c1d..7ac7af0 100644 --- a/src/service/api/views/bis.py +++ b/src/service/api/views/bis.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from aiohttp.web import Response, View from typing import Iterable, Optional @@ -33,7 +41,7 @@ class BiSView(View): except Exception: data = dict(await self.request.post()) - required = ['action', 'job', 'nick'] + required = ['action', 'is_tome', 'job', 'nick', 'piece'] if any(param not in data for param in required): return wrap_invalid_param(required, data) player_id = PlayerId(Job[data['job']], data['nick']) @@ -42,20 +50,11 @@ class BiSView(View): if action not in ('add', 'remove'): return wrap_invalid_param(['action'], data) - piece: Optional[Piece] = None try: + piece = Piece.get(data) # type: ignore if action == 'add': - if 'is_tome' not in data or 'piece' not in data: - return wrap_invalid_param(['is_tome', 'piece'], data) - - piece = Piece.get(data) # type: ignore self.request.app['party'].set_item_bis(player_id, piece) - elif action == 'remove': - if 'is_tome' not in data or 'piece' not in data: - return wrap_invalid_param(['is_tome', 'piece'], data) - - piece = Piece.get(data) # type: ignore self.request.app['party'].remove_item_bis(player_id, piece) except Exception as e: diff --git a/src/service/api/views/loot.py b/src/service/api/views/loot.py index 0c2bf36..c2cfd58 100644 --- a/src/service/api/views/loot.py +++ b/src/service/api/views/loot.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from aiohttp.web import Response, View from typing import Iterable @@ -45,7 +53,6 @@ class LootView(View): piece = Piece.get(data) if action == 'add': self.request.app['party'].set_item(player_id, piece) - elif action == 'remove': self.request.app['party'].remove_item(player_id, piece) diff --git a/src/service/api/views/player.py b/src/service/api/views/player.py index 3d07c2c..0f0f652 100644 --- a/src/service/api/views/player.py +++ b/src/service/api/views/player.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from aiohttp.web import Response, View from typing import Iterable diff --git a/src/service/api/web.py b/src/service/api/web.py index 51741ba..7ea7ebf 100644 --- a/src/service/api/web.py +++ b/src/service/api/web.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import logging from aiohttp import web diff --git a/src/service/application/application.py b/src/service/application/application.py index 187a050..1f5ee3a 100644 --- a/src/service/application/application.py +++ b/src/service/application/application.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from service.core.config import Configuration from .core import Application diff --git a/src/service/application/core.py b/src/service/application/core.py index a86fd0a..5e42a90 100644 --- a/src/service/application/core.py +++ b/src/service/application/core.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import logging from service.api.web import run_server, setup_service diff --git a/src/service/core/ariyala_parser.py b/src/service/core/ariyala_parser.py index 3130743..86ca080 100644 --- a/src/service/core/ariyala_parser.py +++ b/src/service/core/ariyala_parser.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import os import requests diff --git a/src/service/core/config.py b/src/service/core/config.py index c03f64f..5c1d710 100644 --- a/src/service/core/config.py +++ b/src/service/core/config.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import configparser import os diff --git a/src/service/core/database.py b/src/service/core/database.py index 6c10010..f7748a3 100644 --- a/src/service/core/database.py +++ b/src/service/core/database.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from __future__ import annotations import datetime diff --git a/src/service/core/exceptions.py b/src/service/core/exceptions.py index 66c83d2..83e4657 100644 --- a/src/service/core/exceptions.py +++ b/src/service/core/exceptions.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from typing import Any, Mapping diff --git a/src/service/core/loot_selector.py b/src/service/core/loot_selector.py index 90737d5..fa3cf21 100644 --- a/src/service/core/loot_selector.py +++ b/src/service/core/loot_selector.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from typing import Iterable, List, Tuple, Union from service.models.player import Player, PlayerIdWithCounters diff --git a/src/service/core/party.py b/src/service/core/party.py index b82a1d6..19457bc 100644 --- a/src/service/core/party.py +++ b/src/service/core/party.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from __future__ import annotations from threading import Lock diff --git a/src/service/core/sqlite.py b/src/service/core/sqlite.py index 1d0bfce..ad9fc7f 100644 --- a/src/service/core/sqlite.py +++ b/src/service/core/sqlite.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from typing import List, Optional, Union from service.models.bis import BiS diff --git a/src/service/core/sqlite_helper.py b/src/service/core/sqlite_helper.py index c5d9413..2079214 100644 --- a/src/service/core/sqlite_helper.py +++ b/src/service/core/sqlite_helper.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# # because sqlite3 does not support context management import sqlite3 diff --git a/src/service/core/version.py b/src/service/core/version.py index 541f859..4ed65ba 100644 --- a/src/service/core/version.py +++ b/src/service/core/version.py @@ -1 +1,9 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# __version__ = '0.1.0' \ No newline at end of file diff --git a/src/service/models/bis.py b/src/service/models/bis.py index 2f2b752..419a955 100644 --- a/src/service/models/bis.py +++ b/src/service/models/bis.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# import itertools from dataclasses import dataclass diff --git a/src/service/models/job.py b/src/service/models/job.py index 1cf2504..05a1af2 100644 --- a/src/service/models/job.py +++ b/src/service/models/job.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from __future__ import annotations from enum import Enum, auto diff --git a/src/service/models/loot.py b/src/service/models/loot.py index 668375e..3447ae1 100644 --- a/src/service/models/loot.py +++ b/src/service/models/loot.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from dataclasses import dataclass from typing import Union diff --git a/src/service/models/piece.py b/src/service/models/piece.py index 881182b..7068085 100644 --- a/src/service/models/piece.py +++ b/src/service/models/piece.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from __future__ import annotations from dataclasses import dataclass diff --git a/src/service/models/player.py b/src/service/models/player.py index 437e921..9979feb 100644 --- a/src/service/models/player.py +++ b/src/service/models/player.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from dataclasses import dataclass from typing import List, Optional, Union diff --git a/src/service/models/upgrade.py b/src/service/models/upgrade.py index 49e00cf..7baf37e 100644 --- a/src/service/models/upgrade.py +++ b/src/service/models/upgrade.py @@ -1,3 +1,11 @@ +# +# Copyright (c) 2019 Evgeniy Alekseev. +# +# This file is part of ffxivbis +# (see https://github.com/arcan1s/ffxivbis). +# +# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause +# from enum import Enum, auto from typing import List