mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	slack importer: Clean 'create_converted_data_files' function.
The 'make_new_dir' bool value was used to create a new directory every time True is passed. Now that avatars and uploads directory are being created seperately, we don't need this anymore.
This commit is contained in:
		@@ -768,15 +768,15 @@ def do_convert_data(slack_zip_file: str, realm_subdomain: str, output_dir: str,
 | 
			
		||||
    attachment = {"zerver_attachment": zerver_attachment}
 | 
			
		||||
 | 
			
		||||
    # IO realm.json
 | 
			
		||||
    create_converted_data_files(realm, output_dir, '/realm.json', False)
 | 
			
		||||
    create_converted_data_files(realm, output_dir, '/realm.json')
 | 
			
		||||
    # IO message.json
 | 
			
		||||
    create_converted_data_files(message_json, output_dir, '/messages-000001.json', False)
 | 
			
		||||
    create_converted_data_files(message_json, output_dir, '/messages-000001.json')
 | 
			
		||||
    # IO avatar records
 | 
			
		||||
    create_converted_data_files(avatar_records, output_dir, '/avatars/records.json', False)
 | 
			
		||||
    create_converted_data_files(avatar_records, output_dir, '/avatars/records.json')
 | 
			
		||||
    # IO uploads TODO
 | 
			
		||||
    create_converted_data_files(uploads_records, output_dir, '/uploads/records.json', False)
 | 
			
		||||
    create_converted_data_files(uploads_records, output_dir, '/uploads/records.json')
 | 
			
		||||
    # IO attachments
 | 
			
		||||
    create_converted_data_files(attachment, output_dir, '/attachment.json', False)
 | 
			
		||||
    create_converted_data_files(attachment, output_dir, '/attachment.json')
 | 
			
		||||
 | 
			
		||||
    # remove slack dir
 | 
			
		||||
    rm_tree(slack_data_dir)
 | 
			
		||||
@@ -856,10 +856,6 @@ def get_user_data(token: str) -> List[ZerverFieldsT]:
 | 
			
		||||
    else:
 | 
			
		||||
        raise Exception('Enter a valid token!')
 | 
			
		||||
 | 
			
		||||
def create_converted_data_files(data: Any, output_dir: str, file_path: str,
 | 
			
		||||
                                make_new_dir: bool) -> None:
 | 
			
		||||
def create_converted_data_files(data: Any, output_dir: str, file_path: str) -> None:
 | 
			
		||||
    output_file = output_dir + file_path
 | 
			
		||||
    if make_new_dir:
 | 
			
		||||
        new_directory = os.path.dirname(file_path)
 | 
			
		||||
        os.makedirs(output_dir + new_directory, exist_ok=True)
 | 
			
		||||
    json.dump(data, open(output_file, 'w'))
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user