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