|
|
# Coding standards
|
|
|
|
|
|
**Code Style**
|
|
|
## Code Style
|
|
|
|
|
|
We have a .pylintrc config file in the repository use it.
|
|
|
We have a `.pylintrc` config file in the repository use it.
|
|
|
|
|
|
**Variable and method names**
|
|
|
### Variable and method names
|
|
|
|
|
|
* **Dont** use CamelCase for variables and method names
|
|
|
|
|
|
**Callbacks**
|
|
|
### Callbacks
|
|
|
|
|
|
The default style is used, so we have:
|
|
|
|
|
|
* on_chat_button_clicked
|
|
|
* on_new_message_menuitem_activated
|
|
|
* _on_chat_button_clicked
|
|
|
* _on_new_message_menuitem_activated
|
|
|
|
|
|
In the callbacks we use 'key_press' and 'button_press' events and not the release ones.
|
|
|
The arguments in the the callbacks (and in the .connect()s) have this sequence of 'abstract to specific'. So we write:
|
|
|
|
|
|
# notice we start from ACCOUNT ending up in contact.
|
|
|
foo.connect('clicked', on_foo_clicked, account, group, contact)
|
|
|
# Notice we start from ACCOUNT ending up in contact.
|
|
|
foo.connect('clicked', _on_foo_clicked, account, group, contact)
|
|
|
|
|
|
**Classes**
|
|
|
### Classes
|
|
|
|
|
|
We use CamelCase for Classes
|
|
|
|
|
|
|
|
|
**UI**
|
|
|
### UI
|
|
|
|
|
|
See: [Gnome guidelines on how to design UIs](https://developer.gnome.org/hig/stable/).
|
|
|
|
|
|
NOTE: The point is for the widgets to look nice in an objective way, and to be aligned well.
|
|
|
Most windows/dialogs that have many children have borders with width 12 (else 6), and most GTK boxes have a spacing of 6. In tables, horizontal spacing is set to 12 and vertical spacing to 6. In general the widgets you draw should look nice, so have a look at the glade file to see already implemented windows/dialogs.
|
|
|
Most windows/dialogs that have many children have borders of 18 px, and most GTK boxes have a spacing of 6 (vertically), and 12 (horizontally).
|
|
|
|
|
|
**Tabulations**
|
|
|
### Tabulations
|
|
|
|
|
|
We use spaces not tabs. We use 4 spaces to indent.
|
|
|
|
|
|
**Write clean, readable, optimized pythonic code**
|
|
|
### Write clean, readable, optimized pythonic code
|
|
|
|
|
|
You can always consult the [PEP 8 python style guide](https://www.python.org/dev/peps/pep-0008/).
|
|
|
|
|
|
We love Python and we try to write the pythonic way, therefore:
|
|
|
|
|
|
* Read [Python Performance Tips](https://wiki.python.org/moin/PythonSpeed/PerformanceTips) and [PythonSpeed](https://wiki.python.org/moin/PythonSpeed)
|
|
|
* Use !True/False instead of 1 and 0
|
|
|
* Use single quotes (' ') not double quotes (" ")
|
... | ... | @@ -51,24 +51,23 @@ We love Python and we try to write the pythonic way, therefore: |
|
|
* Write isinstance(a, dict) instead of type(a) == type({}) as it is faster
|
|
|
* Readability comes first and only after readability comes code optimization
|
|
|
|
|
|
**Comments**
|
|
|
### Comments
|
|
|
|
|
|
Comments for developers MUST be in the form
|
|
|
|
|
|
'# comment'
|
|
|
'# Comment'
|
|
|
|
|
|
Comments for translators MUST be in the form
|
|
|
|
|
|
'#comment'
|
|
|
'#Comment'
|
|
|
|
|
|
Documentation style has to follow [PEP 287](http://www.python.org/dev/peps/pep-0287/) and is using [reST markup](http://epydoc.sourceforge.net/othermarkup.html)
|
|
|
|
|
|
**Write good strings**
|
|
|
### Write good strings
|
|
|
|
|
|
Write good English strings (easy to understand, without typos, correct syntax). Your strings should follow [Layout GNOME Hig Rules](https://developer.gnome.org/hig/stable/visual-layout.html) and 'primary text has puncation only if ? so not . in primary text. In secondary always put .'
|
|
|
'As HIG says, alert dialogs don't have titles, etc.' READ THE HIG.
|
|
|
|
|
|
**Using %s %d and not + for strings**
|
|
|
### Using %s %d and not + for strings
|
|
|
|
|
|
Using %s %d and not + for strings that the user sees or has chances to see in the future and being translation friendly.
|
|
|
|
... | ... | @@ -93,7 +92,8 @@ People talk hundreds of languages, keep that in mind and follow this example: |
|
|
#eg. OS can be feminine and Client can be masculine. and Unknown adjective can differ between feminine and masculine
|
|
|
|
|
|
|
|
|
**Vim modelines**
|
|
|
|
|
|
## Vim modelines
|
|
|
|
|
|
Here are some settings for your .vimrc that will help you follow the Gajim coding standards. In this example, all the Gajim source is found in a directory that matches the pattern: "/home/travis/devel/gajim-*/*".
|
|
|
|
... | ... | |