@@ -469,21 +469,22 @@ def add_data_directories(
469469 key : str , field : ModelField , debug : bool = False
470470) -> dict [str , str ]:
471471 def get_directory () -> Optional [Path ]:
472+ message = "What is the full file path to the data directory you wish to add?"
472473 answer = prompt (
473- "What is the full file path to the data directory you wish to add?" ,
474+ message ,
474475 style = "yellow" ,
475- )
476+ ). strip ()
476477 # Convert "" into None
477478 if not answer :
478479 return None
479480 return Path (answer )
480481
481482 def get_directory_type ():
482- answer = prompt (
483+ message = (
483484 "What type of data is stored in this directory? Options: 'microscope', "
484- "'detector'" ,
485- style = "yellow" ,
486- ).lower ()
485+ "'detector'"
486+ )
487+ answer = prompt ( message , style = "yellow" ).lower (). strip ()
487488 if answer not in ("microscope" , "detector" ):
488489 console .print ("Invalid directory type." , style = "red" )
489490 if ask_for_input ("directory type" , True ) is True :
@@ -532,6 +533,70 @@ def get_directory_type():
532533 return {}
533534
534535
536+ def add_create_directories (
537+ key : str , field : ModelField , debug : bool = False
538+ ) -> dict [str , str ]:
539+ def get_folder () -> str :
540+ message = (
541+ "Please input the name of the folder for Murfey to create. Press Enter "
542+ "to skip this."
543+ )
544+ answer = prompt (message , style = "yellow" ).lower ().strip ()
545+ if bool (re .fullmatch (r"[\w\s\-]*" , answer )) is False :
546+ console .print (
547+ "There are unsafe characters present in this folder name. Please "
548+ "use a different one." ,
549+ style = "red" ,
550+ )
551+ if ask_for_input ("folder name" , True ) is True :
552+ return get_folder ()
553+ return ""
554+ return answer
555+
556+ def get_folder_alias () -> str :
557+ message = "Please enter the name you want to map this folder to within Murfey."
558+ answer = prompt (message , style = "yellow" ).lower ().strip ()
559+ if bool (re .fullmatch (r"[\w\s\-]*" , answer )) is False :
560+ console .print (
561+ "There are unsafe characters present in this folder name. Please "
562+ "use a different one." ,
563+ style = "red" ,
564+ )
565+ if ask_for_input ("folder alias" , True ) is True :
566+ return get_folder_alias ()
567+ return ""
568+ return answer
569+
570+ """
571+ Start of add_create_directories
572+ """
573+ print_field_info (field )
574+ directories_to_create : dict [str , str ] = {}
575+ category = "directory for Murfey to create"
576+ add_directory : bool = ask_for_input (category , False )
577+ while add_directory is True :
578+ folder_name = get_folder ()
579+ if not folder_name :
580+ console .print (
581+ "No folder name provided" ,
582+ style = "red" ,
583+ )
584+ add_directory = ask_for_input (category , True )
585+ continue
586+ folder_alias = get_folder_alias ()
587+ if not folder_alias :
588+ console .print (
589+ "No folder alias provided" ,
590+ style = "red" ,
591+ )
592+ add_directory = ask_for_input (category , True )
593+ continue
594+ directories_to_create [folder_alias ] = folder_name
595+ add_directory = ask_for_input (category , True )
596+ continue
597+ return directories_to_create
598+
599+
535600def set_up_data_transfer (config : dict , debug : bool = False ) -> dict :
536601 return config
537602
@@ -574,10 +639,10 @@ def set_up_machine_config(debug: bool = False):
574639 # End of software block
575640
576641 if key == "data_directories" :
577- # TODO
578642 new_config [key ] = add_data_directories (key , field , debug )
579643 continue
580644 if key == "create_directories" :
645+ new_config [key ] = add_create_directories (key , field , debug )
581646 # TODO
582647 continue
583648 if key == "analyse_created_directories" :
0 commit comments