add guidelines for uniformity in the code base
@mschraal
Submitted by Marinus Schraal Link to original bug (#765593)
Description
Python is an easy to enter language, but having no guidelines has resulted in a rather messy codebase for gnome-music in my opinion. It would be nice to have music act both as an entry-level project and an example of clean Gtk/GNOME PyGI application development.
I propose to adopt a few guidelines for how to contribute to gnome-music and step-by-step move it to a cleaner state.
I suggest updating slowly as parts get rewritten naturally, not in one giant step. Updating probably per function as parts of a function get updated.
Accepted guidelines should be eventually put in a document in the source tree.
Suggested guidelines:
-
Adhere to PEP-8 ( https://www.python.org/dev/peps/pep-0008/ )
-
function notation with underscores (new_function)
-
private variables and functions prefixed with _
-
docstrings for functions
-
etc.
-
Following from PEP-8 is PEP-257 on Docstrings
-
Use PyGI shorthands for accessing GtkTreeModel/GtkTreeStore
-
store[iter][column]
-
see https://python-gtk-3-tutorial.readthedocs.org/en/latest/treeview.html for details
-
comment GtkTreeStore/GtkListStore with actual value number & description for clarity
store = Gtk.ListStore( str, # 1 - Name int, # 2 - Number )
-
All tracker interaction in Query.py
-
All Grilo interaction in Grilo.py
-
All functions need to have @log decorator