Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: switch to importlib.metadata for detecting version #414

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/promnesia/server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/python3
from __future__ import annotations

__package__ = 'promnesia' # ugh. hacky way to make wsgi runner work properly...

import argparse
from dataclasses import dataclass
from datetime import timedelta
from functools import lru_cache
import importlib.metadata
import json
import logging
import os
Expand Down Expand Up @@ -51,8 +50,7 @@ def get_logger() -> logging.Logger:


def get_version() -> str:
from pkg_resources import get_distribution
return get_distribution(__package__).version
return importlib.metadata.version(__package__)


class ServerConfig(NamedTuple):
Expand Down Expand Up @@ -232,6 +230,7 @@ def status() -> Json:
try:
version = get_version()
except Exception as e:
logger.exception(e)
version = None

return {
Expand All @@ -241,7 +240,6 @@ def status() -> Json:
}


from dataclasses import dataclass
@dataclass
class VisitsRequest:
url: str
Expand Down
1 change: 1 addition & 0 deletions src/promnesia/sources/filetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def ignore(*args, **kwargs):
'font/woff2': ignore,
'font/woff': ignore,
'text/x-Algol68': ignore, # ugh some license file had this?? maybe always index text/ as text?
'text/x-bytecode.python': ignore, # todo ignore all x-bytecode?

# TODO not sure what to do about these..
'application/octet-stream': handle_later,
Expand Down
Loading