Skip to content

Commit

Permalink
V0120 (#41)
Browse files Browse the repository at this point in the history
* session.timetable_extended + additional properties PeriodObject

* more info Periodobject

* Create codeql-analysis.yml

* cleanup

* new info: teacher1 and teacher2 in KlassenObject

* change backcolor/forecolor to Result or None
added PeriodObject.code_color

* Update .gitignore

added additional directories

* tox: up to Python 3.10

fixed deprecated assert_

* added "Rights needed" to documentation

* fix teacher1, teacher2

* remove double code

* version bump 0.1.20, remove python2 from supported versions
  • Loading branch information
AugustH committed Sep 17, 2022
1 parent 51aa2df commit ee7b5ac
Show file tree
Hide file tree
Showing 19 changed files with 411 additions and 55 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '17 4 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ env*
fabfile*
htmlcov

*.pyc
.cache
.mypy_cache
.pytest_cache
.idea
17 changes: 16 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
include README.rst
include LICENSE
recursive-include webuntis/tests/static *
include .coveragerc
#include Makefile
include tox.ini

recursive-include docs *.rst
recursive-include docs Makefile
recursive-exclude docs/_build *

recursive-include examples *.py
recursive-exclude examples/mytests *

recursive-include webuntis *.pyi
recursive-include docs *.py
recursive-include tests *.json

include webuntis/py.typed
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
.PHONY: release build check

release:
python setup.py sdist bdist_wheel upload

build:
python setup.py build sdist
ls -al dist
tar tvzf $(shell ls -1 dist/webuntis-* | tail -n1)

check:
check-manifest
42 changes: 28 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
=====================================
This project is now maintained again. It was originally written by `untitaker <https://github.com/untitaker>`_
=====================================
|
|
|

===============
python-webuntis
===============

.. image:: https://travis-ci.org/maphy-psd/python-webuntis.png?branch=master
.. image:: https://img.shields.io/pypi/v/webuntis
:target: https://pypi.org/project/webuntis/

.. image:: https://img.shields.io/pypi/pyversions/webuntis
:target: https://pypi.org/project/webuntis/

.. image:: https://img.shields.io/pypi/l/webuntis
:target: https://pypi.org/project/webuntis/

.. image:: https://travis-ci.org/AugustH/python-webuntis.png?branch=master
:target: https://travis-ci.org/maphy-psd/python-webuntis

.. image:: https://coveralls.io/repos/github/maphy-psd/python-webuntis/badge.svg?branch=master
:target: https://coveralls.io/r/maphy-psd/python-webuntis

.. image:: https://pepy.tech/badge/webuntis
:target: https://pepy.tech/project/webuntis

.. image:: https://pepy.tech/badge/webuntis/month
:target: https://pepy.tech/project/webuntis



Bindings for WebUntis API
=========================

::

import webuntis

s = webuntis.Session(
username='api',
password='api',
with webuntis.Session(
username='name',
password='passwd',
server='webuntis.grupet.at:8080',
school='demo_inf',
useragent='WebUntis Test'
).login()

for klasse in s.klassen():
print(klasse.name)
).login() as s:
for klasse in s.klassen():
print(klasse.name)

`read more... <http://python-webuntis.readthedocs.org/en/latest/>`_

Expand All @@ -47,3 +57,7 @@ License

``python-webuntis`` is released under the 3-clause BSD license, see ``LICENSE``
for details.


This project is now maintained again. It was originally written by `untitaker <https://github.com/untitaker>`_
==============================================================================================================
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
master_doc = 'index'

project = 'python-webuntis'
copyright = '2013, Markus Unterwaditzer'
copyright = u'2013, Markus Unterwaditzer; 2018, August Hörandl'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -74,7 +74,7 @@
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'python-webuntis.tex', 'python-webuntis Documentation',
'Markus Unterwaditzer', 'manual'),
u'Markus Unterwaditzer, August Hörandl', 'manual'),
]


Expand All @@ -84,7 +84,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'python-webuntis', 'python-webuntis Documentation',
['Markus Unterwaditzer'], 1)
['Markus Unterwaditzer', u'August Hörandl'], 1)
]


Expand All @@ -95,7 +95,7 @@
# dir menu entry, description, category)
texinfo_documents = [
('index', 'python-webuntis', 'python-webuntis Documentation',
'Markus Unterwaditzer', 'python-webuntis', 'Bindings for WebUntis.',
u'Markus Unterwaditzer, August Hörandl', 'python-webuntis', 'Bindings for WebUntis.',
'Miscellaneous'),
]

