11# This Source Code Form is subject to the terms of the Mozilla Public
22# License, v. 2.0. If a copy of the MPL was not distributed with this
33# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+ from typing import Dict
5+ from typing import Optional
46
57FORMAT_HTML = "html"
68FORMAT_IMAGE = "image"
1012FORMAT_VIDEO = "video"
1113
1214
13- def extra (content , format_type , name = None , mime_type = None , extension = None ):
15+ def extra (
16+ content : str ,
17+ format_type : str ,
18+ name : Optional [str ] = None ,
19+ mime_type : Optional [str ] = None ,
20+ extension : Optional [str ] = None ,
21+ ) -> Dict [str , Optional [str ]]:
1422 return {
1523 "name" : name ,
1624 "format_type" : format_type ,
@@ -20,41 +28,51 @@ def extra(content, format_type, name=None, mime_type=None, extension=None):
2028 }
2129
2230
23- def html (content ) :
31+ def html (content : str ) -> Dict [ str , Optional [ str ]] :
2432 return extra (content , FORMAT_HTML )
2533
2634
27- def image (content , name = "Image" , mime_type = "image/png" , extension = "png" ):
35+ def image (
36+ content : str ,
37+ name : str = "Image" ,
38+ mime_type : str = "image/png" ,
39+ extension : str = "png" ,
40+ ) -> Dict [str , Optional [str ]]:
2841 return extra (content , FORMAT_IMAGE , name , mime_type , extension )
2942
3043
31- def png (content , name = "Image" ):
44+ def png (content : str , name : str = "Image" ) -> Dict [ str , Optional [ str ]] :
3245 return image (content , name , mime_type = "image/png" , extension = "png" )
3346
3447
35- def jpg (content , name = "Image" ):
48+ def jpg (content : str , name : str = "Image" ) -> Dict [ str , Optional [ str ]] :
3649 return image (content , name , mime_type = "image/jpeg" , extension = "jpg" )
3750
3851
39- def svg (content , name = "Image" ):
52+ def svg (content : str , name : str = "Image" ) -> Dict [ str , Optional [ str ]] :
4053 return image (content , name , mime_type = "image/svg+xml" , extension = "svg" )
4154
4255
43- def json (content , name = "JSON" ):
56+ def json (content : str , name : str = "JSON" ) -> Dict [ str , Optional [ str ]] :
4457 return extra (content , FORMAT_JSON , name , "application/json" , "json" )
4558
4659
47- def text (content , name = "Text" ):
60+ def text (content : str , name : str = "Text" ) -> Dict [ str , Optional [ str ]] :
4861 return extra (content , FORMAT_TEXT , name , "text/plain" , "txt" )
4962
5063
51- def url (content , name = "URL" ):
64+ def url (content : str , name : str = "URL" ) -> Dict [ str , Optional [ str ]] :
5265 return extra (content , FORMAT_URL , name )
5366
5467
55- def video (content , name = "Video" , mime_type = "video/mp4" , extension = "mp4" ):
68+ def video (
69+ content : str ,
70+ name : str = "Video" ,
71+ mime_type : str = "video/mp4" ,
72+ extension : str = "mp4" ,
73+ ) -> Dict [str , Optional [str ]]:
5674 return extra (content , FORMAT_VIDEO , name , mime_type , extension )
5775
5876
59- def mp4 (content , name = "Video" ):
77+ def mp4 (content : str , name : str = "Video" ) -> Dict [ str , Optional [ str ]] :
6078 return video (content , name )
0 commit comments