Difference between revisions of "Contribute code"
(→Code Style Guide For Archivematica: Docstrings examples) |
(→Code Style Guide For Archivematica: Tweaking) |
||
Line 15: | Line 15: | ||
=== Code Style Guide For Archivematica === | === Code Style Guide For Archivematica === | ||
− | Archivematica follows common Python coding standards, | + | Archivematica follows common Python coding standards, linked below. We encourage installing a Python [http://stackoverflow.com/questions/8503559/what-is-linting linter] to help with this. [https://pypi.python.org/pypi/flake8 flake8] is recommended because it wraps three common linters (pep8, pyflakes, mccabe). |
* [https://www.python.org/dev/peps/pep-0008/ PEP8] for styling | * [https://www.python.org/dev/peps/pep-0008/ PEP8] for styling | ||
** Exception is line length, which should be wrapped at 79 characters or left long for the IDE to wrap. | ** Exception is line length, which should be wrapped at 79 characters or left long for the IDE to wrap. | ||
Line 21: | Line 21: | ||
* [https://www.python.org/dev/peps/pep-0257/ PEP257] for docstring structure | * [https://www.python.org/dev/peps/pep-0257/ PEP257] for docstring structure | ||
** Parameters and return values should be specified in [http://sphinx-doc.org/domains.html#info-field-lists Sphinx-style]. | ** Parameters and return values should be specified in [http://sphinx-doc.org/domains.html#info-field-lists Sphinx-style]. | ||
− | + | * See also [https://github.com/artefactual/archivematica/pull/218 this pull request] and associated discussion. | |
− | |||
− | |||
− | * | ||
Example docstrings with Sphinx markup below. Other attributes that can be used in a docstring can be found [http://sphinx-doc.org/domains.html#the-python-domain on the Sphinx website]. | Example docstrings with Sphinx markup below. Other attributes that can be used in a docstring can be found [http://sphinx-doc.org/domains.html#the-python-domain on the Sphinx website]. |
Revision as of 15:14, 11 August 2015
Main Page > Development > Contribute code
Patches
If you find a bug in this project or would like to make an enhancement, please be encouraged to contribute a patch by following these instructions.
Commit access
Anyone can contribute code patches to this project. Project collaborators and regular patch contributors will be given access to commit directly to the git code repository.
Contributor's Agreement
In order to accept any patches or code commits, contributors must first sign the Archivematica Contributor's Agreement.
Standards
Code Style Guide For Archivematica
Archivematica follows common Python coding standards, linked below. We encourage installing a Python linter to help with this. flake8 is recommended because it wraps three common linters (pep8, pyflakes, mccabe).
- PEP8 for styling
- Exception is line length, which should be wrapped at 79 characters or left long for the IDE to wrap.
- Imports are sorted alphabetically within their grouping to reduce duplicate imports
- PEP257 for docstring structure
- Parameters and return values should be specified in Sphinx-style.
- See also this pull request and associated discussion.
Example docstrings with Sphinx markup below. Other attributes that can be used in a docstring can be found on the Sphinx website.
def get_unit_status(unit_uuid, unit_type): """ Get status for a SIP or Transfer. Returns a dict with status info. Keys will always include 'status' and 'microservice', and may include 'sip_uuid'. Status is one of FAILED, REJECTED, USER_INPUT, COMPLETE or PROCESSING. Microservice is the name of the current microservice. SIP UUID is populated only if the unit_type was unitTransfer and status is COMPLETE. Otherwise, it is None. :param str unit_uuid: UUID of the SIP or Transfer :param str unit_type: unitSIP or unitTransfer :return: Dict with status info. """
def each_child(path, file_group_identifier, base_path, base_path_name, sip_uuid): """ Iterates over entries in a filesystem, beginning at `path`. At each entry in the filesystem, yields either a File model instance (for files) or a string (for directories). When iterating, makes two passes: first iterating over files, then directories. Does not iterate over directories; consumers should call this function again on directory strings to recurse. :param string path: path to a directory on disk to recurse into. :raises ValueError: if the specified path does not exist, or is not a directory. """
File Structure
The file structure in Archivematica will comply with the Filesystem Hierarchy Standard (FHS).
More information on this standard is available at:
http://www.pathname.com/fhs/