Skip to content

Commit

Permalink
Merge pull request #525 from AlexElvers/python-3.13
Browse files Browse the repository at this point in the history
Simplify resources.files calls and update tests
  • Loading branch information
almarklein authored Jan 17, 2025
2 parents 62c1dc7 + fed2645 commit 1774114
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions tests/test_server_assetserver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import subprocess
from pkg_resources import resource_filename
from importlib import resources

from timetagger.server import create_assets_from_dir
import asgineer
Expand All @@ -11,9 +11,9 @@

# Create asset handler
assets = {}
assets.update(create_assets_from_dir(resource_filename("timetagger.app", ".")))
assets.update(create_assets_from_dir(resource_filename("timetagger.common", ".")))
assets.update(create_assets_from_dir(resource_filename("timetagger.images", ".")))
assets.update(create_assets_from_dir(resources.files("timetagger.app")))
assets.update(create_assets_from_dir(resources.files("timetagger.common")))
assets.update(create_assets_from_dir(resources.files("timetagger.images")))
asset_handler = asgineer.utils.make_asset_handler(assets, max_age=0)


Expand Down Expand Up @@ -74,12 +74,12 @@ def test_assets():


hash_checker_code = """
from pkg_resources import resource_filename
from importlib import resources
from timetagger.server import create_assets_from_dir, enable_service_worker
assets = {}
assets.update(create_assets_from_dir(resource_filename("timetagger.app", ".")))
assets.update(create_assets_from_dir(resource_filename("timetagger.common", ".")))
assets.update(create_assets_from_dir(resource_filename("timetagger.images", ".")))
assets.update(create_assets_from_dir(resources.files("timetagger.app")))
assets.update(create_assets_from_dir(resources.files("timetagger.common")))
assets.update(create_assets_from_dir(resources.files("timetagger.images")))
enable_service_worker(assets)
cachename = assets["sw.js"].split("currentCacheName =")[1].split("\n")[0]
print(cachename)
Expand Down
8 changes: 4 additions & 4 deletions timetagger/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
logger = logging.getLogger("asgineer")

# Get sets of assets provided by TimeTagger
common_assets = create_assets_from_dir(resources.files("timetagger.common") / ".")
apponly_assets = create_assets_from_dir(resources.files("timetagger.app") / ".")
image_assets = create_assets_from_dir(resources.files("timetagger.images") / ".")
page_assets = create_assets_from_dir(resources.files("timetagger.pages") / ".")
common_assets = create_assets_from_dir(resources.files("timetagger.common"))
apponly_assets = create_assets_from_dir(resources.files("timetagger.app"))
image_assets = create_assets_from_dir(resources.files("timetagger.images"))
page_assets = create_assets_from_dir(resources.files("timetagger.pages"))

# Combine into two groups. You could add/replace assets here.
app_assets = dict(**common_assets, **image_assets, **apponly_assets)
Expand Down

0 comments on commit 1774114

Please sign in to comment.