Skip to content

Commit 9c1e5fc

Browse files
committed
feat: 리소스 경로 함수 추가 및 프롬프트 템플릿 경로 수정
1 parent e4f22d7 commit 9c1e5fc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

commitgen/config.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
import sys
12
import os
23
import json
34
import yaml
45

6+
7+
def resource_path(relative_path):
8+
if hasattr(sys, '_MEIPASS'):
9+
return os.path.join(sys._MEIPASS, relative_path)
10+
return os.path.join(os.path.abspath("."), relative_path)
11+
12+
513
def load_api_key():
614
path = os.path.join(os.path.expanduser("~/.api_keys"), "openai.json")
715
if not os.path.exists(path):
@@ -11,9 +19,10 @@ def load_api_key():
1119
return data["api_key"]
1220

1321

14-
def load_prompt_template(path: str = './prompt_template.yml'):
15-
if not os.path.exists(path):
22+
def load_prompt_template(path: str = 'prompt_template.yml'):
23+
full_path = resource_path(path)
24+
if not os.path.exists(full_path):
1625
raise FileNotFoundError(f"❌ Prompt template not found: {path}")
17-
with open(path, "r", encoding='utf-8') as f:
26+
with open(full_path, "r", encoding='utf-8') as f:
1827
config = yaml.safe_load(f)
1928
return config['commit_format'], config['commit_type']

0 commit comments

Comments
 (0)