Tidying up the PAT stuff a little

--HG--
extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%4086
issue20
tibs 2008-11-03 11:53:19 +00:00
rodzic b94eaecaf0
commit a390c6f52c
2 zmienionych plików z 18 dodań i 3 usunięć

Wyświetl plik

@ -488,6 +488,14 @@ We should be able to retrieve (the next) PAT from our file:
440
>>> print fp1
PAT({1:0x20})
For convenience, once we're found a PAT, it is remembered on the file
(all sorts of caveats immediately spring to mind, since a file can contain
more than one PAT - for the moment, the last PAT "found" by such a method
call will be remembered).
>>> print f.PAT
PAT({1:0x20})
>>> f.close()

Wyświetl plik

@ -853,6 +853,8 @@ cdef class TSFile:
cdef readonly object name
cdef readonly object mode
cdef readonly object PAT # The latest PAT read, if any
# It appears to be recommended to make __cinit__ expand to take more
# arguments (if __init__ ever gains them), since both get the same
# things passed to them. Hmm, normally I'd trust myself, but let's
@ -927,6 +929,8 @@ cdef class TSFile:
def read(self):
"""Read the next TS packet from this stream.
"""
# XXX Should we update self.PAT if the packet has PID 0?
# XXX See tsreport.c::report_ts for how to do this
try:
return _next_TSPacket(self.tsreader,self.name)
except StopIteration:
@ -938,7 +942,7 @@ cdef class TSFile:
pass
def find_PAT(self,max=0,verbose=False,quiet=False):
"""Find the (next) PAT and return it.
"""Read TS packets to find the (next) PAT.
If non-zero, `max` is the maximum number of TS packets to scan forwards
whilst looking. If it is zero, there is no limit.
@ -949,6 +953,9 @@ cdef class TSFile:
Returns (num_read, pat), where `num_read` is how many TS packets were
read (whether the PAT is found or not), and `pat` is None if no PAT
was found.
The new PAT is also saved as self.PAT (replacing, rather than updating,
any previous self.PAT object).
"""
cdef pidint_list_p prog_list
cdef int num_read
@ -963,12 +970,12 @@ cdef class TSFile:
pat = PAT()
for 0 <= ii < prog_list.length:
pat[prog_list.number[ii]] = prog_list.pid[ii]
# And remember it on the file as well
self.PAT = pat
finally:
free_pidint_list(&prog_list)
return (num_read,pat)
def close(self):
## Since we don't appear to be able to call our __dealloc__ "method",
## and we're not allowed to call Python methods..