Skip to content

Commit a4c6e3b

Browse files
authored
Initial commit
0 parents  commit a4c6e3b

File tree

12 files changed

+878
-0
lines changed

12 files changed

+878
-0
lines changed

.github/workflows/d4g-utils.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Copy File to Organization Repos
2+
3+
on:
4+
push:
5+
paths:
6+
- 'd4g-utils/**' # Trigger the workflow only when changes are made in the d4g-utils directory
7+
branches:
8+
- main
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
jobs:
14+
copy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout template repo
18+
uses: actions/checkout@v2
19+
20+
- name: Set up Git
21+
run: |
22+
git config --global user.email "tech@dataforgood.fr"
23+
git config --global user.name "D4G Tech"
24+
25+
- name: Get organization repositories
26+
id: org_repos
27+
run: |
28+
ORG_NAME="dataforgoodfr"
29+
TEMPLATE_REPO="$ORG_NAME/python_template"
30+
TOKEN=$1
31+
32+
# Fetch repositories from the organization
33+
repos=`gh repo list $ORG_NAME --limit 500 | awk ' {print $1}'`
34+
35+
echo "::set-output name=repos::$repos"
36+
env:
37+
GH_TOKEN: ${{ secrets.D4GTECH_TOKEN }}
38+
39+
- name: Copy files to organization repos
40+
run: |
41+
echo "Searching for repositories generated from template: $template_repo"
42+
for repo in ${{ steps.org_repos.outputs.repos }}; do
43+
repo_info=`gh api repos/$repo`
44+
echo "$repo_info" | jq -r ".template_repository.full_name" | grep "$template_repo" 2>&1 > /dev/null
45+
if [ "$?" -eq "0" ]
46+
then
47+
echo "repo_using_template: $repo"
48+
fi
49+
done
50+
env:
51+
GH_TOKEN: ${{ secrets.D4GTECH_TOKEN }}
52+
53+
54+
# for repo in ${{ steps.org_repos.outputs.repos }}; do
55+
# # Clone the repository
56+
# git clone "https://github.com/$repo" target_repo
57+
58+
# # Copy all files from d4g-utils to target repository d4g-utlis
59+
# rsync -av --exclude='.git' d4g-utils/ target_repo/d4g-utils
60+
61+
# # Commit and push changes
62+
# cd target_repo
63+
# git add .
64+
# git commit -m "Copy files from d4g-utils directory"
65+
# git push origin main
66+
67+
# cd ..
68+
# done

.github/workflows/pre-commit.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
15+
- name: Install poetry
16+
run: |
17+
python -m pip install poetry
18+
poetry export --with dev --format=requirements.txt --output=requirements.txt
19+
- name: set PY
20+
run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
21+
- uses: actions/cache@v1
22+
with:
23+
path: ~/.cache/pre-commit
24+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
25+
- uses: pre-commit/action@v3.0.0

.gitignore

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# From https://github.com/github/gitignore/blob/main/Python.gitignore
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
bin/
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
lib64
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
.python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# poetry
101+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105+
#poetry.lock
106+
107+
# pdm
108+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109+
#pdm.lock
110+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111+
# in version control.
112+
# https://pdm.fming.dev/#use-with-ide
113+
.pdm.toml
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.env.test
128+
.venv
129+
env/
130+
venv/
131+
ENV/
132+
env.bak/
133+
venv.bak/
134+
135+
# Spyder project settings
136+
.spyderproject
137+
.spyproject
138+
139+
# VS Code
140+
.vscode
141+
142+
# Rope project settings
143+
.ropeproject
144+
145+
# mkdocs documentation
146+
/site
147+
148+
# mypy
149+
.mypy_cache/
150+
.dmypy.json
151+
dmypy.json
152+
153+
# Pyre type checker
154+
.pyre/
155+
156+
# pytype static type analyzer
157+
.pytype/
158+
159+
# Cython debug symbols
160+
cython_debug/
161+
162+
# Precommit hooks: ruff cache
163+
.ruff_cache

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/charliermarsh/ruff-pre-commit
3+
# Ruff version.
4+
rev: "v0.2.1"
5+
hooks:
6+
- id: ruff
7+
args: [--fix]
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.3.0
10+
hooks:
11+
- id: check-merge-conflict
12+
- id: mixed-line-ending
13+
#- repo: https://github.com/pycqa/bandit
14+
# rev: 1.7.4
15+
# hooks:
16+
# - id: bandit
17+
# exclude: tests/
18+
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
19+
rev: v1.3.1
20+
hooks:
21+
- id: python-safety-dependencies-check

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2015-2024 Data4Good
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Template DataForGood
2+
3+
This file will become your README and also the index of your
4+
documentation.
5+
6+
# Contributing
7+
8+
## Installer Poetry
9+
10+
Plusieurs [méthodes d'installation](https://python-poetry.org/docs/#installation) sont décrites dans la documentation de poetry dont:
11+
12+
- avec pipx
13+
- avec l'installateur officiel
14+
15+
Chaque méthode a ses avantages et inconvénients. Par exemple, la méthode pipx nécessite d'installer pipx au préable, l'installateur officiel utilise curl pour télécharger un script qui doit ensuite être exécuté et comporte des instructions spécifiques pour la completion des commandes poetry selon le shell utilisé (bash, zsh, etc...).
16+
17+
L'avantage de pipx est que l'installation de pipx est documentée pour linux, windows et macos. D'autre part, les outils installées avec pipx bénéficient d'un environment d'exécution isolé, ce qui est permet de fiabiliser leur fonctionnement. Finalement, l'installation de poetry, voire d'autres outils est relativement simple avec pipx.
18+
19+
Cependant, libre à toi d'utiliser la méthode qui te convient le mieux ! Quelque soit la méthode choisie, il est important de ne pas installer poetry dans l'environnement virtuel qui sera créé un peu plus tard dans ce README pour les dépendances de la base de code de ce repo git.
20+
21+
### Installation de Poetry avec pipx
22+
23+
Suivre les instructions pour [installer pipx](https://pipx.pypa.io/stable/#install-pipx) selon ta plateforme (linux, windows, etc...)
24+
25+
Par exemple pour Ubuntu 23.04+:
26+
27+
sudo apt update
28+
sudo apt install pipx
29+
pipx ensurepath
30+
31+
[Installer Poetry avec pipx](https://python-poetry.org/docs/#installing-with-pipx):
32+
33+
pipx install poetry
34+
35+
### Installation de Poetry avec l'installateur officiel
36+
37+
L'installation avec l'installateur officiel nécessitant quelques étapes supplémentaires,
38+
se référer à la [documentation officielle](https://python-poetry.org/docs/#installing-with-the-official-installer).
39+
40+
## Utiliser un venv python
41+
42+
python3 -m venv .venv
43+
44+
source .venv/bin/activate
45+
46+
## Utiliser Poetry
47+
48+
Installer les dépendances:
49+
50+
poetry install
51+
52+
Ajouter une dépendance:
53+
54+
poetry add pandas
55+
56+
Mettre à jour les dépendances:
57+
58+
poetry update
59+
60+
## Lancer les precommit-hook localement
61+
62+
[Installer les precommit](https://pre-commit.com/)
63+
64+
pre-commit run --all-files
65+
66+
## Utiliser Tox pour tester votre code
67+
68+
tox -vv

0 commit comments

Comments
 (0)