Skip to content

Commit

Permalink
discord: add flag to disable zippath (#53)
Browse files Browse the repository at this point in the history
* discord: add flag to disable zippath
  • Loading branch information
purarue authored Feb 8, 2024
1 parent 360e09b commit 6c6035a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions my/discord/data_export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Discord Data: messages and events data
"""

REQUIRES = [
"git+https://github.com/seanbreckenridge/discord_data",
"urlextract",
Expand All @@ -11,21 +12,31 @@
from typing import List

from my.config import discord as user_config # type: ignore[attr-defined]
from my.core import PathIsh, dataclass
from my.core import PathIsh, dataclass, make_config
from my.core.common import mcachew


@dataclass
class config(user_config.data_export):
class discord_config(user_config.data_export):
# path to the top level discord export directory
# see https://github.com/seanbreckenridge/discord_data for more info
export_path: PathIsh

# whether to guess the compression of the files in the export_path
# this uses kompress.ZipPath, which is a bit experimental
#
# NOTE: before adding this config flag, this was enabled,
# since guess_compression=True on get_files by default
_use_zippath: bool = True


config = make_config(discord_config)


from typing import Iterator, Optional, Tuple, Set, NamedTuple
from datetime import datetime

from my.core import make_logger, Stats, get_files
from my.core.common import mcachew
from my.core.structure import match_structure
from discord_data.parse import parse_messages, parse_activity
from discord_data.model import Activity, Message
Expand Down Expand Up @@ -113,7 +124,7 @@ def _cachew_depends_on() -> List[str]:


def get_discord_exports() -> Iterator[Path]:
for exp in get_files(config.export_path):
for exp in get_files(config.export_path, guess_compression=config._use_zippath):
# weak type check here, ZipPath is a bit experimental, so don't want a dependency
# see https://github.com/karlicoss/HPI/blob/master/my/core/kompress.py#L160
if type(exp).__name__ == "ZipPath":
Expand Down

0 comments on commit 6c6035a

Please sign in to comment.