diff --git a/Makefile b/Makefile index ae89419..2dfd395 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ clean-test: ## remove test and coverage artifacts rm -fr .pytest_cache lint: ## check style with flake8 - flake8 erepublik_script tests + flake8 erepublik tests test: ## run tests quickly with the default Python python setup.py test @@ -60,15 +60,15 @@ test-all: ## run tests on every Python version with tox tox coverage: ## check code coverage quickly with the default Python - coverage run --source erepublik_script setup.py test + coverage run --source erepublik setup.py test coverage report -m coverage html $(BROWSER) htmlcov/index.html docs: ## generate Sphinx HTML documentation, including API docs - rm -f docs/erepublik_script.rst + rm -f docs/erepublik.rst rm -f docs/modules.rst - sphinx-apidoc -o docs/ erepublik_script + sphinx-apidoc -o docs/ erepublik $(MAKE) -C docs clean $(MAKE) -C docs html $(BROWSER) docs/_build/html/index.html diff --git a/docs/Makefile b/docs/Makefile index 6376cdf..d596818 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = python -msphinx -SPHINXPROJ = erepublik_script +SPHINXPROJ = erepublik SOURCEDIR = . BUILDDIR = _build diff --git a/docs/conf.py b/docs/conf.py index dbd31f2..6558391 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# erepublik_script documentation build configuration file, created by +# erepublik documentation build configuration file, created by # sphinx-quickstart on Fri Jun 9 13:47:02 2017. # # This file is execfile()d with the current directory set to its @@ -22,7 +22,7 @@ import os import sys sys.path.insert(0, os.path.abspath('..')) -import erepublik_script +import erepublik # -- General configuration --------------------------------------------- @@ -56,9 +56,9 @@ author = u"Eriks Karls" # the built documents. # # The short X.Y version. -version = erepublik_script.__version__ +version = erepublik.__version__ # The full version, including alpha/beta/rc tags. -release = erepublik_script.__version__ +release = erepublik.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -128,7 +128,7 @@ latex_elements = { # (source start file, target name, title, author, documentclass # [howto, manual, or own class]). latex_documents = [ - (master_doc, 'erepublik_script.tex', + (master_doc, 'erepublik.tex', u'eRepublik script Documentation', u'Eriks Karls', 'manual'), ] @@ -139,7 +139,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'erepublik_script', + (master_doc, 'erepublik', u'eRepublik script Documentation', [author], 1) ] @@ -151,10 +151,10 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'erepublik_script', + (master_doc, 'erepublik', u'eRepublik script Documentation', author, - 'erepublik_script', + 'erepublik', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/installation.rst b/docs/installation.rst index af81116..e9751ac 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -12,7 +12,7 @@ To install eRepublik script, run this command in your terminal: .. code-block:: console - $ pip install erepublik_script + $ pip install erepublik This is the preferred method to install eRepublik script, as it will always install the most recent stable release. diff --git a/docs/usage.rst b/docs/usage.rst index 0765a49..ad4642f 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -4,4 +4,4 @@ Usage To use eRepublik script in a project:: - import erepublik_script + import erepublik diff --git a/erepublik_script/__init__.py b/erepublik/__init__.py similarity index 62% rename from erepublik_script/__init__.py rename to erepublik/__init__.py index 7a1ecd2..ab2dc89 100644 --- a/erepublik_script/__init__.py +++ b/erepublik/__init__.py @@ -6,6 +6,5 @@ __author__ = """Eriks Karls""" __email__ = 'eriks@72.lv' __version__ = '0.14.4' -from erepublik_script import classes, utils -from erepublik_script.citizen import Citizen - +from erepublik import classes, utils +from erepublik.citizen import Citizen diff --git a/erepublik_script/citizen.py b/erepublik/citizen.py similarity index 99% rename from erepublik_script/citizen.py rename to erepublik/citizen.py index 94a5dd6..d54cb97 100644 --- a/erepublik_script/citizen.py +++ b/erepublik/citizen.py @@ -9,7 +9,7 @@ from typing import Dict, List, Tuple, Any, Union import requests from requests import Response, RequestException -from erepublik_script import classes, utils +from erepublik import classes, utils class Citizen(classes.CitizenAPI): @@ -622,10 +622,8 @@ class Citizen(classes.CitizenAPI): battle_id = r.get("citizen_contribution")[0].get("battle_id", 0) ret_battles.append(battle_id) - ret_battles += (cs_battles_air + cs_battles_ground + - deployed_battles_air + deployed_battles_ground + - ally_battles_air + ally_battles_ground + - other_battles_air + other_battles_ground) + ret_battles += cs_battles_air + cs_battles_ground + deployed_battles_air + deployed_battles_ground + \ + ally_battles_air + ally_battles_ground + other_battles_air + other_battles_ground return ret_battles @property @@ -646,8 +644,8 @@ class Citizen(classes.CitizenAPI): if battle.is_rw: side_id = battle.defender.id if self.config.rw_def_side else battle.invader.id else: - side_id = battle.defender.id if (self.details.current_country in battle.defender.allies + - [battle.defender.id, ]) else battle.invader.id + side = self.details.current_country in battle.defender.allies + [battle.defender.id, ] + side_id = battle.defender.id if side else battle.invader.id try: def_points = battle.div.get(div).dom_pts.get('def') inv_points = battle.div.get(div).dom_pts.get('inv') @@ -1449,11 +1447,12 @@ class Citizen(classes.CitizenAPI): raw = wrm else: continue + effective_bonus = cdata["effective_bonus"] + base_prod = float(cdata["base_production"]) if cdata["is_raw"]: - raw += float(cdata["base_production"]) * cdata["effective_bonus"] / 100 + raw += base_prod * effective_bonus / 100 else: - raw -= cdata["effective_bonus"] / 100 * cdata["base_production"] * \ - cdata["upgrades"][str(cdata["quality"])]["raw_usage"] + raw -= effective_bonus / 100 * base_prod * cdata["upgrades"][str(cdata["quality"])]["raw_usage"] if cdata["industry_token"] == "FOOD": frm = raw elif cdata["industry_token"] == "WEAPON": diff --git a/erepublik_script/classes.py b/erepublik/classes.py similarity index 99% rename from erepublik_script/classes.py rename to erepublik/classes.py index d0fc27b..c842ad5 100644 --- a/erepublik_script/classes.py +++ b/erepublik/classes.py @@ -11,7 +11,7 @@ from typing import Any, Dict, List, Union from requests import Response, Session from slugify import slugify -from erepublik_script import utils +from erepublik import utils class ErepublikException(Exception): @@ -228,7 +228,7 @@ class SlowRequests(Session): file.write(body.encode("UTF-8")) def _log_response(self, url, resp, redirect: bool = False): - from erepublik_script import Citizen + from erepublik import Citizen if self.debug: if resp.history and not redirect: for hist_resp in resp.history: diff --git a/erepublik_script/utils.py b/erepublik/utils.py similarity index 99% rename from erepublik_script/utils.py rename to erepublik/utils.py index eee147e..d764c9d 100644 --- a/erepublik_script/utils.py +++ b/erepublik/utils.py @@ -214,7 +214,7 @@ def write_file(filename: str, content: str) -> int: def write_request(response: requests.Response, is_error: bool = False): - from erepublik_script import Citizen + from erepublik import Citizen # Remove GET args from url name url = response.url last_index = url.index("?") if "?" in url else len(response.url) @@ -238,7 +238,7 @@ def write_request(response: requests.Response, is_error: bool = False): def send_email(name, content: list, player=None, local_vars=dict, promo: bool = False, captcha: bool = False): - from erepublik_script import Citizen + from erepublik import Citizen file_content_template = "