コード例 #1
0
 def __init__(self, string_in, objlist, level=1):
     self.rawstring = string_in
     self.objlist = objlist
     self.clean_string = self.rawstring.replace('\n',' ')
     self.list = break_at_pipes(self.clean_string)
     self.path = self.list.pop()
     self.options = {'center':True}
     self.level = level
     mydict, loners = OptionsDictFromList(self.list)
     self.options.update(mydict)
     self.caption = ''
     self.height = None
     self.width = None
     self.label = None
     assert len(loners) < 2, 'self.list has more than 1 unlabeled option'
     if len(loners) == 1:
         self.options['caption'] = loners[0]
         self.caption = loners[0]
     elif self.options.has_key('caption'):
         self.caption = self.options['caption']
     if not (self.options.has_key('width') or self.options.has_key('height')):
         #self.options['height']='0.9\\textheight'
         self.options['width']='0.9\\textwidth'
     self.center = self.options['center']
     map_list = ['height','width','label','placestr']
     for key in map_list:
         if self.options.has_key(key):
             setattr(self, key, self.options[key])
コード例 #2
0
 def replace_line(self, linein):
     q = self.p.search(linein)
     if q:
         chunk = q.group(1)
         args_list = break_at_pipes(chunk)
         img_path = args_list.pop()
         my_opts, loners = OptionsDictFromList(args_list)
         assert len(loners) < 2, "Got more than one unlabeled option" + \
                chunk
         if len(loners) == 1:
             my_opts['caption'] = loners[0]
         kwargs = {}
         if my_opts.has_key('caption'):
             kwargs['caption'] = my_opts['caption']
         listout =  self.decorator(img_path, **kwargs)
         return listout
     else:
         return linein