|
|
Here are listes some usefull tools to know for dev.
|
|
|
|
|
|
## Git
|
|
|
|
|
|
### Config files
|
|
|
|
|
|
#### Relative config files
|
|
|
|
|
|
Since Git 2.13, it is possible to define config files for directories.
|
|
|
Example: the file `~/dev/dbnomics` define user email for all dbnomics repositories:
|
|
|
|
|
|
* in `~/.gitconfig`:
|
|
|
```ini
|
|
|
[includeIf "gitdir:~/dev/dbnomics/"]
|
|
|
path = ~/dev/dbnomics/gitconfig
|
|
|
```
|
|
|
* in `~/dev/dbnomics/gitconfig`:
|
|
|
```ini
|
|
|
[user]
|
|
|
email = jc.dus@cepremap.org
|
|
|
```
|
|
|
|
|
|
##### Multiple config files (one in the subtree of the other)
|
|
|
|
|
|
Example:
|
|
|
|
|
|
```ini
|
|
|
[includeIf "gitdir:~/dev/"]
|
|
|
path = ~/dev/gitconfig
|
|
|
[includeIf "gitdir:~/dev/dbnomics/"]
|
|
|
path = ~/dev/dbnomics/gitconfig
|
|
|
```
|
|
|
|
|
|
#### Preventing git from auto-generating email adress (user@host):
|
|
|
|
|
|
```
|
|
|
[user]
|
|
|
useConfigOnly = true
|
|
|
```
|
|
|
|
|
|
### Good commit messages
|
|
|
|
|
|
https://chris.beams.io/posts/git-commit/
|
|
|
|
|
|
## Python
|
|
|
|
|
|
### Useful dev tools
|
|
|
|
|
|
- [jupyter-notebook](http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html)
|
|
|
|
|
|
### Virtualenvs
|
|
|
|
|
|
* We recommend using [virtualenv wrapper](http://virtualenvwrapper.readthedocs.io/en/latest/) to ease shell integration
|
|
|
* To automatically activate venvs: https://github.com/kennethreitz/autoenv
|
|
|
|
|
|
### autopep8
|
|
|
|
|
|
We use [autopep8](https://github.com/hhatto/autopep8) to reformat Python code automatically, and avoid bikeshedding.
|
|
|
|
|
|
It works very well with the Visual Studio Code editor, and is enabled by default, as soon as you `pip install autopep8` in your venv.
|
|
|
|
|
|
To define a limit of 120 characters per line, edit your user settings, and paste this block:
|
|
|
|
|
|
```json
|
|
|
"python.formatting.autopep8Args": [
|
|
|
"--max-line-length=120"
|
|
|
],
|
|
|
```
|
|
|
|
|
|
### pylint
|
|
|
|
|
|
We use [pylint](https://pylint.readthedocs.io/en/latest/) to check code quality directly from our source code editor.
|
|
|
|
|
|
It works very well with the Visual Studio Code editor, and is enabled by default, as soon as you `pip install pylint` in your venv.
|
|
|
But you'll be annoyed by the huge amount of warnings, so edit your user settings, and paste this block:
|
|
|
|
|
|
```json
|
|
|
"python.linting.pylintArgs": [
|
|
|
"--errors-only"
|
|
|
]
|
|
|
```
|
|
|
|
|
|
### isort
|
|
|
|
|
|
To sort imports automatically and separate them in 3 sections (Python, third-party, local), use [isort](https://github.com/timothycrosley/isort).
|
|
|
|
|
|
Install in your virtualenv:
|
|
|
```sh
|
|
|
pip install isort
|
|
|
```
|
|
|
|
|
|
To sort imports in Visual Studio Code, press `F1` and execute "Sort imports" action.
|
|
|
|
|
|
## CSV tools
|
|
|
|
|
|
### Xsv
|
|
|
|
|
|
https://github.com/BurntSushi/xsv
|
|
|
|
|
|
#### Sample
|
|
|
|
|
|
Usefull function: **sample** => to test a script parsing a HUGE CSV source file, instead of testing it on the n firsts lines of file, we can generate a sample of the file, representing a "rich" mix of the values found in the file:
|
|
|
|
|
|
xsv sample 10000 services_annual_dataset.csv > services_annual_dataset-sample.csv
|
|
|
|
|
|
generate a 10000 lines sample of `services_annual_dataset.csv` file |
|
|
\ No newline at end of file |