fix: tangle.py write-once-then-append logic (was always-appending, triplicating files); confirm-dialog option plist comparison; mouse-event button type (or keyword null)
This commit is contained in:
@@ -18,6 +18,7 @@ def tangle_file(org_path):
|
||||
)
|
||||
|
||||
count = 0
|
||||
block_count = {}
|
||||
for match in pattern.finditer(text):
|
||||
lang = match.group(1)
|
||||
header = match.group(2)
|
||||
@@ -42,14 +43,18 @@ def tangle_file(org_path):
|
||||
if tangle_path == 'no':
|
||||
continue
|
||||
|
||||
# Write the content (append if same file already written)
|
||||
# Write the content (write mode — each run produces clean files)
|
||||
content = content.rstrip('\n') + '\n'
|
||||
if os.path.exists(target):
|
||||
if os.path.exists(target) and block_count.get(target, 0) == 0:
|
||||
with open(target, 'w') as f:
|
||||
f.write(content)
|
||||
elif os.path.exists(target):
|
||||
with open(target, 'a') as f:
|
||||
f.write('\n' + content)
|
||||
else:
|
||||
with open(target, 'w') as f:
|
||||
f.write(content)
|
||||
block_count[target] = block_count.get(target, 0) + 1
|
||||
print(f" {target} ({len(content)} bytes)")
|
||||
count += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user