Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Christoph Pirkl <[email protected]>
Co-authored-by: Nicola Coretti <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2023
1 parent a54ec1a commit 678fe82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
23 changes: 2 additions & 21 deletions secret-store/secret_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _use_master_password(self) -> None:
sanitized = self.master_password.replace("'", "\\'")
self.cursor().execute(f"PRAGMA key = '{sanitized}'")

def cursor(self) -> sqlcipher.Cursor:
def _cursor(self) -> sqlcipher.Cursor:
if self._cur is None:
self._cur = self.connection().cursor()
return self._cur
Expand Down Expand Up @@ -109,7 +109,7 @@ def save(self, key: str, data: Union[str, Credentials]) -> "Secrets":
return self._save_data(SECRETS_TABLE, key, [data.user, data.password])
raise Exception("Unsupported type of data: " + type(data).__name__)

def _get_data(self, table: Table, key: str) -> Optional[list[str]]:
def _data(self, table: Table, key: str) -> Optional[list[str]]:
columns = ", ".join(table.columns)
res = self.cursor().execute(
f"SELECT {columns} FROM {table.name} WHERE key=?",
Expand All @@ -124,22 +124,3 @@ def get_config_item(self, key: str) -> Optional[str]:
row = self._get_data(CONFIG_ITEMS_TABLE, key)
return row[0] if row else None


# def sample_usage():
# secrets = Secrets("mydb.db", master_password="my secret master password")
#
# c = secrets.get_credentials("aws")
# print(f'old value of aws credentials {c}')
# secrets.save("aws", Credentials("user-a", "pwd-aaa"))
# c = secrets.get_credentials("aws")
# print(f'aws credentials: {c}')
#
# c = secrets.get_config_item("url")
# print(f'old value of config item "url" {c}')
# secrets.save("url", "http://def")
# c = secrets.get_config_item("url")
# print(f'config item url: {c}')
#
#
# if __name__ == "__main__":
# sample_usage()
2 changes: 1 addition & 1 deletion secret-store/test/test_secret_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


@pytest.fixture
def sample_file(tmp_path) -> Path:
def sample_file(tmp_path: Path) -> Path:
return tmp_path / "sample_database.db"


Expand Down

0 comments on commit 678fe82

Please sign in to comment.