## Summary epic r04 - begin refactor ## Change Type - [x] Cowork feature - [ ] Bug fix - [ ] Core AI contribution - [ ] Test / hardening - [ ] Performance - [ ] Documentation ## Related Work Cowork Task: Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets Core AI Issue: Core Task: Related PR: ## Scope What is intentionally included? What is intentionally NOT included? ## Validation - [ ] Unit tests - [ ] Integration tests - [ ] Manual verification - [ ] Regression check Commands / evidence: ## Security Impact Permission / credential / network / customer data impact: ## Compatibility - [ ] No breaking change - [ ] Breaking change documented ## Reviewer Notes Anything Cowork reviewers should pay attention to. --------- Co-authored-by: Anh Tran Nguyen Minh <anhtnm1@fpt.com> Co-authored-by: Huong Le Thi Thien <huongltt35@fpt.com> Co-authored-by: Nam Pham Dinh Thanh <nampdt@fpt.com> Co-authored-by: Vu Dam Tuan <vudt15@fpt.com> Co-authored-by: Hiep Ha Van <hiephv3@fpt.com> Co-authored-by: Lam Hoang Van <lamhv7@fpt.com> Reviewed-on: #7 Co-authored-by: Duy Le Huu <duylh19@fpt.com>
This commit was merged in pull request #7.
This commit is contained in:
@@ -73,6 +73,7 @@ def auto_chain_in_order(tasks: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
|
||||
# ---- CSV -----------------------------------------------------------------
|
||||
def _import_csv(path: Path) -> List[Dict[str, Any]]:
|
||||
"""Đọc danh sách task từ file CSV (chấp nhận BOM của Excel)."""
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8-sig")
|
||||
except OSError as exc:
|
||||
@@ -111,6 +112,7 @@ def _import_csv(path: Path) -> List[Dict[str, Any]]:
|
||||
|
||||
# ---- JSON ----------------------------------------------------------------
|
||||
def _import_json(path: Path) -> List[Dict[str, Any]]:
|
||||
"""Đọc danh sách task từ file JSON."""
|
||||
try:
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError) as exc:
|
||||
@@ -138,6 +140,11 @@ def _import_json(path: Path) -> List[Dict[str, Any]]:
|
||||
|
||||
|
||||
def _pick(d: Dict[str, Any], *keys, default=""):
|
||||
"""Lấy giá trị đầu tiên khác rỗng trong các khoá được nêu.
|
||||
|
||||
File nhập từ nhiều nguồn đặt tên cột khác nhau (``title``/``name``/``Tiêu đề``),
|
||||
nên phải thử lần lượt.
|
||||
"""
|
||||
for k in keys:
|
||||
if k in d and d[k] not in (None, ""):
|
||||
return d[k]
|
||||
@@ -145,6 +152,7 @@ def _pick(d: Dict[str, Any], *keys, default=""):
|
||||
|
||||
|
||||
def _clamp(value, allowed, default):
|
||||
"""Ép một giá trị về tập hợp lệ; ngoài tập thì lấy mặc định."""
|
||||
v = str(value or "").strip().lower()
|
||||
return v if v in allowed else default
|
||||
|
||||
@@ -213,6 +221,7 @@ _TRUE = {"yes", "y", "true", "1", "x", "có", "co"}
|
||||
|
||||
|
||||
def _truthy(value) -> bool:
|
||||
"""Đọc giá trị đúng/sai từ nhiều kiểu ghi khác nhau (bool, 'yes', '1', 'có'…)."""
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return str(value or "").strip().lower() in _TRUE
|
||||
|
||||
Reference in New Issue
Block a user