diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6d327ec..db066e3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,7 +11,7 @@ jobs:
matrix:
directory:
- python-initiation
- - python-avance
+ - python-avancé
- drf-initiation
- django-initiation
- python-perfs
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 0937bd1..4717bbd 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -21,6 +21,7 @@ jobs:
python-version: '3.10'
cache: pip
- run: sudo apt-get install -y cutycapt
+ - run: python3 -m pip install -r requirements.txt
- run: make -C ${{ inputs.directory }} test
- name: Publish
env:
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..07ee9ed
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,34 @@
+SRCS := $(sort $(wildcard *.md))
+DEST := $(notdir $(PWD))
+
+.PHONY: static
+static: output/index.html
+
+%.html: %.md
+ sed 's/#!//e;' perfs.md | mdtoreveal /dev/stdin --output $@
+
+output/index.md: $(SRCS)
+ mkdir -p output
+ cat $(SRCS) > output/index.md
+
+.PHONY: rsync
+rsync: static
+ rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/$DEST/
+
+.PHONY: clean
+clean:
+ rm -fr output
+
+.PHONY: entr
+entr:
+ ls -1 *.md | entr $(MAKE) static
+
+.PHONY: serve
+serve: static
+ python3 -m http.server -d output/
+
+.PHONY: test
+test:
+ if [ -f test.py ]; then \
+ python test.py *.md; \
+ fi
diff --git a/README.md b/README.md
index 9e67892..97911a8 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,16 @@
-# Python Introduction Slides
+# The slides I use while teaching
-https://mdk.fr/python-initiation/
+Each directory contains a Makefile that builds the slides using
+[mdtoreveal](https://pypi.org/project/mdtoreveal/).
+
+Each directory is also uploaded to mdk.fr:
+
+- https://mdk.fr/python-initiation
+- https://mdk.fr/python-avancé
+- https://mdk.fr/drf-initiation
+- https://mdk.fr/django-initiation
+- https://mdk.fr/python-perfs
+- https://mdk.fr/git-initiation
## TODO
@@ -74,3 +84,76 @@ Souci : Jour 1 pytest nécessite Jour 2 pip...
- jupyter
Ce(tte) œuvre est mise à disposition selon les termes de la Licence Creative Commons Attribution 4.0 International.
+
+# DRF
+
+Side project : https://github.com/JulienPalard/drf-demos
+
+- Revue des bases et consolidation Python et Django
+- Présentation des types d'API, approfondissement de REST/HATEOAS
+- Rappels autour de la sémantique HTTP
+- django-rest-framework: La sérialisation
+- django-rest-framework: Les différents types de vues
+- django-rest-framework: Les permissions
+- django-rest-framework: Les relations
+- Les tests et la maintenabilité
+
+
+# Objectifs pédagogiques
+
+- Pouvoir démarrer rapidement un projet DRF.
+- Savoir designer une API.
+- Implémenter un service headless en utilisant DRF.
+
+
+# TP
+
+- Projet 1 : API « Horloge parlante ».
+- Projet 2 : API « memcached ».
+- Projet 3 : API « file system ».
+- Projet 4 : API « uptime manager ».
+
+
+# Formation Initiation Linux (2 jours)
+
+Cette formation est destinée à toute personne souhaitant utiliser
+Linux, pour du développement, de l'administration système, ou pour un
+usage quotidien.
+
+
+## Stagiaires
+
+Maximum 5 par sessions, pour commencer, peut monter à 7.
+
+
+## Pré-requis
+
+Aucun.
+
+
+## Objectifs pédagogiques
+
+- Pouvoir utiliser une machine sous Linux au quotidien.
+- Être à l'aise avec les interfaces en ligne de commande.
+- Savoir installer et utiliser des logiciels.
+- Manipuler des fichiers, des données.
+
+
+## Plan
+
+### Jour 1
+
+- Présentation de l'environnement Linux.
+- Maniement de l'émulateur de terminal.
+- Approche des commandes classiques :
+ - `man`, `cd`, `ls`, `pwd`, `mv`, `cp`, `rm`, `less`, …
+- Installer, désinstaller des applications depuis le gestionnaire de paquets.
+
+
+### Jour 2
+
+- L'accès à l'extérieur avec `ssh`, `rsync`, `curl`, et gestion des sauvegardes.
+- Introduction à la gestion de sources en utilisant `git`.
+- Manipulation de données en utilisant `awk`, `sed`, `grep`, `find`.
+- L'édition de texte depuis un terminal en utilisant `emacs`.
+- Approche du système de fichier : les droits, la sécurité, `mount`.
diff --git a/culture-unix/COMMERCIAL.md b/culture-unix/COMMERCIAL.md
deleted file mode 100644
index 53be14a..0000000
--- a/culture-unix/COMMERCIAL.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Formation Initiation Linux (2 jours)
-
-Cette formation est destinée à toute personne souhaitant utiliser
-Linux, pour du développement, de l'administration système, ou pour un
-usage quotidien.
-
-
-## Stagiaires
-
-Maximum 5 par sessions, pour commencer, peut monter à 7.
-
-
-## Pré-requis
-
-Aucun.
-
-
-## Objectifs pédagogiques
-
-- Pouvoir utiliser une machine sous Linux au quotidien.
-- Être à l'aise avec les interfaces en ligne de commande.
-- Savoir installer et utiliser des logiciels.
-- Manipuler des fichiers, des données.
-
-
-## Plan
-
-### Jour 1
-
-- Présentation de l'environnement Linux.
-- Maniement de l'émulateur de terminal.
-- Approche des commandes classiques :
- - `man`, `cd`, `ls`, `pwd`, `mv`, `cp`, `rm`, `less`, …
-- Installer, désinstaller des applications depuis le gestionnaire de paquets.
-
-
-### Jour 2
-
-- L'accès à l'extérieur avec `ssh`, `rsync`, `curl`, et gestion des sauvegardes.
-- Introduction à la gestion de sources en utilisant `git`.
-- Manipulation de données en utilisant `awk`, `sed`, `grep`, `find`.
-- L'édition de texte depuis un terminal en utilisant `emacs`.
-- Approche du système de fichier : les droits, la sécurité, `mount`.
diff --git a/culture-unix/Makefile b/culture-unix/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/culture-unix/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/culture-unix/README.md b/culture-unix/culture-unix.md
similarity index 100%
rename from culture-unix/README.md
rename to culture-unix/culture-unix.md
diff --git a/django-initiation/Makefile b/django-initiation/Makefile
deleted file mode 100644
index 52099c4..0000000
--- a/django-initiation/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static # to build static version."
- @echo " make test # to run tests."
- @echo " make rsync # rsync to prod"
- @echo " make clean"
-
-.PHONY: static
-static: output/index.html
-
-.PHONY: check
-test:
- python test.py *.md
-
-%.html: %.md
- mdtoreveal $< --output $@
-
-output/index.md: django.md
- mkdir -p output
- cat $< > $@
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/django-initiation/
-
-.PHONY: clean
-clean:
- rm -fr output/
-
-.PHONY: serve
-serve:
- python -m http.server -d output/
diff --git a/django-initiation/Makefile b/django-initiation/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/django-initiation/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/django-initiation/README.md b/django-initiation/README.md
deleted file mode 100644
index 6a7bbc1..0000000
--- a/django-initiation/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Contenu
-
-Side project : https://github.com/JulienPalard/drf-demos
-
-- Revue des bases et consolidation Python et Django
-- Présentation des types d'API, approfondissement de REST/HATEOAS
-- Rappels autour de la sémantique HTTP
-- django-rest-framework: La sérialisation
-- django-rest-framework: Les différents types de vues
-- django-rest-framework: Les permissions
-- django-rest-framework: Les relations
-- Les tests et la maintenabilité
-
-
-# Objectifs pédagogiques
-
-- Pouvoir démarrer rapidement un projet DRF.
-- Savoir designer une API.
-- Implémenter un service headless en utilisant DRF.
-
-
-# TP
-
-- Projet 1 : API « Horloge parlante ».
-- Projet 2 : API « memcached ».
-- Projet 3 : API « file system ».
-- Projet 4 : API « uptime manager ».
diff --git a/django-initiation/django.md b/django-initiation/django.md
index 8a0874f..00d9ffc 100644
--- a/django-initiation/django.md
+++ b/django-initiation/django.md
@@ -35,7 +35,7 @@ Dans Django on va avoir principalement des `models`, des `vues`, des
On travaillera toujours dans un `venv` :
-```python
+```bash
python -m pip install django
```
@@ -43,7 +43,7 @@ python -m pip install django
Pour démarrer un projet, une commande :
-```python
+```bash
django-admin startproject project
```
@@ -51,7 +51,7 @@ django-admin startproject project
Une fois dans le projet, pour créer une application, une commande :
-```python
+```bash
python manage.py startapp watch
```
@@ -307,8 +307,8 @@ Dans `project/urls.py` on va se rajouter une URL pour la page d'accueil :
from watch import views
urlpatterns = [
- ...
- ...
+ ...,
+ ...,
path("", views.index, name="index"),
]
```
@@ -721,7 +721,7 @@ fichier doit commencer par `test` pour être trouvé.
Les tests s'exécutent via :
-```python
+```bash
python manage.py test
```
diff --git a/django-initiation/test.py b/django-initiation/test.py
deleted file mode 100755
index 7d22261..0000000
--- a/django-initiation/test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-from string import ascii_letters, digits
-import re
-import doctest
-from tempfile import NamedTemporaryFile
-import importlib.util
-
-parser = argparse.ArgumentParser()
-parser.add_argument("file", nargs="+")
-parser.add_argument("-v", "--verbose", action="store_true")
-parser.add_argument("-d", "--debug", action="store_true")
-args = parser.parse_args()
-
-for file_to_test in args.file:
- with open(file_to_test) as f:
- source = f.read()
-
- with NamedTemporaryFile(mode="w", suffix=".py") as f:
- for example_match in re.finditer("```python.*?```", source, re.S):
- example = example_match.group()
- example = "\n".join(example.split("\n")[1:-1])
- lineno = source[:example_match.start()].count("\n") + 1
- function_name = ''.join(letter if letter in ascii_letters + digits else '_' for letter in file_to_test[:-3]) + "_line_" + str(lineno)
- if example.startswith(">>> "):
- if '"""' in example:
- f.write(f"""def _{function_name}():\n r'''""" + example + """\n'''\n\n""")
- else:
- f.write(f'''def _{function_name}():\n r"""''' + example + '''\n"""\n\n''')
- else:
- f.write(example + "\n\n")
- f.flush()
- if args.debug:
- with open(f.name) as py_source:
- print(py_source.read())
- spec = importlib.util.spec_from_file_location("to_test", f.name)
- to_test = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(to_test)
- doctest.testmod(to_test, verbose=args.verbose)
diff --git a/doddling/find_sum.py b/doddling/find_sum.py
new file mode 100644
index 0000000..55f1338
--- /dev/null
+++ b/doddling/find_sum.py
@@ -0,0 +1,152 @@
+def find_sum1(n, l):
+ """Gros nombre non trouvé : pour 10**4 elements : 10s
+ Petit nombre non trouvé : pour 10**4 elements : 10s
+ """
+ for i in range(len(l)):
+ for j in range(len(l)):
+ if i == j:
+ continue
+ if l[i] + l[j] == n:
+ return True
+ return False
+
+
+def find_sum2(n, l):
+ """Gros nombre non trouvé : pour 10**4 elements : 12s
+ Petit nombre non trouvé : 0s
+ """
+
+ for i in range(len(l)):
+ if l[i] > n:
+ continue
+ for j in range(len(l)):
+ if i == j:
+ continue
+ if l[j] > n:
+ continue
+ if l[i] + l[j] == n:
+ return True
+ return False
+
+
+def find_sum3(n, l):
+ """Gros nombre non trouvé : pour 10**4 elements : 8s
+ Petit nombre non trouvé : pour 10**4 elements : 0s
+ """
+ for i in range(len(l)):
+ if l[i] > n:
+ return False
+ for j in range(i + 1, len(l)):
+ if l[i] + l[j] == n:
+ return True
+ if l[i] + l[j] > n:
+ break
+ return False
+
+
+def find_sum3(n, l):
+ """Gros nombre non trouvé : pour 10**4 elements : 8s
+ Petit nombre non trouvé : pour 10**4 elements : 0s
+ """
+ for i in range(len(l)):
+ if l[i] > n:
+ return False
+ for j in range(i + 1, len(l)):
+ if l[i] + l[j] == n:
+ return True
+ if l[i] + l[j] > n:
+ break
+ return False
+
+
+def find_sum4(n, l):
+ """Gros nombre non trouvé : pour 10**4 elements : 8s
+ Petit nombre non trouvé : pour 10**4 elements : 5s
+ """
+ if len(l) <= 1:
+ return False
+ i = 0
+ j = len(l) - 1
+ while True:
+ if l[i] + l[j] == n:
+ return True
+ i += 1
+ if i == j or l[i] + l[j] > n:
+ if l[i] + l[j] < n:
+ return False
+ i = 0
+ j -= 1
+ if j == 0:
+ return False
+
+
+def find_sum5(n, l):
+ if len(l) <= 1:
+ return False
+ i = 0
+ j = len(l) - 1
+ while True:
+ print(f"Searching at {i}+{j} ({l[i]+l[j]})")
+ if l[i] + l[j] == n:
+ return True
+ if l[i] + l[j] > n:
+ j -= 1
+ if l[i] + l[j] < n:
+ i += 1
+
+
+find_sum5(12, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
+
+exit(0)
+
+find_sum4(2, [10, 10, 10])
+from time import perf_counter
+import matplotlib.pyplot as plt
+
+k = 4
+seed = list(range(10, 10 ** 5))
+print(f"Testing small int a list of length {10 ** k}...")
+to_find = seed[: 10 ** k]
+begin = perf_counter()
+find_sum4(2, to_find)
+end = perf_counter()
+print(f"Done in {end - begin}s")
+
+print(f"Testing big int a list of length {10 ** k}...")
+to_find = seed[: 10 ** k]
+begin = perf_counter()
+find_sum4(2 ** 32, to_find)
+end = perf_counter()
+print(f"Done in {end - begin}s")
+
+
+assert find_sum1(2, [1, 1])
+assert find_sum1(5, [1, 2, 3, 4, 5])
+assert not find_sum1(5, [1, 3, 6])
+assert not find_sum1(4, [2, 3, 4, 5, 6])
+assert find_sum1(10, [2, 3, 5, 6, 7, 9])
+
+assert find_sum2(2, [1, 1])
+assert find_sum2(5, [1, 2, 3, 4, 5])
+assert not find_sum2(5, [1, 3, 6])
+assert not find_sum2(4, [2, 3, 4, 5, 6])
+assert find_sum2(10, [2, 3, 5, 6, 7, 9])
+
+assert find_sum3(2, [1, 1])
+assert find_sum3(5, [1, 2, 3, 4, 5])
+assert not find_sum3(5, [1, 3, 6])
+assert not find_sum3(4, [2, 3, 4, 5, 6])
+assert find_sum3(10, [2, 3, 5, 6, 7, 9])
+
+
+assert find_sum4(2, [1, 1])
+assert find_sum4(5, [1, 2, 3, 4, 5])
+assert not find_sum4(5, [1, 3, 6])
+assert not find_sum4(4, [2, 3, 4, 5, 6])
+assert find_sum4(10, [2, 3, 5, 6, 7, 9])
+
+assert find_sum5(2, [1, 1])
+assert find_sum5(5, [1, 2, 3, 4, 5])
+assert not find_sum5(5, [1, 3, 6])
+assert not find_sum5(4, [2, 3, 4, 5, 6])
+assert find_sum5(10, [2, 3, 5, 6, 7, 9])
diff --git a/doddling/sudoku.py b/doddling/sudoku.py
new file mode 100644
index 0000000..e220f5c
--- /dev/null
+++ b/doddling/sudoku.py
@@ -0,0 +1,127 @@
+import numpy as np
+from collections import Counter
+
+
+def is_done(grid):
+ for square in (
+ grid[0:3, 0:3],
+ grid[0:3, 3:6],
+ grid[0:3, 6:9],
+ grid[3:6, 0:3],
+ grid[3:6, 3:6],
+ grid[3:6, 6:9],
+ grid[6:9, 0:3],
+ grid[6:9, 3:6],
+ grid[6:9, 6:9],
+ ):
+ if set(square.ravel()) != {1, 2, 3, 4, 5, 6, 7, 8, 9}:
+ return False
+ for line in grid:
+ if set(line) != {1, 2, 3, 4, 5, 6, 7, 8, 9}:
+ return False
+ for line in grid.T:
+ if set(line) != {1, 2, 3, 4, 5, 6, 7, 8, 9}:
+ return False
+ return True
+
+
+def is_valid(grid):
+ for square in (
+ grid[0:3, 0:3],
+ grid[0:3, 3:6],
+ grid[0:3, 6:9],
+ grid[3:6, 0:3],
+ grid[3:6, 3:6],
+ grid[3:6, 6:9],
+ grid[6:9, 0:3],
+ grid[6:9, 3:6],
+ grid[6:9, 6:9],
+ ):
+ c = Counter(square.ravel())
+ if 0 in c:
+ del c[0]
+ try:
+ value, occurences = c.most_common(1)[0]
+ if occurences > 1:
+ return False
+ except IndexError:
+ pass
+ for line in grid:
+ c = Counter(line)
+ if 0 in c:
+ del c[0]
+ try:
+ value, occurences = c.most_common(1)[0]
+ if occurences > 1:
+ return False
+ except IndexError:
+ pass
+ for line in grid.T:
+ c = Counter(line)
+ if 0 in c:
+ del c[0]
+ try:
+ value, occurences = c.most_common(1)[0]
+ if occurences > 1:
+ return False
+ except IndexError:
+ pass
+ return True
+
+
+grid = np.zeros((9, 9), dtype=int)
+grid = np.array(
+ [
+ [0, 0, 0, 1, 1, 1, 2, 2, 2],
+ [0, 0, 0, 1, 1, 1, 2, 2, 2],
+ [0, 0, 0, 1, 1, 1, 2, 2, 2],
+ [3, 3, 3, 4, 4, 4, 5, 5, 5],
+ [3, 3, 3, 4, 4, 4, 5, 5, 5],
+ [3, 3, 3, 4, 4, 4, 5, 5, 5],
+ [6, 6, 6, 7, 7, 7, 8, 8, 8],
+ [6, 6, 6, 7, 7, 7, 8, 8, 8],
+ [6, 6, 6, 7, 7, 7, 8, 8, 8],
+ ]
+)
+is_valid(grid)
+
+
+def find_first_blank(grid):
+ i, j = 0, 0
+ for i in range(9):
+ for j in range(9):
+ if grid[i, j] == 0:
+ return i, j
+
+
+def solve(grid):
+ print(grid)
+ if is_done(grid):
+ print(grid)
+ exit(0)
+ try:
+ my_i, my_j = find_first_blank(grid)
+ except TypeError:
+ return
+ for i in range(1, 10):
+ grid[my_i, my_j] = i
+ if is_valid(grid):
+ solve(grid.copy())
+
+
+grid = np.array(
+ [
+ [0, 0, 0, 7, 3, 0, 6, 0, 0],
+ [0, 7, 0, 0, 8, 0, 1, 5, 0],
+ [2, 3, 0, 5, 0, 0, 0, 0, 0],
+ [0, 0, 0, 6, 0, 2, 4, 0, 5],
+ [6, 4, 0, 0, 0, 0, 0, 8, 2],
+ [5, 0, 9, 3, 0, 8, 0, 0, 0],
+ [0, 0, 0, 0, 0, 5, 0, 4, 8],
+ [0, 9, 4, 0, 2, 0, 0, 7, 0],
+ [0, 0, 5, 0, 7, 6, 0, 0, 0],
+ ]
+)
+
+
+solve(grid)
diff --git a/drf-initiation/Makefile b/drf-initiation/Makefile
deleted file mode 100644
index d59b9a2..0000000
--- a/drf-initiation/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static # to build static version."
- @echo " make test # to run tests."
- @echo " make rsync # rsync to prod"
- @echo " make clean"
-
-.PHONY: static
-static: output/index.html
-
-.PHONY: check
-test:
- python test.py *.md
-
-%.html: %.md
- mdtoreveal $< --output $@
-
-output/index.md: drf.md
- mkdir -p output
- cat $< > $@
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/drf-initiation/
-
-.PHONY: clean
-clean:
- rm -fr output/
-
-.PHONY: serve
-serve:
- python -m http.server -d output/
diff --git a/drf-initiation/Makefile b/drf-initiation/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/drf-initiation/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/drf-initiation/README.md b/drf-initiation/README.md
deleted file mode 100644
index 6a7bbc1..0000000
--- a/drf-initiation/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# Contenu
-
-Side project : https://github.com/JulienPalard/drf-demos
-
-- Revue des bases et consolidation Python et Django
-- Présentation des types d'API, approfondissement de REST/HATEOAS
-- Rappels autour de la sémantique HTTP
-- django-rest-framework: La sérialisation
-- django-rest-framework: Les différents types de vues
-- django-rest-framework: Les permissions
-- django-rest-framework: Les relations
-- Les tests et la maintenabilité
-
-
-# Objectifs pédagogiques
-
-- Pouvoir démarrer rapidement un projet DRF.
-- Savoir designer une API.
-- Implémenter un service headless en utilisant DRF.
-
-
-# TP
-
-- Projet 1 : API « Horloge parlante ».
-- Projet 2 : API « memcached ».
-- Projet 3 : API « file system ».
-- Projet 4 : API « uptime manager ».
diff --git a/drf-initiation/test.py b/drf-initiation/test.py
deleted file mode 100755
index 7d22261..0000000
--- a/drf-initiation/test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-from string import ascii_letters, digits
-import re
-import doctest
-from tempfile import NamedTemporaryFile
-import importlib.util
-
-parser = argparse.ArgumentParser()
-parser.add_argument("file", nargs="+")
-parser.add_argument("-v", "--verbose", action="store_true")
-parser.add_argument("-d", "--debug", action="store_true")
-args = parser.parse_args()
-
-for file_to_test in args.file:
- with open(file_to_test) as f:
- source = f.read()
-
- with NamedTemporaryFile(mode="w", suffix=".py") as f:
- for example_match in re.finditer("```python.*?```", source, re.S):
- example = example_match.group()
- example = "\n".join(example.split("\n")[1:-1])
- lineno = source[:example_match.start()].count("\n") + 1
- function_name = ''.join(letter if letter in ascii_letters + digits else '_' for letter in file_to_test[:-3]) + "_line_" + str(lineno)
- if example.startswith(">>> "):
- if '"""' in example:
- f.write(f"""def _{function_name}():\n r'''""" + example + """\n'''\n\n""")
- else:
- f.write(f'''def _{function_name}():\n r"""''' + example + '''\n"""\n\n''')
- else:
- f.write(example + "\n\n")
- f.flush()
- if args.debug:
- with open(f.name) as py_source:
- print(py_source.read())
- spec = importlib.util.spec_from_file_location("to_test", f.name)
- to_test = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(to_test)
- doctest.testmod(to_test, verbose=args.verbose)
diff --git a/git-initiation/Makefile b/git-initiation/Makefile
deleted file mode 100644
index c8699df..0000000
--- a/git-initiation/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static # to build static version."
- @echo " make test # to run tests."
- @echo " make rsync # rsync to prod"
- @echo " make clean"
-
-.PHONY: static
-static: output/index.html
- cp -a static/ output/
-
-.PHONY: check
-test:
- python test.py *.md
-
-%.html: %.md
- mdtoreveal $< --output $@
-
-output/index.md: git.md
- mkdir -p output
- cat $< > $@
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/git-initiation/
-
-.PHONY: clean
-clean:
- rm -fr output/
-
-.PHONY: serve
-serve:
- python -m http.server -d output/
diff --git a/git-initiation/Makefile b/git-initiation/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/git-initiation/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/git-initiation/README.md b/git-initiation/README.md
deleted file mode 100644
index a967f74..0000000
--- a/git-initiation/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# GIT
diff --git a/git-initiation/test.py b/git-initiation/test.py
deleted file mode 100755
index 7d22261..0000000
--- a/git-initiation/test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-from string import ascii_letters, digits
-import re
-import doctest
-from tempfile import NamedTemporaryFile
-import importlib.util
-
-parser = argparse.ArgumentParser()
-parser.add_argument("file", nargs="+")
-parser.add_argument("-v", "--verbose", action="store_true")
-parser.add_argument("-d", "--debug", action="store_true")
-args = parser.parse_args()
-
-for file_to_test in args.file:
- with open(file_to_test) as f:
- source = f.read()
-
- with NamedTemporaryFile(mode="w", suffix=".py") as f:
- for example_match in re.finditer("```python.*?```", source, re.S):
- example = example_match.group()
- example = "\n".join(example.split("\n")[1:-1])
- lineno = source[:example_match.start()].count("\n") + 1
- function_name = ''.join(letter if letter in ascii_letters + digits else '_' for letter in file_to_test[:-3]) + "_line_" + str(lineno)
- if example.startswith(">>> "):
- if '"""' in example:
- f.write(f"""def _{function_name}():\n r'''""" + example + """\n'''\n\n""")
- else:
- f.write(f'''def _{function_name}():\n r"""''' + example + '''\n"""\n\n''')
- else:
- f.write(example + "\n\n")
- f.flush()
- if args.debug:
- with open(f.name) as py_source:
- print(py_source.read())
- spec = importlib.util.spec_from_file_location("to_test", f.name)
- to_test = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(to_test)
- doctest.testmod(to_test, verbose=args.verbose)
diff --git a/python-avance/Makefile b/python-avance/Makefile
deleted file mode 100644
index 65acf63..0000000
--- a/python-avance/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-SRCS := $(sort $(wildcard *-*.md))
-
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static # to build static version."
- @echo " make test # to run tests."
- @echo " make rsync # rsync to prod"
- @echo " make clean"
-
-.PHONY: check
-test:
- python test.py *.md
-
-.PHONY: static
-static: output/index.html
-
-%.html: %.md
- mdtoreveal $< --output $@
-
-output/index.md: $(SRCS)
- mkdir -p output
- cat $(SRCS) > output/index.md
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/python-avancé/
-
-.PHONY: clean
-clean:
- rm -fr output
diff --git a/python-avance/README.md b/python-avance/README.md
deleted file mode 100644
index 1b5bb8c..0000000
--- a/python-avance/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# TODO
-
-- [ ] Ajouter les nombres imaginaires.
diff --git a/python-avance/1-for.md b/python-avancé/1-for.md
similarity index 100%
rename from python-avance/1-for.md
rename to python-avancé/1-for.md
diff --git a/python-avance/2-object.md b/python-avancé/2-object.md
similarity index 100%
rename from python-avance/2-object.md
rename to python-avancé/2-object.md
diff --git a/python-avance/3-language.md b/python-avancé/3-language.md
similarity index 100%
rename from python-avance/3-language.md
rename to python-avancé/3-language.md
diff --git a/python-avance/4-encodage.md b/python-avancé/4-encodage.md
similarity index 100%
rename from python-avance/4-encodage.md
rename to python-avancé/4-encodage.md
diff --git a/python-avance/5-packaging.md b/python-avancé/5-packaging.md
similarity index 100%
rename from python-avance/5-packaging.md
rename to python-avancé/5-packaging.md
diff --git a/python-avance/6-coro.md b/python-avancé/6-coro.md
similarity index 100%
rename from python-avance/6-coro.md
rename to python-avancé/6-coro.md
diff --git a/python-avancé/Makefile b/python-avancé/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/python-avancé/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/python-avance/exercises/BANO.ipynb b/python-avancé/exercises/BANO.ipynb
similarity index 100%
rename from python-avance/exercises/BANO.ipynb
rename to python-avancé/exercises/BANO.ipynb
diff --git a/python-avance/exercises/README.md b/python-avancé/exercises/README.md
similarity index 100%
rename from python-avance/exercises/README.md
rename to python-avancé/exercises/README.md
diff --git a/python-avance/exercises/engrai.py b/python-avancé/exercises/engrai.py
similarity index 100%
rename from python-avance/exercises/engrai.py
rename to python-avancé/exercises/engrai.py
diff --git a/python-avance/exercises/maze.py b/python-avancé/exercises/maze.py
similarity index 100%
rename from python-avance/exercises/maze.py
rename to python-avancé/exercises/maze.py
diff --git a/python-avance/exercises/my_quest.py b/python-avancé/exercises/my_quest.py
similarity index 100%
rename from python-avance/exercises/my_quest.py
rename to python-avancé/exercises/my_quest.py
diff --git a/python-avance/exercises/rectangle-packing.ipynb b/python-avancé/exercises/rectangle-packing.ipynb
similarity index 100%
rename from python-avance/exercises/rectangle-packing.ipynb
rename to python-avancé/exercises/rectangle-packing.ipynb
diff --git a/python-avance/exercises/what_is_your_quest.py b/python-avancé/exercises/what_is_your_quest.py
similarity index 100%
rename from python-avance/exercises/what_is_your_quest.py
rename to python-avancé/exercises/what_is_your_quest.py
diff --git a/python-avance/memory.dot b/python-avancé/memory.dot
similarity index 100%
rename from python-avance/memory.dot
rename to python-avancé/memory.dot
diff --git a/python-avance/static/Anaconda_Logo.png b/python-avancé/static/Anaconda_Logo.png
similarity index 100%
rename from python-avance/static/Anaconda_Logo.png
rename to python-avancé/static/Anaconda_Logo.png
diff --git a/python-avance/static/Black-hole-M87.jpg b/python-avancé/static/Black-hole-M87.jpg
similarity index 100%
rename from python-avance/static/Black-hole-M87.jpg
rename to python-avancé/static/Black-hole-M87.jpg
diff --git a/python-avance/static/Evolution_of_Python.png b/python-avancé/static/Evolution_of_Python.png
similarity index 100%
rename from python-avance/static/Evolution_of_Python.png
rename to python-avancé/static/Evolution_of_Python.png
diff --git a/python-avance/static/fifix.css b/python-avancé/static/fifix.css
similarity index 100%
rename from python-avance/static/fifix.css
rename to python-avancé/static/fifix.css
diff --git a/python-avance/static/github.css b/python-avancé/static/github.css
similarity index 100%
rename from python-avance/static/github.css
rename to python-avancé/static/github.css
diff --git a/python-avance/test.py b/python-avancé/test.py
similarity index 100%
rename from python-avance/test.py
rename to python-avancé/test.py
diff --git a/python-initiation/Makefile b/python-initiation/Makefile
deleted file mode 100644
index 17172b8..0000000
--- a/python-initiation/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-.PHONY: static
-static: output/index.html
-
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static"
- @echo " make test"
- @echo " make rsync"
- @echo " make clean"
-
-.PHONY: check
-test:
- python test.py *.md
-
-output/index.html: initiation.md
- mdtoreveal $< --output $@
- cp -a static output
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/python-initiation/
-
-.PHONY: clean
-clean:
- rm -f $(HTML)
-
-.PHONY: serve
-serve:
- python3 -m http.server -d output/
diff --git a/python-initiation/Makefile b/python-initiation/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/python-initiation/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file
diff --git a/python-initiation/README.md b/python-initiation/README.md
deleted file mode 100644
index 2cd1368..0000000
--- a/python-initiation/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# TODO
-
-Lors de la présentation des fonctions natives dans un REPL, il y a une
-ambiguité (`print` vs `return`):
-
- >>> int("42")
- 42
- >>> print("42")
- 42
-
-On pourrait passer par une variable peut-être :
-
- >>> quarante_deux = int("42")
- >>> quarante_deux
- 42
-
- >>> result = print("42")
- 42
- >>> print(result)
- None
diff --git a/python-perfs/Makefile b/python-perfs/Makefile
deleted file mode 100644
index f36eaa3..0000000
--- a/python-perfs/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-export PATH := $(PATH):bin
-
-# Only run watch with -j2 so entr and serve are run in parallel.
-.PHONY: watch
-watch: entr serve
-
-.PHONY: static
-static: output/index.html
- cp -a .cache/*.png output/
-
-.PHONY: help
-help:
- @echo "Usage:"
- @echo " make static"
- @echo " make test"
- @echo " make rsync"
- @echo " make clean"
-
-.PHONY: entr
-entr:
- ls -1 *.md include/*.py | entr $(MAKE) static
-
-output/index.html: perfs.md
- mkdir -p .cache
- sed 's/#!//e;' perfs.md | mdtoreveal /dev/stdin --output $@
- if [ -d static ]; then cp -a static output; fi
-
-.PHONY: rsync
-rsync: static
- rsync -vah --delete output/ mdk_fr@mdk.fr:/var/www/mdk.fr/python-perfs/
-
-.PHONY: clean
-clean:
- rm -f $(HTML)
-
-.PHONY: serve
-serve:
- python3 -m http.server -d output/
diff --git a/python-perfs/Makefile b/python-perfs/Makefile
new file mode 120000
index 0000000..d0b0e8e
--- /dev/null
+++ b/python-perfs/Makefile
@@ -0,0 +1 @@
+../Makefile
\ No newline at end of file