Skip to content

Commit 7d7de61

Browse files
committed
web: Move DirectoryEntry to web_utils
1 parent 1d996f4 commit 7d7de61

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

elixir/web.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from .api import ApiIdentGetterResource
4242
from .query import get_query
4343
from .web_utils import ProjectConverter, IdentConverter, validate_version, validate_project, validate_ident, \
44-
get_elixir_version_string, get_elixir_repo_url, RequestContext, Config
44+
get_elixir_version_string, get_elixir_repo_url, RequestContext, Config, DirectoryEntry
4545
from .diff import format_diff
4646

4747
VERSION_CACHE_DURATION_SECONDS = 2 * 60 # 2 minutes
@@ -649,14 +649,6 @@ def get_ident_url(ident, ident_family=None):
649649

650650
return html_code_block, html_code_other_block
651651

652-
# Represents a file entry in git tree
653-
# type : either tree (directory), blob (file) or symlink
654-
# name: filename of the file
655-
# path: path of the file, path to the target in case of symlinks
656-
# url: absolute URL of the file
657-
# size: int, file size in bytes, None for directories and symlinks
658-
DirectoryEntry = namedtuple('DirectoryEntry', 'type, name, path, url, size')
659-
660652
# Returns a list of DirectoryEntry objects with information about files in a directory
661653
# base_url: file URLs will be created by appending file path to this URL. It shouldn't end with a slash
662654
# tag: requested repository tag

elixir/web_utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
import logging
44
import threading
5+
from collections import namedtuple
56
from urllib import parse
67
from typing import Any, Dict, NamedTuple
78
import falcon
@@ -81,3 +82,11 @@ def convert(self, value: str) -> str|None:
8182
value = parse.unquote(value)
8283
return validate_ident(value)
8384

85+
# Represents a file entry in git tree
86+
# type : either tree (directory), blob (file) or symlink
87+
# name: filename of the file
88+
# path: path of the file, path to the target in case of symlinks
89+
# url: absolute URL of the file
90+
# size: int, file size in bytes, None for directories and symlinks
91+
DirectoryEntry = namedtuple('DirectoryEntry', 'type, name, path, url, size')
92+

0 commit comments

Comments
 (0)