diff --git a/src/osw/auth.py b/src/osw/auth.py index 9ebbeea..ab969b3 100644 --- a/src/osw/auth.py +++ b/src/osw/auth.py @@ -321,11 +321,13 @@ def save_credentials_to_file( else: # Test if the default_path.osw_files_dir is a subdirectory of the # directory containing the .gitignore file - to_add = f"\n*{default_paths.osw_files_dir.absolute().as_posix()}/*" + to_add = ( + f"\n*/{default_paths.osw_files_dir.absolute().as_posix()}/*" + ) osw_dir_added = True - elif fp.name not in content: + elif f"*/{fp.name}" not in content: print(f"Adding '{fp.name}' to gitignore file '{gitignore_fp}'.") - to_add = f"\n*{fp.name}" + to_add = f"\n*/{fp.name}" # If to_add is not empty, write to .gitignore file if to_add: with open(gitignore_fp, "a") as stream: diff --git a/src/osw/defaults.py b/src/osw/defaults.py index 8b396f7..66dfe7e 100644 --- a/src/osw/defaults.py +++ b/src/osw/defaults.py @@ -71,6 +71,10 @@ class Paths(OswBaseModel): _changed: List[str] = PrivateAttr(default_factory=list) """A flag to indicate if any of the paths have been changed.""" + def __init__(self, **data): + super().__init__(**data) + self._changed = [key for key in data.keys() if key != "_changed"] + def __setattr__(self, name, value): old_value = getattr(self, name) super().__setattr__(name, value) @@ -81,6 +85,10 @@ def __setattr__(self, name, value): def has_changed(self, name): return name in self._changed + @property + def changed(self): + return self._changed + def on_attribute_set(self, attr_name, new_value, old_value): """ This method is called every time an attribute is set. It is used to update the @@ -136,19 +144,27 @@ class Params(OswBaseModel): _changed: List[str] = PrivateAttr(default_factory=list) """A flag to indicate if any of the parameters have been changed.""" - @validator("wiki_domain") - def validate_wiki_domain(cls, v): - pattern = r"^(?!-)[A-Za-z0-9.-]{1,63}(?