Return a string representation in the usual format. >>> print IP('127.0.0.1').strNormal() 127.0.0.1 >>> print IP('2001:0658:022a:cafe:0200::1').strNormal() 2001:658:22a:cafe:200:0:0:1
(self, wantprefixlen=None)
| 351 | return self.strNormal(0) + self._printPrefix(wantprefixlen) |
| 352 | |
| 353 | def strNormal(self, wantprefixlen=None): |
| 354 | """Return a string representation in the usual format. |
| 355 | |
| 356 | >>> print IP('127.0.0.1').strNormal() |
| 357 | 127.0.0.1 |
| 358 | >>> print IP('2001:0658:022a:cafe:0200::1').strNormal() |
| 359 | 2001:658:22a:cafe:200:0:0:1 |
| 360 | """ |
| 361 | |
| 362 | if self.WantPrefixLen == None and wantprefixlen == None: |
| 363 | wantprefixlen = 1 |
| 364 | |
| 365 | if self._ipversion == 4: |
| 366 | ret = self.strFullsize(0) |
| 367 | elif self._ipversion == 6: |
| 368 | ret = ':'.join([hex(x)[2:] for x in [int(x, 16) for x in self.strFullsize(0).split(':')]]) |
| 369 | else: |
| 370 | raise ValueError, "only IPv4 and IPv6 supported" |
| 371 | |
| 372 | return ret + self._printPrefix(wantprefixlen) |
| 373 | |
| 374 | def strFullsize(self, wantprefixlen=None): |
| 375 | """Return a string representation in the non-mangled format. |
no test coverage detected