Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 first stable release #2

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/sample.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
nom_batterie,pui_batterie_mAh,tension_V,poids_g,prix_euro
nom batterie,puissance (mAh),tension (V),poids (grammes),prix (euros)
AFG90EH,2500,3.7,45,12.99
XF1AKPGM,3500,3.6,50,19.99
LMG3P7EQ,2000,3.8,40,9.99
Expand Down
28 changes: 18 additions & 10 deletions src/bot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,26 @@ def __init__(self):
)

else:
# nom_batterie,pui_batterie_mAh,tension_V,poids_g,prix_euro
# get each column of the csv file
# header is in the form of:
# name of the column (unit if any)
raw_context = pd.read_csv(filename)
self.context += "".join(
(
f"nom batterie: {row['nom_batterie']}, "
f"puissance {row['pui_batterie_mAh']} mAh, "
f"tension {row['tension_V']} V, "
f"poids {row['poids_g']} grammes, "
f"prix {row['prix_euro']} euros ;\n"
for _, row in raw_context.iterrows()
header = raw_context.columns
# make a dict with the part of the header that is the name as key and the unit as value
# if no unit, value is None
units = {
col.split("(")[0].strip(): col.split("(")[1][:-1].strip()
if "(" in col
else ""
for col in header
}
for row in raw_context.iterrows():
self.context += "".join(
# if ValueError, you might want to check encoding and delimiter of the csv file
f"{scol} {row[1][col]} {units[scol]}, "
for col, scol in zip(header, units, strict=True)
)
)
self.context += ";\n"

self.logger.debug(f"context is being displayed\n\n---\n{self.context}\n---\n")
self.logger.info("Context loaded")
Expand Down
10 changes: 3 additions & 7 deletions src/helper/cli/gp_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ def gp_parser() -> ArgumentParser:
)

subparsers = parser.add_subparsers(dest="command", help="command to run")
subparsers.add_parser("run", help="run app")
subparsers.add_parser("do", help="do something")

run_parser = subparsers.add_parser("run", help="run app")
run_parser.add_argument("-d", "--debug", action="store_true", help="debug mode")
run_parser.add_argument(
"-r", "--release", action="store_true", help="release mode", default=True
)
run_parser.add_argument("-r", "--release", action="store_true", help="release mode")

do_parser = subparsers.add_parser("do", help="do something")
do_parser = subparsers.add_parser("do", help="perform action")
do_subparsers = do_parser.add_subparsers(dest="action", help="action to do")
scrap_parser = do_subparsers.add_parser("scrap", help="scrap data")
scrap_parser.add_argument(
Expand Down Expand Up @@ -57,7 +53,7 @@ def check_args(self, nsp: Namespace) -> "App":
if nsp.command == "run":
if nsp.debug:
if nsp.release:
raise RuntimeError("debug and release are mutually exclusive")
raise RuntimeError("--debug and --release are mutually exclusive")
self.__args.debug = True

elif nsp.command == "do":
Expand Down