Fixed byte pattern. @type pattern: str @ivar pattern: Byte string to search for. @type length: int @ivar length: Length of the byte pattern.
| 175 | |
| 176 | |
| 177 | class BytePattern(Pattern): |
| 178 | """ |
| 179 | Fixed byte pattern. |
| 180 | |
| 181 | @type pattern: str |
| 182 | @ivar pattern: Byte string to search for. |
| 183 | |
| 184 | @type length: int |
| 185 | @ivar length: Length of the byte pattern. |
| 186 | """ |
| 187 | |
| 188 | def __init__(self, pattern): |
| 189 | """ |
| 190 | @type pattern: str |
| 191 | @param pattern: Byte string to search for. |
| 192 | """ |
| 193 | self.pattern = str(pattern) |
| 194 | self.length = len(pattern) |
| 195 | |
| 196 | def __len__(self): |
| 197 | """ |
| 198 | Returns the exact length of the pattern. |
| 199 | |
| 200 | @see: L{Pattern.__len__} |
| 201 | """ |
| 202 | return self.length |
| 203 | |
| 204 | def find(self, buffer, pos=None): |
| 205 | return buffer.find(self.pattern, pos), self.length |
| 206 | |
| 207 | |
| 208 | # ------------------------------------------------------------------------------ |
no outgoing calls
no test coverage detected