src/eric7/QScintilla/Editor.py

branch
eric7
changeset 9405
99e65bd24e7d
parent 9333
b0541ec21e51
child 9408
e993c39097d3
equal deleted inserted replaced
9404:717e1e87dc8f 9405:99e65bd24e7d
396 self.syntaxCheckService = None 396 self.syntaxCheckService = None
397 397
398 self.isResourcesFile = False 398 self.isResourcesFile = False
399 if editor is None: 399 if editor is None:
400 if self.fileName: 400 if self.fileName:
401 if ( 401 if not Utilities.MimeTypes.isTextFile(self.fileName):
402 pathlib.Path(self.fileName).stat().st_size // 1024 402 EricMessageBox.warning(
403 ) > Preferences.getEditor("WarnFilesize"): 403 None,
404 self.tr("Open File"),
405 self.tr(
406 "<p>The file <b>{0}</b> is not a text file. It will not be"
407 " opened!</p>"
408 ).format(self.fileName)
409 )
410 raise OSError()
411
412 fileSizeKB = pathlib.Path(self.fileName).stat().st_size // 1024
413 if fileSizeKB > Preferences.getEditor("RejectFilesize"):
414 EricMessageBox.warning(
415 None,
416 self.tr("Open File"),
417 self.tr(
418 "<p>The size of the file <b>{0}</b> is <b>{1} KB</b> and"
419 " exceeds the configured limit of <b>{2} KB</b>. It will"
420 " not be opened!</p>"
421 ).format(
422 self.fileName,
423 fileSizeKB,
424 Preferences.getEditor("RejectFilesize"),
425 )
426 )
427 raise OSError()
428 elif fileSizeKB > Preferences.getEditor("WarnFilesize"):
404 res = EricMessageBox.yesNo( 429 res = EricMessageBox.yesNo(
405 self, 430 None,
406 self.tr("Open File"), 431 self.tr("Open File"),
407 self.tr( 432 self.tr(
408 """<p>The size of the file <b>{0}</b>""" 433 """<p>The size of the file <b>{0}</b>"""
409 """ is <b>{1} KB</b>.""" 434 """ is <b>{1} KB</b>."""
410 """ Do you really want to load it?</p>""" 435 """ Do you really want to load it?</p>"""
411 ).format( 436 ).format(self.fileName, fileSizeKB),
412 self.fileName,
413 pathlib.Path(self.fileName).stat().st_size // 1024,
414 ),
415 icon=EricMessageBox.Warning, 437 icon=EricMessageBox.Warning,
416 ) 438 )
417 if not res: 439 if not res:
418 raise OSError() 440 raise OSError()
441
419 self.readFile(self.fileName, True) 442 self.readFile(self.fileName, True)
420 self.__bindLexer(self.fileName) 443 self.__bindLexer(self.fileName)
421 self.__bindCompleter(self.fileName) 444 self.__bindCompleter(self.fileName)
422 self.checkSyntax() 445 self.checkSyntax()
423 self.isResourcesFile = self.fileName.endswith(".qrc") 446 self.isResourcesFile = self.fileName.endswith(".qrc")

eric ide

mercurial