1818from collections .abc import Generator
1919from typing import List
2020
21- from fastapi import APIRouter
2221from fastapi .responses import RedirectResponse
2322from pydantic import FilePath , PositiveInt
2423
@@ -35,8 +34,6 @@ class StrEnum(str, Enum):
3534 """Override for python 3.10 due to lack of StrEnum."""
3635
3736
38- router = APIRouter ()
39-
4037FILE_EXTENSIONS : List [str ] = [".html" , ".py" , ".scpt" , ".sh" , ".xml" ]
4138
4239
@@ -49,17 +46,17 @@ class ValidColors(StrEnum):
4946 https://github.com/badges/buckler/blob/master/README.md#valid-colours
5047 """
5148
52- brightgreen : str = "brightgreen"
53- green : str = "green"
54- yellowgreen : str = "yellowgreen"
55- yellow : str = "yellow"
56- orange : str = "orange"
57- red : str = "red"
58- grey : str = "grey"
59- gray : str = "grey"
60- lightgrey : str = "lightgrey"
61- lightgray : str = "lightgray"
62- blue : str = "blue"
49+ brightgreen = "brightgreen"
50+ green = "green"
51+ yellowgreen = "yellowgreen"
52+ yellow = "yellow"
53+ orange = "orange"
54+ red = "red"
55+ grey = "grey"
56+ gray = "grey"
57+ lightgrey = "lightgrey"
58+ lightgray = "lightgray"
59+ blue = "blue"
6360
6461
6562def should_include (filepath : FilePath ) -> bool :
@@ -89,7 +86,7 @@ def count_lines(filepath: FilePath) -> PositiveInt:
8986 return sum (1 for _ in file )
9087
9188
92- def get_files () -> Generator [FilePath ]:
89+ def get_files () -> Generator [str ]:
9390 """Walk through the directory and collect all relevant files.
9491
9592 Yields:
@@ -126,9 +123,10 @@ def total_files() -> PositiveInt:
126123 return len (list (get_files ()))
127124
128125
129- @router .get (path = "/line-count" , include_in_schema = True )
130126async def line_count (
131- badge : bool = False , color : ValidColors = "blue" , text : str = "lines of code"
127+ badge : bool = False ,
128+ color : ValidColors = ValidColors .blue ,
129+ text : str = "lines of code" ,
132130):
133131 """Get total lines of code for Jarvis.
134132
@@ -151,9 +149,10 @@ async def line_count(
151149 return total_lines
152150
153151
154- @router .get (path = "/file-count" , include_in_schema = True )
155152async def file_count (
156- badge : bool = False , color : ValidColors = "blue" , text : str = "total files"
153+ badge : bool = False ,
154+ color : ValidColors = ValidColors .blue ,
155+ text : str = "total files" ,
157156):
158157 """Get total number of files for Jarvis.
159158
0 commit comments