Skip to end of metadata
Go to start of metadata

Python

Encoding

NOC uses UTF8 encoding for source files. Do not forget to add first (or second, if shebang string present) line

# -*- coding: utf8 -*-

Module header

Insert following header to the start of each of your modules (except empty init.py)

##----------------------------------------------------------------------
## <description>
##----------------------------------------------------------------------
## Copyright (C) 2007-2016 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------

Import statements

Code conventions

NOC follows PEP8 code formatting. Always check your patches before submitting

/opt/noc$ ./scripts/check_pep8 <file>

Identation

Use 4 spaces per indentation level. Indent code with spaces only. Tabs usage is strongly discouraged. Replace all tabs with 4 spaces.

Class names

Class names must follow mixed case convention. Beginnings of the words in uppercase, rests in lowercase, no underscores between words. Acronyms may be in uppercase

Examples:

  • ClassName
  • TCPPacket

Function and method names

Function and method names must be in lowercase with words separated by underscore. Acronyms in the names may be in uppercase

Examples:

  • create_object
  • destroy_all_objects
  • create_TCP_packet

Variable names

Variable names must be in lowercase with words separated by underscore.
Acronyms in the names may be in uppercase

Examples:

  • word_count
  • TCP_count

Constant names

Constants names must be all in uppercase. Words are separated by underscore.

Examples:

  • BUFFER_SIZE

Pycharm setting about pep8

 Click here to expand...

 

 

  • No labels