WizardDataUriEncoder/DataUriEncoderWizardDialog.py

changeset 2
f33d9d82ae69
parent 1
2fa6997ff09c
child 3
f01e48994421
equal deleted inserted replaced
1:2fa6997ff09c 2:f33d9d82ae69
156 try: 156 try:
157 output = '"{0}{1}{2}{3}"'.format( 157 output = '"{0}{1}{2}{3}"'.format(
158 'data:' if self.dataCheckBox.isChecked() else '', 158 'data:' if self.dataCheckBox.isChecked() else '',
159 mimetype if self.dataCheckBox.isChecked() else '', 159 mimetype if self.dataCheckBox.isChecked() else '',
160 ';charset=utf-8;base64,' if self.dataCheckBox.isChecked() 160 ';charset=utf-8;base64,' if self.dataCheckBox.isChecked()
161 else '', 161 else '',
162 base64.b64encode(open(filepath, "rb").read()).decode() 162 base64.b64encode(open(filepath, "rb").read()).decode()
163 ) 163 )
164 except (IOError, OSError) as err: 164 except (IOError, OSError) as err:
165 E5MessageBox.critical( 165 E5MessageBox.critical(
166 self, 166 self,
224 Private method to get the mime type from the user. 224 Private method to get the mime type from the user.
225 225
226 @return entered mime type (string) 226 @return entered mime type (string)
227 """ 227 """
228 mimetypesList = [""] + list(sorted( 228 mimetypesList = [""] + list(sorted(
229 set(mimetypes.types_map.values()).union( 229 set(mimetypes.types_map.values()).union(
230 set(mimetypes.common_types.values())))) 230 set(mimetypes.common_types.values()))))
231 try: 231 try:
232 index = mimetypesList.index("application/octet-stream") 232 index = mimetypesList.index("application/octet-stream")
233 except ValueError: 233 except ValueError:
234 index = 0 234 index = 0

eric ide

mercurial