Lines Matching refs:self

38     def error(self, text, msg):
41 "Error encoding '%s' as %s barcode: %s\n" % (text, self.name, msg))
44 def encode(self, text):
51 def __init__(self, param):
53 self.document = param.get('document', None)
54 self.known_ids = []
55 self._extra = []
57 self.pos_x = int(param.get('x', 0))
58 self.pos_y = int(param.get('y', 0))
59 self.text = param.get('text', None)
60 self.scale = param.get('scale', 1)
61 self.height = param.get('height', self.default_height)
62 self.pos_text = param.get('text_pos', TEXT_POS_BOTTOM)
64 if self.document:
65 self.known_ids = list(self.document.xpath('//@id'))
67 if not self.text:
70 def get_id(self, name='element'):
73 while name in self.known_ids:
76 self.known_ids.append(name)
79 def add_extra_barcode(self, barcode, **kw):
82 kw['height'] = self.height
83 kw['document'] = self.document
85 self._extra.append(getBarcode(barcode, **kw).generate())
87 def generate(self):
89 string = self.encode(self.text)
94 name = self.get_id('barcode')
100 if self.scale:
102 self.pos_x, self.pos_y, self.scale))
105 self.pos_x, self.pos_y))
111 for datum in self.graphical_array(string):
113 style = self.get_style(int(datum[0]))
123 if self.pos_text == TEXT_POS_TOP:
124 rect.set('y', str(style['top'] + self.font_size))
131 for extra in self._extra:
139 text.set('y', str(min(tops) + self.font_size - 1))
140 if self.pos_text == TEXT_POS_BOTTOM:
141 text.set('y', str(self.height + max(tops) + self.font_size))
142 text.set('style', TEXT_TEMPLATE % self.font_size)
145 text.text = str(self.text)
148 def graphical_array(self, code):
152 def get_style(self, index):
156 result['height'] = int(self.height)
158 result['height'] = int(self.height) + int(self.font_size / 2)