-
Notifications
You must be signed in to change notification settings - Fork 0
Mvr/#15/conversation handler #24
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
base: dev
Are you sure you want to change the base?
Changes from all commits
81826b7
87588fb
fe78725
9b7dade
52b2cc5
209969e
b5f810f
a0418a9
529297a
9cc6083
04073a0
de72995
4080a33
657c9e0
eebb216
52c03bb
7bdcc71
452fc4d
2f691fa
96d1da7
eb4f98c
450f21d
2d8b547
44ffeb7
edc539b
e6b7c6f
cb5a6e9
3dd2342
43e1a9d
2716e3a
08e8fdf
df49c24
c1876d8
ee88cce
d4b94cc
09b7529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import os | ||
| import platform | ||
| import uuid | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def get_config_dir() -> Path: | ||
| """Cross-platform config directory.""" | ||
| system = platform.system() | ||
|
|
||
| if system == "Windows": | ||
| # TODO: To be tested -> also consider language-specific if needed | ||
| base = os.environ.get("APPDATA", os.path.expanduser("~/AppData/Roaming")) | ||
| elif system == "Darwin": | ||
| # TODO: To be tested -> also consider language-specific if needed | ||
| base = os.path.expanduser("~/Library/Application Support") | ||
| else: | ||
| base = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) | ||
|
|
||
| config_dir = Path(base) / "huri" | ||
| config_dir.mkdir(parents=True, exist_ok=True) | ||
| return config_dir | ||
|
|
||
|
|
||
| def load_user_id(path: str | None = None) -> str | None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. je trouve ca plus logique de le laisser dans la classe Client
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pas d accord
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh je vois ce que tu veux dire Pour moi le client c'est une instance et le user c'est genre la mémoire etc. donc un user peut avoir plusieur client similaire en meme temps
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bah plusieurs client ont la meme url de HuRI, pourtant on met huri-url dans le config ? |
||
| """Load existing _user_id, or return None if new user.""" | ||
| id_file: Path | ||
|
|
||
| if path is None: | ||
| id_file = get_config_dir() / "_user_id" | ||
| else: | ||
| id_file = Path(path) | ||
| if id_file.exists(): | ||
| uid = id_file.read_text().strip() | ||
| if uid: | ||
| return uid | ||
| return None | ||
|
|
||
|
|
||
| def save_user_id(_user_id: str, path: str | None = None): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cette fonction aussi
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same qu au dessus |
||
| id_file: Path | ||
|
|
||
| if path is None: | ||
| id_file = get_config_dir() / "_user_id" | ||
| else: | ||
| id_file = Path(path) | ||
|
|
||
| id_file.write_text(_user_id) | ||
| if platform.system() != "Windows": | ||
| id_file.chmod(0o600) | ||
|
|
||
|
|
||
| def get_or_create_user_id(path: str | None = None) -> str: | ||
| """Load existing or generate new _user_id.""" | ||
| uid = load_user_id(path) | ||
| if uid: | ||
| return uid | ||
| uid = str(uuid.uuid4()) | ||
| save_user_id(uid, path) | ||
| return uid | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok je pensais que tu voulais mettre le user_id_file dans le config/client.yaml