@@ -2068,19 +2068,40 @@ def create_translation_memory_import(
20682068 def upload_translation_memory_file (
20692069 self ,
20702070 translation_memory_import : Union [str , TranslationMemoryImport ],
2071- input_file : Union [BinaryIO , bytes , Any ],
2071+ content : Union [BinaryIO , bytes , Any ] = None ,
20722072 content_type : str = "application/xml" ,
2073+ * ,
2074+ input_file : Union [BinaryIO , bytes , Any ] = None ,
20732075 ) -> None :
20742076 """Uploads a TMX file to the upload URL of an import job, which starts
20752077 processing.
20762078
20772079 :param translation_memory_import: TranslationMemoryImport returned by
20782080 create_translation_memory_import(), or its upload URL.
2079- :param input_file : TMX file content as bytes or a file-like object
2081+ :param content : TMX file content as bytes or a file-like object
20802082 opened in binary mode.
20812083 :param content_type: (Optional) MIME type of the file. Must match the
20822084 content_type declared when the import job was created.
2085+ :param input_file: Deprecated alias of content.
2086+
2087+ .. deprecated::
2088+ Use content instead. input_file will be removed in the next
2089+ major version.
20832090 """
2091+ if input_file is not None :
2092+ if content is not None :
2093+ raise ValueError ("pass either content or input_file, not both" )
2094+ warnings .warn (
2095+ "input_file is deprecated, use content" ,
2096+ DeprecationWarning ,
2097+ stacklevel = 2 ,
2098+ )
2099+ content = input_file
2100+ if content is None :
2101+ raise TypeError (
2102+ "upload_translation_memory_file() missing required argument: "
2103+ "'content'"
2104+ )
20842105 if isinstance (translation_memory_import , TranslationMemoryImport ):
20852106 upload_url = translation_memory_import .upload_url
20862107 else :
@@ -2091,17 +2112,17 @@ def upload_translation_memory_file(
20912112 # Read a file-like object into bytes up front. The request is prepared
20922113 # once and reused across retries, so a stream body would already be at
20932114 # EOF on the second attempt and upload nothing.
2094- if hasattr (input_file , "read" ):
2095- input_file = input_file .read ()
2115+ if hasattr (content , "read" ):
2116+ content = content .read ()
20962117
2097- status_code , content = self ._asset_call (
2118+ status_code , response_content = self ._asset_call (
20982119 "PUT" ,
20992120 upload_url ,
2100- data = input_file ,
2121+ data = content ,
21012122 headers = {"Content-Type" : content_type },
21022123 )
21032124 self ._raise_for_asset_status (
2104- status_code , content , "uploading translation memory file"
2125+ status_code , response_content , "uploading translation memory file"
21052126 )
21062127
21072128 def create_translation_memory_export (
0 commit comments