File: FormatEditor.py

package info (click to toggle)
bibus 1.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,488 kB
  • sloc: python: 30,790; sql: 211; makefile: 158; xml: 10; sh: 3
file content (29 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import StyleEditor.FormatEditor

class FormatEditor(StyleEditor.FormatEditor.FormatEditor):
	def Save(self,evt):
		"""Save the Format.Converter and exit"""
		self.__Save()
		try:
			f = open(self.filename,'wb')
			cPickle.dump(self.conv,f,False)		# we save the style file. ascii mode for readibility
			f.flush()
			f.close()
			BIB.FORMAT_DICO = self.conv			# we keep the current format
			BIB.FORMAT_CONV = Format.Converter.Converter(self.conv['fields'])	# we update the Format.Converter
			self.Close()
		except IOError:
			self.SaveAs(evt)

	def SaveAs(self,evt):
		self.filename = wxFileSelector(_('Where to save the style file?'))
		#print "%r"%self.filename
		if self.filename:
			self.Save(evt)
			if os.path.dirname(self.filename) != os.path.join(BIB.SOURCEDIR,'Format','Styles'):
				BIB.CONFIG.writeStyle(self.filename)
			if self.filename not in BIB.STYLES.values():	# not already in style menu
				self.GetParent().addUserStyle(self.filename)
		else:
			self.Close()	# the user clicked cancel in the file dialog => we cancel everything