Skip to content

Commit a11463b

Browse files
committed
Add BREAKLINE constant and update raw property formatting in models
1 parent dda6874 commit a11463b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

codetide/core/defaults.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@
5252

5353
DEFAULT_SERIALIZATION_PATH = "./storage/tide.json"
5454
DEFAULT_CACHED_ELEMENTS_FILE = "cached_elements.json"
55-
DEFAULT_CACHED_IDS_FILE = "cached_ids.json"
55+
DEFAULT_CACHED_IDS_FILE = "cached_ids.json"
56+
57+
BREAKLINE = "\n"

codetide/core/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .common import CONTEXT_INTRUCTION, TARGET_INSTRUCTION, wrap_content
2+
from .defaults import BREAKLINE
23
from .logs import logger
34

45
from pydantic import BaseModel, Field, computed_field, field_validator
@@ -256,7 +257,7 @@ class PartialClasses(BaseModel):
256257

257258
@property
258259
def raw(self)->str:
259-
return f"{self.class_header}\n{'\n'.join(self.attributes)}\n{'\n\n'.join(self.methods)}" # noqa: E999
260+
return f"{self.class_header}{BREAKLINE}{BREAKLINE.join(self.attributes)}{BREAKLINE}{(2*BREAKLINE).join(self.methods)}" # noqa: E999
260261

261262
class CodeContextStructure(BaseModel):
262263
imports :Dict[str, ImportStatement] = Field(default_factory=dict)
@@ -352,7 +353,7 @@ def as_list_str(self)->List[List[str]]:
352353
for requested_elemtent in self.requested_elements:
353354
if isinstance(requested_elemtent, (ClassAttribute, MethodDefinition)):
354355
classObj :ClassDefinition = self._cached_elements.get(requested_elemtent.class_id)
355-
requested_elemtent.raw = f"{classObj.raw.split('\n')[0]}\n ...\n\n{requested_elemtent.raw}"
356+
requested_elemtent.raw = f"{classObj.raw.split(BREAKLINE)[0]}{BREAKLINE} ...{2*BREAKLINE}{requested_elemtent.raw}"
356357

357358
wrapped_list = [
358359
[

0 commit comments

Comments
 (0)