Initial commit
This commit is contained in:
21
training/LICENSE
Normal file
21
training/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 sk-dwtoulouse
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
5
training/README.md
Normal file
5
training/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Exercices et démonstrations
|
||||
|
||||
Démonstrations et exercices pour la formation d'initiation à Python.
|
||||
|
||||
TODO: Thèmes possibles (Jeu de rôle ou une histoire de Toto)
|
17
training/answers/02-language-basics/01-prints.adoc
Normal file
17
training/answers/02-language-basics/01-prints.adoc
Normal file
@ -0,0 +1,17 @@
|
||||
= Exercices
|
||||
|
||||
== Exercice 1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
print("La rue Rostand,")
|
||||
print(" se trouve au")
|
||||
print("Feu à droite")
|
||||
----
|
||||
|
||||
== Exercice 2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
print("Haut", "les", "cœurs", "!")
|
||||
----
|
65
training/answers/02-language-basics/02-variables.adoc
Normal file
65
training/answers/02-language-basics/02-variables.adoc
Normal file
@ -0,0 +1,65 @@
|
||||
= Exercices
|
||||
|
||||
== Exercice 1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
prenom = "Paul"
|
||||
temperature = 24.8
|
||||
paul_age = 30
|
||||
print(prenom, temperature, paul_age)
|
||||
----
|
||||
|
||||
== Exercice 2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
saisie = input("Saisissez du texte :")
|
||||
print(saisie)
|
||||
----
|
||||
|
||||
== Exercice 3
|
||||
|
||||
[source, python]
|
||||
----
|
||||
val1 = 53 * 46 + 13
|
||||
val2 = 99 > 13
|
||||
val3 = "Bonjour " + "chef"
|
||||
val4 = (59 * 62 + 13) / 6.5
|
||||
print(val1, val2, val3, val4)
|
||||
----
|
||||
|
||||
== Exercice A1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
distance = 42195
|
||||
print(distance // 1000) # nombre de kilomètres
|
||||
print(distance % 1000) # nombre de mètres restants
|
||||
----
|
||||
|
||||
== Exercice A2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
weight = 4_502_177
|
||||
print(weight // 1000000, "tonnes") # combien de groupes de 1000000 de grammes
|
||||
print((weight // 1000) % 1000) # combien de kilos restants, sans compter les tonnes
|
||||
print(weight % 1000) # combien de grammes restants
|
||||
----
|
||||
|
||||
== Exercice A3
|
||||
|
||||
[source, python]
|
||||
----
|
||||
saisie1 = input("Premier nombre :") # attention, je vais récupérer du texte
|
||||
saisie2 = input("Second nombre :")
|
||||
saisie1 = float(saisie1) # convertir en flottant
|
||||
saisie2 = float(saisie2) # convertir en flottant
|
||||
if saisie1 > saisie2:
|
||||
print(saisie1)
|
||||
else:
|
||||
print(saisie2)
|
||||
# Autre possibilité intéressante
|
||||
print(max(saisie1, saisie2))
|
||||
----
|
88
training/answers/02-language-basics/03-conditions.adoc
Normal file
88
training/answers/02-language-basics/03-conditions.adoc
Normal file
@ -0,0 +1,88 @@
|
||||
= Exercices
|
||||
|
||||
== Exercice 1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
roll = 5
|
||||
if roll > 4:
|
||||
print("Lancer réussi !")
|
||||
----
|
||||
|
||||
== Exercice 2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
text = "Bonjour"
|
||||
if text == "bonjouR":
|
||||
print("Bien le bonjour")
|
||||
----
|
||||
|
||||
== Exercice 2B
|
||||
|
||||
[source, python]
|
||||
----
|
||||
text = "Bonjour"
|
||||
if text == "Bonjour":
|
||||
print("Bien le bonjour")
|
||||
else:
|
||||
print("Je ne comprends pas !")
|
||||
----
|
||||
|
||||
== Exercice 3
|
||||
|
||||
[source, python]
|
||||
----
|
||||
value = 7
|
||||
if value >= 9:
|
||||
print("Élevé")
|
||||
elif value >= 7:
|
||||
print("Haut")
|
||||
elif value >= 4:
|
||||
print("Standard")
|
||||
else:
|
||||
print("Bas")
|
||||
----
|
||||
|
||||
== Exercice A1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
a1 = 4
|
||||
a2 = 7
|
||||
if a1 > 5 and a2 < 6:
|
||||
print("OK")
|
||||
else:
|
||||
print("Valeurs incorrectes")
|
||||
----
|
||||
|
||||
== Exercice A2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
a1 = 5
|
||||
a2 = 5
|
||||
if a1 > 5 or a2 < 6:
|
||||
print("Conditions suffisantes")
|
||||
else:
|
||||
print("Valeurs incorrectes")
|
||||
----
|
||||
|
||||
== Exercice A3
|
||||
|
||||
[source, python]
|
||||
----
|
||||
is_on = True
|
||||
saisie = input("Saisissez une commande (Marche ou Arrêt) :")
|
||||
if saisie == "Marche":
|
||||
if is_on is False:
|
||||
print("Allumage en cours…")
|
||||
else:
|
||||
print("Déjà allumé !")
|
||||
elif saisie == "Arrêt":
|
||||
if is_on:
|
||||
print("Extinction…")
|
||||
else:
|
||||
print("Déjà éteint !")
|
||||
----
|
||||
|
27
training/answers/02-language-basics/05-for-loop.adoc
Normal file
27
training/answers/02-language-basics/05-for-loop.adoc
Normal file
@ -0,0 +1,27 @@
|
||||
= Exercices
|
||||
|
||||
== Exercice 1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
for number in range(10):
|
||||
print(number)
|
||||
----
|
||||
|
||||
== Exercice 2
|
||||
|
||||
[source, python]
|
||||
----
|
||||
for number in range(10):
|
||||
if number % 2 == 0: # Est pair / reste 0 quand on fait la division entière
|
||||
print(number)
|
||||
----
|
||||
|
||||
== Exercice A1
|
||||
|
||||
[source, python]
|
||||
----
|
||||
for item1 in range(10):
|
||||
for item2 in range(item1):
|
||||
print(item1, item2)
|
||||
----
|
26
training/answers/02-language-basics/09-dictionaries.adoc
Normal file
26
training/answers/02-language-basics/09-dictionaries.adoc
Normal file
@ -0,0 +1,26 @@
|
||||
= Exercices sur les dictionnaires
|
||||
|
||||
'''
|
||||
|
||||
== Exercice A1 : compréhension de dictionnaire
|
||||
|
||||
*Rappel* : Convertir un dictionnaire en gardant les clés originales,
|
||||
mais y associer comme valeurs uniquement les températures.
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# Dictionnaire original
|
||||
meteo = {
|
||||
"Pau": (21.0, "Nuageux", 1015),
|
||||
"Gap": (20.3, "Dégagé", 1019),
|
||||
"Osny": (19.1, "Brouillard", 1015)
|
||||
}
|
||||
# Récupérer un dictionnaire dont les clés sont les noms de ville
|
||||
# et dont les valeurs sont uniquement les températures :
|
||||
# ici on conserve la clé, telle quelle, et comme chaque valeur
|
||||
# associée aux clés est toujours un tuple dont le premier élément est la
|
||||
# température, on peut s'y prendre ainsi :
|
||||
converted = {key: meteo[key][0] for key in meteo}
|
||||
# On affiche le résultat pour le vérifier
|
||||
print(converted)
|
||||
----
|
3
training/code/02-language-basics/01-prints/prints_01.py
Normal file
3
training/code/02-language-basics/01-prints/prints_01.py
Normal file
@ -0,0 +1,3 @@
|
||||
print("La rue Rostand,")
|
||||
print(" se trouve au")
|
||||
print("Feu à droite")
|
1
training/code/02-language-basics/01-prints/prints_02.py
Normal file
1
training/code/02-language-basics/01-prints/prints_02.py
Normal file
@ -0,0 +1 @@
|
||||
print("Hauts", "les", "cœurs", "!")
|
@ -0,0 +1,11 @@
|
||||
prenom = "Paul"
|
||||
temperature = 24.5
|
||||
age = 35
|
||||
|
||||
# Afficher les valeurs des variables
|
||||
print(prenom)
|
||||
print(temperature)
|
||||
print(age)
|
||||
|
||||
# Ou bien sur une seule ligne
|
||||
print(prenom, temperature, age)
|
@ -0,0 +1,4 @@
|
||||
saisie = input("Saisissez du texte :")
|
||||
|
||||
# Afficher le texte qui a été récupéré de la fonction input
|
||||
print(saisie)
|
@ -0,0 +1,10 @@
|
||||
result1 = 5 * 15 + 30 # Expression avec opérateurs arithmétiques
|
||||
result2 = 9 > 4 # Stocke si 9 est supérieur à 4, donc `True`
|
||||
result3 = "Chapi" + "Chapo" # concaténation
|
||||
result4 = (59 * 62 + 13) / 6.5 # tester la valeur
|
||||
|
||||
# Afficher les expressions
|
||||
print(result1)
|
||||
print(result2)
|
||||
print(result3)
|
||||
print(result4)
|
@ -0,0 +1,7 @@
|
||||
distance = 42195 # distance en mètres
|
||||
kilometers = distance // 1000 # nombre entier de paquets de 1 000
|
||||
meters = distance % 1000 # Reste après division entière par 1 000
|
||||
|
||||
# Affichage avec un peu de texte en plus.
|
||||
print(kilometers, "km et", meters, "mètres.")
|
||||
|
@ -0,0 +1,9 @@
|
||||
weight = 17_254_433 # Poids en grammes
|
||||
tons = weight // 1_000_000 # Combien de paquets de 1 tonne
|
||||
kilograms = (weight // 1_000) % 1_000 # Nombre de kilos restants sous la tonne
|
||||
grams = weight % 1_000 # Nombre de grammes sous le kilo
|
||||
|
||||
# Afficher les unités
|
||||
print("Tonnes :", tons)
|
||||
print("Kilogrammes :", kilograms)
|
||||
print("Grammes :", grams)
|
@ -0,0 +1,11 @@
|
||||
saisie1 = input("Entrez un premier nombre :")
|
||||
saisie2 = input("Entrez un second nombre :")
|
||||
# Convertir les deux entrées en entiers pour pouvoir les comparer
|
||||
saisie1 = float(saisie1)
|
||||
saisie2 = float(saisie2)
|
||||
|
||||
# Afficher le nombre le plus grand, nécessite d'avoir vu les conditions
|
||||
if saisie1 > saisie2:
|
||||
print(saisie1, "est le plus grand nombre")
|
||||
else:
|
||||
print(saisie2, "est le plus grand nombre")
|
@ -0,0 +1,5 @@
|
||||
if __name__ == '__main__':
|
||||
dice_roll = 5
|
||||
|
||||
if dice_roll > 4:
|
||||
print("Lancer réussi !")
|
@ -0,0 +1,5 @@
|
||||
if __name__ == '__main__':
|
||||
text = "Bonjour"
|
||||
# Ne devrait rien afficher puisque la chaîne ne correspond pas
|
||||
if text == "bonjouR":
|
||||
print("Bien le bonjour !")
|
@ -0,0 +1,7 @@
|
||||
if __name__ == '__main__':
|
||||
text = "Bonjour"
|
||||
# Ne devrait rien afficher puisque la chaîne ne correspond pas
|
||||
if text == "bonjouR":
|
||||
print("Bien le bonjour !")
|
||||
else:
|
||||
print("Je n'ai pas compris !")
|
@ -0,0 +1,12 @@
|
||||
# Valeur de départ à changer au besoin pour tester
|
||||
value = 8
|
||||
|
||||
# Tester plusieurs cas de figure s'excluant progressivement
|
||||
if value >= 9:
|
||||
print("Élevé")
|
||||
elif value >= 7:
|
||||
print("Haut")
|
||||
elif value >= 4:
|
||||
print("Standard")
|
||||
else:
|
||||
print("Bas")
|
@ -0,0 +1,7 @@
|
||||
a1 = 6
|
||||
a2 = 5
|
||||
|
||||
if a1 > 5 and a2 < 6:
|
||||
print("Conditions OK")
|
||||
else:
|
||||
print("Valeurs incorrectes")
|
@ -0,0 +1,7 @@
|
||||
a1 = 6
|
||||
a2 = 5
|
||||
|
||||
if a1 > 5 or a2 < 6:
|
||||
print("Conditions OK")
|
||||
else:
|
||||
print("Valeurs incorrectes")
|
@ -0,0 +1,13 @@
|
||||
is_on = True
|
||||
saisie = input("Saisissez une commande (Marche ou Arrêt) :")
|
||||
|
||||
if saisie == "Marche":
|
||||
if is_on is False:
|
||||
print("Allumage en cours…")
|
||||
else:
|
||||
print("Déjà allumé !")
|
||||
elif saisie == "Arrêt":
|
||||
if is_on:
|
||||
print("Extinction…")
|
||||
else:
|
||||
print("Déjà éteint !")
|
@ -0,0 +1,2 @@
|
||||
for number in range(10):
|
||||
print(number)
|
@ -0,0 +1,3 @@
|
||||
for number in range(10):
|
||||
if number % 2 == 0: # Est pair / reste 0 quand on fait la division entière
|
||||
print(number)
|
@ -0,0 +1,3 @@
|
||||
for item1 in range(10):
|
||||
for item2 in range(item1):
|
||||
print(item1, item2)
|
@ -0,0 +1,5 @@
|
||||
number = 10
|
||||
|
||||
while number >= 0:
|
||||
print(number)
|
||||
number -= 1 # ou number = number - 1
|
@ -0,0 +1,6 @@
|
||||
iteration = 1
|
||||
|
||||
# Quitter la boucle avec Ctrl+C ou le bouton Stop de PyCharm
|
||||
while True:
|
||||
print("Itération", iteration)
|
||||
iteration += 1
|
@ -0,0 +1,6 @@
|
||||
iteration = 1
|
||||
|
||||
# Ne se lancera pas
|
||||
while iteration > 10:
|
||||
print("Itération", iteration)
|
||||
iteration += 1
|
@ -0,0 +1,45 @@
|
||||
# Possibilité 1
|
||||
left = 0
|
||||
right = 1
|
||||
new = 1
|
||||
|
||||
# Afficher les éléments successifs de la séquence avec une variable new
|
||||
while new < 10_000:
|
||||
new = left + right
|
||||
print(new)
|
||||
left = right
|
||||
right = new
|
||||
|
||||
|
||||
# Possibilité 2
|
||||
left = 0
|
||||
right = 1
|
||||
temp = None
|
||||
|
||||
# Afficher les éléments successifs de la séquence avec une variable temporaire
|
||||
while left + right < 10_000:
|
||||
print(left + right)
|
||||
temp = left
|
||||
left = right
|
||||
right = temp + right
|
||||
|
||||
|
||||
# Possibilité 3 : algorithme
|
||||
left = 0
|
||||
right = 1
|
||||
|
||||
# Afficher les éléments successifs de la séquence sans variable temporaire
|
||||
while left + right < 10_000:
|
||||
print(left + right)
|
||||
right = left + right
|
||||
left = right - left
|
||||
|
||||
|
||||
# Possibilité 4
|
||||
left = 0
|
||||
right = 1
|
||||
|
||||
# Afficher les éléments successifs de la séquence via l'unpacking
|
||||
while left + right < 10_000:
|
||||
print(left + right)
|
||||
left, right = (right, left + right)
|
7
training/code/02-language-basics/07-lists/lists_01.py
Normal file
7
training/code/02-language-basics/07-lists/lists_01.py
Normal file
@ -0,0 +1,7 @@
|
||||
even_numbers = [0, 2, 4, 6, 8, 10]
|
||||
length = len(even_numbers)
|
||||
# Afficher le dernier élément
|
||||
print(even_numbers[length - 1])
|
||||
# Ajouter un élément et vérifier la modification
|
||||
even_numbers.append(12)
|
||||
print(even_numbers)
|
11
training/code/02-language-basics/07-lists/lists_02.py
Normal file
11
training/code/02-language-basics/07-lists/lists_02.py
Normal file
@ -0,0 +1,11 @@
|
||||
# Puissances de 2 de 0 à 6
|
||||
numbers = [1, 2, 4, 8, 16, 32, 64]
|
||||
|
||||
# Retirer le nombre 8 (par sa valeur)
|
||||
numbers.remove(8)
|
||||
|
||||
# Ajouter la valeur 128 à la fin
|
||||
numbers.append(128)
|
||||
|
||||
# Affiher le résultat
|
||||
print(numbers)
|
8
training/code/02-language-basics/07-lists/lists_03.py
Normal file
8
training/code/02-language-basics/07-lists/lists_03.py
Normal file
@ -0,0 +1,8 @@
|
||||
# Liste contenant quelques valeurs
|
||||
values = ["text", 3.14159, 16, True]
|
||||
|
||||
# Afficher le dernier élément, quelle que soit la taille de la liste
|
||||
print(values[-1])
|
||||
|
||||
# Afficher le premier élément en utilisant un index négatif
|
||||
print(values[-len(values)])
|
9
training/code/02-language-basics/07-lists/lists_04.py
Normal file
9
training/code/02-language-basics/07-lists/lists_04.py
Normal file
@ -0,0 +1,9 @@
|
||||
# Créer une liste de 6 nombres
|
||||
numbers = [2, 3, 5, 8, 13, 21]
|
||||
|
||||
# Afficher une liste contenant les 3 premiers éléments
|
||||
print(numbers[0:3])
|
||||
|
||||
# Afficher une liste contenant les éléments de numbers du 2nd au dernier
|
||||
print(numbers[1:])
|
||||
|
15
training/code/02-language-basics/07-lists/lists_05.py
Normal file
15
training/code/02-language-basics/07-lists/lists_05.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Créer une liste de 6 nombres
|
||||
numbers = [2, 3, 5, 8, 13, 21]
|
||||
|
||||
# Afficher une liste contenant les 3 premiers éléments
|
||||
print(numbers[0:3])
|
||||
|
||||
# Afficher une liste contenant les éléments de numbers du 2nd au dernier
|
||||
print(numbers[1:])
|
||||
|
||||
# Afficher une liste contenant les éléments à l'envers
|
||||
print(numbers[::-1])
|
||||
|
||||
# Afficher une liste contenant les éléments aux index pairs
|
||||
print(numbers[0::2])
|
||||
print(numbers[::2])
|
7
training/code/02-language-basics/07-lists/lists_a1.py
Normal file
7
training/code/02-language-basics/07-lists/lists_a1.py
Normal file
@ -0,0 +1,7 @@
|
||||
# Multiples de 3
|
||||
numbers = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]
|
||||
|
||||
# Parcourir la liste et afficher les éléments pairs
|
||||
for number in numbers:
|
||||
if (number % 2) == 0:
|
||||
print(number)
|
15
training/code/02-language-basics/08-sets/sets_01.py
Normal file
15
training/code/02-language-basics/08-sets/sets_01.py
Normal file
@ -0,0 +1,15 @@
|
||||
# Créer des ensembles avec au moins deux valeurs en commun
|
||||
set1 = {2, 4, 6, 8, 10}
|
||||
set2 = {8, 10, 12, 14, 16}
|
||||
|
||||
# Tenter d'ajouter une valeur déjà présente dans set1
|
||||
set1.add(6)
|
||||
|
||||
# Afficher l'intersection des deux ensembles (valeurs en commun)
|
||||
print(set1 & set2) # c'est pareil mais moins explicite
|
||||
print(set1.intersection(set2)) # c'est pareil mais plus explicite
|
||||
|
||||
# Afficher l'union des deux ensembles (toutes valeurs)
|
||||
print(set1 | set2)
|
||||
print(set1.union(set2))
|
||||
|
7
training/code/02-language-basics/08-sets/sets_02.py
Normal file
7
training/code/02-language-basics/08-sets/sets_02.py
Normal file
@ -0,0 +1,7 @@
|
||||
# Déclarer une liste avec des doublons
|
||||
duplicated = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]
|
||||
print(duplicated)
|
||||
|
||||
# Créer un ensemble dédupliquant les éléments
|
||||
deduplicated = set(duplicated)
|
||||
print(deduplicated)
|
21
training/code/02-language-basics/08-sets/sets_03.py
Normal file
21
training/code/02-language-basics/08-sets/sets_03.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Al et Kim sont inscrits sur un réseau social. Al a les amis suivants :
|
||||
#
|
||||
# - Josephine
|
||||
# - Meghan
|
||||
# - Amy
|
||||
# - Bob
|
||||
#
|
||||
# Kim a les amis suivants :
|
||||
#
|
||||
# - Frank
|
||||
# - Amy
|
||||
# - Josephine
|
||||
# - Susan
|
||||
#
|
||||
# Quels sont leurs amis en commun ? Écrivez un code qui représente et résout cet énoncé.
|
||||
al_friends = {"Josephine", "Meghan", "Amy", "Bob"}
|
||||
kim_friends = {"Frank", "Amy", "Josephine", "Susan"}
|
||||
|
||||
# Afficher le bon résultat
|
||||
print(al_friends & kim_friends) # Affichier l'intersection avec des opérateurs
|
||||
print(al_friends.intersection(kim_friends)) # Affichier l'intersection plus explicite
|
5
training/code/02-language-basics/08-sets/sets_04.py
Normal file
5
training/code/02-language-basics/08-sets/sets_04.py
Normal file
@ -0,0 +1,5 @@
|
||||
# Partant du tuple suivant :
|
||||
# `(1, 4, 6, 9, 1, 3, 6, 12, 2, 5, 7, 10, 3, 5, 2, 6, 4, 6, 1, 8, 5, 2, 3, 6)`
|
||||
# - Affichez le nombre de valeurs différentes présentes dans le tuple.
|
||||
sample = (1, 4, 6, 9, 1, 3, 6, 12, 2, 5, 7, 10, 3, 5, 2, 6, 4, 6, 1, 8, 5, 2, 3, 6)
|
||||
print(len(set(sample)))
|
@ -0,0 +1,15 @@
|
||||
# - Écrivez un simple dictionnaire associant des noms à des âges :
|
||||
# * Paul → 30
|
||||
# * Karim → 22
|
||||
# * Gina → 41
|
||||
# * Anna → 25
|
||||
# - Affichez l'âge de Gina
|
||||
# - Ajoutez les associations suivantes :
|
||||
# * Alina → 33
|
||||
# * Victor → 55
|
||||
# - Affichez le contenu du dictionnaire
|
||||
ages = {"Paul": 30, "Karim": 22, "Gina": 41, "Anna": 25}
|
||||
print(ages["Gina"])
|
||||
ages["Victor"] = 55
|
||||
ages["Alina"] = 33
|
||||
print(ages)
|
@ -0,0 +1,18 @@
|
||||
# - Écrivez un simple dictionnaire associant des noms à des âges :
|
||||
# * Paul → 30
|
||||
# * Karim → 22
|
||||
# * Gina → 41
|
||||
# * Anna → 25
|
||||
# - Affichez l'âge de Gina
|
||||
# - Ajoutez les associations suivantes :
|
||||
# * Alina → 33
|
||||
# * Victor → 55
|
||||
# - Affichez le contenu du dictionnaire
|
||||
ages = {"Paul": 30, "Karim": 22, "Gina": 41, "Anna": 25}
|
||||
ages["Victor"] = 55
|
||||
ages["Alina"] = 33
|
||||
|
||||
# Parcourir les clés et afficher la valeur associée
|
||||
for name in ages:
|
||||
print(name)
|
||||
print(ages[name])
|
@ -0,0 +1,18 @@
|
||||
# - Écrivez un simple dictionnaire associant des noms à des âges :
|
||||
# * Paul → 30
|
||||
# * Karim → 22
|
||||
# * Gina → 41
|
||||
# * Anna → 25
|
||||
# - Affichez l'âge de Gina
|
||||
# - Ajoutez les associations suivantes :
|
||||
# * Alina → 33
|
||||
# * Victor → 55
|
||||
# - Affichez le contenu du dictionnaire
|
||||
ages = {"Paul": 30, "Karim": 22, "Gina": 41, "Anna": 25}
|
||||
ages["Victor"] = 55
|
||||
ages["Alina"] = 33
|
||||
|
||||
# Parcourir les clés et afficher la valeur associée
|
||||
for name, age in ages.items(): # Utiliser l'unpacking
|
||||
print(name)
|
||||
print(age)
|
@ -0,0 +1,6 @@
|
||||
# Conditions météo
|
||||
meteo = {"Pau": (21.0, "Nuageux", 1015), "Gap": (20.3, "Dégagé", 1019), "Osny": (19.1, "Brouillard", 1015)}
|
||||
|
||||
# Conditions avec uniquement la température comme valeur associée
|
||||
converted = {ville: meteo[ville][0] for ville in meteo}
|
||||
print(converted)
|
@ -0,0 +1,9 @@
|
||||
# Nombres pairs non divisibles par 5
|
||||
values = [x * 2 for x in range(50) if (x * 2) % 5 != 0]
|
||||
print(values)
|
||||
|
||||
# Liste de mots
|
||||
words = ["matin", "le", "pour", "lapin", "carotte", "justesse", "ambroisie", "cuticule", "aube", "flanc", "flan"]
|
||||
# Créer une liste avec uniquement les mots de plus de 4 lettres
|
||||
short_words = [w for w in words if len(w) > 4]
|
||||
print(short_words)
|
6
training/code/04-functions/01-base/base_01.py
Normal file
6
training/code/04-functions/01-base/base_01.py
Normal file
@ -0,0 +1,6 @@
|
||||
"""Déclaration de fonction simple."""
|
||||
def show_something():
|
||||
print("Something")
|
||||
|
||||
# Exécuter la fonction
|
||||
show_something()
|
8
training/code/04-functions/01-base/base_02.py
Normal file
8
training/code/04-functions/01-base/base_02.py
Normal file
@ -0,0 +1,8 @@
|
||||
"""Fonction simple retournant une constante."""
|
||||
def return_constant():
|
||||
print("Texte : 99")
|
||||
return 99 # renvoie un nombre entier
|
||||
|
||||
# Appeler la fonction et récupérer la valeur renvoyée
|
||||
result = return_constant()
|
||||
print(result)
|
10
training/code/04-functions/01-base/base_03.py
Normal file
10
training/code/04-functions/01-base/base_03.py
Normal file
@ -0,0 +1,10 @@
|
||||
# Fonction produit
|
||||
def product(x, y):
|
||||
return x * y
|
||||
|
||||
|
||||
# Tests d'appel de la fonction
|
||||
print(product(10, 10))
|
||||
print(product(15, -15))
|
||||
print(product("hello ", 3))
|
||||
print(product([1, 2, 3], 2))
|
22
training/code/04-functions/01-base/base_04.py
Normal file
22
training/code/04-functions/01-base/base_04.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""Fonction qui calcule un quotient."""
|
||||
|
||||
|
||||
def quotient(numerator, denominator=1):
|
||||
"""
|
||||
Fonction de quotient.
|
||||
|
||||
Renvoie `None` si l'argument `denominator` vaut 0.
|
||||
|
||||
"""
|
||||
try:
|
||||
return numerator / denominator
|
||||
except ZeroDivisionError:
|
||||
# Si impossible d'évaluer l'expression ligne 4
|
||||
return None
|
||||
|
||||
|
||||
# Tester plusieurs arguments pour la fonction
|
||||
print(quotient(10, denominator=4))
|
||||
print(quotient(10, denominator=-1))
|
||||
print(quotient(1, denominator=0))
|
||||
print(quotient(5))
|
1
training/demos/08-text-files/lxml-demo/requirements.txt
Normal file
1
training/demos/08-text-files/lxml-demo/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
lxml
|
211
training/demos/08-text-files/lxml-demo/source/files/catalog.xml
Normal file
211
training/demos/08-text-files/lxml-demo/source/files/catalog.xml
Normal file
@ -0,0 +1,211 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CATALOG>
|
||||
<CD>
|
||||
<TITLE>Empire Burlesque</TITLE>
|
||||
<ARTIST>Bob Dylan</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Columbia</COMPANY>
|
||||
<PRICE>10.90</PRICE>
|
||||
<YEAR>1985</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Hide your heart</TITLE>
|
||||
<ARTIST>Bonnie Tyler</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>CBS Records</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1988</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Greatest Hits</TITLE>
|
||||
<ARTIST>Dolly Parton</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>RCA</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1982</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Still got the blues</TITLE>
|
||||
<ARTIST>Gary Moore</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Virgin records</COMPANY>
|
||||
<PRICE>10.20</PRICE>
|
||||
<YEAR>1990</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Eros</TITLE>
|
||||
<ARTIST>Eros Ramazzotti</ARTIST>
|
||||
<COUNTRY>EU</COUNTRY>
|
||||
<COMPANY>BMG</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1997</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>One night only</TITLE>
|
||||
<ARTIST>Bee Gees</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Polydor</COMPANY>
|
||||
<PRICE>10.90</PRICE>
|
||||
<YEAR>1998</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Sylvias Mother</TITLE>
|
||||
<ARTIST>Dr.Hook</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>CBS</COMPANY>
|
||||
<PRICE>8.10</PRICE>
|
||||
<YEAR>1973</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Maggie May</TITLE>
|
||||
<ARTIST>Rod Stewart</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Pickwick</COMPANY>
|
||||
<PRICE>8.50</PRICE>
|
||||
<YEAR>1990</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Romanza</TITLE>
|
||||
<ARTIST>Andrea Bocelli</ARTIST>
|
||||
<COUNTRY>EU</COUNTRY>
|
||||
<COMPANY>Polydor</COMPANY>
|
||||
<PRICE>10.80</PRICE>
|
||||
<YEAR>1996</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>When a man loves a woman</TITLE>
|
||||
<ARTIST>Percy Sledge</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Atlantic</COMPANY>
|
||||
<PRICE>8.70</PRICE>
|
||||
<YEAR>1987</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Black angel</TITLE>
|
||||
<ARTIST>Savage Rose</ARTIST>
|
||||
<COUNTRY>EU</COUNTRY>
|
||||
<COMPANY>Mega</COMPANY>
|
||||
<PRICE>10.90</PRICE>
|
||||
<YEAR>1995</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>1999 Grammy Nominees</TITLE>
|
||||
<ARTIST>Many</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Grammy</COMPANY>
|
||||
<PRICE>10.20</PRICE>
|
||||
<YEAR>1999</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>For the good times</TITLE>
|
||||
<ARTIST>Kenny Rogers</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Mucik Master</COMPANY>
|
||||
<PRICE>8.70</PRICE>
|
||||
<YEAR>1995</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Big Willie style</TITLE>
|
||||
<ARTIST>Will Smith</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Columbia</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1997</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Tupelo Honey</TITLE>
|
||||
<ARTIST>Van Morrison</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Polydor</COMPANY>
|
||||
<PRICE>8.20</PRICE>
|
||||
<YEAR>1971</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Soulsville</TITLE>
|
||||
<ARTIST>Jorn Hoel</ARTIST>
|
||||
<COUNTRY>Norway</COUNTRY>
|
||||
<COMPANY>WEA</COMPANY>
|
||||
<PRICE>7.90</PRICE>
|
||||
<YEAR>1996</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>The very best of</TITLE>
|
||||
<ARTIST>Cat Stevens</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Island</COMPANY>
|
||||
<PRICE>8.90</PRICE>
|
||||
<YEAR>1990</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Stop</TITLE>
|
||||
<ARTIST>Sam Brown</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>A and M</COMPANY>
|
||||
<PRICE>8.90</PRICE>
|
||||
<YEAR>1988</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Bridge of Spies</TITLE>
|
||||
<ARTIST>T'Pau</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Siren</COMPANY>
|
||||
<PRICE>7.90</PRICE>
|
||||
<YEAR>1987</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Private Dancer</TITLE>
|
||||
<ARTIST>Tina Turner</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>Capitol</COMPANY>
|
||||
<PRICE>8.90</PRICE>
|
||||
<YEAR>1983</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Midt om natten</TITLE>
|
||||
<ARTIST>Kim Larsen</ARTIST>
|
||||
<COUNTRY>EU</COUNTRY>
|
||||
<COMPANY>Medley</COMPANY>
|
||||
<PRICE>7.80</PRICE>
|
||||
<YEAR>1983</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Pavarotti Gala Concert</TITLE>
|
||||
<ARTIST>Luciano Pavarotti</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>DECCA</COMPANY>
|
||||
<PRICE>9.90</PRICE>
|
||||
<YEAR>1991</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>The dock of the bay</TITLE>
|
||||
<ARTIST>Otis Redding</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>Stax Records</COMPANY>
|
||||
<PRICE>7.90</PRICE>
|
||||
<YEAR>1968</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Picture book</TITLE>
|
||||
<ARTIST>Simply Red</ARTIST>
|
||||
<COUNTRY>EU</COUNTRY>
|
||||
<COMPANY>Elektra</COMPANY>
|
||||
<PRICE>7.20</PRICE>
|
||||
<YEAR>1985</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Red</TITLE>
|
||||
<ARTIST>The Communards</ARTIST>
|
||||
<COUNTRY>UK</COUNTRY>
|
||||
<COMPANY>London</COMPANY>
|
||||
<PRICE>7.80</PRICE>
|
||||
<YEAR>1987</YEAR>
|
||||
</CD>
|
||||
<CD>
|
||||
<TITLE>Unchain my heart</TITLE>
|
||||
<ARTIST>Joe Cocker</ARTIST>
|
||||
<COUNTRY>USA</COUNTRY>
|
||||
<COMPANY>EMI</COMPANY>
|
||||
<PRICE>8.20</PRICE>
|
||||
<YEAR>1987</YEAR>
|
||||
</CD>
|
||||
</CATALOG>
|
@ -0,0 +1,12 @@
|
||||
"""XML demo to parse a simple ctalog file."""
|
||||
from lxml import etree
|
||||
|
||||
|
||||
tree = etree.parse(r"files/catalog.xml") # Get the whole document as the root element
|
||||
# Récupérer les éléments de la racine CATALOG qui ont le nom CD
|
||||
items = tree.xpath("//CATALOG/CD")
|
||||
|
||||
for cd in items:
|
||||
for attribute in cd:
|
||||
print(attribute.tag, attribute.attrib) # afficher le nom et les attributs
|
||||
print(attribute.text)
|
@ -0,0 +1,2 @@
|
||||
pandas==1.2.5
|
||||
xlrd>=1.0.0
|
@ -0,0 +1,26 @@
|
||||
"""
|
||||
Pandas getting started script.
|
||||
|
||||
Pandas introduction demo script for Python beginners.
|
||||
Makes a few calls taken from the official docs to see what can be done
|
||||
with Pandas.
|
||||
|
||||
See Also:
|
||||
https://pandas.pydata.org/docs/getting_started/comparison/comparison_with_sql.html
|
||||
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Read dataframe from CSV file
|
||||
frame: pd.DataFrame = pd.read_csv("files/demo-file-985.csv")
|
||||
# Get basic information on data
|
||||
print(frame.dtypes)
|
||||
|
||||
# Access, within column zero, to all rows
|
||||
for row in frame.street:
|
||||
print(row)
|
||||
|
||||
# Make the equivalent to a SELECT WHERE query
|
||||
# Get a frame where the price column is > 100,000
|
||||
print(frame[frame["price"] > 100000])
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,26 @@
|
||||
"""
|
||||
Pandas getting started script.
|
||||
|
||||
Pandas introduction demo script for Python beginners.
|
||||
Makes a few calls taken from the official docs to see what can be done
|
||||
with Pandas.
|
||||
|
||||
See Also:
|
||||
https://pandas.pydata.org/docs/getting_started/comparison/comparison_with_sql.html
|
||||
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Read dataframe from CSV file
|
||||
frame: pd.DataFrame = pd.read_excel("files/demo-file-1000.xls")
|
||||
# Get basic information on data
|
||||
print(frame.dtypes)
|
||||
|
||||
# Access, within column zero, to all rows
|
||||
for row in frame["First Name"]:
|
||||
print(row)
|
||||
|
||||
# Make the equivalent to a SELECT WHERE query
|
||||
# Get a frame where the age column is >= 40
|
||||
print(frame[frame["Age"] >= 40])
|
4
training/demos/09-sqlite/orm-peewee/README.md
Normal file
4
training/demos/09-sqlite/orm-peewee/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Simple ORM demo with Peewee
|
||||
|
||||
Peewee simple definition of a model and simple code to
|
||||
take advantage of the tool.
|
1
training/demos/09-sqlite/orm-peewee/requirements.txt
Normal file
1
training/demos/09-sqlite/orm-peewee/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
peewee
|
Binary file not shown.
27
training/demos/09-sqlite/orm-peewee/source/demo_app.py
Normal file
27
training/demos/09-sqlite/orm-peewee/source/demo_app.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""
|
||||
Simple demo application to showcase Peewee.
|
||||
|
||||
Simple script with model definition to showcase the
|
||||
use of ORMs and Peewee for beginners in database usage.
|
||||
|
||||
"""
|
||||
import peewee as pw # pip install peewee
|
||||
from models import Person
|
||||
|
||||
|
||||
if __name__ == "__main__": # Only True if current script is executed manually.
|
||||
# Initialize a Peewee database for SQLite
|
||||
db = pw.SqliteDatabase("database/demo-file.sqlite3")
|
||||
# Make the Person model use the database.
|
||||
Person.bind(db)
|
||||
# Query the `person` table.
|
||||
query = Person.select().where(Person.age > 50)
|
||||
|
||||
# Display the results with a friendly formatting.
|
||||
print(f"List of people older than 50 years old:\n{'–' * 80}")
|
||||
for person in query: # type: Person
|
||||
print(f"{person.id:02d}. {person.get_full_name():<30}: {person.age} years old.")
|
||||
|
||||
# Exemple pour créer un nouvel objet Person dans ma table
|
||||
# nouvelle_personne = Person(first_name="Bob", last_name="Bob", age=90)
|
||||
# nouvelle_personne.save()
|
1
training/demos/09-sqlite/orm-peewee/source/demo_test.py
Normal file
1
training/demos/09-sqlite/orm-peewee/source/demo_test.py
Normal file
@ -0,0 +1 @@
|
||||
import demo_app
|
@ -0,0 +1,3 @@
|
||||
from .person import Person
|
||||
|
||||
__all__ = ["Person"]
|
32
training/demos/09-sqlite/orm-peewee/source/models/person.py
Normal file
32
training/demos/09-sqlite/orm-peewee/source/models/person.py
Normal file
@ -0,0 +1,32 @@
|
||||
import peewee as pw
|
||||
|
||||
|
||||
class Person(pw.Model):
|
||||
"""
|
||||
Model class for the Person table.
|
||||
|
||||
Simple representation as a class of the Person
|
||||
table columns. Each object of a Person can be persisted or
|
||||
retrieved from the database.
|
||||
|
||||
Attributes:
|
||||
Person.id: identifier column. Primary key.
|
||||
Person.last_name: N/A
|
||||
Person.first_name: N/A
|
||||
Person.age: Age of the person in years.
|
||||
|
||||
"""
|
||||
id = pw.BigAutoField(primary_key=True)
|
||||
last_name = pw.CharField(column_name="nom", max_length=30, null=False)
|
||||
first_name = pw.CharField(column_name="prenom", max_length=20, null=False)
|
||||
age = pw.IntegerField(null=False)
|
||||
|
||||
class Meta:
|
||||
indexes = (
|
||||
# Make a UNIQUE index with the two following columns
|
||||
(("last_name", "first_name"), True),
|
||||
)
|
||||
|
||||
def get_full_name(self) -> str:
|
||||
"""Get the full name of the person."""
|
||||
return f"{self.first_name} {self.last_name}"
|
@ -0,0 +1,102 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.application API documentation</title>
|
||||
<meta name="description" content="Entry point for our demo application …" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.application</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<p>Entry point for our demo application.</p>
|
||||
<p>Uses a "WindowManager" class holding the main window and the
|
||||
CSV data manager used in it.</p>
|
||||
<h2 id="configuring-your-project-for-the-application">Configuring your project for the application</h2>
|
||||
<p>You will need to associate the code to a project if not
|
||||
already done. If you don't have a project, just opening the folder
|
||||
with PyCharm should suffice.</p>
|
||||
<p>However, you need to have a <code>virtualenv</code> for your project (for good
|
||||
practice), that uses Python 3.6+.</p>
|
||||
<p>In this virtualenv, you'll have to install :</p>
|
||||
<ul>
|
||||
<li><code>pyside6</code></li>
|
||||
</ul>
|
||||
<p>Note that Qt has issues with theming; if PySide6 is installed, using <code>pip</code> or
|
||||
another medium, it won't follow the system theme. However, if PySide2 is
|
||||
installed globally on the system (via <code>apt-get</code> or <code>pacman</code>), programs seem to
|
||||
follow the system theme. One would then have to revert to importing from
|
||||
<code>PySide2</code> instead of <code>PySide6</code> (with no other changes).</p>
|
||||
<h2 id="how-to-run-the-application">How to run the application</h2>
|
||||
<p>The application is very simple to run in PyCharm.
|
||||
To do it, right-click on the source file content pane, somewhere where
|
||||
there is an empty space.</p>
|
||||
<p>Then, click the <code>Run <application>...</code>.</p>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">"""
|
||||
Entry point for our demo application.
|
||||
|
||||
Uses a "WindowManager" class holding the main window and the
|
||||
CSV data manager used in it.
|
||||
|
||||
.. include:: documentation/includes/application.md
|
||||
|
||||
"""
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from interface import WindowManager # look at interface/__init__.py
|
||||
|
||||
if __name__ == "__main__":
|
||||
application = QApplication()
|
||||
window_manager = WindowManager()
|
||||
window_manager.show()
|
||||
application.exec()</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul>
|
||||
<li><a href="#configuring-your-project-for-the-application">Configuring your project for the application</a></li>
|
||||
<li><a href="#how-to-run-the-application">How to run the application</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion" href="index.html">data-conversion</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,70 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Namespace <code>data-conversion</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
|
||||
<dl>
|
||||
<dt><code class="name"><a title="data-conversion.application" href="application.html">data-conversion.application</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Entry point for our demo application …</p></div>
|
||||
</dd>
|
||||
<dt><code class="name"><a title="data-conversion.interface" href="interface/index.html">data-conversion.interface</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt><code class="name"><a title="data-conversion.loaders" href="loaders/index.html">data-conversion.loaders</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.application" href="application.html">data-conversion.application</a></code></li>
|
||||
<li><code><a title="data-conversion.interface" href="interface/index.html">data-conversion.interface</a></code></li>
|
||||
<li><code><a title="data-conversion.loaders" href="loaders/index.html">data-conversion.loaders</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,76 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.interface API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.interface</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">from .windowmanager import WindowManager</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
|
||||
<dl>
|
||||
<dt><code class="name"><a title="data-conversion.interface.mainwindow" href="mainwindow.html">data-conversion.interface.mainwindow</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt><code class="name"><a title="data-conversion.interface.windowmanager" href="windowmanager.html">data-conversion.interface.windowmanager</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion" href="../index.html">data-conversion</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.interface.mainwindow" href="mainwindow.html">data-conversion.interface.mainwindow</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.windowmanager" href="windowmanager.html">data-conversion.interface.windowmanager</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,161 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.interface.mainwindow API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.interface.mainwindow</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">from PySide6.QtWidgets import QMainWindow, QPushButton, QListWidget
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
"""
|
||||
Class written just for autocompletion and type hinting.
|
||||
|
||||
Lists dynamic attributes of the loaded window
|
||||
so that PyCharm can know that the following attributes
|
||||
exist in the loaded file.
|
||||
|
||||
The class is then used for type hinting in the
|
||||
`WindowManager` class.
|
||||
|
||||
"""
|
||||
file_button: QPushButton
|
||||
button_csv_export: QPushButton
|
||||
button_txt_export: QPushButton
|
||||
list_widget: QListWidget</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-classes">Classes</h2>
|
||||
<dl>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow"><code class="flex name class">
|
||||
<span>class <span class="ident">MainWindow</span></span>
|
||||
<span>(</span><span>parent: Optional[PySide6.QtWidgets.QWidget] = None, flags: PySide6.QtCore.Qt.WindowFlags = Default(Qt.WindowFlags))</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Class written just for autocompletion and type hinting.</p>
|
||||
<p>Lists dynamic attributes of the loaded window
|
||||
so that PyCharm can know that the following attributes
|
||||
exist in the loaded file.</p>
|
||||
<p>The class is then used for type hinting in the
|
||||
<code>WindowManager</code> class.</p>
|
||||
<p><strong>init</strong>(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, flags: PySide6.QtCore.Qt.WindowFlags = Default(Qt.WindowFlags)) -> None</p>
|
||||
<p>Initialize self.
|
||||
See help(type(self)) for accurate signature.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">class MainWindow(QMainWindow):
|
||||
"""
|
||||
Class written just for autocompletion and type hinting.
|
||||
|
||||
Lists dynamic attributes of the loaded window
|
||||
so that PyCharm can know that the following attributes
|
||||
exist in the loaded file.
|
||||
|
||||
The class is then used for type hinting in the
|
||||
`WindowManager` class.
|
||||
|
||||
"""
|
||||
file_button: QPushButton
|
||||
button_csv_export: QPushButton
|
||||
button_txt_export: QPushButton
|
||||
list_widget: QListWidget</code></pre>
|
||||
</details>
|
||||
<h3>Ancestors</h3>
|
||||
<ul class="hlist">
|
||||
<li>PySide6.QtWidgets.QMainWindow</li>
|
||||
<li>PySide6.QtWidgets.QWidget</li>
|
||||
<li>PySide6.QtCore.QObject</li>
|
||||
<li>PySide6.QtGui.QPaintDevice</li>
|
||||
<li>Shiboken.Object</li>
|
||||
</ul>
|
||||
<h3>Class variables</h3>
|
||||
<dl>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow.button_csv_export"><code class="name">var <span class="ident">button_csv_export</span> : PySide6.QtWidgets.QPushButton</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow.button_txt_export"><code class="name">var <span class="ident">button_txt_export</span> : PySide6.QtWidgets.QPushButton</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow.file_button"><code class="name">var <span class="ident">file_button</span> : PySide6.QtWidgets.QPushButton</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow.list_widget"><code class="name">var <span class="ident">list_widget</span> : PySide6.QtWidgets.QListWidget</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.mainwindow.MainWindow.staticMetaObject"><code class="name">var <span class="ident">staticMetaObject</span></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.interface" href="index.html">data-conversion.interface</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3><a href="#header-classes">Classes</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<h4><code><a title="data-conversion.interface.mainwindow.MainWindow" href="#data-conversion.interface.mainwindow.MainWindow">MainWindow</a></code></h4>
|
||||
<ul class="">
|
||||
<li><code><a title="data-conversion.interface.mainwindow.MainWindow.button_csv_export" href="#data-conversion.interface.mainwindow.MainWindow.button_csv_export">button_csv_export</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.mainwindow.MainWindow.button_txt_export" href="#data-conversion.interface.mainwindow.MainWindow.button_txt_export">button_txt_export</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.mainwindow.MainWindow.file_button" href="#data-conversion.interface.mainwindow.MainWindow.file_button">file_button</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.mainwindow.MainWindow.list_widget" href="#data-conversion.interface.mainwindow.MainWindow.list_widget">list_widget</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.mainwindow.MainWindow.staticMetaObject" href="#data-conversion.interface.mainwindow.MainWindow.staticMetaObject">staticMetaObject</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,343 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.interface.windowmanager API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.interface.windowmanager</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">from typing import Union
|
||||
|
||||
from PySide6.QtUiTools import QUiLoader
|
||||
from PySide6.QtWidgets import QFileDialog, QWidget, QListWidgetItem
|
||||
|
||||
from interface.mainwindow import MainWindow
|
||||
from loaders import CSVManager
|
||||
|
||||
|
||||
class WindowManager:
|
||||
"""
|
||||
Class used to manage the Qt window and its associated data.
|
||||
|
||||
Attributes:
|
||||
_window: Private, contains the main window.
|
||||
_csv_manager: Private, holds a CSV manager.
|
||||
|
||||
"""
|
||||
_window: Union[QWidget, MainWindow] = None # Qt window managed by this class
|
||||
_csv_manager: CSVManager = None # Object used to manage CSV data
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize our window manager.
|
||||
|
||||
"""
|
||||
loader = QUiLoader()
|
||||
self._window = loader.load("files/designer/demo-dialog.ui")
|
||||
# Once the window is loaded, connect actions to code
|
||||
self.setup_actions()
|
||||
|
||||
def setup_actions(self):
|
||||
"""Connect actions of controls to methods."""
|
||||
self._window.file_button.clicked.connect(self.on_file_select)
|
||||
self._window.button_csv_export.clicked.connect(self.on_export_csv)
|
||||
|
||||
def on_file_select(self):
|
||||
"""
|
||||
Action when the file button is clicked.
|
||||
|
||||
Shows a file select dialog to pick a CSV
|
||||
and loads the CSV file in the CSVManager instance of the object.
|
||||
|
||||
"""
|
||||
filter_text = "CSV File (*.csv)"
|
||||
selection: tuple = QFileDialog.getOpenFileName(self._window, "CSV File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager = CSVManager(path)
|
||||
self._window.button_csv_export.setEnabled(True)
|
||||
# Empty and enable the list widget
|
||||
self._window.list_widget.clear()
|
||||
self._window.list_widget.setEnabled(True)
|
||||
for row in self._csv_manager.data:
|
||||
item = QListWidgetItem(";".join(row))
|
||||
self._window.list_widget.addItem(item)
|
||||
|
||||
def on_export_csv(self):
|
||||
"""
|
||||
Action when the export to CSV button is clicked.
|
||||
|
||||
Shows a file select dialog to select a file destination.
|
||||
The output file is then saved to the selected path.
|
||||
|
||||
"""
|
||||
filter_text = "Text File (*.txt)"
|
||||
selection: tuple = QFileDialog.getSaveFileName(self._window, "Text File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager.export_text(selection[0])
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
Public method to show our window.
|
||||
|
||||
The window is loaded automatically at instanciation
|
||||
in the `__init__` method.
|
||||
|
||||
"""
|
||||
self._window.show()</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-classes">Classes</h2>
|
||||
<dl>
|
||||
<dt id="data-conversion.interface.windowmanager.WindowManager"><code class="flex name class">
|
||||
<span>class <span class="ident">WindowManager</span></span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Class used to manage the Qt window and its associated data.</p>
|
||||
<h2 id="attributes">Attributes</h2>
|
||||
<dl>
|
||||
<dt><strong><code>_window</code></strong></dt>
|
||||
<dd>Private, contains the main window.</dd>
|
||||
<dt><strong><code>_csv_manager</code></strong></dt>
|
||||
<dd>Private, holds a CSV manager.</dd>
|
||||
</dl>
|
||||
<p>Initialize our window manager.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">class WindowManager:
|
||||
"""
|
||||
Class used to manage the Qt window and its associated data.
|
||||
|
||||
Attributes:
|
||||
_window: Private, contains the main window.
|
||||
_csv_manager: Private, holds a CSV manager.
|
||||
|
||||
"""
|
||||
_window: Union[QWidget, MainWindow] = None # Qt window managed by this class
|
||||
_csv_manager: CSVManager = None # Object used to manage CSV data
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize our window manager.
|
||||
|
||||
"""
|
||||
loader = QUiLoader()
|
||||
self._window = loader.load("files/designer/demo-dialog.ui")
|
||||
# Once the window is loaded, connect actions to code
|
||||
self.setup_actions()
|
||||
|
||||
def setup_actions(self):
|
||||
"""Connect actions of controls to methods."""
|
||||
self._window.file_button.clicked.connect(self.on_file_select)
|
||||
self._window.button_csv_export.clicked.connect(self.on_export_csv)
|
||||
|
||||
def on_file_select(self):
|
||||
"""
|
||||
Action when the file button is clicked.
|
||||
|
||||
Shows a file select dialog to pick a CSV
|
||||
and loads the CSV file in the CSVManager instance of the object.
|
||||
|
||||
"""
|
||||
filter_text = "CSV File (*.csv)"
|
||||
selection: tuple = QFileDialog.getOpenFileName(self._window, "CSV File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager = CSVManager(path)
|
||||
self._window.button_csv_export.setEnabled(True)
|
||||
# Empty and enable the list widget
|
||||
self._window.list_widget.clear()
|
||||
self._window.list_widget.setEnabled(True)
|
||||
for row in self._csv_manager.data:
|
||||
item = QListWidgetItem(";".join(row))
|
||||
self._window.list_widget.addItem(item)
|
||||
|
||||
def on_export_csv(self):
|
||||
"""
|
||||
Action when the export to CSV button is clicked.
|
||||
|
||||
Shows a file select dialog to select a file destination.
|
||||
The output file is then saved to the selected path.
|
||||
|
||||
"""
|
||||
filter_text = "Text File (*.txt)"
|
||||
selection: tuple = QFileDialog.getSaveFileName(self._window, "Text File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager.export_text(selection[0])
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
Public method to show our window.
|
||||
|
||||
The window is loaded automatically at instanciation
|
||||
in the `__init__` method.
|
||||
|
||||
"""
|
||||
self._window.show()</code></pre>
|
||||
</details>
|
||||
<h3>Methods</h3>
|
||||
<dl>
|
||||
<dt id="data-conversion.interface.windowmanager.WindowManager.on_export_csv"><code class="name flex">
|
||||
<span>def <span class="ident">on_export_csv</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Action when the export to CSV button is clicked.</p>
|
||||
<p>Shows a file select dialog to select a file destination.
|
||||
The output file is then saved to the selected path.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def on_export_csv(self):
|
||||
"""
|
||||
Action when the export to CSV button is clicked.
|
||||
|
||||
Shows a file select dialog to select a file destination.
|
||||
The output file is then saved to the selected path.
|
||||
|
||||
"""
|
||||
filter_text = "Text File (*.txt)"
|
||||
selection: tuple = QFileDialog.getSaveFileName(self._window, "Text File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager.export_text(selection[0])</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.windowmanager.WindowManager.on_file_select"><code class="name flex">
|
||||
<span>def <span class="ident">on_file_select</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Action when the file button is clicked.</p>
|
||||
<p>Shows a file select dialog to pick a CSV
|
||||
and loads the CSV file in the CSVManager instance of the object.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def on_file_select(self):
|
||||
"""
|
||||
Action when the file button is clicked.
|
||||
|
||||
Shows a file select dialog to pick a CSV
|
||||
and loads the CSV file in the CSVManager instance of the object.
|
||||
|
||||
"""
|
||||
filter_text = "CSV File (*.csv)"
|
||||
selection: tuple = QFileDialog.getOpenFileName(self._window, "CSV File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager = CSVManager(path)
|
||||
self._window.button_csv_export.setEnabled(True)
|
||||
# Empty and enable the list widget
|
||||
self._window.list_widget.clear()
|
||||
self._window.list_widget.setEnabled(True)
|
||||
for row in self._csv_manager.data:
|
||||
item = QListWidgetItem(";".join(row))
|
||||
self._window.list_widget.addItem(item)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.windowmanager.WindowManager.setup_actions"><code class="name flex">
|
||||
<span>def <span class="ident">setup_actions</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Connect actions of controls to methods.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def setup_actions(self):
|
||||
"""Connect actions of controls to methods."""
|
||||
self._window.file_button.clicked.connect(self.on_file_select)
|
||||
self._window.button_csv_export.clicked.connect(self.on_export_csv)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="data-conversion.interface.windowmanager.WindowManager.show"><code class="name flex">
|
||||
<span>def <span class="ident">show</span></span>(<span>self)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Public method to show our window.</p>
|
||||
<p>The window is loaded automatically at instanciation
|
||||
in the <code>__init__</code> method.</p></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def show(self):
|
||||
"""
|
||||
Public method to show our window.
|
||||
|
||||
The window is loaded automatically at instanciation
|
||||
in the `__init__` method.
|
||||
|
||||
"""
|
||||
self._window.show()</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.interface" href="index.html">data-conversion.interface</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3><a href="#header-classes">Classes</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<h4><code><a title="data-conversion.interface.windowmanager.WindowManager" href="#data-conversion.interface.windowmanager.WindowManager">WindowManager</a></code></h4>
|
||||
<ul class="">
|
||||
<li><code><a title="data-conversion.interface.windowmanager.WindowManager.on_export_csv" href="#data-conversion.interface.windowmanager.WindowManager.on_export_csv">on_export_csv</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.windowmanager.WindowManager.on_file_select" href="#data-conversion.interface.windowmanager.WindowManager.on_file_select">on_file_select</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.windowmanager.WindowManager.setup_actions" href="#data-conversion.interface.windowmanager.WindowManager.setup_actions">setup_actions</a></code></li>
|
||||
<li><code><a title="data-conversion.interface.windowmanager.WindowManager.show" href="#data-conversion.interface.windowmanager.WindowManager.show">show</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,327 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.loaders.csvmanager API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.loaders.csvmanager</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">import csv
|
||||
|
||||
|
||||
class CSVManager:
|
||||
"""
|
||||
Utility class to keep CSV data for export in other formats.
|
||||
|
||||
Attributes:
|
||||
data: Contains loaded file data as a list of lists.
|
||||
|
||||
"""
|
||||
|
||||
data: list = None
|
||||
|
||||
def __init__(self, url: str):
|
||||
"""
|
||||
Initialize the object with a URL.
|
||||
|
||||
Args:
|
||||
url: CSV URL to load from.
|
||||
|
||||
"""
|
||||
self.load(url)
|
||||
|
||||
def load(self, url: str, encoding: str = "iso8859-1"):
|
||||
"""
|
||||
Load a CSV given its file path.
|
||||
|
||||
Args:
|
||||
url: Path of the CSV file.
|
||||
encoding: Codepage name of the text file.
|
||||
|
||||
"""
|
||||
with open(url, "r", encoding=encoding) as f:
|
||||
reader = csv.reader(f, delimiter=",")
|
||||
if self.data is None:
|
||||
self.data = []
|
||||
for row in reader:
|
||||
self.data.append(row)
|
||||
|
||||
def export_text(self, url: str):
|
||||
"""
|
||||
Save data as a text file.
|
||||
|
||||
Every column is save in its own line as an example.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
for row in self.data:
|
||||
file.write("\n".join(row))
|
||||
|
||||
def export_csv(self, url: str):
|
||||
"""
|
||||
Save data as a CSV file with semicolons.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
writer = csv.writer(file, delimiter=";")
|
||||
for row in self.data:
|
||||
writer.writerow(row)</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-classes">Classes</h2>
|
||||
<dl>
|
||||
<dt id="data-conversion.loaders.csvmanager.CSVManager"><code class="flex name class">
|
||||
<span>class <span class="ident">CSVManager</span></span>
|
||||
<span>(</span><span>url: str)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Utility class to keep CSV data for export in other formats.</p>
|
||||
<h2 id="attributes">Attributes</h2>
|
||||
<dl>
|
||||
<dt><strong><code>data</code></strong></dt>
|
||||
<dd>Contains loaded file data as a list of lists.</dd>
|
||||
</dl>
|
||||
<p>Initialize the object with a URL.</p>
|
||||
<h2 id="args">Args</h2>
|
||||
<dl>
|
||||
<dt><strong><code>url</code></strong></dt>
|
||||
<dd>CSV URL to load from.</dd>
|
||||
</dl></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">class CSVManager:
|
||||
"""
|
||||
Utility class to keep CSV data for export in other formats.
|
||||
|
||||
Attributes:
|
||||
data: Contains loaded file data as a list of lists.
|
||||
|
||||
"""
|
||||
|
||||
data: list = None
|
||||
|
||||
def __init__(self, url: str):
|
||||
"""
|
||||
Initialize the object with a URL.
|
||||
|
||||
Args:
|
||||
url: CSV URL to load from.
|
||||
|
||||
"""
|
||||
self.load(url)
|
||||
|
||||
def load(self, url: str, encoding: str = "iso8859-1"):
|
||||
"""
|
||||
Load a CSV given its file path.
|
||||
|
||||
Args:
|
||||
url: Path of the CSV file.
|
||||
encoding: Codepage name of the text file.
|
||||
|
||||
"""
|
||||
with open(url, "r", encoding=encoding) as f:
|
||||
reader = csv.reader(f, delimiter=",")
|
||||
if self.data is None:
|
||||
self.data = []
|
||||
for row in reader:
|
||||
self.data.append(row)
|
||||
|
||||
def export_text(self, url: str):
|
||||
"""
|
||||
Save data as a text file.
|
||||
|
||||
Every column is save in its own line as an example.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
for row in self.data:
|
||||
file.write("\n".join(row))
|
||||
|
||||
def export_csv(self, url: str):
|
||||
"""
|
||||
Save data as a CSV file with semicolons.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
writer = csv.writer(file, delimiter=";")
|
||||
for row in self.data:
|
||||
writer.writerow(row)</code></pre>
|
||||
</details>
|
||||
<h3>Class variables</h3>
|
||||
<dl>
|
||||
<dt id="data-conversion.loaders.csvmanager.CSVManager.data"><code class="name">var <span class="ident">data</span> : list</code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Methods</h3>
|
||||
<dl>
|
||||
<dt id="data-conversion.loaders.csvmanager.CSVManager.export_csv"><code class="name flex">
|
||||
<span>def <span class="ident">export_csv</span></span>(<span>self, url: str)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Save data as a CSV file with semicolons.</p>
|
||||
<h2 id="args">Args</h2>
|
||||
<dl>
|
||||
<dt><strong><code>url</code></strong></dt>
|
||||
<dd>Output file path.</dd>
|
||||
</dl></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def export_csv(self, url: str):
|
||||
"""
|
||||
Save data as a CSV file with semicolons.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
writer = csv.writer(file, delimiter=";")
|
||||
for row in self.data:
|
||||
writer.writerow(row)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="data-conversion.loaders.csvmanager.CSVManager.export_text"><code class="name flex">
|
||||
<span>def <span class="ident">export_text</span></span>(<span>self, url: str)</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Save data as a text file.</p>
|
||||
<p>Every column is save in its own line as an example.</p>
|
||||
<h2 id="args">Args</h2>
|
||||
<dl>
|
||||
<dt><strong><code>url</code></strong></dt>
|
||||
<dd>Output file path.</dd>
|
||||
</dl></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def export_text(self, url: str):
|
||||
"""
|
||||
Save data as a text file.
|
||||
|
||||
Every column is save in its own line as an example.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
for row in self.data:
|
||||
file.write("\n".join(row))</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
<dt id="data-conversion.loaders.csvmanager.CSVManager.load"><code class="name flex">
|
||||
<span>def <span class="ident">load</span></span>(<span>self, url: str, encoding: str = 'iso8859-1')</span>
|
||||
</code></dt>
|
||||
<dd>
|
||||
<div class="desc"><p>Load a CSV given its file path.</p>
|
||||
<h2 id="args">Args</h2>
|
||||
<dl>
|
||||
<dt><strong><code>url</code></strong></dt>
|
||||
<dd>Path of the CSV file.</dd>
|
||||
<dt><strong><code>encoding</code></strong></dt>
|
||||
<dd>Codepage name of the text file.</dd>
|
||||
</dl></div>
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">def load(self, url: str, encoding: str = "iso8859-1"):
|
||||
"""
|
||||
Load a CSV given its file path.
|
||||
|
||||
Args:
|
||||
url: Path of the CSV file.
|
||||
encoding: Codepage name of the text file.
|
||||
|
||||
"""
|
||||
with open(url, "r", encoding=encoding) as f:
|
||||
reader = csv.reader(f, delimiter=",")
|
||||
if self.data is None:
|
||||
self.data = []
|
||||
for row in reader:
|
||||
self.data.append(row)</code></pre>
|
||||
</details>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.loaders" href="index.html">data-conversion.loaders</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3><a href="#header-classes">Classes</a></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<h4><code><a title="data-conversion.loaders.csvmanager.CSVManager" href="#data-conversion.loaders.csvmanager.CSVManager">CSVManager</a></code></h4>
|
||||
<ul class="">
|
||||
<li><code><a title="data-conversion.loaders.csvmanager.CSVManager.data" href="#data-conversion.loaders.csvmanager.CSVManager.data">data</a></code></li>
|
||||
<li><code><a title="data-conversion.loaders.csvmanager.CSVManager.export_csv" href="#data-conversion.loaders.csvmanager.CSVManager.export_csv">export_csv</a></code></li>
|
||||
<li><code><a title="data-conversion.loaders.csvmanager.CSVManager.export_text" href="#data-conversion.loaders.csvmanager.CSVManager.export_text">export_text</a></code></li>
|
||||
<li><code><a title="data-conversion.loaders.csvmanager.CSVManager.load" href="#data-conversion.loaders.csvmanager.CSVManager.load">load</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,71 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.9.2" />
|
||||
<title>data-conversion.loaders API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>data-conversion.loaders</code></h1>
|
||||
</header>
|
||||
<section id="section-intro">
|
||||
<details class="source">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">from .csvmanager import CSVManager # Imports in the package so it can be imported from the package too</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
|
||||
<dl>
|
||||
<dt><code class="name"><a title="data-conversion.loaders.csvmanager" href="csvmanager.html">data-conversion.loaders.csvmanager</a></code></dt>
|
||||
<dd>
|
||||
<div class="desc"></div>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
<li><h3>Super-module</h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion" href="../index.html">data-conversion</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
|
||||
<ul>
|
||||
<li><code><a title="data-conversion.loaders.csvmanager" href="csvmanager.html">data-conversion.loaders.csvmanager</a></code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,26 @@
|
||||
## Configuring your project for the application
|
||||
|
||||
You will need to associate the code to a project if not
|
||||
already done. If you don't have a project, just opening the folder
|
||||
with PyCharm should suffice.
|
||||
|
||||
However, you need to have a `virtualenv` for your project (for good
|
||||
practice), that uses Python 3.6+.
|
||||
|
||||
In this virtualenv, you'll have to install :
|
||||
|
||||
- `pyside6`
|
||||
|
||||
Note that Qt has issues with theming; if PySide6 is installed, using `pip` or
|
||||
another medium, it won't follow the system theme. However, if PySide2 is
|
||||
installed globally on the system (via `apt-get` or `pacman`), programs seem to
|
||||
follow the system theme. One would then have to revert to importing from
|
||||
`PySide2` instead of `PySide6` (with no other changes).
|
||||
|
||||
## How to run the application
|
||||
|
||||
The application is very simple to run in PyCharm.
|
||||
To do it, right-click on the source file content pane, somewhere where
|
||||
there is an empty space.
|
||||
|
||||
Then, click the `Run <application>...`.
|
@ -0,0 +1 @@
|
||||
pyside6
|
@ -0,0 +1,18 @@
|
||||
"""
|
||||
Entry point for our demo application.
|
||||
|
||||
Uses a "WindowManager" class holding the main window and the
|
||||
CSV data manager used in it.
|
||||
|
||||
.. include:: documentation/includes/application.md
|
||||
|
||||
"""
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from interface import WindowManager # look at interface/__init__.py
|
||||
|
||||
if __name__ == "__main__":
|
||||
application = QApplication()
|
||||
window_manager = WindowManager()
|
||||
window_manager.show()
|
||||
application.exec()
|
@ -0,0 +1,100 @@
|
||||
1,"Eldon Base for stackable storage shelf, platinum",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8
|
||||
2,"1.7 Cubic Foot Compact ""Cube"" Office Refrigerators",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58
|
||||
3,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
4,R380,Clay Rozendal,483,1198.97,195.99,3.99,Nunavut,Telephones and Communication,0.58
|
||||
5,Holmes HEPA Air Purifier,Carlos Soltero,515,30.94,21.78,5.94,Nunavut,Appliances,0.5
|
||||
6,G.E. Longer-Life Indoor Recessed Floodlight Bulbs,Carlos Soltero,515,4.43,6.64,4.95,Nunavut,Office Furnishings,0.37
|
||||
7,"Angle-D Binders with Locking Rings, Label Holders",Carl Jackson,613,-54.04,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
8,"SAFCO Mobile Desk Side File, Wire Frame",Carl Jackson,613,127.70,42.76,6.22,Nunavut,Storage & Organization,
|
||||
9,"SAFCO Commercial Wire Shelving, Black",Monica Federle,643,-695.26,138.14,35,Nunavut,Storage & Organization,
|
||||
10,Xerox 198,Dorothy Badders,678,-226.36,4.98,8.33,Nunavut,Paper,0.38
|
||||
11,Xerox 1980,Neola Schneider,807,-166.85,4.28,6.18,Nunavut,Paper,0.4
|
||||
12,Advantus Map Pennant Flags and Round Head Tacks,Neola Schneider,807,-14.33,3.95,2,Nunavut,Rubber Bands,0.53
|
||||
13,Holmes HEPA Air Purifier,Carlos Daly,868,134.72,21.78,5.94,Nunavut,Appliances,0.5
|
||||
14,"DS/HD IBM Formatted Diskettes, 200/Pack - Staples",Carlos Daly,868,114.46,47.98,3.61,Nunavut,Computer Peripherals,0.71
|
||||
15,"Wilson Jones 1"" Hanging DublLock<63> Ring Binders",Claudia Miner,933,-4.72,5.28,2.99,Nunavut,Binders and Binder Accessories,0.37
|
||||
16,Ultra Commercial Grade Dual Valve Door Closer,Neola Schneider,995,782.91,39.89,3.04,Nunavut,Office Furnishings,0.53
|
||||
17,"#10-4 1/8"" x 9 1/2"" Premium Diagonal Seam Envelopes",Allen Rosenblatt,998,93.80,15.74,1.39,Nunavut,Envelopes,0.4
|
||||
18,Hon 4-Shelf Metal Bookcases,Sylvia Foulston,1154,440.72,100.98,26.22,Nunavut,Bookcases,0.6
|
||||
19,"Lesro Sheffield Collection Coffee Table, End Table, Center Table, Corner Table",Sylvia Foulston,1154,-481.04,71.37,69,Nunavut,Tables,0.68
|
||||
20,g520,Jim Radford,1344,-11.68,65.99,5.26,Nunavut,Telephones and Communication,0.59
|
||||
21,LX 788,Jim Radford,1344,313.58,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
22,Avery 52,Carlos Soltero,1412,26.92,3.69,0.5,Nunavut,Labels,0.38
|
||||
23,Plymouth Boxed Rubber Bands by Plymouth,Carlos Soltero,1412,-5.77,4.71,0.7,Nunavut,Rubber Bands,0.8
|
||||
24,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Carl Ludwig,1539,-172.88,15.99,13.18,Nunavut,Binders and Binder Accessories,0.37
|
||||
25,"Maxell 3.5"" DS/HD IBM-Formatted Diskettes, 10/Pack",Carl Ludwig,1539,-144.55,4.89,4.93,Nunavut,Computer Peripherals,0.66
|
||||
26,Newell 335,Don Miller,1540,5.76,2.88,0.7,Nunavut,Pens & Art Supplies,0.56
|
||||
27,SANFORD Liquid Accent<6E> Tank-Style Highlighters,Annie Cyprus,1702,4.90,2.84,0.93,Nunavut,Pens & Art Supplies,0.54
|
||||
28,Canon PC940 Copier,Carl Ludwig,1761,-547.61,449.99,49,Nunavut,Copiers and Fax,0.38
|
||||
29,"Tenex Personal Project File with Scoop Front Design, Black",Carlos Soltero,1792,-5.45,13.48,4.51,Nunavut,Storage & Organization,0.59
|
||||
30,Col-Erase<73> Pencils with Erasers,Grant Carroll,2275,41.67,6.08,1.17,Nunavut,Pens & Art Supplies,0.56
|
||||
31,"Imation 3.5"" DS/HD IBM Formatted Diskettes, 10/Pack",Don Miller,2277,-46.03,5.98,4.38,Nunavut,Computer Peripherals,0.75
|
||||
32,"White Dual Perf Computer Printout Paper, 2700 Sheets, 1 Part, Heavyweight, 20 lbs., 14 7/8 x 11",Don Miller,2277,33.67,40.99,19.99,Nunavut,Paper,0.36
|
||||
33,Self-Adhesive Address Labels for Typewriters by Universal,Alan Barnes,2532,140.01,7.31,0.49,Nunavut,Labels,0.38
|
||||
34,Accessory37,Alan Barnes,2532,-78.96,20.99,2.5,Nunavut,Telephones and Communication,0.81
|
||||
35,Fuji 5.2GB DVD-RAM,Jack Garza,2631,252.66,40.96,1.99,Nunavut,Computer Peripherals,0.55
|
||||
36,Bevis Steel Folding Chairs,Julia West,2757,-1766.01,95.95,74.35,Nunavut,Chairs & Chairmats,0.57
|
||||
37,Avery Binder Labels,Eugene Barchas,2791,-236.27,3.89,7.01,Nunavut,Binders and Binder Accessories,0.37
|
||||
38,Hon Every-Day<61> Chair Series Swivel Task Chairs,Eugene Barchas,2791,80.44,120.98,30,Nunavut,Chairs & Chairmats,0.64
|
||||
39,"IBM Multi-Purpose Copy Paper, 8 1/2 x 11"", Case",Eugene Barchas,2791,118.94,30.98,5.76,Nunavut,Paper,0.4
|
||||
40,Global Troy<6F> Executive Leather Low-Back Tilter,Edward Hooks,2976,3424.22,500.98,26,Nunavut,Chairs & Chairmats,0.6
|
||||
41,XtraLife<EFBFBD> ClearVue<75> Slant-D<> Ring Binders by Cardinal,Brad Eason,3232,-11.83,7.84,4.71,Nunavut,Binders and Binder Accessories,0.35
|
||||
42,Computer Printout Paper with Letter-Trim Perforations,Nicole Hansen,3524,52.35,18.97,9.03,Nunavut,Paper,0.37
|
||||
43,6160,Dorothy Wardle,3908,-180.20,115.99,2.5,Nunavut,Telephones and Communication,0.57
|
||||
44,Avery 49,Aaron Bergman,4132,1.32,2.88,0.5,Nunavut,Labels,0.36
|
||||
45,Hoover Portapower<65> Portable Vacuum,Jim Radford,4612,-375.64,4.48,49,Nunavut,Appliances,0.6
|
||||
46,Timeport L7089,Annie Cyprus,4676,-104.25,125.99,7.69,Nunavut,Telephones and Communication,0.58
|
||||
47,Avery 510,Annie Cyprus,4676,85.96,3.75,0.5,Nunavut,Labels,0.37
|
||||
48,Xerox 1881,Annie Cyprus,4676,-8.38,12.28,6.47,Nunavut,Paper,0.38
|
||||
49,LX 788,Annie Cyprus,4676,1115.69,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
50,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Annie Cyprus,5284,-3.05,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
51,"Memorex 4.7GB DVD-RAM, 3/Pack",Clay Rozendal,5316,514.07,31.78,1.99,Nunavut,Computer Peripherals,0.42
|
||||
52,Unpadded Memo Slips,Don Jones,5409,-7.04,3.98,2.97,Nunavut,Paper,0.35
|
||||
53,"Adams Telephone Message Book W/Dividers/Space For Phone Numbers, 5 1/4""X8 1/2"", 300/Messages",Beth Thompson,5506,4.41,5.88,3.04,Nunavut,Paper,0.36
|
||||
54,"Eldon Expressions<6E> Desk Accessory, Wood Pencil Holder, Oak",Frank Price,5569,-0.06,9.65,6.22,Nunavut,Office Furnishings,0.55
|
||||
55,Bell Sonecor JB700 Caller ID,Michelle Lonsdale,5607,-50.33,7.99,5.03,Nunavut,Telephones and Communication,0.6
|
||||
56,Avery Arch Ring Binders,Ann Chong,5894,87.68,58.1,1.49,Nunavut,Binders and Binder Accessories,0.38
|
||||
57,APC 7 Outlet Network SurgeArrest Surge Protector,Ann Chong,5894,-68.22,80.48,4.5,Nunavut,Appliances,0.55
|
||||
58,"Deflect-o RollaMat Studded, Beveled Mat for Medium Pile Carpeting",Joy Bell,5925,-354.90,92.23,39.61,Nunavut,Office Furnishings,0.67
|
||||
59,Accessory4,Joy Bell,5925,-267.01,85.99,0.99,Nunavut,Telephones and Communication,0.85
|
||||
60,Personal Creations<6E> Ink Jet Cards and Labels,Skye Norling,6016,3.63,11.48,5.43,Nunavut,Paper,0.36
|
||||
61,High Speed Automatic Electric Letter Opener,Barry Weirich,6116,-1759.58,1637.53,24.49,Nunavut,"Scissors, Rulers and Trimmers",0.81
|
||||
62,Xerox 1966,Grant Carroll,6182,-116.79,6.48,6.65,Nunavut,Paper,0.36
|
||||
63,Xerox 213,Grant Carroll,6182,-67.28,6.48,7.86,Nunavut,Paper,0.37
|
||||
64,"Boston Electric Pencil Sharpener, Model 1818, Charcoal Black",Adrian Hane,6535,-19.33,28.15,8.99,Nunavut,Pens & Art Supplies,0.57
|
||||
65,Hammermill CopyPlus Copy Paper (20Lb. and 84 Bright),Skye Norling,6884,-61.21,4.98,4.75,Nunavut,Paper,0.36
|
||||
66,"Telephone Message Books with Fax/Mobile Section, 5 1/2"" x 3 3/16""",Skye Norling,6884,119.09,6.35,1.02,Nunavut,Paper,0.39
|
||||
67,Crate-A-Files<65>,Andrew Gjertsen,6916,-141.27,10.9,7.46,Nunavut,Storage & Organization,0.59
|
||||
68,"Angle-D Binders with Locking Rings, Label Holders",Ralph Knight,6980,-77.28,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
69,"80 Minute CD-R Spindle, 100/Pack - Staples",Dorothy Wardle,6982,407.44,39.48,1.99,Nunavut,Computer Peripherals,0.54
|
||||
70,"Bush Westfield Collection Bookcases, Dark Cherry Finish, Fully Assembled",Dorothy Wardle,6982,-338.27,100.98,57.38,Nunavut,Bookcases,0.78
|
||||
71,12-1/2 Diameter Round Wall Clock,Dorothy Wardle,6982,52.56,19.98,10.49,Nunavut,Office Furnishings,0.49
|
||||
72,SAFCO Arco Folding Chair,Grant Carroll,7110,1902.24,276.2,24.49,Nunavut,Chairs & Chairmats,
|
||||
73,"#10 White Business Envelopes,4 1/8 x 9 1/2",Barry Weirich,7430,353.20,15.67,1.39,Nunavut,Envelopes,0.38
|
||||
74,3M Office Air Cleaner,Beth Paige,7906,271.78,25.98,5.37,Nunavut,Appliances,0.5
|
||||
75,"Global Leather and Oak Executive Chair, Black",Sylvia Foulston,8391,-268.36,300.98,64.73,Nunavut,Chairs & Chairmats,0.56
|
||||
76,Xerox 1936,Nicole Hansen,8419,70.39,19.98,5.97,Nunavut,Paper,0.38
|
||||
77,Xerox 214,Nicole Hansen,8419,-86.62,6.48,7.03,Nunavut,Paper,0.37
|
||||
78,Carina Double Wide Media Storage Towers in Natural & Black,Nicole Hansen,8833,-846.73,80.98,35,Nunavut,Storage & Organization,0.81
|
||||
79,Staples<EFBFBD> General Use 3-Ring Binders,Beth Paige,8995,8.05,1.88,1.49,Nunavut,Binders and Binder Accessories,0.37
|
||||
80,Xerox 1904,Beth Paige,8995,-78.02,6.48,5.86,Northwest Territories,Paper,0.36
|
||||
81,Luxo Professional Combination Clamp-On Lamps,Beth Paige,8995,737.94,102.3,21.26,Northwest Territories,Office Furnishings,0.59
|
||||
82,Xerox 217,Beth Paige,8995,-191.28,6.48,8.19,Northwest Territories,Paper,0.37
|
||||
83,Revere Boxed Rubber Bands by Revere,Beth Paige,8995,-21.49,1.89,0.76,Northwest Territories,Rubber Bands,0.83
|
||||
84,"Acco Smartsocket<65> Table Surge Protector, 6 Color-Coded Adapter Outlets",Sylvia Foulston,9126,884.08,62.05,3.99,Northwest Territories,Appliances,0.55
|
||||
85,"Tennsco Snap-Together Open Shelving Units, Starter Sets and Add-On Units",Bryan Davis,9127,-329.49,279.48,35,Northwest Territories,Storage & Organization,0.8
|
||||
86,Hon 4070 Series Pagoda<64> Round Back Stacking Chairs,Joy Bell,9509,2825.15,320.98,58.95,Northwest Territories,Chairs & Chairmats,0.57
|
||||
87,Xerox 1887,Joy Bell,9509,2.13,18.97,5.21,Northwest Territories,Paper,0.37
|
||||
88,Xerox 1891,Joy Bell,9509,707.15,48.91,5.81,Northwest Territories,Paper,0.38
|
||||
89,Avery 506,Alan Barnes,9763,75.13,4.13,0.5,Northwest Territories,Labels,0.39
|
||||
90,"Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order",Grant Carroll,9927,-270.63,140.98,53.48,Northwest Territories,Bookcases,0.65
|
||||
91,"Lifetime Advantage<67> Folding Chairs, 4/Carton",Grant Carroll,9927,3387.35,218.08,18.06,Northwest Territories,Chairs & Chairmats,0.57
|
||||
92,Microsoft Natural Multimedia Keyboard,Grant Carroll,9927,-82.16,50.98,6.5,Northwest Territories,Computer Peripherals,0.73
|
||||
93,"Staples Wirebound Steno Books, 6"" x 9"", 12/Pack",Delfina Latchford,10022,-3.88,10.14,2.27,Northwest Territories,Paper,0.36
|
||||
94,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Don Jones,10437,-191.22,15.99,13.18,Northwest Territories,Binders and Binder Accessories,0.37
|
||||
95,Bevis Boat-Shaped Conference Table,Doug Bickford,10499,31.21,262.11,62.74,Northwest Territories,Tables,0.75
|
||||
96,"Linden<EFBFBD> 12"" Wall Clock With Oak Frame",Doug Bickford,10535,-44.14,33.98,19.99,Northwest Territories,Office Furnishings,0.55
|
||||
97,Newell 326,Doug Bickford,10535,-0.79,1.76,0.7,Northwest Territories,Pens & Art Supplies,0.56
|
||||
98,Prismacolor Color Pencil Set,Jamie Kunitz,10789,76.42,19.84,4.1,Northwest Territories,Pens & Art Supplies,0.44
|
||||
99,Xerox Blank Computer Paper,Anthony Johnson,10791,93.36,19.98,5.77,Northwest Territories,Paper,0.38
|
||||
100,600 Series Flip,Ralph Knight,10945,4.22,95.99,8.99,Northwest Territories,Telephones and Communication,0.57
|
|
@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>625</width>
|
||||
<height>438</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Conversion de données CSV</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset theme="application-excel">
|
||||
<normaloff>../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Sélectionnez un CSV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="file_button">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cliquez pour sélectionner</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="fileopen">
|
||||
<normaloff>../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="info_label">
|
||||
<property name="text">
|
||||
<string>Veuillez sélectionner un fichier CSV valide pour continuer...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="list_widget">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0" columnstretch="1,2,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="button_csv_export">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exporter en CSV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="button_txt_export">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exporter en texte</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>625</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1 @@
|
||||
from .windowmanager import WindowManager
|
@ -0,0 +1,19 @@
|
||||
from PySide6.QtWidgets import QMainWindow, QPushButton, QListWidget
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
"""
|
||||
Class written just for autocompletion and type hinting.
|
||||
|
||||
Lists dynamic attributes of the loaded window
|
||||
so that PyCharm can know that the following attributes
|
||||
exist in the loaded file.
|
||||
|
||||
The class is then used for type hinting in the
|
||||
`WindowManager` class.
|
||||
|
||||
"""
|
||||
file_button: QPushButton
|
||||
button_csv_export: QPushButton
|
||||
button_txt_export: QPushButton
|
||||
list_widget: QListWidget
|
@ -0,0 +1,81 @@
|
||||
from typing import Union
|
||||
|
||||
from PySide6.QtUiTools import QUiLoader
|
||||
from PySide6.QtWidgets import QFileDialog, QWidget, QListWidgetItem
|
||||
|
||||
from interface.mainwindow import MainWindow
|
||||
from loaders import CSVManager
|
||||
|
||||
|
||||
class WindowManager:
|
||||
"""
|
||||
Class used to manage the Qt window and its associated data.
|
||||
|
||||
Attributes:
|
||||
_window: Private, contains the main window.
|
||||
_csv_manager: Private, holds a CSV manager.
|
||||
|
||||
"""
|
||||
_window: Union[QWidget, MainWindow] = None # Qt window managed by this class
|
||||
_csv_manager: CSVManager = None # Object used to manage CSV data
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize our window manager.
|
||||
|
||||
"""
|
||||
loader = QUiLoader()
|
||||
self._window = loader.load("files/designer/demo-dialog.ui")
|
||||
# Once the window is loaded, connect actions to code
|
||||
self.setup_actions()
|
||||
|
||||
def setup_actions(self):
|
||||
"""Connect actions of controls to methods."""
|
||||
self._window.file_button.clicked.connect(self.on_file_select)
|
||||
self._window.button_csv_export.clicked.connect(self.on_export_csv)
|
||||
|
||||
def on_file_select(self):
|
||||
"""
|
||||
Action when the file button is clicked.
|
||||
|
||||
Shows a file select dialog to pick a CSV
|
||||
and loads the CSV file in the CSVManager instance of the object.
|
||||
|
||||
"""
|
||||
filter_text = "CSV File (*.csv)"
|
||||
selection: tuple = QFileDialog.getOpenFileName(self._window, "CSV File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager = CSVManager(path)
|
||||
self._window.button_csv_export.setEnabled(True)
|
||||
# Empty list items and enable the list widget
|
||||
self._window.list_widget.clear()
|
||||
self._window.list_widget.setEnabled(True)
|
||||
# Add rows in the list widget containing CSV rows
|
||||
for row in self._csv_manager.data:
|
||||
item = QListWidgetItem(";".join(row))
|
||||
self._window.list_widget.addItem(item)
|
||||
|
||||
def on_export_csv(self):
|
||||
"""
|
||||
Action when the export to CSV button is clicked.
|
||||
|
||||
Shows a file select dialog to select a file destination.
|
||||
The output file is then saved to the selected path.
|
||||
|
||||
"""
|
||||
filter_text = "Text File (*.txt)"
|
||||
selection: tuple = QFileDialog.getSaveFileName(self._window, "Text File", "", filter_text)
|
||||
path: str = selection[0]
|
||||
if path:
|
||||
self._csv_manager.export_text(selection[0])
|
||||
|
||||
def show(self):
|
||||
"""
|
||||
Public method to show our window.
|
||||
|
||||
The window is loaded automatically at instanciation
|
||||
in the `__init__` method.
|
||||
|
||||
"""
|
||||
self._window.show()
|
@ -0,0 +1 @@
|
||||
from .csvmanager import CSVManager # Imports in the package so it can be imported from the package too
|
@ -0,0 +1,16 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from loaders.formats import DataFormat
|
||||
|
||||
|
||||
class BaseDataManager(ABC):
|
||||
"""Base class for data managers."""
|
||||
|
||||
@abstractmethod
|
||||
def load(self, url: str, encoding: str = "iso8859-1"):
|
||||
"""Load data for the manager."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def export(self, url: str, fmt: DataFormat):
|
||||
"""Export data in a specific format."""
|
||||
pass
|
@ -0,0 +1,78 @@
|
||||
import csv
|
||||
|
||||
from loaders.basemanager import BaseDataManager
|
||||
from loaders.formats import DataFormat
|
||||
|
||||
|
||||
class CSVManager(BaseDataManager):
|
||||
"""
|
||||
Utility class to keep CSV data for export in other formats.
|
||||
|
||||
Attributes:
|
||||
data: Contains loaded file data as a list of lists.
|
||||
|
||||
"""
|
||||
|
||||
data: list = None
|
||||
|
||||
def __init__(self, url: str):
|
||||
"""
|
||||
Initialize the object with a URL.
|
||||
|
||||
Args:
|
||||
url: CSV URL to load from.
|
||||
|
||||
"""
|
||||
self.load(url)
|
||||
|
||||
def load(self, url: str, encoding: str = "iso8859-1"):
|
||||
"""
|
||||
Load a CSV given its file path.
|
||||
|
||||
Args:
|
||||
url: Path of the CSV file.
|
||||
encoding: Codepage name of the text file.
|
||||
|
||||
"""
|
||||
with open(url, "r", encoding=encoding) as f:
|
||||
reader = csv.reader(f, delimiter=",")
|
||||
if self.data is None:
|
||||
self.data = []
|
||||
for row in reader:
|
||||
self.data.append(row)
|
||||
|
||||
def export(self, url: str, fmt: DataFormat):
|
||||
"""Official method to export data."""
|
||||
if fmt is DataFormat.TEXT:
|
||||
self.export_text(url)
|
||||
elif fmt is DataFormat.CSV:
|
||||
self.export_csv(url)
|
||||
else:
|
||||
raise ValueError(f"{fmt}: unsupported format.")
|
||||
|
||||
def export_text(self, url: str):
|
||||
"""
|
||||
Save data as a text file.
|
||||
|
||||
Every column is save in its own line as an example.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
for row in self.data:
|
||||
file.write("\n".join(row))
|
||||
|
||||
def export_csv(self, url: str):
|
||||
"""
|
||||
Save data as a CSV file with semicolons.
|
||||
|
||||
Args:
|
||||
url: Output file path.
|
||||
|
||||
"""
|
||||
with open(url, "w", encoding="utf-8") as file:
|
||||
writer = csv.writer(file, delimiter=";")
|
||||
for row in self.data:
|
||||
writer.writerow(row)
|
@ -0,0 +1,7 @@
|
||||
from enum import IntEnum
|
||||
|
||||
|
||||
class DataFormat(IntEnum):
|
||||
"""Supported formats enumeration."""
|
||||
CSV = 0
|
||||
TEXT = 1
|
@ -0,0 +1 @@
|
||||
pyside6
|
@ -0,0 +1,21 @@
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtUiTools import QUiLoader
|
||||
from PySide6.QtWidgets import QApplication, QListWidget, QListWidgetItem, QMainWindow
|
||||
|
||||
if __name__ == "__main__":
|
||||
application = QApplication()
|
||||
# Load main window with list widget from Designer file
|
||||
window: QMainWindow = QUiLoader().load("files/list-widget.ui")
|
||||
list1: QListWidget = window.list1
|
||||
# Add icon
|
||||
sleep_icon = QIcon.fromTheme("text-x-python")
|
||||
for i in range(20):
|
||||
item = QListWidgetItem(sleep_icon, f"Élément {i}")
|
||||
list1.addItem(item)
|
||||
|
||||
def on_clicked(list_item: QListWidgetItem):
|
||||
print(list_item.text())
|
||||
|
||||
list1.itemClicked.connect(on_clicked)
|
||||
window.show()
|
||||
application.exec()
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>List widget demonstration</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset theme="emblem-favorite"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="list1"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,10 @@
|
||||
from data.csvmanager import CSVManager
|
||||
from data.basemanager import BaseManager
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
csv1 = CSVManager("files/demo-csv.csv")
|
||||
csv2 = CSVManager("files/demo-csv-incorrect.csv")
|
||||
base1 = BaseManager("files/demo-csv.csv")
|
||||
print(csv1.get_info())
|
||||
print(csv2.get_info())
|
@ -0,0 +1,14 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
logger = logging.getLogger("data")
|
||||
|
||||
# Configure the main logger for the data package
|
||||
if not logger.handlers:
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
formatting = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
|
||||
handler.setFormatter(formatting)
|
||||
handler.setLevel(logging.DEBUG)
|
||||
logger.addHandler(handler)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.debug("Data logger registered.")
|
@ -0,0 +1,24 @@
|
||||
import logging
|
||||
from os.path import getsize
|
||||
|
||||
|
||||
logger = logging.getLogger("data.basemanager")
|
||||
|
||||
|
||||
class BaseManager:
|
||||
"""Base data file manager."""
|
||||
|
||||
def __init__(self, path: str):
|
||||
self._path = path
|
||||
logger.info(f"New file manager initialized for file {path}")
|
||||
|
||||
def get_info(self) -> dict:
|
||||
"""Get basic information about the file."""
|
||||
try:
|
||||
data = {"size": getsize(self._path)}
|
||||
return data
|
||||
except IOError:
|
||||
logger.error("Could not get file size.")
|
||||
return {"size": -1}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
import csv
|
||||
import logging
|
||||
|
||||
from data.basemanager import BaseManager
|
||||
|
||||
|
||||
logger = logging.getLogger("data.csvmanager")
|
||||
|
||||
|
||||
class CSVManager(BaseManager):
|
||||
"""Data manager for CSV files."""
|
||||
|
||||
def get_info(self) -> dict:
|
||||
data = super().get_info()
|
||||
try:
|
||||
with open(self._path, "r", encoding="utf-8") as file:
|
||||
reader = csv.reader(file)
|
||||
for idx, _ in enumerate(reader):
|
||||
pass
|
||||
data["rows"] = idx
|
||||
return data
|
||||
except IOError:
|
||||
logger.error("Could not decode CSV, IO error occurred.")
|
||||
return data
|
||||
except UnicodeDecodeError:
|
||||
logger.error("CSV is not encoded in UTF8, skipping.")
|
||||
return data
|
||||
|
@ -0,0 +1,100 @@
|
||||
1,"Eldon Base for stackable storage shelf, platinum",Muhammed MacIntyre,3,-213.25,38.94,35,Nunavut,Storage & Organization,0.8
|
||||
2,"1.7 Cubic Foot Compact ""Cube"" Office Refrigerators",Barry French,293,457.81,208.16,68.02,Nunavut,Appliances,0.58
|
||||
3,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Barry French,293,46.71,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
4,R380,Clay Rozendal,483,1198.97,195.99,3.99,Nunavut,Telephones and Communication,0.58
|
||||
5,Holmes HEPA Air Purifier,Carlos Soltero,515,30.94,21.78,5.94,Nunavut,Appliances,0.5
|
||||
6,G.E. Longer-Life Indoor Recessed Floodlight Bulbs,Carlos Soltero,515,4.43,6.64,4.95,Nunavut,Office Furnishings,0.37
|
||||
7,"Angle-D Binders with Locking Rings, Label Holders",Carl Jackson,613,-54.04,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
8,"SAFCO Mobile Desk Side File, Wire Frame",Carl Jackson,613,127.70,42.76,6.22,Nunavut,Storage & Organization,
|
||||
9,"SAFCO Commercial Wire Shelving, Black",Monica Federle,643,-695.26,138.14,35,Nunavut,Storage & Organization,
|
||||
10,Xerox 198,Dorothy Badders,678,-226.36,4.98,8.33,Nunavut,Paper,0.38
|
||||
11,Xerox 1980,Neola Schneider,807,-166.85,4.28,6.18,Nunavut,Paper,0.4
|
||||
12,Advantus Map Pennant Flags and Round Head Tacks,Neola Schneider,807,-14.33,3.95,2,Nunavut,Rubber Bands,0.53
|
||||
13,Holmes HEPA Air Purifier,Carlos Daly,868,134.72,21.78,5.94,Nunavut,Appliances,0.5
|
||||
14,"DS/HD IBM Formatted Diskettes, 200/Pack - Staples",Carlos Daly,868,114.46,47.98,3.61,Nunavut,Computer Peripherals,0.71
|
||||
15,"Wilson Jones 1"" Hanging DublLock<63> Ring Binders",Claudia Miner,933,-4.72,5.28,2.99,Nunavut,Binders and Binder Accessories,0.37
|
||||
16,Ultra Commercial Grade Dual Valve Door Closer,Neola Schneider,995,782.91,39.89,3.04,Nunavut,Office Furnishings,0.53
|
||||
17,"#10-4 1/8"" x 9 1/2"" Premium Diagonal Seam Envelopes",Allen Rosenblatt,998,93.80,15.74,1.39,Nunavut,Envelopes,0.4
|
||||
18,Hon 4-Shelf Metal Bookcases,Sylvia Foulston,1154,440.72,100.98,26.22,Nunavut,Bookcases,0.6
|
||||
19,"Lesro Sheffield Collection Coffee Table, End Table, Center Table, Corner Table",Sylvia Foulston,1154,-481.04,71.37,69,Nunavut,Tables,0.68
|
||||
20,g520,Jim Radford,1344,-11.68,65.99,5.26,Nunavut,Telephones and Communication,0.59
|
||||
21,LX 788,Jim Radford,1344,313.58,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
22,Avery 52,Carlos Soltero,1412,26.92,3.69,0.5,Nunavut,Labels,0.38
|
||||
23,Plymouth Boxed Rubber Bands by Plymouth,Carlos Soltero,1412,-5.77,4.71,0.7,Nunavut,Rubber Bands,0.8
|
||||
24,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Carl Ludwig,1539,-172.88,15.99,13.18,Nunavut,Binders and Binder Accessories,0.37
|
||||
25,"Maxell 3.5"" DS/HD IBM-Formatted Diskettes, 10/Pack",Carl Ludwig,1539,-144.55,4.89,4.93,Nunavut,Computer Peripherals,0.66
|
||||
26,Newell 335,Don Miller,1540,5.76,2.88,0.7,Nunavut,Pens & Art Supplies,0.56
|
||||
27,SANFORD Liquid Accent<6E> Tank-Style Highlighters,Annie Cyprus,1702,4.90,2.84,0.93,Nunavut,Pens & Art Supplies,0.54
|
||||
28,Canon PC940 Copier,Carl Ludwig,1761,-547.61,449.99,49,Nunavut,Copiers and Fax,0.38
|
||||
29,"Tenex Personal Project File with Scoop Front Design, Black",Carlos Soltero,1792,-5.45,13.48,4.51,Nunavut,Storage & Organization,0.59
|
||||
30,Col-Erase<73> Pencils with Erasers,Grant Carroll,2275,41.67,6.08,1.17,Nunavut,Pens & Art Supplies,0.56
|
||||
31,"Imation 3.5"" DS/HD IBM Formatted Diskettes, 10/Pack",Don Miller,2277,-46.03,5.98,4.38,Nunavut,Computer Peripherals,0.75
|
||||
32,"White Dual Perf Computer Printout Paper, 2700 Sheets, 1 Part, Heavyweight, 20 lbs., 14 7/8 x 11",Don Miller,2277,33.67,40.99,19.99,Nunavut,Paper,0.36
|
||||
33,Self-Adhesive Address Labels for Typewriters by Universal,Alan Barnes,2532,140.01,7.31,0.49,Nunavut,Labels,0.38
|
||||
34,Accessory37,Alan Barnes,2532,-78.96,20.99,2.5,Nunavut,Telephones and Communication,0.81
|
||||
35,Fuji 5.2GB DVD-RAM,Jack Garza,2631,252.66,40.96,1.99,Nunavut,Computer Peripherals,0.55
|
||||
36,Bevis Steel Folding Chairs,Julia West,2757,-1766.01,95.95,74.35,Nunavut,Chairs & Chairmats,0.57
|
||||
37,Avery Binder Labels,Eugene Barchas,2791,-236.27,3.89,7.01,Nunavut,Binders and Binder Accessories,0.37
|
||||
38,Hon Every-Day<61> Chair Series Swivel Task Chairs,Eugene Barchas,2791,80.44,120.98,30,Nunavut,Chairs & Chairmats,0.64
|
||||
39,"IBM Multi-Purpose Copy Paper, 8 1/2 x 11"", Case",Eugene Barchas,2791,118.94,30.98,5.76,Nunavut,Paper,0.4
|
||||
40,Global Troy<6F> Executive Leather Low-Back Tilter,Edward Hooks,2976,3424.22,500.98,26,Nunavut,Chairs & Chairmats,0.6
|
||||
41,XtraLife<EFBFBD> ClearVue<75> Slant-D<> Ring Binders by Cardinal,Brad Eason,3232,-11.83,7.84,4.71,Nunavut,Binders and Binder Accessories,0.35
|
||||
42,Computer Printout Paper with Letter-Trim Perforations,Nicole Hansen,3524,52.35,18.97,9.03,Nunavut,Paper,0.37
|
||||
43,6160,Dorothy Wardle,3908,-180.20,115.99,2.5,Nunavut,Telephones and Communication,0.57
|
||||
44,Avery 49,Aaron Bergman,4132,1.32,2.88,0.5,Nunavut,Labels,0.36
|
||||
45,Hoover Portapower<65> Portable Vacuum,Jim Radford,4612,-375.64,4.48,49,Nunavut,Appliances,0.6
|
||||
46,Timeport L7089,Annie Cyprus,4676,-104.25,125.99,7.69,Nunavut,Telephones and Communication,0.58
|
||||
47,Avery 510,Annie Cyprus,4676,85.96,3.75,0.5,Nunavut,Labels,0.37
|
||||
48,Xerox 1881,Annie Cyprus,4676,-8.38,12.28,6.47,Nunavut,Paper,0.38
|
||||
49,LX 788,Annie Cyprus,4676,1115.69,155.99,8.99,Nunavut,Telephones and Communication,0.58
|
||||
50,"Cardinal Slant-D<> Ring Binder, Heavy Gauge Vinyl",Annie Cyprus,5284,-3.05,8.69,2.99,Nunavut,Binders and Binder Accessories,0.39
|
||||
51,"Memorex 4.7GB DVD-RAM, 3/Pack",Clay Rozendal,5316,514.07,31.78,1.99,Nunavut,Computer Peripherals,0.42
|
||||
52,Unpadded Memo Slips,Don Jones,5409,-7.04,3.98,2.97,Nunavut,Paper,0.35
|
||||
53,"Adams Telephone Message Book W/Dividers/Space For Phone Numbers, 5 1/4""X8 1/2"", 300/Messages",Beth Thompson,5506,4.41,5.88,3.04,Nunavut,Paper,0.36
|
||||
54,"Eldon Expressions<6E> Desk Accessory, Wood Pencil Holder, Oak",Frank Price,5569,-0.06,9.65,6.22,Nunavut,Office Furnishings,0.55
|
||||
55,Bell Sonecor JB700 Caller ID,Michelle Lonsdale,5607,-50.33,7.99,5.03,Nunavut,Telephones and Communication,0.6
|
||||
56,Avery Arch Ring Binders,Ann Chong,5894,87.68,58.1,1.49,Nunavut,Binders and Binder Accessories,0.38
|
||||
57,APC 7 Outlet Network SurgeArrest Surge Protector,Ann Chong,5894,-68.22,80.48,4.5,Nunavut,Appliances,0.55
|
||||
58,"Deflect-o RollaMat Studded, Beveled Mat for Medium Pile Carpeting",Joy Bell,5925,-354.90,92.23,39.61,Nunavut,Office Furnishings,0.67
|
||||
59,Accessory4,Joy Bell,5925,-267.01,85.99,0.99,Nunavut,Telephones and Communication,0.85
|
||||
60,Personal Creations<6E> Ink Jet Cards and Labels,Skye Norling,6016,3.63,11.48,5.43,Nunavut,Paper,0.36
|
||||
61,High Speed Automatic Electric Letter Opener,Barry Weirich,6116,-1759.58,1637.53,24.49,Nunavut,"Scissors, Rulers and Trimmers",0.81
|
||||
62,Xerox 1966,Grant Carroll,6182,-116.79,6.48,6.65,Nunavut,Paper,0.36
|
||||
63,Xerox 213,Grant Carroll,6182,-67.28,6.48,7.86,Nunavut,Paper,0.37
|
||||
64,"Boston Electric Pencil Sharpener, Model 1818, Charcoal Black",Adrian Hane,6535,-19.33,28.15,8.99,Nunavut,Pens & Art Supplies,0.57
|
||||
65,Hammermill CopyPlus Copy Paper (20Lb. and 84 Bright),Skye Norling,6884,-61.21,4.98,4.75,Nunavut,Paper,0.36
|
||||
66,"Telephone Message Books with Fax/Mobile Section, 5 1/2"" x 3 3/16""",Skye Norling,6884,119.09,6.35,1.02,Nunavut,Paper,0.39
|
||||
67,Crate-A-Files<65>,Andrew Gjertsen,6916,-141.27,10.9,7.46,Nunavut,Storage & Organization,0.59
|
||||
68,"Angle-D Binders with Locking Rings, Label Holders",Ralph Knight,6980,-77.28,7.3,7.72,Nunavut,Binders and Binder Accessories,0.38
|
||||
69,"80 Minute CD-R Spindle, 100/Pack - Staples",Dorothy Wardle,6982,407.44,39.48,1.99,Nunavut,Computer Peripherals,0.54
|
||||
70,"Bush Westfield Collection Bookcases, Dark Cherry Finish, Fully Assembled",Dorothy Wardle,6982,-338.27,100.98,57.38,Nunavut,Bookcases,0.78
|
||||
71,12-1/2 Diameter Round Wall Clock,Dorothy Wardle,6982,52.56,19.98,10.49,Nunavut,Office Furnishings,0.49
|
||||
72,SAFCO Arco Folding Chair,Grant Carroll,7110,1902.24,276.2,24.49,Nunavut,Chairs & Chairmats,
|
||||
73,"#10 White Business Envelopes,4 1/8 x 9 1/2",Barry Weirich,7430,353.20,15.67,1.39,Nunavut,Envelopes,0.38
|
||||
74,3M Office Air Cleaner,Beth Paige,7906,271.78,25.98,5.37,Nunavut,Appliances,0.5
|
||||
75,"Global Leather and Oak Executive Chair, Black",Sylvia Foulston,8391,-268.36,300.98,64.73,Nunavut,Chairs & Chairmats,0.56
|
||||
76,Xerox 1936,Nicole Hansen,8419,70.39,19.98,5.97,Nunavut,Paper,0.38
|
||||
77,Xerox 214,Nicole Hansen,8419,-86.62,6.48,7.03,Nunavut,Paper,0.37
|
||||
78,Carina Double Wide Media Storage Towers in Natural & Black,Nicole Hansen,8833,-846.73,80.98,35,Nunavut,Storage & Organization,0.81
|
||||
79,Staples<EFBFBD> General Use 3-Ring Binders,Beth Paige,8995,8.05,1.88,1.49,Nunavut,Binders and Binder Accessories,0.37
|
||||
80,Xerox 1904,Beth Paige,8995,-78.02,6.48,5.86,Northwest Territories,Paper,0.36
|
||||
81,Luxo Professional Combination Clamp-On Lamps,Beth Paige,8995,737.94,102.3,21.26,Northwest Territories,Office Furnishings,0.59
|
||||
82,Xerox 217,Beth Paige,8995,-191.28,6.48,8.19,Northwest Territories,Paper,0.37
|
||||
83,Revere Boxed Rubber Bands by Revere,Beth Paige,8995,-21.49,1.89,0.76,Northwest Territories,Rubber Bands,0.83
|
||||
84,"Acco Smartsocket<65> Table Surge Protector, 6 Color-Coded Adapter Outlets",Sylvia Foulston,9126,884.08,62.05,3.99,Northwest Territories,Appliances,0.55
|
||||
85,"Tennsco Snap-Together Open Shelving Units, Starter Sets and Add-On Units",Bryan Davis,9127,-329.49,279.48,35,Northwest Territories,Storage & Organization,0.8
|
||||
86,Hon 4070 Series Pagoda<64> Round Back Stacking Chairs,Joy Bell,9509,2825.15,320.98,58.95,Northwest Territories,Chairs & Chairmats,0.57
|
||||
87,Xerox 1887,Joy Bell,9509,2.13,18.97,5.21,Northwest Territories,Paper,0.37
|
||||
88,Xerox 1891,Joy Bell,9509,707.15,48.91,5.81,Northwest Territories,Paper,0.38
|
||||
89,Avery 506,Alan Barnes,9763,75.13,4.13,0.5,Northwest Territories,Labels,0.39
|
||||
90,"Bush Heritage Pine Collection 5-Shelf Bookcase, Albany Pine Finish, *Special Order",Grant Carroll,9927,-270.63,140.98,53.48,Northwest Territories,Bookcases,0.65
|
||||
91,"Lifetime Advantage<67> Folding Chairs, 4/Carton",Grant Carroll,9927,3387.35,218.08,18.06,Northwest Territories,Chairs & Chairmats,0.57
|
||||
92,Microsoft Natural Multimedia Keyboard,Grant Carroll,9927,-82.16,50.98,6.5,Northwest Territories,Computer Peripherals,0.73
|
||||
93,"Staples Wirebound Steno Books, 6"" x 9"", 12/Pack",Delfina Latchford,10022,-3.88,10.14,2.27,Northwest Territories,Paper,0.36
|
||||
94,"GBC Pre-Punched Binding Paper, Plastic, White, 8-1/2"" x 11""",Don Jones,10437,-191.22,15.99,13.18,Northwest Territories,Binders and Binder Accessories,0.37
|
||||
95,Bevis Boat-Shaped Conference Table,Doug Bickford,10499,31.21,262.11,62.74,Northwest Territories,Tables,0.75
|
||||
96,"Linden<EFBFBD> 12"" Wall Clock With Oak Frame",Doug Bickford,10535,-44.14,33.98,19.99,Northwest Territories,Office Furnishings,0.55
|
||||
97,Newell 326,Doug Bickford,10535,-0.79,1.76,0.7,Northwest Territories,Pens & Art Supplies,0.56
|
||||
98,Prismacolor Color Pencil Set,Jamie Kunitz,10789,76.42,19.84,4.1,Northwest Territories,Pens & Art Supplies,0.44
|
||||
99,Xerox Blank Computer Paper,Anthony Johnson,10791,93.36,19.98,5.77,Northwest Territories,Paper,0.38
|
||||
100,600 Series Flip,Ralph Knight,10945,4.22,95.99,8.99,Northwest Territories,Telephones and Communication,0.57
|
|
@ -0,0 +1,13 @@
|
||||
import argparse
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Argparse demo: accept running this script with options like command tools.
|
||||
parser = argparse.ArgumentParser(description="Demonstration argument parser")
|
||||
parser.add_argument("--plop", required=True, help="Argument inutile", type=int)
|
||||
parser.add_argument("--plip", required=False, default=None, help="Autre argument inutile", type=int)
|
||||
options = parser.parse_args()
|
||||
|
||||
print(options)
|
||||
print(options.plip)
|
||||
print(options.plop)
|
||||
print(options.__dict__)
|
32
training/exercices/02-language-basics/01-prints.asciidoc
Normal file
32
training/exercices/02-language-basics/01-prints.asciidoc
Normal file
@ -0,0 +1,32 @@
|
||||
= Exercices sur la fonction `print()`
|
||||
|
||||
== Exercice 1
|
||||
|
||||
Affichez dans la console le texte suivant :
|
||||
|
||||
- La rue Rostand,
|
||||
- `3 espaces` se trouve au
|
||||
- Feu à droite
|
||||
|
||||
== Exercice 2
|
||||
|
||||
La fonction `print()` accepte plusieurs arguments, dont les valeurs sont affichées sur la même ligne, et par défaut séparés par un espace.
|
||||
|
||||
*La syntaxe est la suivante* : `print("a", "b", "c", 19)`
|
||||
|
||||
Affichez, en imitant cette syntaxe, le texte suivant :
|
||||
|
||||
* Hauts les cœurs !
|
||||
|
||||
(sous Linux, le e dans l'o s'obtient avec la combinaison de touches `Alt Gr + O`. Sous Windows, `Alt + 339` devrait donner le même résultat)
|
||||
|
||||
== Exercice A1
|
||||
|
||||
La fonction `print()` accepte des arguments avec des noms spécifiques, dont `sep` et `end`. `sep` permet de désigner quelle chaîne sépare les arguments à afficher, et `end` permet de préciser par quelle chaîne terminer le `print`.
|
||||
Par défaut, `sep=" "` et `end="\n"`. La fonction s'utiliserait ainsi :
|
||||
|
||||
```python
|
||||
# Ne sépare pas les éléments via un espace et passe deux fois
|
||||
# à la ligne à la fin du print.
|
||||
print("1", "2", "3", sep="", end="\n\n")
|
||||
```
|
70
training/exercices/02-language-basics/02-variables.asciidoc
Normal file
70
training/exercices/02-language-basics/02-variables.asciidoc
Normal file
@ -0,0 +1,70 @@
|
||||
= Variables
|
||||
|
||||
---
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Déclarez trois variables, avec des noms corrects, contenant :
|
||||
* Le nom d'une personne, ex. "Paul"
|
||||
* La température courante en °C, ex. 25.3
|
||||
* L'âge d'une personne, ex. 30
|
||||
- Affichez dans la console les valeurs de ces trois variables.
|
||||
|
||||
---
|
||||
|
||||
== Exercice 2
|
||||
|
||||
- Demandez à l'utilisateur de saisir du texte, et mettez-le dans une variable
|
||||
- Affichez le contenu de la variable.
|
||||
|
||||
*Fonctions nécessaires* : `variable = input("Texte d'invite:")`, `print()`
|
||||
|
||||
---
|
||||
|
||||
== Exercice 3 : Expressions
|
||||
|
||||
- Déclarez plusieurs variables, contenant le résultats de :
|
||||
* Une opération arithmétique entre nombres
|
||||
* Une comparaison entre nombres
|
||||
* Une opération d'addition entre deux chaînes
|
||||
* L'expression `(59 * 62 + 13) / 6.5`
|
||||
- Affichez leur contenu dans la console.
|
||||
|
||||
---
|
||||
|
||||
== Exercice A1 : Conversion en ordres de grandeur
|
||||
|
||||
- Déclarez une variable contenant une distance en mètres (au moins 1001, ex 4210)
|
||||
- Affichez le nombre de kilomètres dans cette valeur (nombre entier, ex. 4)
|
||||
- Afficher le nombre de mètres restants dans cette valeur (ex. 210)
|
||||
|
||||
*Outils nécessaires* : opérateurs `//` (division entière), `%` (modulo)
|
||||
|
||||
Vous pouvez afficher tout cela sur une ligne avec un seul appel à la fonction `print()`, par exemple :
|
||||
|
||||
```python
|
||||
kilometers = 5
|
||||
meters = 450
|
||||
print(kilometers, "kilomètres et", meters, "mètres.")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
== Exercice A2 : Deux ordres de grandeur
|
||||
|
||||
- Déclarez une variable contenant une masse en grammes (au moins 1 000 000)
|
||||
- Affichez le nombre de tonnes, de kilogrammes et de grammes dans cette masse.
|
||||
|
||||
Vous devrez utiliser les mêmes outils que dans l'exercice précédent, mais il
|
||||
y a deux ordres de grandeur à prendre en compte !
|
||||
|
||||
---
|
||||
|
||||
== Exercice A3 : Saisie de nombres
|
||||
|
||||
- Demandez à l'utilisateur de saisir deux nombres (en deux fois).
|
||||
- Indiquez quel est le nombre le plus grand qui a été saisi.
|
||||
|
||||
Sachant que la saisie récupérée est toujours une chaîne de caractères vous devez récupérer une version de la saisie qui est un nombre pour pouvoir faire des comparaisons intéressantes.
|
||||
|
||||
*Rappel* : pour récupérer un entier depuis une chaîne, utilisez `int(valeur)`
|
72
training/exercices/02-language-basics/03-conditions.asciidoc
Normal file
72
training/exercices/02-language-basics/03-conditions.asciidoc
Normal file
@ -0,0 +1,72 @@
|
||||
= Conditions
|
||||
|
||||
---
|
||||
|
||||
== Exercice 1 : `if` seul
|
||||
|
||||
- Déclarez une variable avec une valeur entière entre 1 et 6 (lancer de dé).
|
||||
- Affichez `"Lancer réussi !"` si la valeur est supérieure strictement à 4
|
||||
- Retestez votre code en changeant la valeur du lancer
|
||||
|
||||
---
|
||||
|
||||
== Exercice 2 : `if` seul, comparer du texte
|
||||
|
||||
- Déclarez une variable avec le texte `"Bonjour"`;
|
||||
- Affichez `"Bien le bonjour"` si votre variable est égale à `"bonjouR"`.
|
||||
|
||||
(Les majuscules ne sont pas placées ici par hasard, conservez-les)
|
||||
|
||||
---
|
||||
|
||||
== Exercice 2B : `if…else`
|
||||
|
||||
- Assignez à une variable le texte `"Bonjour"`;
|
||||
- Affichez `"Bien le bonjour"` si votre variable est égale à `"Bonjour"`;
|
||||
- Sinon, (dans tous les autres cas) afficher `"Je ne comprends pas !"`.
|
||||
|
||||
---
|
||||
|
||||
== Exercice 3 : `if…elif…else`
|
||||
|
||||
- Assignez à une variable un entier arbitraire entre 0 et 10 inclus;
|
||||
- Si cette valeur est d'au moins 9, afficher `"Élevé"`;
|
||||
- Sinon, si cette valeur est d'au moins 7, afficher `"Haut"`;
|
||||
- Sinon, si cette valeur est d'au moins 4, afficher `"Standard"`;
|
||||
- Sinon, afficher `"Bas"`.
|
||||
|
||||
---
|
||||
|
||||
== Exercice A1 : Multiples conditions
|
||||
|
||||
- Assignez à deux variables `a1` et `a2` des nombres entiers entre 0 et 10
|
||||
- Si `a1` est supérieur à 5 *et* `a2` est inférieur à 6, afficher `"OK"`
|
||||
- Sinon, afficher `"Valeurs incorrectes"`
|
||||
|
||||
---
|
||||
|
||||
== Exercice A2 (conditions avec `and` et `or`)
|
||||
|
||||
- Assignez à deux variables `a1` *et* `a2` des nombres entre 0 et 10
|
||||
- Si `a1` est supérieur à 5 *ou* `a2` est inférieur à 6, afficher `"Conditions suffisantes"`
|
||||
- Sinon, afficher `"Valeurs incorrectes"`
|
||||
|
||||
---
|
||||
|
||||
== Exercice A3
|
||||
|
||||
- Déclarez une variable de statut `is_on` contenant un booléen (`True` ou `False`)
|
||||
- Demandez à l'utilisateur de *saisir un texte*, et assignez-le à une variable `saisie`
|
||||
- Si `saisie` vaut "Marche" :
|
||||
* Si `is_on` est `False`, alors afficher "Allumage en cours..."
|
||||
* Sinon, afficher "Déjà allumé !"
|
||||
- Sinon, si `saisie` vaut "Arrêt" :
|
||||
* Si `is_on` est `True`, afficher "Extinction..."
|
||||
* Sinon, afficher "Déjà éteint !"
|
||||
|
||||
Exemple de rappel :
|
||||
|
||||
```python
|
||||
# Demander de saisir un texte et récupérer le résultat dans une variable
|
||||
saisie = input("Saisissez du texte :")
|
||||
```
|
@ -0,0 +1,6 @@
|
||||
= Exercices sur les blocs vides
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Écrivez un bloc `if` dont le code, lorsqu'il est exécuté, ne fait rien.
|
||||
- *Outils* : `pass`
|
17
training/exercices/02-language-basics/05-for-loop.asciidoc
Normal file
17
training/exercices/02-language-basics/05-for-loop.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
= Exercices sur les boucles `for`
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Écrivez une boucle `for` sur les nombres de 0 à 9.
|
||||
- Affichez la valeur du nombre parcouru.
|
||||
|
||||
== Exercice 2
|
||||
|
||||
- Écrivez une boucle `for` sur les nombres de 0 à 9.
|
||||
- Affichez la valeur du nombre s'il est pair (`nombre % 2 == 0`)
|
||||
|
||||
== Exercice A1
|
||||
|
||||
- Écrivez une boucle `for` sur les nombres de 0 à 9 (variable nommée `item1`).
|
||||
- Dans cette boucle, écrivez une autre boucle sur les nombres de 0 à `item1` (variable `item2`)
|
||||
- Dans cette sous-boucle, affichez sur la même ligne `item1` et `item2`.
|
22
training/exercices/02-language-basics/06-while-loop.asciidoc
Normal file
22
training/exercices/02-language-basics/06-while-loop.asciidoc
Normal file
@ -0,0 +1,22 @@
|
||||
= Exercices sur les boucles `while`
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Déclarer une variable `number` égale à 10
|
||||
- Écrivez une boucle `while` tournant tant que `number` est supérieur ou égal à 0.
|
||||
- Dans la boucle, afficher `number`, et retirer `1` à `number`.
|
||||
|
||||
== Exercice 2
|
||||
|
||||
- Écrire une boucle `while` qui tourne indéfiniment (condition `True`, ou soyez créatif)
|
||||
|
||||
== Exercice 3
|
||||
|
||||
- Écrire une boucle `while` qui ne se lance jamais (condition `False`, ou soyez créatif)
|
||||
- (il suffit que la condition soit fausse dès le départ)
|
||||
|
||||
== Exercice A1 : Fibonacci
|
||||
|
||||
- Écrire du code, affichant dans la console, les éléments successifs de la suite de Fibonacci jusqu'à 10 000 :
|
||||
* Utiliser deux variables, `left` and `right` qui vont, au départ, contenir les deux premiers éléments de la suite.
|
||||
* Dans la boucle, modifier `left` and `right` pour ne garder que les deux derniers éléments de la suite.
|
60
training/exercices/02-language-basics/07-lists.asciidoc
Normal file
60
training/exercices/02-language-basics/07-lists.asciidoc
Normal file
@ -0,0 +1,60 @@
|
||||
= Exercices sur les listes
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Écrivez une liste contenant les nombres entiers pairs de 0 à 10 inclus
|
||||
- Assignez la longueur de la liste à une variable (`len()`)
|
||||
- Affichez le dernier élément de la liste (en utilisant la longueur)
|
||||
- Ajoutez un élément à la fin de la liste
|
||||
- Affichez le nouveau contenu de la liste
|
||||
|
||||
== Exercice 2
|
||||
|
||||
- Écrivez une liste contenant les nombres 1, 2, 4, 8, 16, 32, 64
|
||||
- Supprimez de la liste le nombre 8
|
||||
- Ajoutez à la fin de la liste le nombre 128
|
||||
- Affichez le contenu de la liste dans la console.
|
||||
|
||||
== Exercice 3 (indices négatifs)
|
||||
|
||||
- Écrivez une liste contenant 3 éléments
|
||||
- Affichez le *dernier* élément en utilisant un indice négatif
|
||||
- Affichez le *premier* élément en utilisant un indice négatif
|
||||
|
||||
== Pré-Exercice 4 (slicing)
|
||||
|
||||
[source,python]
|
||||
----
|
||||
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
b = a[0:5] # Index 0 à 5 non inclus. Marche aussi sur les chaînes.
|
||||
c = a[5:0] # L'index de fin est inférieur au départ, renvoie une liste vide
|
||||
f = a[:] # Renvoie toute la liste
|
||||
d = a[::-1] # Tout parcourir à l'envers
|
||||
e = a[::2] # Tout parcourir 2 par 2
|
||||
----
|
||||
|
||||
|
||||
== Exercice 4 (slicing)
|
||||
|
||||
- Écrivez une liste de 6 nombres
|
||||
- Affichez la liste comprenant les 3 premiers éléments
|
||||
- Affichez la liste comprenant tout sauf le premier élément
|
||||
|
||||
== Exercice 5 (slicing avancé)
|
||||
|
||||
- Réutilisez la liste de l'exercice 4
|
||||
- Affichez toute la liste, mais à l'envers
|
||||
- Affichez une liste comprenant les éléments aux indices pairs
|
||||
|
||||
== Exercice A1
|
||||
|
||||
- Écrivez une liste contenant les nombres multiples de 3 de 0 à 15.
|
||||
- Faites une boucle `for` sur cette liste,
|
||||
* et affichez uniquement les nombres pairs de cette liste (`valeur % 2 == 0`)
|
||||
|
||||
== Exercice A2
|
||||
|
||||
- Consultez la https://docs.python.org/3/tutorial/datastructures.html#more-on-lists[référence des fonctions de listes]
|
||||
- Déclarez une liste de nombres flottants
|
||||
- Utilisez la méthode qui sert à renvoyer le dernier élément et le supprimer de la liste
|
||||
- Affichez cet élément, puis la liste
|
42
training/exercices/02-language-basics/08-sets.asciidoc
Normal file
42
training/exercices/02-language-basics/08-sets.asciidoc
Normal file
@ -0,0 +1,42 @@
|
||||
= Exercices sur les ensembles
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Écrivez un `set` contenant 5 valeurs
|
||||
- Déclarez un second `set` contenant au moins 2 valeurs du premier set
|
||||
- Essayez d'ajouter une valeur déjà existante à un set
|
||||
- Affichez les valeurs communes aux deux sets (`intersection()`)
|
||||
- Affichez un set contenant toutes les valeurs des 2 sets (`union()`)
|
||||
|
||||
== Exercice 2 (conversion)
|
||||
|
||||
- Écrivez une *liste* contenant des valeurs en doublons
|
||||
- Affichez le contenu de la liste
|
||||
- Assignez à une variable la conversion de la liste en set (`set(x)`)
|
||||
- Affichez la valeur du set obtenu
|
||||
|
||||
== Exercice 3
|
||||
|
||||
Al et Kim sont inscrits sur un réseau social. Al a les amis suivants :
|
||||
|
||||
- Josephine
|
||||
- Meghan
|
||||
- Amy
|
||||
- Bob
|
||||
|
||||
Kim a les amis suivants :
|
||||
|
||||
- Frank
|
||||
- Amy
|
||||
- Josephine
|
||||
- Susan
|
||||
|
||||
Quels sont leurs amis en commun ? Écrivez un code qui représente et résout cet énoncé.
|
||||
|
||||
== Exercice 4
|
||||
|
||||
Partant du tuple suivant :
|
||||
|
||||
`(1, 4, 6, 9, 1, 3, 6, 12, 2, 5, 7, 10, 3, 5, 2, 6, 4, 6, 1, 8, 5, 2, 3, 6)`
|
||||
|
||||
- Affichez le nombre de valeurs différentes présentes dans le tuple.
|
@ -0,0 +1,40 @@
|
||||
= Exercices sur les dictionnaires
|
||||
|
||||
== Exercice 1
|
||||
|
||||
- Écrivez un simple dictionnaire associant des noms à des âges :
|
||||
* Paul → 30
|
||||
* Karim → 22
|
||||
* Gina → 41
|
||||
* Anna → 25
|
||||
- Affichez l'âge de Gina
|
||||
- Ajoutez les associations suivantes :
|
||||
* Alina → 33
|
||||
* Victor → 55
|
||||
- Affichez le contenu du dictionnaire
|
||||
|
||||
== Exercice 2 (parcours)
|
||||
|
||||
- Réutilisez votre dictionnaire
|
||||
- Utilisez une boucle `for` normale pour :
|
||||
* Afficher les clés du dictionnaire
|
||||
* Afficher la valeur associée à chaque clé
|
||||
|
||||
== Exercice 3 (parcours + `.items()`)
|
||||
|
||||
- Réutilisez votre dictionnaire
|
||||
- Utilisez une boucle `for` sur `.items()` avec deux variables :
|
||||
* Affichez clé et valeur associée
|
||||
|
||||
== Exercice A1 (compréhension)
|
||||
|
||||
- Déclarez un dictionnaire de conditions météo (°C, condition, pression)
|
||||
* `meteo = {"Pau": (21.0, "Nuageux", 1015), "Gap": (20.3, "Dégagé", 1019), "Osny": (19.1, "Brouillard", 1015)}`
|
||||
- À l'aide d'une compréhension de dictionnaire, récupérer un dictionnaire :
|
||||
* Dont les clés sont les mêmes noms de villes
|
||||
* Dont les valeurs sont uniquement la température associée
|
||||
|
||||
== Exercice A2 (compréhensions)
|
||||
|
||||
- Déclarez une liste via une compréhension, qui contient les nombres pairs de 0 à 98, sauf ceux divisibles par 5. (comprendre, uniquement ceux non divisibles par 5).
|
||||
- Déclarez une liste de mots manuellement. Puis déclarez un générateur (compréhension de tuple) qui contient uniquement les mots de plus de 4 lettres. (`len()`).
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user