mirror of
https://github.com/The-Pocket/PocketFlow-Tutorial-Codebase-Knowledge.git
synced 2026-08-30 00:50:32 +08:00
fix: improve file filtering, add new utility,
- Improved the speed of file filtering in `crawl_local_files.py` with folder-level exclusion - Added `fix_yaml.py` utility for YAML indentation fixes - Updated `nodes.py` to support up to 20 core abstractions - add option for no cache.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import re
|
||||
|
||||
def add_indentation(text):
|
||||
# This pattern matches lines that don't start with a hyphen or whitespace
|
||||
pattern = r'^(?![-\s])(.*)$'
|
||||
|
||||
# Replace with 4 spaces followed by the captured content
|
||||
result = re.sub(pattern, r' \1', text, flags=re.MULTILINE)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Example usage
|
||||
text = """This line will be indented
|
||||
- This line won't be indented
|
||||
This line won't be indented either
|
||||
Another line that will be indented"""
|
||||
|
||||
indented_text = add_indentation(text)
|
||||
Reference in New Issue
Block a user