Expand Down
2 changes: 1 addition & 1 deletion docs/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Errors and Exceptions
=====================

`python-webuntis` tries to cover as many error codes recieved by the API as possible.
`python-webuntis` tries to cover as many error codes received by the API as possible.

.. automodule:: webuntis.errors
:members:
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ Index
session
objects
exceptions
changelog
license
25 changes: 23 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ and its API:
- **The API is read-only.** And there's nothing you can do about it.

- **The API documentation does not explain the purpose of some methods.**
So i can't do a much better job at it.
So i can't do a much better job at it. If you want to read the
official documentation: please ask the untis support.

- **Different schools, different rules.** It is not neccessary that schools
- **Different schools, different rules.** It is not necessary that schools
enter information about, for example, a teacher, in the correct format.
It might happen that a school abuses the name field of a teacher to just
write the teacher's initials in it. Testing is the only sane way out of
Expand All @@ -30,6 +31,26 @@ and its API:
the timezone provided as part of the API. So this library can't make real
efforts to handle date and time in a more professional manner.

- There are **permissions** for the different calls. If you get `no right for ...`
you will have to ask your admin.

Rights to ask for/needed for specific calls (call: needed right):

* getTimetable: timetable view for the requested element
* getTeachers: masterdata teachers read for all
* getStudents: masterdata students read for all
* getKlassen: masterdata Klassen read for all
* getClassregEvents: classregevents read for all
* getExams: examinations read for all
* getExamTypes: examtypes read for all
* getTimetableWithAbsences: Student absences
* getClassregCategories: classregister
* getClassregCategoryGroups: classregister
* getClassregEvents: classevent

- The official untis app is **NOT** using this api. So the app can
do a lot of additional things.

Initially i started writing this library with the goal to abstract away all the
pain that otherwise would result in direct interaction with the API. This is
still an unreached goal. Some things like the problem with time and date is
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

setup(
name='webuntis',
version='0.1.12',
author='Markus Unterwaditzer',
author_email='markus@unterwaditzer.net',
version='0.1.20',
author=u'Markus Unterwaditzer, August Hörandl',
author_email='markus@unterwaditzer.net, august.hoerandl@gmx.at',
packages=find_packages(),
include_package_data=True,
url='https://github.com/python-webuntis/python-webuntis',
Expand All @@ -28,14 +28,14 @@
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: OS Independent',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: PyPy'
]
)
19 changes: 18 additions & 1 deletion tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ def test_basics(self):
self.assert_strict_equal(x.name, u'1A')
self.assert_strict_equal(x.long_name, u'Erste A')

def test_teacher(self):
x = webuntis.objects.KlassenObject(
data={
u'id': 1,
u'name': u'1A',
u'longName': u'Erste A',
'teacher1': 3,
'teacher2': 7
},
session=StubSession())

self.assert_strict_equal(x.name, u'1A')
self.assert_strict_equal(x.long_name, u'Erste A')

self.assert_strict_equal(x.teacher1.name, u'Hans Gans')
self.assert_strict_equal(x.teacher2.name, u'Daniel Duesentrieb')


class PeriodTests(WebUntisTestCase):
Obj = webuntis.objects.PeriodObject
Expand Down Expand Up @@ -311,7 +328,7 @@ def test_basics(self):
exp = datetime.date(2015, 1, 2)

self.assertEqual(x.date.date(), exp)
self.assert_(x.date.time().hour in [12, 13]) # travis says: 12, local test says: 13
self.assertTrue(x.date.time().hour in [12, 13]) # travis says: 12, local test says: 13
self.assertEqual(x.date.time().minute, 33)
self.assertEqual(x.date.time().second, 40)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist=
py27,py34,py35,py36,py37,py38,pypy2,pypy3
py34,py35,py36,py37,py38,py39,py310,pypy3
[testenv]
deps = pytest
mock
Expand Down
2 changes: 1 addition & 1 deletion webuntis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:copyright: (c) 2012 by Markus Unterwaditzer.
:license: BSD, see LICENSE for more details.
"""
__version__ = '0.1.12'
__version__ = '0.1.20'
from webuntis.session import Session

from webuntis import errors

0 comments on commit ee7b5ac

Please sign in to comment.