Skip to content

Commit

Permalink
Merge pull request #22 from akrherz/ruff
Browse files Browse the repository at this point in the history
format python code with ruff
  • Loading branch information
akrherz authored Jan 3, 2024
2 parents 60e5f9f + b24cc5d commit 9981534
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
7 changes: 2 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.290"
rev: "v0.1.11"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

43 changes: 13 additions & 30 deletions cgi-bin/rtstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
.../iddstats_vol_nc1?EXP+10.100.69.110 [volume summaries]
.../rtstats_summary_volume1?10.100.69.110+GRAPH [volume summary]
"""
from html import escape
import sys
import datetime
import re
import sys
from html import escape
from io import BytesIO
import datetime

import requests
import myview
import numpy as np
import pandas as pd
import requests
from anytree import Node, RenderTree

import myview
from rtstats_util import fancy_labels, plt

RE_IP = re.compile(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
Expand Down Expand Up @@ -75,19 +74,15 @@ def handle_topoindex(start_response, link="rtstats_feedtree"):
feedtype,
)
view = myview.MyView()
view.vars[
"content"
] = """
view.vars["content"] = """
<h2>RTSTATS Index by Sites Reporting Feeds</h2>
<p>
For information regarding the type of data contained within a feed type or feed
set listed below, see the <a href="fixme">LDM Feedtypes</a> documentation.</p>
<p>
<h2>IDD Topology Feed List</h2>
%s
""" % (
listing,
)
""" % (listing,)
return [view.render("main.html").encode("ascii", "ignore")]


Expand All @@ -109,9 +104,7 @@ def handle_site(start_response, hostname):
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
</thead>
""" % (
hostname,
)
""" % (hostname,)
for feedtype in j["feedtypes"]:
content += ("<tr><th>%s</th>") % (feedtype,)
content += """
Expand All @@ -121,18 +114,14 @@ def handle_site(start_response, hostname):
<td><a href="%(p)s/iddstats_vol_nc?%(f)s+%(h)s">volume</a></td>
<td><a href="%(p)s/iddstats_num_nc?%(f)s+%(h)s">products</a></td>
<td><a href="%(p)s/iddstats_topo_nc?%(f)s+%(h)s">topology</a></td>
""" % dict(
h=hostname, f=feedtype, p="/cgi-bin/rtstats"
)
""" % dict(h=hostname, f=feedtype, p="/cgi-bin/rtstats")
content += "</tr>"
content += "</table>"

content += """<p>
<a href="%(p)s?%(h)s">Cumulative volume summary</a>
<a href="%(p)s?%(h)s+GRAPH">Cumulative volume summary graph</a>
""" % dict(
h=hostname, p="/cgi-bin/rtstats/rtstats_summary_volume"
)
""" % dict(h=hostname, p="/cgi-bin/rtstats/rtstats_summary_volume")
content += timing(j, URI)
view = myview.MyView()
view.vars["content"] = content
Expand Down Expand Up @@ -162,18 +151,14 @@ def handle_sitesummary(start_response, hostname):
<td><a href="%(p)s/iddstats_vol_nc1?%(f)s+%(h)s+-b 86400">Daily volume</a></td>
<td><a href="%(p)s/iddstats_vol_nc1?%(f)s+%(h)s+-b 604800">Weekly volume</a>
</td>
""" % dict(
h=hostname, f=feedtype, p="/cgi-bin/rtstats"
)
""" % dict(h=hostname, f=feedtype, p="/cgi-bin/rtstats")
content += "</tr>"
content += "</table>"

content += """<p>
<a href="%(p)s?%(h)s">Cumulative volume summary</a>
<a href="%(p)s?%(h)s+GRAPH">Cumulative volume summary graph</a>
""" % dict(
h=hostname, p="/cgi-bin/rtstats/rtstats_summary_volume1"
)
""" % dict(h=hostname, p="/cgi-bin/rtstats/rtstats_summary_volume1")
view = myview.MyView()
view.vars["content"] = content
return [view.render("main.html").encode("ascii", "ignore")]
Expand Down Expand Up @@ -203,9 +188,7 @@ def handle_siteindex(start_response, link, feedtype=None):
<thead>
<tr><th>Domain</th><th>Hosts</th></tr>
</thead>
""" % (
"ANY" if feedtype is None else feedtype,
)
""" % ("ANY" if feedtype is None else feedtype,)
keys = list(domains.keys())
keys.sort()
for d in keys:
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tool.black]
line-length = 79

[tool.ruff]
line-length = 79
select = ["E", "F", "I"]
target-version = "py39"

0 comments on commit 9981534

Please sign in to comment.