.. _shell: hrcli shell =========== Mit ``hrlci shell`` erhält man man eine interaktive ``iypthon`` shell .. highlight:: none :: # hrcli shell Python 3.6.0 (default, Mar 3 2017, 23:25:37) Type "copyright", "credits" or "license" for more information. IPython 5.3.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. wsgi ...... Application Instance db ....... db Instance models ... wsgi.models (auch als import * importiert) qa ....... wsgi.qa (auch als import * importiert) mandate... wsgi.mandate (auch als import * importiert) In [1]: Hier kann man interaktiv Abfragen etc erstellen. Alle Wahlen anzeigen -------------------- .. highlight:: none :: In [2]: Wahl.query.all() Out[2]: [, , , , , , , , , , , ] Eine Wahl mit einer bestimmten id (ID == Primary Key) holen ----------------------------------------------------------- .. highlight:: none :: In [8]: w = Wahl.query.get(1) In [9]: w Out[9]: In der ``ipython`` shell wir bei Eingabe einer Variable, hier ``w`` die Magic Methode ``__repr__`` des Objekts aufgerufen, wie hier für ``wsgi.models.Wahl.__repr__``. .. highlight:: python :: def __repr__(self): """ Attention: Uses Python 3.6 format string """ return f"" Autovervollständigen mit TAB ---------------------------- Mit TAB kann man wie in der Shell autovervollständigen. .. highlight:: none :: In [3]: w. w.anz_parteien w.bezl w.delete_meta w.gemeindeergebnisse w.berechne_wahlkarten w.bl w.discriminator w.get_ergpos_for_liste w.berechne_wahlkarten_for_bl w.clear_erg w.eingabelisten w.get_listen_for_bl w.bez w.datum w.ergdict w.id Methodendoc mit ? anzeigen lassen --------------------------------- Mit ``?`` kann man sich für Methoden oder Funktionen den Docstring anzeigen lassen. .. highlight:: none :: In [3]: w.clear_erg? Signature: w.clear_erg(commit=True) Docstring: Setzt bei allen Gemeindeergebnissen der Wahl ABG, GIG, PXX auf 0. Die WAB bleiben erhalten. Ruft dafür für jedes Gemeindeergebnise :py:method:`GemeindeErgebnis.clear_erg` auf. :param commit: Soll automatisch ein db.session.commit() erfolgen? :return: File: /opt/hr/wsgi/models.py Type: method