Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit 5c20ce1

Browse files
committed
Updated for cache module
1 parent 4f28c8d commit 5c20ce1

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

src/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from pathlib import Path
22

3-
SRC = Path(__file__).parent
4-
ROOT = SRC.parent
5-
RES = ROOT / 'res'
3+
SRC: Path = Path(__file__).parent
4+
ROOT: Path = SRC.parent
5+
RES: Path = ROOT / 'res'
66

7-
SETTINGS = RES / 'settings.ini'
8-
IMAGES = RES / 'images'
9-
SOUNDS = RES / 'sounds'
7+
SETTINGS: Path = RES / 'settings.ini'
8+
IMAGES: Path = RES / 'images'
9+
SOUNDS: Path = RES / 'sounds'

src/cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import aiohttp
22
from random import randint, choice, sample
33
from PIL import Image, ImageTk
4-
import os
54
import io
65
import configparser
76

7+
from . import SETTINGS, IMAGES
8+
89

910
class Cache:
1011
'''Class used for caching images and data about the cats'''
@@ -20,9 +21,8 @@ def __init__(self, root):
2021
self.session = None
2122

2223
# get settings
23-
self.dir = os.path.dirname(os.path.realpath(__file__))
2424
cp = configparser.ConfigParser()
25-
cp.read(os.path.join(self.dir, 'settings.ini'))
25+
cp.read(str(SETTINGS))
2626
cp.read('settings.ini')
2727

2828
# for now, let's just look up the DEV settings
@@ -54,8 +54,8 @@ async def refill(self):
5454
# get a random number for an image
5555
image_number = randint(1, 10)
5656
# open and resize the image using Pillow
57-
im = Image.open(os.path.join(self.dir, os.path.join("res",
58-
os.path.join("images", f"{image_number}.jpg"))))
57+
imagepath = IMAGES / f"{image_number}.jpg"
58+
im = Image.open(imagepath)
5959
im = im.resize((self.screen_x, self.screen_y - 150), Image.NEAREST)
6060
# make the image a tkinter image
6161
image = ImageTk.PhotoImage(im)

src/mainwindow.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import tkinter as tk
33
import asyncio
44
from pygame import mixer
5-
import os
6-
from cache import Cache
5+
from .cache import Cache
76

8-
from . import SETTINGS, IMAGES, SOUNDS
7+
from . import SETTINGS
98

109

1110
class Tinder:
@@ -16,9 +15,8 @@ def __init__(self):
1615
mixer.init()
1716

1817
# get settings
19-
self.dir = os.path.dirname(os.path.realpath(__file__))
2018
cp = configparser.ConfigParser()
21-
cp.read(os.path.join(self.dir, 'settings.ini'))
19+
cp.read(SETTINGS)
2220

2321
# for now, let's just look up the DEV settings
2422
# can change this later

0 commit comments

Comments
 (0)