From ad97639bbf982b5b3b2757e75c3f91556e3a8eac Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 11 Aug 2022 13:55:50 +0200 Subject: clean up unused pieces of code --- src/hydrilla/proxy/store.py | 181 -------------------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 src/hydrilla/proxy/store.py (limited to 'src/hydrilla/proxy/store.py') diff --git a/src/hydrilla/proxy/store.py b/src/hydrilla/proxy/store.py deleted file mode 100644 index 4978b65..0000000 --- a/src/hydrilla/proxy/store.py +++ /dev/null @@ -1,181 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later - -# Haketilo proxy on-disk data storage. -# -# This file is part of Hydrilla&Haketilo. -# -# Copyright (C) 2022 Wojtek Kosior -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# -# I, Wojtek Kosior, thereby promise not to sue for violation of this -# file's license. Although I request that you do not make use this code -# in a proprietary program, I am not going to enforce this in court. - -"""This module facilitates storing and modifying Haketilo proxy data on-disk.""" - -# Enable using with Python 3.7. -from __future__ import annotations - -import threading -import dataclasses as dc -import typing as t - -from pathlib import Path -from enum import Enum - -from immutables import Map - -from .. url_patterns import parse_pattern -from .. import versions -from . import state - - -@dc.dataclass(frozen=True, eq=False) -class StoredItemRef(state.ItemRef): - item_id: int - - def __eq__(self, other: object) -> bool: - return isinstance(other, StoredItemRef) and \ - self.item_id == other.item_id - - def __hash__(self) -> int: - return hash(self.item_id) - - def _id(self) -> str: - return str(self.item_id) - - -@dc.dataclass(frozen=True, eq=False) -class StoredPayloadRef(state.PayloadRef): - payload_id: int - - def __eq__(self, other: object) -> bool: - return isinstance(other, StoredPayloadRef) and \ - self.payload_id == other.payload_id - - def __hash__(self) -> int: - return hash(self.payload_id) - - def _id(self) -> str: - return str(self.payload_id) - - -# class ItemStoredData: -# """....""" -# def __init__( -# self, -# item_id: int -# ty#pe: ItemType -# repository_id: int -# version: str -# identifier: str -# orphan: bool -# installed: bool -# enabled: EnabledStatus -# ) -> None: -# """....""" -# self.item_id = item_id -# self.type = ItemType(type) -# self.repository_id = repository_id -# self.version = parse -# identifier: str -# orphan: bool -# installed: bool -# enabled: EnabledStatus - - -@dc.dataclass -class HaketiloStore: - """....""" - store_dir: Path - - lock: threading.RLock = dc.field(default_factory=threading.RLock) - - # def load_all_resources(self) -> t.Sequence[item_infos.ResourceInfo]: - # """....""" - # # TODO: implement - # with self.lock: - # return [] - - def load_installed_mappings_data(self) \ - -> t.Mapping[state.MappingRef, state.EnabledStatus]: - """....""" - # TODO: implement - with self.lock: - dummy_item_ref = StoredItemRef( - item_id = 47, - identifier = 'somemapping', - version = versions.parse_normalize_version('1.2.3'), - repository = 'somerepo', - orphan = False - ) - - return Map({ - state.MappingRef(dummy_item_ref): state.EnabledStatus.ENABLED - }) - - def load_payloads_data(self) \ - -> t.Mapping[state.MappingRef, t.Iterable[state.PayloadRef]]: - """....""" - # TODO: implement - with self.lock: - dummy_item_ref = StoredItemRef( - item_id = 47, - identifier = 'somemapping', - version = versions.parse_normalize_version('1.2.3'), - repository = 'somerepo', - orphan = False - ) - - dummy_mapping_ref = state.MappingRef(dummy_item_ref) - - payload_refs = [] - for parsed_pattern in parse_pattern('http*://example.com/a/***'): - dummy_payload_ref = StoredPayloadRef( - payload_id = 22, - mapping_ref = dummy_mapping_ref, - pattern = parsed_pattern - ) - - payload_refs.append(dummy_payload_ref) - - return Map({dummy_mapping_ref: payload_refs}) - - def load_file_data( - self, - payload_ref: state.PayloadRef, - resource_identifier: str, - file_path: t.Sequence[str] - ) -> t.Optional[state.FileData]: - # TODO: implement - with self.lock: - return None - - def load_global_settings(self) -> state.HaketiloGlobalSettings: - """....""" - # TODO: implement - with self.lock: - return state.HaketiloGlobalSettings( - state.MappingApplicationMode.WHEN_ENABLED, - False - ) - - def write_global_settings(self, settings: state.HaketiloGlobalSettings) \ - -> None: - """....""" - # TODO: implement - with self.lock: - pass -- cgit v1.2.3