MCPcopy Index your code
hub / github.com/lincolnloop/python-qrcode / write

Method write

qrcode/util.py:444–464  ·  view source on GitHub ↗
(self, buffer)

Source from the content-addressed store, hash-verified

442 return len(self.data)
443
444 def write(self, buffer):
445 if self.mode == MODE_NUMBER:
446 for i in range(0, len(self.data), 3):
447 chars = self.data[i : i + 3]
448 bit_length = NUMBER_LENGTH[len(chars)]
449 buffer.put(int(chars), bit_length)
450 elif self.mode == MODE_ALPHA_NUM:
451 for i in range(0, len(self.data), 2):
452 chars = self.data[i : i + 2]
453 if len(chars) > 1:
454 buffer.put(
455 ALPHA_NUM.find(chars[0]) * 45 + ALPHA_NUM.find(chars[1]), 11
456 )
457 else:
458 buffer.put(ALPHA_NUM.find(chars), 6)
459 else:
460 # Iterating a bytestring in Python 3 returns an integer,
461 # no need to ord().
462 data = self.data
463 for c in data:
464 buffer.put(c, 8)
465
466 def __repr__(self):
467 return repr(self.data)

Callers 8

update_manpageFunction · 0.80
create_dataFunction · 0.80
best_fitMethod · 0.80
print_ttyMethod · 0.80
print_asciiMethod · 0.80
saveMethod · 0.80
_writeMethod · 0.80
_writeMethod · 0.80

Calls 1

putMethod · 0.80

Tested by

no test coverage detected