Skip to content

Commit

Permalink
Fixing pip install (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Jan 30, 2024
1 parent 5a1749a commit 156bcd3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[MESSAGES CONTROL]
disable = bad-continuation, bad-whitespace, cyclic-import, duplicate-code, fixme, global-statement, line-too-long, missing-docstring, multiple-imports, multiple-statements, too-few-public-methods, too-many-arguments, too-many-branches, too-many-instance-attributes, too-many-locals, too-many-nested-blocks, too-many-statements, too-many-return-statements, unused-wildcard-import, wildcard-import, wrong-import-order, wrong-import-position
disable = cyclic-import, duplicate-code, fixme, global-statement, line-too-long, missing-docstring, multiple-imports, multiple-statements, too-few-public-methods, too-many-arguments, too-many-branches, too-many-instance-attributes, too-many-locals, too-many-nested-blocks, too-many-statements, too-many-return-statements, unnecessary-lambda-assignment, unused-wildcard-import, use-dict-literal, wildcard-import, wrong-import-order, wrong-import-position

good-names=db,dx,dy,gs,gv,h,i,j,mz,w,x,x1,x2,y,y1,y2,r,g,b,_GameView
2 changes: 1 addition & 1 deletion pdf_game/js.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import lru_cache as cached

# pylint: disable=no-name-in-module, redefined-outer-name
from pyduktape import DuktapeContext
from pyduktape2 import DuktapeContext

from .mod import Proxy
from .mod.hero import patch_avatar, patch_info
Expand Down
1 change: 1 addition & 0 deletions pdf_game/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _common_gv_ancestor(gv1, gv2):
if id(gv2) in gv1_ancestor_ids:
return gv2
gv2 = gv2.src_view
return None


def diff_game_states(gs1, gs2):
Expand Down
1 change: 0 additions & 1 deletion pdf_game/mapscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def mapscript_add_enemy(coords, name, **kwargs):
condition = kwargs.pop('condition', None)
new_enemy = _make_enemy(name, **kwargs)
# cf. https://github.com/PyCQA/pylint/issues/3877
# pylint: disable=undefined-variable
encounter_func = lambda gv, _: _mapscript_encounter_enemy(gv, new_enemy, condition)
encounter_func.enemy = new_enemy
encounter_func.condition = condition
Expand Down
4 changes: 3 additions & 1 deletion pdf_game/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from contextlib import contextmanager
from textwrap import indent

from fpdf.image_datastructures import ImageCache

from .assigner import assign_page_ids
from .entities import GameMilestone
from .optional_deps import tqdm
Expand Down Expand Up @@ -87,7 +89,7 @@ def render_victory_noop(*_): pass
class FakePdfRecorder:
'Fake fpdf.FPDF class that must implement all the methods used during the pages rendering'
def __init__(self):
self.images = {} # images cache used by get_image_info
self.image_cache = ImageCache()
self._calls = []
self._links = {}

Expand Down
1 change: 1 addition & 0 deletions pdf_game/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from PIL.Image import Resampling
NEAREST = Resampling.NEAREST
except ImportError: # for older versions of Pillow:
# pylint: disable=no-member
NEAREST = Image.NEAREST

from .bitfont import bitfont_set_color_red, bitfont_render, Justify
Expand Down
11 changes: 2 additions & 9 deletions pdf_game/render_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .entities import Position
from .js import action, REL_RELEASE_DIR

from fpdf.image_parsing import get_img_info
from fpdf.image_parsing import preload_image


BACKGROUNDS = 'black,nightsky,tempest,interior'.split(',')
Expand Down Expand Up @@ -126,12 +126,5 @@ def link_from_page_id(pdf, page_id):


def get_image_info(pdf, img_filepath):
# Replicates some logic from FPDF.image().
# Could be exposed as a FPDF method with a minor refactor.
info = pdf.images.get(img_filepath)
if not info:
info = get_img_info(img_filepath)
pdf.images[img_filepath] = info
info['i'] = len(pdf.images)
info['usages'] = 1
_, _, info = preload_image(pdf.image_cache, img_filepath)
return info
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fpdf2
humanfriendly # purely optional
pillow
pyduktape
pyduktape2
tqdm # purely optional
8 changes: 7 additions & 1 deletion trailer/gen_promo_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
from fpdf import FPDF
from livereload import Server
from PIL import Image
try:
from PIL.Image import Resampling
NEAREST = Resampling.NEAREST
except ImportError: # for older versions of Pillow:
# pylint: disable=no-member
NEAREST = Image.NEAREST
from qrcode import QRCode


Expand Down Expand Up @@ -121,7 +127,7 @@ def gen_card(fpdf):

def scale(factor, images):
return [img.resize((factor * config().VIEW_WIDTH, factor * config().VIEW_HEIGHT),
resample=Image.NEAREST) for img in images]
resample=NEAREST) for img in images]

def title_screen(fpdf, text, sizes=(8,)):
assert sizes
Expand Down
8 changes: 7 additions & 1 deletion trailer/img_as_pdf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from contextlib import contextmanager

from PIL import Image
try:
from PIL.Image import Resampling
NEAREST = Resampling.NEAREST
except ImportError: # for older versions of Pillow:
# pylint: disable=no-member
NEAREST = Image.NEAREST


class ImageAsPdf:
Expand Down Expand Up @@ -46,7 +52,7 @@ def _image(self, img_added, x=None, y=None, w=0, h=0, link="", title=None, alt_t
y = 0
rc_width, rc_height = map(int, (rc_width, rc_height)) # .resize box arg must be an int tuple
img_added = img_added.crop((crop_x, crop_y, crop_x + rc_width / scale, crop_y + rc_height / scale))\
.resize((rc_width, rc_height), resample=Image.NEAREST)
.resize((rc_width, rc_height), resample=NEAREST)
else:
assert not (w or h), 'Not implemented yet'
x, y = map(int, (x, y)) # .paste box arg must be an int tuple
Expand Down

0 comments on commit 156bcd3

Please sign in to comment.