5
Classes use CamelCase. Functions use mixedCase. Here is an example:
8
def myMethod(self, arg1, arg2):
12
def anotherMethod(self, arg1, *args, **kwargs):
15
(Why? Because `someLongAndPowerfulMethod` takes less horizontal space than
16
`some_long_and_powerful_method`.)
18
Exception: Classes which implement command methods should use underscores,
19
since the name of the method is used to create the name of the command:
22
def do_t_cmd1(self, line):
26
def parser_t_cmd1(self):
33
Filenames are lowercase. If they contain a class they should match the name of
34
the class they contain.
36
Internal functions and methods should be prefixed with `_`.
40
Indentation is 4 spaces.
42
Try to keep two blank lines between functions.
44
One space before and after operators, except in optional arguments.
50
myFunction(a, verbose=True)
54
Use one import per line:
59
Avoid polluting the local namespace with `from module import function`.
68
from os import listdir
71
You should however import classes like this:
73
from module import SomeClass
75
Keep import in blocks, in this order:
77
1. Standard Python modules
78
2. Third-party modules
81
Keep import blocks sorted. It makes it easier to check if an import line is
86
All commands are documented either through their parser or using the command
87
docstring. To ensure consistency all usage string should follow the same
90
For example assuming your command is named `t_my_command`, which accepts a few
91
options, two mandatory arguments (a task id and a search text) and an optional
92
filename argument. The usage string should look like this:
94
t_my_command [options] <id> <search_text> [<filename>]
96
No need to detail the options in the usage string, they will be listed by the
97
parser below the usage string.
99
# Database schema changes
101
If you want to modify the database schema (adding, removing, changing tables or
104
- Present the changes on the mailing-list
106
- Implement your changes in db.py
108
- Increase the database version number
110
- Write an update script in update/
112
- Assuming the current version is x and your new version is x+1, you should tag
113
the last commit *before* your changes as "db-vx".
114
This way one can checkout the latest version of Yokadi before your changes,
115
create a database version x and test your update script.
116
The correct way to create the tag is:
122
<!-- vim: set ts=4 sw=4 et: -->