<commit_before>Coding Standards
================

* [PEP-8](http://www.python.org/dev/peps/pep-0008/)
* [PEP-257](http://www.python.org/dev/peps/pep-0257/)
* [Mercurial Coding Style](http://mercurial.selenic.com/wiki/CodingStyle)

The overall structure of a file should be:

1. header
2. imports
3. classes and functions
4. unit tests
5. main (only for conveyor/\_\_main\_\_.py)

The standard header is:

    # vim:ai:et:ff=unix:fileencoding=utf-8:sw=4:ts=4:
    # conveyor/path/to/file.extension
    #
    # conveyor - Printing dispatch engine for 3D objects and their friends.
    # Copyright © 2012 <NAME> <<EMAIL>>
    #
    # This program is free software: you can redistribute it and/or modify it under
    # the terms of the GNU Affero General Public License as published by the Free
    # Software Foundation, either version 3 of the License, or (at your option) any
    # later version.
    #
    # This program is distributed in the hope that it will be useful, but WITHOUT
    # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
    # details.
    #
    # You should have received a copy of the GNU Affero General Public License
    # along with this program. If not, see <http://www.gnu.org/licenses/>.

    from __future__ import (absolute_import, print_function, unicode_literals)

The import order is (from PEP-8):

1. standard library imports
2. related third party imports
3. local application/library specific imports

For brevity, imports of conveyor modules should be written like this:

    from conveyor import enum, event

Never use "from module import \*". Always list explicitly the names being
imported.

Identifier names should follow the Mercurial convention: all lowercase, with no
underbars between words. The exception to this rule is test methods. They
should start with the prefix `test_` and should use an underscore whenever a
variant suffix is appended to the test name:

    class ExampleTestCase(unittest.TestCase):
        def test_method(self):
            ...

        def test_method_ValueError(self):
            with self.assertRaises(ValueError):
                ...

Don't do work in constructors. They must contain *only* trivial assignment
statements and calls to other constructors. Use a `@classmethod` or
`@staticmethod` when you need to execute more complicated code during the
construction of an object (a.k.a a named constructor):

    class Example(object):
        @classmethod
        def create(cls, parameter):<commit_msg>Relax the import rule in CodingStandards.md.<commit_after>Coding Standards
================

* [PEP-8](http://www.python.org/dev/peps/pep-0008/)
* [PEP-257](http://www.python.org/dev/peps/pep-0257/)
* [Mercurial Coding Style](http://mercurial.selenic.com/wiki/CodingStyle)

The overall structure of a file should be:

1. header
2. imports
3. classes and functions
4. unit tests
5. main (only for conveyor/\_\_main\_\_.py)

The standard header is:

    # vim:ai:et:ff=unix:fileencoding=utf-8:sw=4:ts=4:
    # conveyor/path/to/file.extension
    #
    # conveyor - Printing dispatch engine for 3D objects and their friends.
    # Copyright © 2012 <NAME> <<EMAIL>>
    #
    # This program is free software: you can redistribute it and/or modify it under
    # the terms of the GNU Affero General Public License as published by the Free
    # Software Foundation, either version 3 of the License, or (at your option) any
    # later version.
    #
    # This program is distributed in the hope that it will be useful, but WITHOUT
    # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
    # details.
    #
    # You should have received a copy of the GNU Affero General Public License
    # along with this program. If not, see <http://www.gnu.org/licenses/>.

    from __future__ import (absolute_import, print_function, unicode_literals)

The import order is (from PEP-8):

1. standard library imports
2. related third party imports
3. local application/library specific imports

For brevity, imports of conveyor modules may be written like this:

    from conveyor import enum, event

Never use "from module import \*". Always list explicitly the names being
imported.

Identifier names should follow the Mercurial convention: all lowercase, with no
underbars between words. The exception to this rule is test methods. They
should start with the prefix `test_` and should use an underscore whenever a
variant suffix is appended to the test name:

    class ExampleTestCase(unittest.TestCase):
        def test_method(self):
            ...

        def test_method_ValueError(self):
            with self.assertRaises(ValueError):
                ...

Don't do work in constructors. They must contain *only* trivial assignment
statements and calls to other constructors. Use a `@classmethod` or
`@staticmethod` when you need to execute more complicated code during the
construction of an object (a.k.a a named constructor):

    class Example(object):
        @classmethod
        def create(cls, parameter):
{'fraction_non_alphanumeric': 0.08326937835763622, 'fraction_numerical': 0.011511895625479662, 'mean_word_length': 3.4252971137521224, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6849664', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1395, 'n_words': 616}