Python implementation of the od UNIX utility (od -b, more exactly). Parameters ---------- filename : str name of the file to get the dump from. Returns ------- out : seq list of lines of od output Notes ----- We only implement enough to get the
(filename)
| 286 | """ |
| 287 | |
| 288 | def pyod(filename): |
| 289 | """Python implementation of the od UNIX utility (od -b, more exactly). |
| 290 | |
| 291 | Parameters |
| 292 | ---------- |
| 293 | filename : str |
| 294 | name of the file to get the dump from. |
| 295 | |
| 296 | Returns |
| 297 | ------- |
| 298 | out : seq |
| 299 | list of lines of od output |
| 300 | |
| 301 | Notes |
| 302 | ----- |
| 303 | We only implement enough to get the necessary information for long double |
| 304 | representation, this is not intended as a compatible replacement for od. |
| 305 | """ |
| 306 | out = [] |
| 307 | with open(filename, 'rb') as fid: |
| 308 | yo2 = [oct(o)[2:] for o in fid.read()] |
| 309 | for i in range(0, len(yo2), 16): |
| 310 | line = ['%07d' % int(oct(i)[2:])] |
| 311 | line.extend(['%03d' % int(c) for c in yo2[i:i+16]]) |
| 312 | out.append(" ".join(line)) |
| 313 | return out |
| 314 | |
| 315 | |
| 316 | _BEFORE_SEQ = ['000', '000', '000', '000', '000', '000', '000', '000', |
no test coverage detected