Skip to content
Permalink
Browse files

Improve minor things

  • Loading branch information...
lukasjuhrich committed Mar 3, 2019
1 parent 71d0bf0 commit 134aa19d13beb23613c05a76eca64146257bdb89
Showing with 29 additions and 18 deletions.
  1. +3 −0 Makefile
  2. +3 −1 docs/source/conf.py
  3. +1 −0 sipa/model/hss/__init__.py
  4. +1 −0 sipa/model/sample/__init__.py
  5. +7 −7 sipa/model/user.py
  6. +8 −9 sipa/utils/git_utils.py
  7. +6 −1 sipa/utils/graph_utils.py
@@ -17,6 +17,9 @@ translate:
poedit sipa/translations/en/LC_MESSAGES/messages.po
pybabel compile -d sipa/translations/

docs-clean:
$(MAKE) -C docs clean

docs:
sphinx-apidoc -o docs/source/ref sipa
$(MAKE) -C docs html
@@ -358,6 +358,8 @@

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'flask_flatpages': ('https://flask-login.readthedocs.io/en/latest/', None),
'flask_login': ('https://flask-login.readthedocs.io/en/latest/', None),
'flask': ('http://flask.pocoo.org/docs/1.0/', None),
'ffp': ('https://flask-flatpages.readthedocs.io/en/latest/', None),
'sqla': ('https://docs.sqlalchemy.org/en/latest/', None),
}
@@ -18,6 +18,7 @@ def init_context(app):
raise InvalidConfiguration(*exception.args)


#: The HSS datasource
datasource = DataSource(
name='hss',
user_class=user.User,
@@ -5,6 +5,7 @@
from sipa.backends import DataSource, Dormitory
from . import user

#: The sample datasource, used for frontend debugging.
datasource = DataSource(
name='sample',
user_class=user.User,
@@ -45,6 +45,9 @@ class BaseUser(AuthenticatedUserMixin, metaclass=ABCMeta):
This includes setting :data:`uid` in :meth:`__init__`, defining
equality, and some others.
This class adheres to the protocol imposed by
:class:`Flask-Login <flask_login:flask_login.UserMixin>`
Abstract methods / properties are prepended with ``[Abstract]``.
"""

@@ -59,11 +62,7 @@ def __eq__(self, other):
datasource = None

def get_id(self):
"""This method is Required by flask-login.
See the `flask_login manual
<https://flask-login.readthedocs.io/en/latest/#your-user-class>`
"""
"""This method is Required by flask-login."""
return self.uid

@classmethod
@@ -246,7 +245,7 @@ def userdb_status(self) -> PropertyBase:
@property
@abstractmethod
def userdb(self) -> BaseUserDB:
"""**[Abstract]** The `BaseUserDB` object, if available.
"""**[Abstract]** The :class:`BaseUserDB` object, if available.
If :data:`userdb_status` is non-empty, it is assumed to exist.
"""
@@ -269,7 +268,8 @@ def finance_information(self) -> Optional[BaseFinanceInformation]:

@property
def finance_balance(self) -> PropertyBase:
"""The ``FancyProperty`` representing the finance balance"""
"""The :class:`fancy property <sipa.model.fancy_property.PropertyBase>`
representing the finance balance"""
info = self.finance_information
if not info:
return UnsupportedProperty('finance_balance')
@@ -2,6 +2,7 @@
from datetime import datetime
from logging import getLogger
from subprocess import call
from typing import List

import git
from flask_babel import format_datetime
@@ -60,12 +61,11 @@ def update_repo(repo_dir):
}})


def get_repo_active_branch(repo_dir):
def get_repo_active_branch(repo_dir: str) -> str:
"""
:param repo_dir: path of repo
:type repo_dir: str
:return: name of currently checked out branch
:rtype: str
"""
try:
sipa_repo = git.Repo(repo_dir)
@@ -76,15 +76,14 @@ def get_repo_active_branch(repo_dir):
return "@{}".format(sipa_repo.head.commit.hexsha[:8])


def get_latest_commits(repo_dir, commit_count):
"""
def get_latest_commits(repo_dir: str, commit_count: int) -> List[dict]:
"""Get a given number of latest commits.
:param repo_dir: path of repo
:type repo_dir: str
:param commit_count: number of commits to return
:type commit_count: int
:return: commit information (hash, message, author, date) about
commit_count last commits
:rtype: list of dicts
commit_count last commits
"""
try:
sipa_repo = git.Repo(repo_dir)
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from typing import List

import pygal
from flask_babel import gettext
from pygal import Graph
from pygal.colors import hsl_to_rgb
from pygal.style import Style

@@ -43,13 +46,15 @@ def default_chart(chart_type, title, inline=True, **kwargs):
)


def generate_traffic_chart(traffic_data, inline=True):
def generate_traffic_chart(traffic_data: List[dict], inline: bool = True) -> Graph:
"""Create a graph object from the input traffic data with pygal.
If inline is set, the chart is being passed the option to not add an xml
declaration header to the beginning of the `render()` output, so it can
be directly included in HTML code (wrapped by a `<figure>`)
:param traffic_data: The traffic data as given by `user.traffic_history`
:param inline: Determines the option `disable_xml_declaration`
:return: The graph object
"""
# choose unit according to maximum of `throughput`

0 comments on commit 134aa19

Please sign in to comment.
You can’t perform that action at this time.