/usr/share/pyshared/pynzb/expat_nzb.py is in python-pynzb 0.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | from xml.parsers import expat
from pynzb.base import BaseNZBParser, NZBFile, NZBSegment
class ExpatNZBParser(BaseNZBParser):
def start_element(self, name, attrs):
if name == 'file':
self.current_file = NZBFile(
poster = attrs['poster'],
date = attrs['date'],
subject = attrs['subject']
)
if name == 'segment':
self.current_segment = NZBSegment(
bytes = attrs['bytes'],
number = attrs['number']
)
def end_element(self, name):
if name == 'file':
self.files.append(self.current_file)
elif name == 'group':
self.current_file.add_group(self.current_data)
elif name == 'segment':
self.current_segment.message_id(self.current_data)
self.current_file.add_segment(self.current_segment)
def char_data(self, data):
self.current_data = data
def parse(self, xml):
self.files = []
parser = expat.ParserCreate()
parser.StartElementHandler = self.start_element
parser.EndElementHandler = self.end_element
parser.CharacterDataHandler = self.char_data
parser.Parse(xml)
return self.files
|