From 616371e01fa96653bd43f4384a6b8ef68b3661b5 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Wed, 19 Jan 2022 19:03:01 -0600 Subject: get it working with pyinstaller on macos --- browser/gemini.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'browser/gemini.py') diff --git a/browser/gemini.py b/browser/gemini.py index 7bedda5..a26f8fc 100644 --- a/browser/gemini.py +++ b/browser/gemini.py @@ -6,6 +6,7 @@ import string import urllib.parse import fsm +from util import resource_path def htmlescape(text: str) -> str: @@ -16,19 +17,19 @@ def gem2html(gem: dict) -> str: params = { 'charset': 'utf-8', 'lang': 'en', - 'css': open('style.css').read() + 'css': open(resource_path('resources/style.css')).read() } if gem['status'][0] == '2': - template = string.Template(open('page_template.html').read()) + template = string.Template(open(resource_path('resources/page_template.html')).read()) body = io.StringIO() parser = fsm.Parser(gem['body'].split('\n'), body) parser.parse() params['body'] = body.getvalue() elif gem['status'][0] == '1': - template = string.Template(open('input_template.html').read()) + template = string.Template(open(resource_path('resources/input_template.html')).read()) params['meta'] = gem['meta'] else: - template = string.Template(open('error_template.html').read()) + template = string.Template(open(resource_path('resources/error_template.html')).read()) if gem['status'] == '00': params['status'] = 'CLIENT ERROR' elif gem['status'][0] == '4': @@ -40,8 +41,6 @@ def gem2html(gem: dict) -> str: params['meta'] = gem['meta'] html = template.substitute(params) - with open('latest.html', 'w') as fp: - fp.write(html) return html -- cgit v1.2.3