summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-08-25 10:44:05 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-28 12:54:53 +0200
commit3a1da529bdba0c353b10f6fe2cf1024feb81f809 (patch)
treeb2d332bd18a6f2167e52cd8a75c497234fcfab18
parentc8eb1012980a08a51d78da0c3955cc5ba6edf5ed (diff)
downloadhaketilo-hydrilla-3a1da529bdba0c353b10f6fe2cf1024feb81f809.tar.gz
haketilo-hydrilla-3a1da529bdba0c353b10f6fe2cf1024feb81f809.zip
[proxy] normalize whitespace in .py and .sql files
-rw-r--r--src/hydrilla/pattern_tree.py2
-rw-r--r--src/hydrilla/proxy/addon.py2
-rw-r--r--src/hydrilla/proxy/state.py4
-rw-r--r--src/hydrilla/proxy/state_impl/_operations/load_packages.py2
-rw-r--r--src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py2
-rw-r--r--src/hydrilla/proxy/state_impl/concrete_state.py2
-rw-r--r--src/hydrilla/proxy/tables.sql252
7 files changed, 133 insertions, 133 deletions
diff --git a/src/hydrilla/pattern_tree.py b/src/hydrilla/pattern_tree.py
index 99f45a5..e71f8d0 100644
--- a/src/hydrilla/pattern_tree.py
+++ b/src/hydrilla/pattern_tree.py
@@ -58,7 +58,7 @@ NodeStoredType = t.TypeVar('NodeStoredType')
class PatternTreeNode(t.Generic[NodeStoredType]):
"""...."""
SelfType = t.TypeVar('SelfType', bound='PatternTreeNode[NodeStoredType]')
-
+
ChildrenType = Map[str, SelfType]
children: 'ChildrenType' = Map()
diff --git a/src/hydrilla/proxy/addon.py b/src/hydrilla/proxy/addon.py
index 4058421..c7fae7e 100644
--- a/src/hydrilla/proxy/addon.py
+++ b/src/hydrilla/proxy/addon.py
@@ -149,7 +149,7 @@ class HaketiloAddon:
def forget_policy(self, flow: http.HTTPFlow) -> None:
"""...."""
with self.policies_lock:
- self.flow_policies.pop(id(flow), None)
+ self.flow_policies.pop(id(flow), None)
@contextmanager
def http_safe_event_handling(self, flow: http.HTTPFlow) -> t.Iterator:
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py
index e5c7bd7..d00658f 100644
--- a/src/hydrilla/proxy/state.py
+++ b/src/hydrilla/proxy/state.py
@@ -299,7 +299,7 @@ class PayloadRef(Ref):
@abstractmethod
def get_mapping(self) -> MappingVersionRef:
"""...."""
- ...
+ ...
@abstractmethod
def get_script_paths(self) \
@@ -317,7 +317,7 @@ class PayloadRef(Ref):
class MappingUseMode(Enum):
"""
AUTO - Apply mappings except for those explicitly disabled.
-
+
WHEN_ENABLED - Only apply mappings explicitly marked as enabled. Don't apply
unmarked nor explicitly disabled mappings.
diff --git a/src/hydrilla/proxy/state_impl/_operations/load_packages.py b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
index 76a24d1..107e8d6 100644
--- a/src/hydrilla/proxy/state_impl/_operations/load_packages.py
+++ b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
@@ -194,7 +194,7 @@ def update_or_make_item_version(
item_id,
version,
installed,
- repo_iteration_id,
+ repo_iteration_id,
definition,
definition_sha256
)
diff --git a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
index 4b48ce8..d4c4d45 100644
--- a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
+++ b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
@@ -209,7 +209,7 @@ def _recompute_dependencies_no_state_update_no_pull_files(
INSERT INTO payloads(
mapping_item_id,
pattern,
- eval_allowed,
+ eval_allowed,
cors_bypass_allowed
)
VALUES (?, ?, ?, ?);
diff --git a/src/hydrilla/proxy/state_impl/concrete_state.py b/src/hydrilla/proxy/state_impl/concrete_state.py
index ef698a0..9e56bff 100644
--- a/src/hydrilla/proxy/state_impl/concrete_state.py
+++ b/src/hydrilla/proxy/state_impl/concrete_state.py
@@ -97,7 +97,7 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
if not db_initialized:
cursor.executescript((here.parent / 'tables.sql').read_text())
-
+
else:
cursor.execute(
'''
diff --git a/src/hydrilla/proxy/tables.sql b/src/hydrilla/proxy/tables.sql
index 918c1f1..54fe3ee 100644
--- a/src/hydrilla/proxy/tables.sql
+++ b/src/hydrilla/proxy/tables.sql
@@ -29,13 +29,13 @@ BEGIN TRANSACTION;
CREATE TABLE general(
haketilo_version VARCHAR NOT NULL,
default_allow_scripts BOOLEAN NOT NULL,
- repo_refresh_seconds INTEGER NOT NULL,
- -- "mapping_use_mode" determines whether current mode is AUTO,
- -- WHEN_ENABLED or QUESTION.
- mapping_use_mode CHAR(1) NOT NULL,
+ repo_refresh_seconds INTEGER NOT NULL,
+ -- "mapping_use_mode" determines whether current mode is AUTO,
+ -- WHEN_ENABLED or QUESTION.
+ mapping_use_mode CHAR(1) NOT NULL,
CHECK (rowid = 1),
- CHECK (mapping_use_mode IN ('A', 'W', 'Q')),
+ CHECK (mapping_use_mode IN ('A', 'W', 'Q')),
CHECK (haketilo_version = '3.0b1')
);
@@ -43,15 +43,15 @@ INSERT INTO general(
rowid,
haketilo_version,
default_allow_scripts,
- repo_refresh_seconds,
- mapping_use_mode
+ repo_refresh_seconds,
+ mapping_use_mode
)
VALUES(
1,
'3.0b1',
FALSE,
- 24 * 60 * 60,
- 'Q'
+ 24 * 60 * 60,
+ 'Q'
);
CREATE TABLE rules(
@@ -60,7 +60,7 @@ CREATE TABLE rules(
pattern VARCHAR NOT NULL,
allow_scripts BOOLEAN NOT NULL,
- UNIQUE (pattern)
+ UNIQUE (pattern)
);
CREATE TABLE repos(
@@ -68,29 +68,29 @@ CREATE TABLE repos(
name VARCHAR NOT NULL,
url VARCHAR NOT NULL,
- deleted BOOLEAN NOT NULL DEFAULT FALSE,
- next_iteration INTEGER NOT NULL DEFAULT 1,
- active_iteration_id INTEGER NULL,
- last_refreshed INTEGER NULL,
+ deleted BOOLEAN NOT NULL DEFAULT FALSE,
+ next_iteration INTEGER NOT NULL DEFAULT 1,
+ active_iteration_id INTEGER NULL,
+ last_refreshed INTEGER NULL,
UNIQUE (name),
- -- The local semi-repo used for packages installed offline is always
- -- marked as deleted. Semi-repo's name is chosen as an empty string so
- -- as not to collide with other names (which are required to be
- -- non-empty).
- CHECK ((repo_id = 1) = (name = '')),
- CHECK (repo_id != 1 OR deleted = TRUE),
- -- All deleted repos shall have "url" set to an empty string. All other
- -- repos shall have a valid http(s) URL.
- CHECK (deleted = (url = '')),
- -- Only non-deleted repos are allowed to have an active iteration.
- CHECK (NOT deleted OR active_iteration_id IS NULL),
- -- Only non-deleted repos are allowed to have last refresh timestamp.
- CHECK (NOT deleted OR last_refreshed IS NULL),
-
- FOREIGN KEY (active_iteration_id)
- REFERENCES repo_iterations(repo_iteration_id)
- ON DELETE SET NULL
+ -- The local semi-repo used for packages installed offline is always
+ -- marked as deleted. Semi-repo's name is chosen as an empty string so
+ -- as not to collide with other names (which are required to be
+ -- non-empty).
+ CHECK ((repo_id = 1) = (name = '')),
+ CHECK (repo_id != 1 OR deleted = TRUE),
+ -- All deleted repos shall have "url" set to an empty string. All other
+ -- repos shall have a valid http(s) URL.
+ CHECK (deleted = (url = '')),
+ -- Only non-deleted repos are allowed to have an active iteration.
+ CHECK (NOT deleted OR active_iteration_id IS NULL),
+ -- Only non-deleted repos are allowed to have last refresh timestamp.
+ CHECK (NOT deleted OR last_refreshed IS NULL),
+
+ FOREIGN KEY (active_iteration_id)
+ REFERENCES repo_iterations(repo_iteration_id)
+ ON DELETE SET NULL
);
INSERT INTO repos(repo_id, name, url, deleted)
@@ -99,26 +99,26 @@ VALUES(1, '', '', TRUE);
CREATE TABLE repo_iterations(
repo_iteration_id INTEGER PRIMARY KEY,
- repo_id INTEGER NOT NULL,
- iteration INTEGER NOT NULL,
+ repo_id INTEGER NOT NULL,
+ iteration INTEGER NOT NULL,
- UNIQUE (repo_id, iteration),
+ UNIQUE (repo_id, iteration),
- FOREIGN KEY (repo_id)
- REFERENCES repos (repo_id)
+ FOREIGN KEY (repo_id)
+ REFERENCES repos (repo_id)
);
CREATE VIEW orphan_iterations
AS
SELECT
ri.repo_iteration_id,
- ri.repo_id,
- ri.iteration
+ ri.repo_id,
+ ri.iteration
FROM
- repo_iterations AS ri
+ repo_iterations AS ri
JOIN repos AS r USING (repo_id)
WHERE
- COALESCE(r.active_iteration_id != ri.repo_iteration_id, TRUE);
+ COALESCE(r.active_iteration_id != ri.repo_iteration_id, TRUE);
CREATE TABLE items(
item_id INTEGER PRIMARY KEY,
@@ -127,90 +127,90 @@ CREATE TABLE items(
type CHAR(1) NOT NULL,
identifier VARCHAR NOT NULL,
- UNIQUE (type, identifier),
+ UNIQUE (type, identifier),
CHECK (type IN ('R', 'M'))
);
CREATE TABLE mapping_statuses(
-- The item with this id shall be a mapping ("type" = 'M'). For each
- -- mapping row in "items" there must be an accompanying row in this
- -- table.
+ -- mapping row in "items" there must be an accompanying row in this
+ -- table.
item_id INTEGER PRIMARY KEY,
-- "enabled" determines whether mapping's status is ENABLED,
- -- DISABLED or NO_MARK.
+ -- DISABLED or NO_MARK.
enabled CHAR(1) NOT NULL DEFAULT 'N',
- -- "frozen" determines whether an enabled mapping is to be kept in its
- -- EXACT_VERSION, is to be updated only with versions from the same
- -- REPOSITORY or is NOT_FROZEN at all.
- frozen CHAR(1) NULL,
- -- Only one version of a mapping is allowed to be active at any time.
- -- "active_version_id" indicates which version it is. Only a mapping
- -- version referenced by "active_version_id" is allowed to have rows
- -- in the "payloads" table reference it.
- -- "active_version_id" shall be updated every time dependency tree is
- -- recomputed.
- active_version_id INTEGER NULL,
-
- CHECK (enabled IN ('E', 'D', 'N')),
- CHECK ((frozen IS NULL) = (enabled != 'E')),
- CHECK (frozen IS NULL OR frozen in ('E', 'R', 'N')),
-
- FOREIGN KEY (item_id)
+ -- "frozen" determines whether an enabled mapping is to be kept in its
+ -- EXACT_VERSION, is to be updated only with versions from the same
+ -- REPOSITORY or is NOT_FROZEN at all.
+ frozen CHAR(1) NULL,
+ -- Only one version of a mapping is allowed to be active at any time.
+ -- "active_version_id" indicates which version it is. Only a mapping
+ -- version referenced by "active_version_id" is allowed to have rows
+ -- in the "payloads" table reference it.
+ -- "active_version_id" shall be updated every time dependency tree is
+ -- recomputed.
+ active_version_id INTEGER NULL,
+
+ CHECK (enabled IN ('E', 'D', 'N')),
+ CHECK ((frozen IS NULL) = (enabled != 'E')),
+ CHECK (frozen IS NULL OR frozen in ('E', 'R', 'N')),
+
+ FOREIGN KEY (item_id)
REFERENCES items (item_id)
- ON DELETE CASCADE,
+ ON DELETE CASCADE,
-- We'd like to set "active_version_id" to NULL when referenced entry is
- -- deleted, but we cannot do it with ON DELETE clause because the
- -- foreign key is composite. For now - this will be done by the
- -- application.
- FOREIGN KEY (active_version_id, item_id)
+ -- deleted, but we cannot do it with ON DELETE clause because the
+ -- foreign key is composite. For now - this will be done by the
+ -- application.
+ FOREIGN KEY (active_version_id, item_id)
REFERENCES item_versions (item_version_id, item_id)
);
CREATE TABLE item_versions(
item_version_id INTEGER PRIMARY KEY,
- item_id INTEGER NOT NULL,
+ item_id INTEGER NOT NULL,
version VARCHAR NOT NULL,
- -- "installed" determines whether item is INSTALLED, is NOT_INSTALLED or
- -- it FAILED_TO_INSTALL when last tried. If "required" in a row of
- -- "mapping_statuses is set to TRUE, the mapping version and all
- -- resource versions corresponding to it are supposed to have
- -- "installed" set to 'I'.
- installed CHAR(1) NOT NULL,
- repo_iteration_id INTEGER NOT NULL,
- definition BLOB NOT NULL,
- definition_sha256 CHAR(64) NOT NULL,
- -- "active" determines whether a version of this mapping is active
- -- because it is REQUIRED, has been AUTO activated or is NOT_ACTIVE.
- -- "active" shall be updated every time dependency tree is recomputed.
- -- It shall be set to NOT_ACTIVE if and only if given row does not
- -- correspond to "active_version_id" of any row in "mapping_statuses".
- active CHAR(1) NOT NULL DEFAULT 'N',
+ -- "installed" determines whether item is INSTALLED, is NOT_INSTALLED or
+ -- it FAILED_TO_INSTALL when last tried. If "required" in a row of
+ -- "mapping_statuses is set to TRUE, the mapping version and all
+ -- resource versions corresponding to it are supposed to have
+ -- "installed" set to 'I'.
+ installed CHAR(1) NOT NULL,
+ repo_iteration_id INTEGER NOT NULL,
+ definition BLOB NOT NULL,
+ definition_sha256 CHAR(64) NOT NULL,
+ -- "active" determines whether a version of this mapping is active
+ -- because it is REQUIRED, has been AUTO activated or is NOT_ACTIVE.
+ -- "active" shall be updated every time dependency tree is recomputed.
+ -- It shall be set to NOT_ACTIVE if and only if given row does not
+ -- correspond to "active_version_id" of any row in "mapping_statuses".
+ active CHAR(1) NOT NULL DEFAULT 'N',
UNIQUE (item_id, version, repo_iteration_id),
- -- Constraint below needed to allow foreign key from "mapping_statuses".
- UNIQUE (item_version_id, item_id),
- CHECK (installed in ('I', 'N', 'F')),
- CHECK (active in ('R', 'A', 'N')),
+ -- Constraint below needed to allow foreign key from "mapping_statuses".
+ UNIQUE (item_version_id, item_id),
+ CHECK (installed in ('I', 'N', 'F')),
+ CHECK (active in ('R', 'A', 'N')),
- FOREIGN KEY (item_id)
+ FOREIGN KEY (item_id)
REFERENCES items (item_id),
- FOREIGN KEY (repo_iteration_id)
+ FOREIGN KEY (repo_iteration_id)
REFERENCES repo_iterations (repo_iteration_id)
);
CREATE VIEW repo_display_infos
AS
SELECT
- r.repo_id, r.name, r.url, r.deleted, r.last_refreshed,
- COALESCE(SUM(i.type = 'R'), 0) AS resource_count,
- COALESCE(SUM(i.type = 'M'), 0) AS mapping_count
+ r.repo_id, r.name, r.url, r.deleted, r.last_refreshed,
+ COALESCE(SUM(i.type = 'R'), 0) AS resource_count,
+ COALESCE(SUM(i.type = 'M'), 0) AS mapping_count
FROM
- repos AS r
- LEFT JOIN repo_iterations AS ir USING (repo_id)
- LEFT JOIN item_versions AS iv USING (repo_iteration_id)
- LEFT JOIN items AS i USING (item_id)
+ repos AS r
+ LEFT JOIN repo_iterations AS ir USING (repo_id)
+ LEFT JOIN item_versions AS iv USING (repo_iteration_id)
+ LEFT JOIN items AS i USING (item_id)
GROUP BY
r.repo_id, r.name, r.url, r.deleted, r.last_refreshed;
@@ -223,35 +223,35 @@ CREATE TABLE payloads(
mapping_item_id INTEGER NOT NULL,
pattern VARCHAR NOT NULL,
- -- What privileges should be granted on pages where this
- -- resource/mapping is used.
- eval_allowed BOOLEAN NOT NULL,
+ -- What privileges should be granted on pages where this
+ -- resource/mapping is used.
+ eval_allowed BOOLEAN NOT NULL,
cors_bypass_allowed BOOLEAN NOT NULL,
UNIQUE (mapping_item_id, pattern),
- FOREIGN KEY (mapping_item_id)
+ FOREIGN KEY (mapping_item_id)
REFERENCES item_versions (item_version_id)
- ON DELETE CASCADE
+ ON DELETE CASCADE
);
CREATE VIEW item_versions_extra
AS
SELECT
iv.item_version_id,
- iv.item_id,
+ iv.item_id,
iv.version,
- iv.installed,
- iv.repo_iteration_id,
- iv.definition,
- iv.active,
- r.name AS repo,
- ri.iteration AS repo_iteration,
- COALESCE(r.active_iteration_id, -1) != ri.repo_iteration_id AND r.repo_id != 1
- AS is_orphan,
- r.repo_id = 1 AS is_local
+ iv.installed,
+ iv.repo_iteration_id,
+ iv.definition,
+ iv.active,
+ r.name AS repo,
+ ri.iteration AS repo_iteration,
+ COALESCE(r.active_iteration_id, -1) != ri.repo_iteration_id AND r.repo_id != 1
+ AS is_orphan,
+ r.repo_id = 1 AS is_local
FROM
- item_versions AS iv
+ item_versions AS iv
JOIN repo_iterations AS ri USING (repo_iteration_id)
JOIN repos AS r USING (repo_id);
@@ -266,46 +266,46 @@ CREATE TABLE resolved_depended_resources(
FOREIGN KEY (payload_id)
REFERENCES payloads (payload_id)
- ON DELETE CASCADE,
+ ON DELETE CASCADE,
FOREIGN KEY (resource_item_id)
REFERENCES item_versions (item_version_id)
- ON DELETE CASCADE
+ ON DELETE CASCADE
) WITHOUT ROWID;
CREATE TABLE files(
file_id INTEGER PRIMARY KEY,
- -- File's hash as hexadecimal string.
+ -- File's hash as hexadecimal string.
sha256 CHAR(64) NOT NULL,
- -- The value of "data" - if not NULL - shall be a bytes sequence that
- -- corresponds the hash stored in "sha256".
- data BLOB NULL,
+ -- The value of "data" - if not NULL - shall be a bytes sequence that
+ -- corresponds the hash stored in "sha256".
+ data BLOB NULL,
- UNIQUE (sha256)
+ UNIQUE (sha256)
);
CREATE TABLE file_uses(
file_use_id INTEGER PRIMARY KEY,
- -- If item version referenced by "item_version_id" has "installed" set
- -- to 'I', the file referenced by "file_id" is supposed to have "data"
- -- set to a valid, non-NULL value.
- item_version_id INTEGER NOT NULL,
+ -- If item version referenced by "item_version_id" has "installed" set
+ -- to 'I', the file referenced by "file_id" is supposed to have "data"
+ -- set to a valid, non-NULL value.
+ item_version_id INTEGER NOT NULL,
file_id INTEGER NOT NULL,
name VARCHAR NOT NULL,
-- "type" determines whether it's license file or web resource.
type CHAR(1) NOT NULL,
- mime_type VARCHAR NOT NULL,
+ mime_type VARCHAR NOT NULL,
-- "idx" determines the ordering of item's files of given type.
idx INTEGER NOT NULL,
CHECK (type IN ('L', 'W')),
- UNIQUE(item_version_id, type, idx),
- UNIQUE(item_version_id, type, name),
+ UNIQUE(item_version_id, type, idx),
+ UNIQUE(item_version_id, type, name),
FOREIGN KEY (item_version_id)
REFERENCES item_versions(item_version_id)
- ON DELETE CASCADE,
+ ON DELETE CASCADE,
FOREIGN KEY (file_id)
REFERENCES files(file_id)
);