Commit 785ee35a authored by Louis's avatar Louis
Browse files

Typo: Fix inversion between words 'row' and 'column'

parent 318deb80
- [ ] `python -m pypimonitor` write an html file to stdout. It taks as argument a yaml file (see below)
- [x] `python -m pypimonitor.http --port PORT DIR1 DIR2` launch a web server
- [ ] - Connection to http://localhost:PORT/foo: render DIR1/foo.yaml as an html page (or DIR2/foo.yaml if not found)
- [ ] - Connection to http://localhost:PORT: same action as now, using pkg=, usr=, and row= arguments. The array is limited to some pypi-only cells
- [ ] - Connection to http://localhost:PORT: same action as now, using pkg=, usr=, and column= arguments. The array is limited to some pypi-only cells
- [x] Change default port
- [x] Use chart.js (see TODO/chart.html)
- [x] Use it
......@@ -25,8 +25,8 @@
- [ ] Add plugins `html`, `img`, `shields`, which can be of any type
- [ ] `render()` method of plugins is passed the type and the pypi slug
- [ ] Plugins have an `agnostic` argument, stating if they can be used when no information is known about a package but its pypi name
- [ ] localhost:PORT/index.html shows a form with text entries for pkg, usr, row if no valid package is given
- [x] pkg= usr= row= arguments can be comma separated lists
- [ ] localhost:PORT/index.html shows a form with text entries for pkg, usr, column if no valid package is given
- [x] pkg= usr= column= arguments can be comma separated lists
- [ ] Add a favicon
- [ ] Each plugin can access global and common options in global configuration
- [ ] Add copyright information
default:
gitlab:
server: http://framagit.org
rows:
columns:
- color
- homepage
- pypiversion
......@@ -12,7 +12,7 @@ rows:
- ci
- coverage
- depends
columns:
packages:
PdfAutoNup:
docs:
type: readthedocs
......
......@@ -56,7 +56,7 @@ class Renderer:
def __init__(self, config):
self.config = config
self.packages = {}
for name in sorted(config['columns']):
for name in sorted(config['packages']):
try:
self.packages[name] = Package(name)
except ValueError as error:
......@@ -69,7 +69,7 @@ class Renderer:
return cls(yaml.safe_load(stream.read()))
@classmethod
def from_args(cls, packages=None, rows=None, users=None):
def from_args(cls, packages=None, columns=None, users=None):
config = {}
# Processing packages
......@@ -80,14 +80,14 @@ class Renderer:
for user in users:
packages.extend(iter_user_packages(user))
packages = list(set(packages))
config['columns'] = {pkg: {} for pkg in set(packages)}
config['packages'] = {pkg: {} for pkg in set(packages)}
# Processing rows
if rows is None:
rows = []
rows = list(itertools.chain(*[item.split(",") for item in rows]))
if rows:
config['rows'] = rows
# Processing columns
if columns is None:
columns = []
columns = list(itertools.chain(*[item.split(",") for item in columns]))
if columns:
config['columns'] = columns
return cls(config)
......@@ -118,16 +118,16 @@ class Renderer:
def render(self):
env = self._get_environment()
# Check rows
rows = []
for row in self.config['rows']:
env.get_template("rows/{}.html".format(row))
rows.append(row)
# Check columns
columns = []
for column in self.config['columns']:
env.get_template("columns/{}.html".format(column))
columns.append(column)
# Render
template = env.get_template("index.html")
return template.render(
rows=rows,
columns=columns,
packages=self.packages,
)
......
......@@ -52,6 +52,6 @@ if __name__ == "__main__":
arguments = commandline_parser().parse_args()
print(pypimonitor.Renderer.from_args(
packages=_flatten(arguments.package),
rows=_flatten(arguments.column),
columns=_flatten(arguments.column),
users=_flatten(arguments.user),
).render())
{%- macro render(row, package) -%}
{%- from "rows/%s.html" % row import render -%}
{%- macro render(column, package) -%}
{%- from "columns/%s.html" % column import render -%}
{{- render(package) -}}
{%- endmacro -%}
{%- macro render(package) -%}
{% from "rows/pypi.html" import render as render_pypi %}
{% from "columns/pypi.html" import render as render_pypi %}
{{ render_pypi(package, "dd", "Daily download", "Daily") }}
{%- endmacro -%}
{%- macro render(package) -%}
{% from "rows/pypi.html" import render as render_pypi %}
{% from "columns/pypi.html" import render as render_pypi %}
{{ render_pypi(package, "dm", "Monthly download", "Monthly") }}
{%- endmacro -%}
{%- macro render(package) -%}
{% from "rows/pypi.html" import render as render_pypi %}
{% from "columns/pypi.html" import render as render_pypi %}
{{ render_pypi(package, "v", "Pypi version", "Version") }}
{%- endmacro -%}
{%- macro render(package) -%}
{% from "rows/pypi.html" import render as render_pypi %}
{% from "columns/pypi.html" import render as render_pypi %}
{{ render_pypi(package, "dw", "Weekly download", "Weekly") }}
{%- endmacro -%}
......@@ -11,19 +11,19 @@
<body>
{{ linecharts.plot(packages.values()) }}
{% from "row.html" import render as render_row %}
{% from "column.html" import render as render_column %}
<table>
<thead><tr>
{% for row in rows -%}
<td>{{ render_row(row, none) }}</td>
{% for column in columns -%}
<td>{{ render_column(column, none) }}</td>
{%- endfor %}
</tr></thead>
<tbody>
{% for package in packages|sort -%}
<tr bgcolor="{{ package |color(0.1, 0.8) }}">
{% for row in rows -%}
{% for column in columns -%}
<td>
{{ render_row(row, packages[package]) }}
{{ render_column(column, packages[package]) }}
</td>
{%- endfor %}
</tr>
......
......@@ -10,10 +10,10 @@ DEFAULT_PORT = 8080
DEFAULT_HOST = ""
class HttpHandler(http.server.BaseHTTPRequestHandler):
def render(self, packages, rows, users):
def render(self, packages, columns, users):
return bytes(pypimonitor.Renderer.from_args(
packages=packages,
rows=rows,
columns=columns,
users=users,
).render(), "utf-8")
......@@ -29,7 +29,7 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
querydict = parse_qs(urlparse(self.path).query)
self.wfile.write(self.render(
packages=querydict.get('pkg'),
rows=querydict.get('rows', ["homepage", "pypi_version", "pypi_mdownload", "pypi_wdownload", "pypi_ddownload"]),
columns=querydict.get('col', ["homepage", "pypi_version", "pypi_mdownload", "pypi_wdownload", "pypi_ddownload"]),
users=querydict.get('user'),
))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment