Output the QR Code only using TTY colors. If the data has not been compiled yet, make it first.
(self, out=None)
| 254 | return pattern |
| 255 | |
| 256 | def print_tty(self, out=None): |
| 257 | """ |
| 258 | Output the QR Code only using TTY colors. |
| 259 | |
| 260 | If the data has not been compiled yet, make it first. |
| 261 | """ |
| 262 | if out is None: |
| 263 | import sys |
| 264 | |
| 265 | out = sys.stdout |
| 266 | |
| 267 | if not out.isatty(): |
| 268 | raise OSError("Not a tty") |
| 269 | |
| 270 | if self.data_cache is None: |
| 271 | self.make() |
| 272 | |
| 273 | modcount = self.modules_count |
| 274 | out.write("\x1b[1;47m" + (" " * (modcount * 2 + 4)) + "\x1b[0m\n") |
| 275 | for r in range(modcount): |
| 276 | out.write("\x1b[1;47m \x1b[40m") |
| 277 | for c in range(modcount): |
| 278 | if self.modules[r][c]: |
| 279 | out.write(" ") |
| 280 | else: |
| 281 | out.write("\x1b[1;47m \x1b[40m") |
| 282 | out.write("\x1b[1;47m \x1b[0m\n") |
| 283 | out.write("\x1b[1;47m" + (" " * (modcount * 2 + 4)) + "\x1b[0m\n") |
| 284 | out.flush() |
| 285 | |
| 286 | def print_ascii(self, out=None, tty=False, invert=False): |
| 287 | """ |