Skip to content

Commit

Permalink
Bug fix code stats featuring API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jun 10, 2024
1 parent 4f11dab commit 5a32032
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 71 deletions.
8 changes: 1 addition & 7 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,7 @@ Routers - Stats

.. automodule:: jarvis.api.routers.stats
:members:
:exclude-members: Customizations

====

.. autoclass:: jarvis.api.routers.stats.Customizations(pydantic.BaseModel)
:members:
:exclude-members: _abc_impl, model_config, model_fields
:exclude-members:

Routers - StockMonitor
======================
Expand Down
10 changes: 2 additions & 8 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ <h2 id="C">C</h2>
<li><a href="index.html#jarvis.modules.tv.lg.LGWebOS.close_app">close_app() (jarvis.modules.tv.lg.LGWebOS method)</a>
</li>
<li><a href="index.html#jarvis.api.triggers.stock_monitor.StockMonitor.closest_maximum">closest_maximum() (jarvis.api.triggers.stock_monitor.StockMonitor static method)</a>
</li>
<li><a href="index.html#jarvis.api.triggers.stock_monitor.StockMonitor.closest_minimum">closest_minimum() (jarvis.api.triggers.stock_monitor.StockMonitor static method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis.api.triggers.stock_monitor.StockMonitor.closest_minimum">closest_minimum() (jarvis.api.triggers.stock_monitor.StockMonitor static method)</a>
</li>
<li><a href="index.html#jarvis.modules.models.classes.Indicators.coin">coin (jarvis.modules.models.classes.Indicators attribute)</a>
</li>
<li><a href="index.html#jarvis.modules.utils.util.comma_separator">comma_separator() (in module jarvis.modules.utils.util)</a>
Expand Down Expand Up @@ -461,8 +461,6 @@ <h2 id="C">C</h2>
<li><a href="index.html#jarvis.modules.logger.custom_handler">custom_handler() (in module jarvis.modules.logger)</a>
</li>
<li><a href="index.html#jarvis.modules.meetings.ics_meetings.custom_meetings">custom_meetings() (in module jarvis.modules.meetings.ics_meetings)</a>
</li>
<li><a href="index.html#jarvis.api.routers.stats.Customizations">Customizations (class in jarvis.api.routers.stats)</a>
</li>
<li><a href="index.html#jarvis.modules.transformer.gpt.Customizer.customize_model">customize_model() (jarvis.modules.transformer.gpt.Customizer method)</a>
</li>
Expand Down Expand Up @@ -637,8 +635,6 @@ <h2 id="E">E</h2>
<li><a href="index.html#jarvis.modules.meetings.events.events_gatherer">events_gatherer() (in module jarvis.modules.meetings.events)</a>
</li>
<li><a href="index.html#jarvis.modules.meetings.events.events_writer">events_writer() (in module jarvis.modules.meetings.events)</a>
</li>
<li><a href="index.html#jarvis.api.routers.stats.Customizations.excluded_dirs">excluded_dirs (jarvis.api.routers.stats.Customizations attribute)</a>
</li>
<li><a href="index.html#jarvis.executors.alarm.executor">executor() (in module jarvis.executors.alarm)</a>

Expand Down Expand Up @@ -703,8 +699,6 @@ <h2 id="F">F</h2>
<li><a href="index.html#jarvis.modules.crontab.expression.CronExpression.FIELD_RANGES">FIELD_RANGES (jarvis.modules.crontab.expression.CronExpression attribute)</a>
</li>
<li><a href="index.html#jarvis.api.routers.stats.file_count">file_count() (in module jarvis.api.routers.stats)</a>
</li>
<li><a href="index.html#jarvis.api.routers.stats.Customizations.file_extensions">file_extensions (jarvis.api.routers.stats.Customizations attribute)</a>
</li>
<li><a href="index.html#jarvis.modules.telegram.settings.Audio.file_id">file_id (jarvis.modules.telegram.settings.Audio attribute)</a>

Expand Down
25 changes: 0 additions & 25 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1712,31 +1712,6 @@ <h1>Models - Settings<a class="headerlink" href="#models-settings" title="Permal
</dl>
</dd></dl>

<hr class="docutils" />
<dl class="py class">
<dt class="sig sig-object py" id="jarvis.api.routers.stats.Customizations">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">jarvis.api.routers.stats.</span></span><span class="sig-name descname"><span class="pre">Customizations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pydantic.BaseModel</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#jarvis.api.routers.stats.Customizations" title="Permalink to this definition">¶</a></dt>
<dd><p>Custom exlusitions and inclusions for the scan.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Customizations</span>
</pre></div>
</div>
<p>Create a new model by parsing and validating input data from keyword arguments.</p>
<p>Raises [<cite>ValidationError</cite>][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.</p>
<p><cite>__init__</cite> uses <cite>__pydantic_self__</cite> instead of the more common <cite>self</cite> for the first arg to
allow <cite>self</cite> as a field name.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="jarvis.api.routers.stats.Customizations.excluded_dirs">
<span class="sig-name descname"><span class="pre">excluded_dirs</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#jarvis.api.routers.stats.Customizations.excluded_dirs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="jarvis.api.routers.stats.Customizations.file_extensions">
<span class="sig-name descname"><span class="pre">file_extensions</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#jarvis.api.routers.stats.Customizations.file_extensions" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

</section>
<section id="module-jarvis.api.routers.stock_monitor">
<span id="routers-stockmonitor"></span><h1>Routers - StockMonitor<a class="headerlink" href="#module-jarvis.api.routers.stock_monitor" title="Permalink to this heading">¶</a></h1>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions docs_gen/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,7 @@ Routers - Stats

.. automodule:: jarvis.api.routers.stats
:members:
:exclude-members: Customizations

====

.. autoclass:: jarvis.api.routers.stats.Customizations(pydantic.BaseModel)
:members:
:exclude-members: _abc_impl, model_config, model_fields
:exclude-members:

Routers - StockMonitor
======================
Expand Down
26 changes: 3 additions & 23 deletions jarvis/api/routers/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from fastapi import APIRouter
from fastapi.responses import RedirectResponse
from pydantic import BaseModel, FilePath, PositiveInt
from pydantic import FilePath, PositiveInt

import jarvis
from jarvis.api.logger import logger
Expand All @@ -37,19 +37,7 @@ class StrEnum(str, Enum):

router = APIRouter()


class Customizations(BaseModel):
"""Custom exlusitions and inclusions for the scan.
>>> Customizations
"""

excluded_dirs: List[str] = ["venv", "docs", "logs"]
file_extensions: List[str] = [".html", ".py", ".scpt", ".sh", ".xml"]


custom = Customizations()
FILE_EXTENSIONS: List[str] = [".html", ".py", ".scpt", ".sh", ".xml"]


class ValidColors(StrEnum):
Expand Down Expand Up @@ -84,13 +72,7 @@ def should_include(filepath: FilePath) -> bool:
bool:
Boolean flag to indicate whether the file has to be included.
"""
if not any(filepath.endswith(ext) for ext in custom.file_extensions):
return False
# Check if the file is in one of the excluded directories
for excluded_dir in custom.excluded_dirs:
if excluded_dir in filepath.split(os.sep):
return False
return True
return any(filepath.endswith(ext) for ext in FILE_EXTENSIONS)


def count_lines(filepath: FilePath) -> PositiveInt:
Expand All @@ -114,8 +96,6 @@ def get_files() -> Generator[FilePath]:
Yields the file path.
"""
for root, dirs, files in os.walk(jarvis.__path__[0]):
# Modify dirs in place to skip the excluded directories
dirs[:] = [d for d in dirs if os.path.join(root, d) not in custom.excluded_dirs]
for file in files:
file_path = os.path.join(root, file)
if should_include(file_path):
Expand Down

0 comments on commit 5a32032

Please sign in to comment.