##// END OF EJS Templates
move stringio class from bugzilla extension into templater module.
Vadim Gelfer -
r2199:f1986a61 default
parent child Browse files
Show More
@@ -43,7 +43,7 b''
43 from mercurial.demandload import *
43 from mercurial.demandload import *
44 from mercurial.i18n import gettext as _
44 from mercurial.i18n import gettext as _
45 from mercurial.node import *
45 from mercurial.node import *
46 demandload(globals(), 'cStringIO mercurial:templater,util os re time')
46 demandload(globals(), 'mercurial:templater,util os re time')
47
47
48 try:
48 try:
49 import MySQLdb
49 import MySQLdb
@@ -241,23 +241,9 b' class bugzilla(object):'
241 count -= 1
241 count -= 1
242 return root
242 return root
243
243
244 class stringio(object):
245 '''wrap cStringIO.'''
246 def __init__(self):
247 self.fp = cStringIO.StringIO()
248
249 def write(self, *args):
250 for a in args:
251 self.fp.write(a)
252
253 write_header = write
254
255 def getvalue(self):
256 return self.fp.getvalue()
257
258 mapfile = self.ui.config('bugzilla', 'style')
244 mapfile = self.ui.config('bugzilla', 'style')
259 tmpl = self.ui.config('bugzilla', 'template')
245 tmpl = self.ui.config('bugzilla', 'template')
260 sio = stringio()
246 sio = templater.stringio()
261 t = templater.changeset_templater(self.ui, self.repo, mapfile, sio)
247 t = templater.changeset_templater(self.ui, self.repo, mapfile, sio)
262 if not mapfile and not tmpl:
248 if not mapfile and not tmpl:
263 tmpl = _('changeset {node|short} in repo {root} refers '
249 tmpl = _('changeset {node|short} in repo {root} refers '
@@ -499,3 +499,17 b' class changeset_templater(object):'
499 inst.args[0]))
499 inst.args[0]))
500 except SyntaxError, inst:
500 except SyntaxError, inst:
501 raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0]))
501 raise util.Abort(_('%s: %s') % (self.t.mapfile, inst.args[0]))
502
503 class stringio(object):
504 '''wrap cStringIO for use by changeset_templater.'''
505 def __init__(self):
506 self.fp = cStringIO.StringIO()
507
508 def write(self, *args):
509 for a in args:
510 self.fp.write(a)
511
512 write_header = write
513
514 def getvalue(self):
515 return self.fp.getvalue()
General Comments 0
You need to be logged in to leave comments. Login now