ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

branch
eric7
changeset 67
807714618a59
parent 65
2616383c037c
child 69
9acb6987ce60
equal deleted inserted replaced
66:e3f6a3121656 67:807714618a59
9 9
10 import datetime 10 import datetime
11 import os 11 import os
12 12
13 from PyQt6.QtCore import QObject 13 from PyQt6.QtCore import QObject
14 from PyQt6.QtWidgets import QMenu, QInputDialog, QDialog, QApplication 14 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QMenu
15 15
16 from eric7 import Utilities
17 from eric7.EricWidgets import EricFileDialog, EricMessageBox 16 from eric7.EricWidgets import EricFileDialog, EricMessageBox
18 from eric7.EricWidgets.EricApplication import ericApp 17 from eric7.EricWidgets.EricApplication import ericApp
18
19 try:
20 from eric7.SystemUtilities.OSUtilities import getHomeDir, getUserName
21 except ImportError:
22 # imports for eric < 23.1
23 from eric7.Utilities import getHomeDir, getUserName
19 24
20 from .DjangoTagInputDialog import DjangoTagInputDialog 25 from .DjangoTagInputDialog import DjangoTagInputDialog
21 26
22 27
23 class DjangoTagsMenuHandler(QObject): 28 class DjangoTagsMenuHandler(QObject):
1621 ) 1626 )
1622 elif tag == "multilinecommentfile": 1627 elif tag == "multilinecommentfile":
1623 filename = EricFileDialog.getOpenFileName( 1628 filename = EricFileDialog.getOpenFileName(
1624 None, 1629 None,
1625 self.tr("Comment File"), 1630 self.tr("Comment File"),
1626 Utilities.getHomeDir(), 1631 getHomeDir(),
1627 self.tr("All Files (*)"), 1632 self.tr("All Files (*)"),
1628 ) 1633 )
1629 if filename: 1634 if filename:
1630 try: 1635 try:
1631 with open(filename, "r", encoding="utf-8") as f: 1636 with open(filename, "r", encoding="utf-8") as f:
1642 """ read.</p><p>Reason: {1}</p>""" 1647 """ read.</p><p>Reason: {1}</p>"""
1643 ).format(str(err)), 1648 ).format(str(err)),
1644 ) 1649 )
1645 elif tag == "singlelinecommentdatetime": 1650 elif tag == "singlelinecommentdatetime":
1646 templateText = "{{# {0} by {1} #}}".format( 1651 templateText = "{{# {0} by {1} #}}".format(
1647 datetime.datetime.now().isoformat().split(), Utilities.getUserName() 1652 datetime.datetime.now().isoformat().split(), getUserName()
1648 ) 1653 )
1649 elif tag == "htmlcomment": 1654 elif tag == "htmlcomment":
1650 templateText = "<!-- {0} -->".format(selectedText) 1655 templateText = "<!-- {0} -->".format(selectedText)
1651 replace = True 1656 replace = True
1652 elif tag == "iecomment": 1657 elif tag == "iecomment":

eric ide

mercurial