ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

changeset 49
ef6c805ae218
parent 47
825bf5861f89
child 51
29c461f7bea0
equal deleted inserted replaced
48:ba771c089e44 49:ef6c805ae218
809 data[0], data[1], selectedText, data[2])) 809 data[0], data[1], selectedText, data[2]))
810 replace = True 810 replace = True
811 elif tag == "if": 811 elif tag == "if":
812 from .IfTagInputDialog import IfTagInputDialog 812 from .IfTagInputDialog import IfTagInputDialog
813 dlg = IfTagInputDialog() 813 dlg = IfTagInputDialog()
814 if dlg.exec_() == QDialog.Accepted: 814 if dlg.exec() == QDialog.Accepted:
815 templateText = dlg.getTag() 815 templateText = dlg.getTag()
816 elif tag == "ifchanged": 816 elif tag == "ifchanged":
817 data, ok = DjangoTagInputDialog.getText( 817 data, ok = DjangoTagInputDialog.getText(
818 None, 818 None,
819 self.tr("Check Variables for Changes"), 819 self.tr("Check Variables for Changes"),
1309 elif tag == "loadweb": 1309 elif tag == "loadweb":
1310 templateText = '{% load webdesign %}' 1310 templateText = '{% load webdesign %}'
1311 elif tag == "lorem": 1311 elif tag == "lorem":
1312 from .LoremTagInputDialog import LoremTagInputDialog 1312 from .LoremTagInputDialog import LoremTagInputDialog
1313 dlg = LoremTagInputDialog() 1313 dlg = LoremTagInputDialog()
1314 if dlg.exec_() == QDialog.Accepted: 1314 if dlg.exec() == QDialog.Accepted:
1315 templateText = "{{% {0} %}}".format(dlg.getTag()) 1315 templateText = "{{% {0} %}}".format(dlg.getTag())
1316 1316
1317 #################################################### 1317 ####################################################
1318 ## Static Template Tags ## 1318 ## Static Template Tags ##
1319 #################################################### 1319 ####################################################
1381 self.tr("Comment File"), 1381 self.tr("Comment File"),
1382 Utilities.getHomeDir(), 1382 Utilities.getHomeDir(),
1383 self.tr("All Files (*)")) 1383 self.tr("All Files (*)"))
1384 if filename: 1384 if filename:
1385 try: 1385 try:
1386 f = open(filename, "r", encoding="utf-8") 1386 with open(filename, "r", encoding="utf-8") as f:
1387 comment = f.read() 1387 comment = f.read()
1388 f.close()
1389 templateText = ( 1388 templateText = (
1390 '{{% comment %}} {0} {{% endcomment %}}'.format( 1389 '{{% comment %}} {0} {{% endcomment %}}'.format(
1391 comment)) 1390 comment))
1392 except (IOError, OSError) as err: 1391 except (IOError, OSError) as err:
1393 E5MessageBox.critical( 1392 E5MessageBox.critical(

eric ide

mercurial