...
 
Commits (5)
.idea/
*.iml
cover/
.coverage
*.egg-info/
dist/
build/
test-res/
\ No newline at end of file
stages:
- mirror
- test
- stats
- release
default:
image: namboy94/ci-docker-environment:0.6.0
before_script:
- echo "$SERVER_ACCESS_KEY" > ~/.ssh/id_rsa
- chmod 0600 ~/.ssh/id_rsa
github_mirror:
stage: mirror
tags: [docker]
only: [master, develop]
before_script:
- echo "$GITHUB_SSH_KEY" > ~/.ssh/id_rsa
- chmod 0600 ~/.ssh/id_rsa
script:
- git-mirror-pusher git@github.com:namboy94/fe3h-checklist.git
master develop
stylecheck:
stage: test
tags: [docker]
script:
- python-codestyle-check
unittest:
stage: test
tags: [docker]
script:
- python-unittest
gitstats:
stage: stats
tags: [docker]
script:
- gitstats-gen
docgen:
stage: stats
tags: [docker]
script:
- pip install flask
- sphinx-docgen
release_upload:
stage: release
only: [master]
tags: [docker]
script:
- github-release-upload $(cat version) "$(changelog-reader)"
- gitlab-release-upload $(cat version) "$(changelog-reader)"
pypi_upload:
stage: release
only: [master]
tags: [docker]
script:
- pypi-upload
V 0.1.0:
- Project Start
\ No newline at end of file
# Contributing
## Copyright and Management
The original author, Hermann Krumrey, has the absolute authority on the management
of this project and may steer the development process as he sees fit.
Contributions will be attributed to the author of said code and the copyright will
remain the author's.
## Contributing
All active development is done on a [self-hosted Gitlab server](https://gitlab.namibsun.net).
To contribute, send an email to hermann@krumreyh.com to create an account. Once you have an
account, you may issue a merge or pull request.
Using the Gitlab issue tracker is preferred, but the issues on Github are also
taken into consideration.
\ No newline at end of file
This diff is collapsed.
include version
graft fe3h_checklist/data
\ No newline at end of file
# Fire Emblem: Three Houses Checklist
\ No newline at end of file
# fe3h-checklist
|master|develop|
|:----:|:-----:|
|[![build status](https://gitlab.namibsun.net/namibsun/python/fe3h-checklist/badges/master/build.svg)](https://gitlab.namibsun.net/namibsun/python/fe3h-checklist/commits/master)|[![build status](https://gitlab.namibsun.net/namibsun/python/fe3h-checklist/badges/develop/build.svg)](https://gitlab.namibsun.net/namibsun/python/fe3h-checklist/commits/develop)|
![Logo](resources/logo/logo-readme.png)
## Further Information
* [Changelog](CHANGELOG)
* [License (GPLv3)](LICENSE)
* [Gitlab](https://gitlab.namibsun.net/namibsun/python/fe3h-checklist)
* [Github](https://github.com/namboy94/fe3h-checklist)
* [Progstats](https://progstats.namibsun.net/projects/fe3h-checklist)
* [PyPi](https://pypi.org/project/fe3h-checklist)
#!/usr/bin/env python
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import argparse
from fe3h_checklist.printer import print_remaining_support_levels
from fe3h_checklist.setters import set_support_level
def main():
"""
The xdcc-dl main method
:return: None
"""
parser = argparse.ArgumentParser()
mode_parser = parser.add_subparsers(required=True, dest="mode")
list_parser = mode_parser.add_parser("list")
set_parser = mode_parser.add_parser("set")
# List Mode
list_mode_parser = list_parser.add_subparsers(
required=True, dest="list_mode"
)
remaining_parser = list_mode_parser.add_parser("remaining")
remaining_parser.add_argument("--no-byleth", action="store_true",
help="Hides support levels with Byleth")
remaining_parser.add_argument("--multi-line", action="store_true",
help="Uses multiple lines per character")
# Set Mode
set_mode_parser = set_parser.add_subparsers(required=True, dest="set_mode")
set_support_parser = set_mode_parser.add_parser("support")
set_support_parser.add_argument("char_one", help="The first character")
set_support_parser.add_argument("char_two", help="The second character")
set_support_parser.add_argument(
"support_level", help="The support level",
choices={"X", "C", "C+", "B", "B+", "A", "A+", "S"}
)
args = parser.parse_args()
if args.mode == "list":
if args.list_mode == "remaining":
print_remaining_support_levels(args.no_byleth, args.multi_line)
elif args.mode == "set":
if args.set_mode == "support":
set_support_level(args.char_one, args.char_two, args.support_level)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("Thanks for using fe3h-checklist!")
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/media-manager.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/media-manager.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/media-manager"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/media-manager"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
buildsource:
sphinx-apidoc -f ../../fe3h_checklist -o source
@echo "Auto-generation of API documentation finished. " \
"The generated files are in 'source/'"
#!/usr/bin/env python3
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
# noinspection PyPackageRequirements
import sphinx_rtd_theme
# noinspection PyPackageRequirements
from sphinx.ext.autodoc import between
# noinspection PyShadowingBuiltins
copyright = '2019 Hermann Krumrey'
author = 'Hermann Krumrey'
project = 'fe3h-checklist'
extensions = ["sphinx.ext.autodoc"]
master_doc = "index"
with open("../../../version", "r") as version_file:
version = version_file.read()
release = version
# HTML Theme Config
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
def setup(app):
"""
Registers an autodoc between listener to ignore License texts
:param app: The sphinx app
:return: None
"""
app.connect('autodoc-process-docstring',
between('^.*LICENSE.*$', exclude=True))
app.connect("autodoc-skip-member",
lambda a, b, name, d, skipper, f:
False if name == "__init__" else skipper)
return app
Welcome to fe3h-checklist's documentation!
==========================================
Contents:
.. toctree::
:maxdepth: 2
fe3h_checklist.rst
modules.rst
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import os
local_dir = os.path.join(os.path.expanduser("~"), ".config/fe3h-checklist")
"""
Directory containing local config files
"""
support_levels_info_file = os.path.join(local_dir, "supportinfo.ods")
"""
File containing the support level info file
"""
support_levels_file = os.path.join(local_dir, "supportlevels.ods")
"""
File containing the support level info file
"""
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from typing import Dict, Tuple
def calculate_remaining_support_levels(
character: str,
support_levels: Dict[str, Dict[str, str]],
support_levels_info: Dict[str, Dict[str, str]]
) -> Tuple[int, Dict[str, int]]:
"""
Calculates how many support levels are left for a character.
This calculates both the total amount of support levels left for the
character as well as the remaining support levels with individual
characters.
:param character: The character for which to calculate the remaining
support levels
:param support_levels: The current support levels
:param support_levels_info: The support levels info
:return: A tuple consisting of the total remaining support levels and
a dictionary mapping individual support levels to characters
"""
total = 0
remaining = {}
for support, info in support_levels_info[character].items():
current = support_levels[character][support]
try:
position = info.index(current)
diff = len(info) - position - 1
# TODO REMOVE ONCE DEVELOPMENT COMPLETE
index = -1 if diff == 0 else -(diff + 1)
calculated_rank = info[index]
if current != calculated_rank:
print("RANK ERROR!")
except ValueError:
diff = len(info)
total += diff
remaining[support] = diff
return total, remaining
def calculate_max_support_rank(
char_one: str,
char_two: str,
support_levels_info: Dict[str, Dict[str, str]]
) -> str:
"""
Calculates the maximal support level between two characters
:param char_one: The first character
:param char_two: The second character
:param support_levels_info: The support levels info
:return: The maximal rank
"""
return support_levels_info[char_one][char_two][-1]
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from colorama import Fore, Style
def color_character_names(string: str) -> str:
"""
Colors character names in their respective house colors
:param string: The string to format
:return: The formatted string
"""
for color, house in [
(Fore.LIGHTRED_EX, [
"Edelgard",
"Hubert",
"Ferdinand",
"Linhardt",
"Caspar",
"Petra",
"Bernadetta",
"Dorothea"
]),
(Fore.LIGHTBLUE_EX, [
"Dimitri",
"Dedue",
"Felix",
"Sylvain",
"Ashe",
"Annette",
"Mercedes",
"Ingrid"
]),
(Fore.LIGHTYELLOW_EX, [
"Claude",
"Hilda",
"Lorenz",
"Raphael",
"Ignatz",
"Lysithea",
"Marianne",
"Leonie"
]),
(Fore.LIGHTGREEN_EX, [
"Rhea",
"Sothis",
"Seteth",
"Flayn",
"Hanneman",
"Manuela",
"Alois",
"Gilbert",
"Catherine",
"Shamir",
"Cyril"
]),
(Fore.LIGHTWHITE_EX, [
"Byleth M",
"Byleth F"
]),
]:
for character in house:
string = string.replace(character, "{}{}{}".format(
color, character, Style.RESET_ALL
))
return string
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from typing import Dict
from pyexcel_ods import read_data, save_data
from fe3h_checklist import support_levels_file, support_levels_info_file
from fe3h_checklist.support_encoding import encode_support_levels, \
decode_support_levels
def load_support_levels() -> Dict[str, Dict[str, str]]:
"""
Loads the information about support levels from the ODS file
and puts the data into a dictionary mapping the character's current
support levels to each other
:return: The dictionary mapping the support levels to characters.
Example: {"Byleth M": {"Edelgard": "A"}}
"""
return load_table(support_levels_file, "SupportLevels")
def load_support_levels_info() -> Dict[str, Dict[str, str]]:
"""
Loads the information about support level info from the ODS file
and puts the data into a dictionary mapping the character's support
levels to each other
:return: The dictionary mapping the support levels to characters.
Example: {"Byleth M": {"Edelgard": "CBAS"}}
"""
return load_table(support_levels_info_file, "SupportLevelsInfo")
def load_table(ods_file: str, sheet_name: str) -> Dict[str, Dict[str, str]]:
"""
Loads a table from an ODS file.
Assumptions about the ODS file:
- Character names at the top and left side of the table
:param ods_file: The ODS file from which to load the data
:param sheet_name: The sheet name from which to load the data
:return: A dictionary mapping the characters to each other and
containing the value mapped to both of them.
Example: {"Byleth M": {"Edelgard": "CBAS"}}
"""
data_map = {}
data_sheet = dict(read_data(ods_file))[sheet_name]
names = data_sheet.pop(0)
names.pop(0)
for row in data_sheet:
name = row.pop(0)
data_map[name] = {}
for i, entry in enumerate(row):
if entry != "":
data_map[name][names[i]] = encode_support_levels(entry)
return data_map
def save_support_levels(support_levels: Dict[str, Dict[str, str]]):
"""
Saves the support levels to file
:param support_levels: The support levels to save
:return: None
"""
write_table(support_levels_file, "SupportLevels", support_levels)
def write_table(
ods_file: str,
sheet_name: str,
data: Dict[str, Dict[str, str]]
):
"""
Writes the content of a dictionary mapping characters to each other
to an ODS file.
:param ods_file: The ODS file to write to
:param sheet_name: The sheet name to write to
:param data: The data to write
:return: None
"""
new_sheet = [[""]]
for char_one in data:
new_sheet[0].append(char_one)
new_row = [char_one]
for char_two in data:
entry = data[char_one].get(char_two, "")
entry = decode_support_levels(entry, for_sheet=True)
new_row.append(entry)
new_sheet.append(new_row)
ods = dict(read_data(ods_file))
ods[sheet_name] = new_sheet
save_data(ods_file, ods)
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from fe3h_checklist.ods_interface import load_support_levels, \
load_support_levels_info
from fe3h_checklist.calc import calculate_remaining_support_levels, \
calculate_max_support_rank
from fe3h_checklist.support_encoding import decode_support_levels
from fe3h_checklist.formatting import color_character_names
def print_remaining_support_levels(no_byleth: bool, multi_line: bool):
"""
Prints the remaining support levels for all characters and orders
them in a descending order.
:param no_byleth: Whether or not to include support levels with Byleth
:param multi_line: Whether or not to use multiple lines per character
:return: None
"""
support_levels = load_support_levels()
support_levels_info = load_support_levels_info()
ranking = []
for character in support_levels_info:
if "Byleth" in character and no_byleth:
continue
total, remaining = calculate_remaining_support_levels(
character, support_levels, support_levels_info
)
if "Byleth" not in character and no_byleth:
total -= remaining.pop("Byleth M", 0)
total -= remaining.pop("Byleth F", 0)
ranking.append((character, total, remaining))
ranking.sort(key=lambda x: x[1], reverse=True)
max_char_length = len(max(ranking, key=lambda x: len(x[0]))[0])
for rank, (character, total, remaining) in enumerate(ranking):
supports = []
for support, diff in remaining.items():
if diff == 0:
continue
current_rank = support_levels[character][support]
max_rank = calculate_max_support_rank(
character, support, support_levels_info
)
supports.append("{}({}/{})".format(
support.ljust(max_char_length) + (" " if multi_line else ""),
decode_support_levels(current_rank),
decode_support_levels(max_rank)
).ljust(max_char_length + 7))
if multi_line:
supports = ("\n" + " " * (max_char_length + 13)).join(supports)
else:
supports = "[" + ", ".join(supports) + "]"
print(color_character_names("{}({}): {} -> {}".format(
str(rank + 1).rjust(2),
str(total).rjust(3),
character.ljust(max_char_length),
supports
)))
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import sys
from fe3h_checklist.support_encoding import encode_support_levels
from fe3h_checklist.ods_interface import load_support_levels_info, \
load_support_levels, save_support_levels
def set_support_level(char_one: str, char_two: str, level: str):
"""
Sets the support level for two characters and saves it.
:param char_one: The first character
:param char_two: The second character
:param level: The support level
:return: None
"""
level = encode_support_levels(level)
current = load_support_levels()
info = load_support_levels_info()
if char_two not in info[char_one]:
print("Invalid character combination")
sys.exit(1)
elif level not in info[char_one][char_two]:
print("Invalid support level")
sys.exit(1)
else:
current[char_one][char_two] = level
current[char_two][char_one] = level
save_support_levels(current)
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
def encode_support_levels(support_levels: str) -> str:
"""
Converts a support level string into something that can easily be indexed.
The existance of a '+' rank like 'C+' is stored in the info sheet as
"CC" and therefore uses up two spaces, making indexing hard.
So we convert these '+' support levels like this:
C+ -> 1
B+ -> 2
A+ -> 3
:param support_levels: The support level string to encode
:return: The encoded support level string
"""
return support_levels\
.replace("C+", "1")\
.replace("B+", "2")\
.replace("A+", "3")\
.replace("CC", "C1")\
.replace("BB", "B2")\
.replace("AA", "A3")
def decode_support_levels(encoded: str, for_sheet: bool = False):
"""
Decodes the support levels back into a human-readable format
:param encoded: The encoded support level
:param for_sheet: Changes the support levels into the format used in the
data sheet (e.g. C1 -> CC)
:return: The decoded support level
"""
if for_sheet:
return encoded \
.replace("1", "C") \
.replace("2", "B") \
.replace("3", "A")
else:
return encoded\
.replace("1", "C+")\
.replace("2", "B+")\
.replace("3", "A+")
[metadata]
description-file = README.md
"""LICENSE
Copyright 2019 Hermann Krumrey <hermann@krumreyh.com>
This file is part of fe3h-checklist.
fe3h-checklist is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fe3h-checklist is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fe3h-checklist. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
import os
import shutil
from setuptools import setup, find_packages
from fe3h_checklist import local_dir, support_levels_file, \
support_levels_info_file
if __name__ == "__main__":
setup(
name="fe3h-checklist",
version=open("version", "r").read(),
description="A checklist for Fire Emblem Three Houses",
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
author="Hermann Krumrey",
author_email="hermann@krumreyh.com",
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)"
],
url="https://gitlab.namibsun.net/namibsun/python/fe3h-checklist",
license="GNU GPL3",
packages=find_packages(),
scripts=list(map(lambda x: os.path.join("bin", x), os.listdir("bin"))),
install_requires=[
"typing",
"colorama",
"pyexcel_ods"
],
test_suite='nose.collector',
tests_require=['nose'],
include_package_data=True,
zip_safe=False
)
if not os.path.isdir(local_dir):
os.makedirs(local_dir)
if not os.path.isfile(support_levels_info_file):
shutil.copyfile(
"fe3h_checklist/data/support_levels_info.ods",
support_levels_info_file
)
if not os.path.isfile(support_levels_file):
shutil.copyfile(
"fe3h_checklist/data/support_levels.ods",
support_levels_file
)
0.1.0
\ No newline at end of file