Skip to content

Commit 70acf24

Browse files
committed
Reorg
Signed-off-by: Alina Buzachis <[email protected]>
1 parent ea29bf8 commit 70acf24

File tree

9 files changed

+29
-51
lines changed

9 files changed

+29
-51
lines changed

core/migrations/0005_remove_task_updated_at.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

core/migrations/0006_task_updated_at.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

core/task_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import logging
33
import os
44

5+
from core.utils.controller import build_collection_uri
6+
from core.utils.controller import download_collection
7+
58
from .models import Pattern
69
from .models import Task
7-
from .utils import build_collection_uri
8-
from .utils import download_collection
910

1011
logger = logging.getLogger(__name__)
1112

core/tests/test_controller_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import core.controller_client as cc
1+
import core.utils.controller.client as cc
22

33

44
def test_get_http_session():

core/utils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .http_helpers import validate_url
2+
3+
__all__ = ["validate_url"]

core/utils/controller/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .helpers import build_collection_uri
2+
from .helpers import download_collection
3+
4+
__all__ = [
5+
"build_collection_uri",
6+
"download_collection",
7+
]
File renamed without changes.

core/utils.py renamed to core/utils/controller/helpers.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,14 @@
66
import tempfile
77
from typing import Iterator
88
from urllib.parse import urljoin
9-
from urllib.parse import urlparse
109

1110
from django.conf import settings
1211

13-
from .controller_client import get
12+
from .client import get
1413

1514
logger = logging.getLogger(__name__)
1615

1716

18-
def validate_url(url: str) -> str:
19-
"""Ensure the URL has a valid scheme and format."""
20-
if not url.startswith(("http://", "https://")):
21-
url = f"http://{url}"
22-
parsed = urlparse(url)
23-
if not parsed.scheme or not parsed.netloc:
24-
raise ValueError(f"Invalid URL: {url}")
25-
return url.rstrip("/")
26-
27-
2817
def build_collection_uri(collection: str, version: str) -> str:
2918
"""
3019
Builds the full URI for a given collection and version.

core/utils/http_helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import logging
2+
from urllib.parse import urlparse
3+
4+
logger = logging.getLogger(__name__)
5+
6+
7+
def validate_url(url: str) -> str:
8+
"""Ensure the URL has a valid scheme and format."""
9+
if not url.startswith(("http://", "https://")):
10+
url = f"http://{url}"
11+
parsed = urlparse(url)
12+
if not parsed.scheme or not parsed.netloc:
13+
raise ValueError(f"Invalid URL: {url}")
14+
return url.rstrip("/")

0 commit comments

Comments
 (0)