<commit_before>Before reading this file, please read the [CONTRIBUTE](CONTRIBUTE.md) file, that
contains the main guidelines of the project.

## Topics:
  - [Development Environment setup](#setup)
    - [Virtualenv (optional)](#virtualenv)
    - [Virtualenv Extras (optional)](#virtualenv-extras)
  - [Tests/TDD](#tdd)

## <a name="setup"></a> Development Environment setup

This project is written in Python (version 3.5).

During the development of the project, what you need is to add the ofp folder,
inside this repository, to your PYTHONPATH environment variable. For that,
you have to execute the following on the command line (being on this current
folder):

```shell
export PYTHONPATH=`pwd`/ofp:$PYTHONPATH
```

Remember that everytime you start a new shell instance you will have to repeat
the command above, since this is an environment variable. To have it executed
automatically in every shell, add it to `~/.bashrc` replacing `pwd` by the full
path (its output).

### <a name="virtualenv"></a> Virtualenv

To make things easier and avoid the need of redoing the export all the time,
we recommend that you install python `virtualenv`. This is not necessary, but
recommended. With `virtualenv`, you can install the required and recommended
python libraries without messing up with your system. To install it, run
the following commands:

```shell
sudo apt install python3-pip
sudo pip3 install virtualenv virtualenvwrapper
```

If you are working with **bash**, add the following lines on your
`~/.bash_profile` or `~/.bashrc` to setup `virtualenvwrapper`:

```shell
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
```

If you are using **[oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)** you
can just add the `virtualenvwrapper` plugin to your plugins list
(inside `~/.zshrc`). This plugin will:
  - Load Python's [virtualenvwrapper shell tools](http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html);
  - Automatically activate virtualenv on `cd` into git repository with matching
name.

We also recommend adding the bellow code to your
`~/.virtualenvs/postmkvirtualenv` file:

```shell
echo '_OLD_PYTHONPATH="$PYTHONPATH"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postactivate
echo "PYTHONPATH="'"'$(pwd)'"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postactivate
echo 'PYTHONPATH="$_OLD_PYTHONPATH"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postdeactivate
```

This will change the PYTHONPATH environment variable to your projects path when
the virtualenv is activated.

After installed, clone this repository locally, `cd` into it and create the
required virtualenv with the same name as the repository directory:

```shell
mkvirtualenv "${PWD##*/}" -r requirements.txt
```

This will create the virtualenv with all project requirements and also activate
it.

The standard setup finishes here.

If you are using `oh-my-zsh` plugin then every time you enter on the project
directory, the virtualenvironment will be automaticaly loaded. If you are using
bash, then you need to run the `workon` command to activate the environment:

```shell
workon python-openflow
```

See more virtualenvwrapper commands on:
http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html

#### <a name="virtualenv-extras"></a> Virtualenv Extras

If you want to show the current activated virtualenv on the right side of your
shell, add the following code to your `~/.virtualenvs/postactivate` file:

```shell
PS1="$_OLD_VIRTUAL_PS1"
_OLD_RPROMPT="$RPROMPT"
RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[white]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT"
```

Change the colors to your own preferences.

and also this code to your `~/.virtualenvs/postdeactivate` file:

```shell
RPROMPT="$_OLD_RPROMPT"
```

## <a name="tdd"></a> TDD (Test Driven Development)
We aim at 100% of test coverage. For that, we are using
Python [unittest](https://docs.python.org/3.5/library/unittest.html) and
to verify the test coverage status we are using
[coverage.py](https://coverage.readthedocs.org/en/coverage-4.0.3/).
To install the coverage (python3 version), run:<commit_msg>Updated HACKGING.md<commit_after>Before reading this file, please read the [CONTRIBUTE](CONTRIBUTE.md) file, that
contains the main guidelines of the project.

## Topics:
  - [Development Environment setup](#setup)
    - [Virtualenv (optional)](#virtualenv)
    - [Virtualenv Extras (optional)](#virtualenv-extras)
  - [Tests/TDD](#tdd)

## <a name="setup"></a> Development Environment setup

This project is written in Python (version 3.5).

During the development of the project, what you need is to add the ofp folder,
inside this repository, to your PYTHONPATH environment variable. For that,
you have to execute the following on the command line (being on this current
folder):

```shell
export PYTHONPATH=`pwd`/ofp:$PYTHONPATH
```

Remember that everytime you start a new shell instance you will have to repeat
the command above, since this is an environment variable. To have it executed
automatically in every shell, add it to `~/.bashrc` replacing `pwd` by the full
path (its output).

### <a name="virtualenv"></a> Virtualenv

To make things easier and avoid the need of redoing the export all the time,
we recommend that you install python `virtualenv`. This is not necessary, but
recommended. With `virtualenv`, you can install the required and recommended
python libraries without messing up with your system. To install it, run
the following commands:

```shell
sudo apt install python3-pip
sudo pip3 install virtualenv virtualenvwrapper
```

If you are working with **bash**, add the following lines on your
`~/.bash_profile` or `~/.bashrc` to setup `virtualenvwrapper`:

```shell
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
```

If you are using **[oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)** you
can just add the `virtualenvwrapper` plugin to your plugins list
(inside `~/.zshrc`). This plugin will:
  - Load Python's [virtualenvwrapper shell tools](http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html);
  - Automatically activate virtualenv on `cd` into git repository with matching
name.

We also recommend adding the bellow code to your
`~/.virtualenvs/postmkvirtualenv` file:

```shell
echo '_OLD_PYTHONPATH="$PYTHONPATH"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postactivate
echo "PYTHONPATH="'"'$(pwd)'"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postactivate
echo 'PYTHONPATH="$_OLD_PYTHONPATH"' >> ~/.virtualenvs/"${PWD##*/}"/bin/postdeactivate
```

This will change the PYTHONPATH environment variable to your projects path when
the virtualenv is activated.

After installed, clone this repository locally, `cd` into it and create the
required virtualenv with the same name as the repository directory:

```shell
mkvirtualenv "${PWD##*/}" -r requirements.txt
```

This will create the virtualenv with all project requirements and also activate
it.

The standard setup finishes here.

If you are using `oh-my-zsh` plugin then every time you enter on the project
directory, the virtualenvironment will be automaticaly loaded. If you are using
bash, then you need to run the `workon` command to activate the environment:

```shell
workon kyco
```

See more virtualenvwrapper commands on:
http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html

#### <a name="virtualenv-extras"></a> Virtualenv Extras

If you want to show the current activated virtualenv on the right side of your
shell, add the following code to your `~/.virtualenvs/postactivate` file:

```shell
PS1="$_OLD_VIRTUAL_PS1"
_OLD_RPROMPT="$RPROMPT"
RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[white]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT"
```

Change the colors to your own preferences.

and also this code to your `~/.virtualenvs/postdeactivate` file:

```shell
RPROMPT="$_OLD_RPROMPT"
```

## <a name="tdd"></a> TDD (Test Driven Development)
We aim at 100% of test coverage. For that, we are using
Python [unittest](https://docs.python.org/3.5/library/unittest.html) and
to verify the test coverage status we are using
[coverage.py](https://coverage.readthedocs.org/en/coverage-4.0.3/).
To install the coverage (python3 version), run:
{'fraction_non_alphanumeric': 0.11971404337816552, 'fraction_numerical': 0.0036350418029807343, 'mean_word_length': 5.196696696696697, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 31, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4953060', 'n_tokens_mistral': 2600, 'n_tokens_neox': 2464, 'n_words': 940}