Skip to content

Commit

Permalink
Fixes for reformat_altlabel script
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Nov 18, 2024
1 parent d722577 commit dc06955
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/morphodict/frontend/templatetags/morphodict_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
observed_wordforms,
)
from morphodict.relabelling import read_labels
from morphodict.utils import url_for_query
from morphodict.utils.views import url_for_query
from morphodict.orthography.templatetags.morphodict_orth import orth_tag
from morphodict.lexicon.models import Wordform

Expand Down
2 changes: 1 addition & 1 deletion src/morphodict/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from morphodict.lexicon.models import Wordform


from morphodict.utils import url_for_query
from morphodict.utils.views import url_for_query

# The index template expects to be rendered in the following "modes";
# The mode dictates which variables MUST be present in the context.
Expand Down
2 changes: 1 addition & 1 deletion src/morphodict/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from string import printable as ascii_printable

import pytest
from morphodict.utils import url_for_query
from morphodict.utils.views import url_for_query


@pytest.mark.parametrize("query", ["awa", "wâpamêw", "ᐚᐸᒣᐤ"])
Expand Down
18 changes: 0 additions & 18 deletions src/morphodict/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
from .cree_lev_dist import get_modified_distance # Unused but exported
from .shared_res_dir import shared_res_dir # Unused but exported
from urllib.parse import ParseResult, urlencode, urlunparse

from django.urls import reverse
import requests
import urllib


def url_for_query(user_query: str) -> str:
"""
Produces a relative URL to search for the given user query.
"""
parts = ParseResult(
scheme="",
netloc="",
params="",
path=reverse("cree-dictionary-search"),
query=urlencode((("q", user_query),)),
fragment="",
)
return urlunparse(parts)


def get_recordings_from_url(search_terms, url, speech_db_eq):
matched_recordings = {}
query_params = [("q", term) for term in search_terms]
Expand Down
17 changes: 17 additions & 0 deletions src/morphodict/utils/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from urllib.parse import ParseResult, urlencode, urlunparse

from django.urls import reverse

def url_for_query(user_query: str) -> str:
"""
Produces a relative URL to search for the given user query.
"""
parts = ParseResult(
scheme="",
netloc="",
params="",
path=reverse("cree-dictionary-search"),
query=urlencode((("q", user_query),)),
fragment="",
)
return urlunparse(parts)

0 comments on commit dc06955

Please sign in to comment.