@@ -65,12 +65,35 @@ def event_dict(self) -> dict[str, Command]:
6565 return self ._commands
6666
6767
68- def build_default_registry () -> ActionRegistry :
69- """Return a registry pre-populated with every built-in ``FA_*`` action."""
68+ def _local_commands () -> dict [str , Command ]:
7069 from automation_file .local import dir_ops , file_ops , zip_ops
71- from automation_file .remote import http_download
72- from automation_file .remote .azure_blob import register_azure_blob_ops
73- from automation_file .remote .dropbox_api import register_dropbox_ops
70+
71+ return {
72+ # Files
73+ "FA_create_file" : file_ops .create_file ,
74+ "FA_copy_file" : file_ops .copy_file ,
75+ "FA_rename_file" : file_ops .rename_file ,
76+ "FA_remove_file" : file_ops .remove_file ,
77+ "FA_copy_all_file_to_dir" : file_ops .copy_all_file_to_dir ,
78+ "FA_copy_specify_extension_file" : file_ops .copy_specify_extension_file ,
79+ # Directories
80+ "FA_copy_dir" : dir_ops .copy_dir ,
81+ "FA_create_dir" : dir_ops .create_dir ,
82+ "FA_remove_dir_tree" : dir_ops .remove_dir_tree ,
83+ "FA_rename_dir" : dir_ops .rename_dir ,
84+ # Zip
85+ "FA_zip_dir" : zip_ops .zip_dir ,
86+ "FA_zip_file" : zip_ops .zip_file ,
87+ "FA_zip_info" : zip_ops .zip_info ,
88+ "FA_zip_file_info" : zip_ops .zip_file_info ,
89+ "FA_set_zip_password" : zip_ops .set_zip_password ,
90+ "FA_unzip_file" : zip_ops .unzip_file ,
91+ "FA_read_zip_file" : zip_ops .read_zip_file ,
92+ "FA_unzip_all" : zip_ops .unzip_all ,
93+ }
94+
95+
96+ def _drive_commands () -> dict [str , Command ]:
7497 from automation_file .remote .google_drive import (
7598 client ,
7699 delete_ops ,
@@ -80,58 +103,51 @@ def build_default_registry() -> ActionRegistry:
80103 share_ops ,
81104 upload_ops ,
82105 )
106+
107+ return {
108+ "FA_drive_later_init" : client .driver_instance .later_init ,
109+ "FA_drive_search_all_file" : search_ops .drive_search_all_file ,
110+ "FA_drive_search_field" : search_ops .drive_search_field ,
111+ "FA_drive_search_file_mimetype" : search_ops .drive_search_file_mimetype ,
112+ "FA_drive_upload_dir_to_folder" : upload_ops .drive_upload_dir_to_folder ,
113+ "FA_drive_upload_to_folder" : upload_ops .drive_upload_to_folder ,
114+ "FA_drive_upload_dir_to_drive" : upload_ops .drive_upload_dir_to_drive ,
115+ "FA_drive_upload_to_drive" : upload_ops .drive_upload_to_drive ,
116+ "FA_drive_add_folder" : folder_ops .drive_add_folder ,
117+ "FA_drive_share_file_to_anyone" : share_ops .drive_share_file_to_anyone ,
118+ "FA_drive_share_file_to_domain" : share_ops .drive_share_file_to_domain ,
119+ "FA_drive_share_file_to_user" : share_ops .drive_share_file_to_user ,
120+ "FA_drive_delete_file" : delete_ops .drive_delete_file ,
121+ "FA_drive_download_file" : download_ops .drive_download_file ,
122+ "FA_drive_download_file_from_folder" : download_ops .drive_download_file_from_folder ,
123+ }
124+
125+
126+ def _http_commands () -> dict [str , Command ]:
127+ from automation_file .remote import http_download
128+
129+ return {"FA_download_file" : http_download .download_file }
130+
131+
132+ def _register_cloud_backends (registry : ActionRegistry ) -> None :
133+ from automation_file .remote .azure_blob import register_azure_blob_ops
134+ from automation_file .remote .dropbox_api import register_dropbox_ops
83135 from automation_file .remote .s3 import register_s3_ops
84136 from automation_file .remote .sftp import register_sftp_ops
85137
86- registry = ActionRegistry ()
87- registry .register_many (
88- {
89- # Files
90- "FA_create_file" : file_ops .create_file ,
91- "FA_copy_file" : file_ops .copy_file ,
92- "FA_rename_file" : file_ops .rename_file ,
93- "FA_remove_file" : file_ops .remove_file ,
94- "FA_copy_all_file_to_dir" : file_ops .copy_all_file_to_dir ,
95- "FA_copy_specify_extension_file" : file_ops .copy_specify_extension_file ,
96- # Directories
97- "FA_copy_dir" : dir_ops .copy_dir ,
98- "FA_create_dir" : dir_ops .create_dir ,
99- "FA_remove_dir_tree" : dir_ops .remove_dir_tree ,
100- "FA_rename_dir" : dir_ops .rename_dir ,
101- # Zip
102- "FA_zip_dir" : zip_ops .zip_dir ,
103- "FA_zip_file" : zip_ops .zip_file ,
104- "FA_zip_info" : zip_ops .zip_info ,
105- "FA_zip_file_info" : zip_ops .zip_file_info ,
106- "FA_set_zip_password" : zip_ops .set_zip_password ,
107- "FA_unzip_file" : zip_ops .unzip_file ,
108- "FA_read_zip_file" : zip_ops .read_zip_file ,
109- "FA_unzip_all" : zip_ops .unzip_all ,
110- # HTTP
111- "FA_download_file" : http_download .download_file ,
112- # Google Drive
113- "FA_drive_later_init" : client .driver_instance .later_init ,
114- "FA_drive_search_all_file" : search_ops .drive_search_all_file ,
115- "FA_drive_search_field" : search_ops .drive_search_field ,
116- "FA_drive_search_file_mimetype" : search_ops .drive_search_file_mimetype ,
117- "FA_drive_upload_dir_to_folder" : upload_ops .drive_upload_dir_to_folder ,
118- "FA_drive_upload_to_folder" : upload_ops .drive_upload_to_folder ,
119- "FA_drive_upload_dir_to_drive" : upload_ops .drive_upload_dir_to_drive ,
120- "FA_drive_upload_to_drive" : upload_ops .drive_upload_to_drive ,
121- "FA_drive_add_folder" : folder_ops .drive_add_folder ,
122- "FA_drive_share_file_to_anyone" : share_ops .drive_share_file_to_anyone ,
123- "FA_drive_share_file_to_domain" : share_ops .drive_share_file_to_domain ,
124- "FA_drive_share_file_to_user" : share_ops .drive_share_file_to_user ,
125- "FA_drive_delete_file" : delete_ops .drive_delete_file ,
126- "FA_drive_download_file" : download_ops .drive_download_file ,
127- "FA_drive_download_file_from_folder" : download_ops .drive_download_file_from_folder ,
128- }
129- )
130- # Cloud / SFTP backends are first-class; register them on every default registry.
131138 register_s3_ops (registry )
132139 register_azure_blob_ops (registry )
133140 register_dropbox_ops (registry )
134141 register_sftp_ops (registry )
142+
143+
144+ def build_default_registry () -> ActionRegistry :
145+ """Return a registry pre-populated with every built-in ``FA_*`` action."""
146+ registry = ActionRegistry ()
147+ registry .register_many (_local_commands ())
148+ registry .register_many (_http_commands ())
149+ registry .register_many (_drive_commands ())
150+ _register_cloud_backends (registry )
135151 file_automation_logger .info (
136152 "action_registry: built default registry with %d commands" , len (registry )
137153 )
0 commit comments