Get the list of available patterns from the specified directory.
()
| 353 | |
| 354 | |
| 355 | def get_patterns(): |
| 356 | """Get the list of available patterns from the specified directory.""" |
| 357 | if not os.path.exists(pattern_dir): |
| 358 | st.error(f"Pattern directory not found: {pattern_dir}") |
| 359 | return [] |
| 360 | try: |
| 361 | patterns = [ |
| 362 | item |
| 363 | for item in os.listdir(pattern_dir) |
| 364 | if os.path.isdir(os.path.join(pattern_dir, item)) |
| 365 | ] |
| 366 | return patterns |
| 367 | except PermissionError: |
| 368 | st.error(f"Permission error accessing pattern directory: {pattern_dir}") |
| 369 | return [] |
| 370 | except Exception as e: |
| 371 | st.error(f"An unexpected error occurred: {e}") |
| 372 | return [] |
| 373 | |
| 374 | |
| 375 | def create_pattern( |