Fixed display of database color

Closes #2139, closes #2119
This commit is contained in:
Simon Willison 2023-08-10 22:16:19 -07:00
commit 4535568f2c
11 changed files with 39 additions and 18 deletions

View file

@ -1,6 +1,7 @@
import asyncio
from collections import namedtuple
from pathlib import Path
import hashlib
import janus
import queue
import sys
@ -62,6 +63,12 @@ class Database:
}
return self._cached_table_counts
@property
def color(self):
if self.hash:
return self.hash[:6]
return hashlib.md5(self.name.encode("utf8")).hexdigest()[:6]
def suggest_name(self):
if self.path:
return Path(self.path).stem