diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef372b0..12a6e1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,29 +1,45 @@ +--- + name: Publish on: [push] jobs: - build: + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: publish - env: - deploy_key: ${{secrets.deploy_key}} - known_hosts: ${{secrets.known_hosts}} - run: | - mkdir -p ${HOME}/.ssh - printf "%s\n" "$known_hosts" > ${HOME}/.ssh/known_hosts - printf "%s\n" "$deploy_key" > ${HOME}/.ssh/id_ed25519 - chmod 600 ${HOME}/.ssh/id_ed25519 - eval $(ssh-agent) - ssh-add - rm ${HOME}/.ssh/id_ed25519 - export deploy_key="" - python3 -m pip install --user --upgrade pip - python3 -m pip install --user mdtoreveal - export PATH="$HOME/.local/bin/:$PATH" - make -C python-initiation rsync - make -C python-avance rsync - make -C drf-initiation rsync - make -C django-initiation rsync + - uses: actions/checkout@v1 + - name: test + run: | + python -m pip install pytest hypothesis django + make -C python-initiation test + make -C python-avance test + # TODO: The following needs a configured Django: + # make -C drf-initiation test + # make -C django-initiation test + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: publish + env: + deploy_key: ${{secrets.deploy_key}} + known_hosts: ${{secrets.known_hosts}} + run: | + mkdir -p ${HOME}/.ssh + printf "%s\n" "$known_hosts" > ${HOME}/.ssh/known_hosts + printf "%s\n" "$deploy_key" > ${HOME}/.ssh/id_ed25519 + chmod 600 ${HOME}/.ssh/id_ed25519 + eval $(ssh-agent) + ssh-add + rm ${HOME}/.ssh/id_ed25519 + export deploy_key="" + python3 -m pip install --user --upgrade pip + python3 -m pip install --user mdtoreveal + export PATH="$HOME/.local/bin/:$PATH" + make -C python-initiation rsync + make -C python-avance rsync + make -C drf-initiation rsync + make -C django-initiation rsync diff --git a/drf-initiation/drf.md b/drf-initiation/drf.md index c079e6a..1a7c5cd 100644 --- a/drf-initiation/drf.md +++ b/drf-initiation/drf.md @@ -10,6 +10,11 @@ https://mdk.fr Introduce yourself! +Et juste pour doctest: +```python +import django.contrib.auth.models +``` + # Les bonnes bases : Python `*args, **kwargs` diff --git a/python-avance/6-coro.md b/python-avance/6-coro.md index b3ee068..8f1e338 100644 --- a/python-avance/6-coro.md +++ b/python-avance/6-coro.md @@ -38,7 +38,10 @@ async def pong_handler(): ## Generator-based coroutines -```python +```pytho +import types + + @types.coroutine def get_then_print(url): ... @@ -183,7 +186,7 @@ print(coro_manager(wont_terminate_here())) ## Gérer ses coroutines -``` +```python def frenetic_coro_manager(coro): try: while True: @@ -196,6 +199,9 @@ def frenetic_coro_manager(coro): ## Gérer ses coroutines ```python +import random + + def frenetic_coros_manager(*coros): coros = list(coros) while coros: @@ -211,14 +217,14 @@ def frenetic_coros_manager(*coros): ```python async def tum(): - while True: + for _ in range(10): # ou : while True: await Awaitable() print("Tum") async def pak(): - while True: + for _ in range(10): # ou : while True: await Awaitable() print("Pak") -frenetic_coro_manager(tum(), pak()) +frenetic_coros_manager(tum(), pak()) ``` diff --git a/python-initiation/README.md b/python-initiation/README.md index 333e523..e579520 100644 --- a/python-initiation/README.md +++ b/python-initiation/README.md @@ -1,7 +1,5 @@ # TODO -On montre `or`, `and`, `not` mais a aucun moment on ne leur montre d'exemple. - On montre la syntaxe d'appel de méthode bien avant de montrer la syntaxe d'appel de fonction, louche. diff --git a/python-initiation/initiation.md b/python-initiation/initiation.md index abe0838..4bd258e 100644 --- a/python-initiation/initiation.md +++ b/python-initiation/initiation.md @@ -171,6 +171,7 @@ False ``` + ## Nombres ```python @@ -257,6 +258,7 @@ Une liste c'est de la donnée, ce qu'elle contint c'est de la donnée. ## *n*-uplets, *tuple* + ```python >>> 1, 2 (1, 2) @@ -275,9 +277,8 @@ liste, par exemple des coordonnées : (x, y). ## Ensembles ```python ->>> {101, 103, 107, 109} -{109, 107, 101, 103} - +>>> {101, 103, 107, 109} == {103, 101, 109, 107} +True ``` ::: notes @@ -386,6 +387,10 @@ False False ``` +::: notes + +On utilisera ça plus tard, avec les structures de contrôle. + ## Test d'appartenance