If you want commit access, all we need is a SourceForge user ID.
Basically the only rules are:
Make sure your code actually compiles (to .pyc or .o) on a
supported platform (e.g. a recent Mac) before checking in. (Sounds
obvious, but people do forget sometimes.)
When changing existing functionality - even just bug fixes - always
run the regression tests.
If you add functionality, also add a regression test if you don't
want someone else to break it later.
Tread lightly when introducing third-party dependencies (we do this
all the time, of course, but we try to do so in a way that avoids
breaking the library for people who don't have the same dependency
installed).
When in doubt, post your diffs to the cctbxbb for feedback.
Before committing code run libtbx.find_clutter and follow the output instructions for adjusting whitespaces and imports to cctbx standards.
In general normal Python coding style guidelines apply. Additionally please be aware of this:
try to make the code self-documenting by using (long) meaningful
names and by keeping functions small
Capitalization:
Please use libtbx.find_clutter to check your code before committing.
Strictly following the rules is more important in C++ than in Python
since C++ code is inherently more difficult to read.
Following the rules in Python helps when moving code from Python to C++.
To avoid problems with platform-specific end-of-line conventions
and stray whitespace characters such as tabs (see below) run the
command
$ libtbx.find_clutter
at the top level of each svn or cvs directory with changes to be
committed. The command will recursively traverse all subdirectories
and list the names of files that are not "clean." To minimize
the chance of accidents, libtbx.find_clutter does not modify
the files listed. A convenient option for cleaning up the problem
files is to use the libtbx.clean_clutter command, e.g.:
$ libtbx.clean_clutter path/to/file
One can also issue
$ libtbx.clean_clutter -c
which will recursively clean those files under the current directory which are modified or added, i.e. which would be committed.
To convert files with Windows or Macintosh end-of-line conventions
use the command:
$ libtbx.any2unix path/to/file
We want to have an easy and reliable way to see who changed what exactly.
cctbx and phenix developers use many different editors. Some
remove trailing whitespace, some insert tabs, etc. Without
libtbx.clean_clutter we'd have a hard time seeing what was
actually changed since we'd have many spurious diffs in the
history.
(diff -b -w helps, but it hides indentation changes.)
It is extremely tedious to re-factor code written by authors
using inconsistent indentation.
This will help make the sources more readable in various situations
(e.g. svn web view). Occasional longer lines are fine, e.g. for
certain assertions.
(Why 80 and not some other number? -- Obviously there has to be
some limit. 80 was chosen because it fits universally.)
Reasons:
- Scripts with relative imports cannot be moved to other locations.
- Python's relative import mechanism easily leads to confusion.
# Good example: from iotbx import reflection_file_reader # Bad example: import reflection_file_reader
Reason:
- Reading code using import * is very difficult because
there is no easy way to tell where symbols come from.
- Name clashes may lead to subtle bugs.
# Good example: from iotbx import mtz mtz_object = mtz.object(file_name="any.mtz") # bad example: from iotbx.mtz import * # name clash: built-in object, iotbz.mtz.object
Reason:
- A bare except will "swallow" keyboard interrupts (Ctrl-C),
forcing the user to hit Ctrl-C multiple times.
# Good example: try: something() except KeyboardInterrupt: raise except: pass # Bad example: try: something() except: pass