validate_patch.SavannahParser Class Reference

parse the More...

Inheritance diagram for validate_patch.SavannahParser:
Collaboration diagram for validate_patch.SavannahParser:

Public Member Functions

def __init__ (self)
 
def handle_starttag (self, tag, attrs)
 
def handle_endtag (self, tag)
 
def handle_data (self, data)
 

Public Attributes

 patch
 

Private Attributes

 _parsingAttachments
 
 _currentFileId
 
 _currentFileData
 

Static Private Attributes

string __attachments_id__ = "hidsubpartcontentattached"
 

Detailed Description

parse the

Definition at line 39 of file validate_patch.py.

Constructor & Destructor Documentation

def validate_patch.SavannahParser.__init__ (   self)

Definition at line 41 of file validate_patch.py.

41  def __init__(self):
42  HTMLParser.__init__(self)
43  # data collected
44  self.patch = None
45 
46  # parsing flags and temporary data
47  self._parsingAttachments = 0 # depth of span tag in the attachment block
48  self._currentFileId = None
49  self._currentFileData = ""
50 
51  # temporary storage
52 

Member Function Documentation

def validate_patch.SavannahParser.handle_data (   self,
  data 
)

Definition at line 78 of file validate_patch.py.

78  def handle_data(self, data):
79  if self._currentFileId:
80  data = data.replace(" ", " ")
81  self._currentFileData += data
82 
def validate_patch.SavannahParser.handle_endtag (   self,
  tag 
)

Definition at line 67 of file validate_patch.py.

67  def handle_endtag(self, tag):
68  if tag == "span" and self._parsingAttachments:
69  self._parsingAttachments -= 1
70  elif tag == "a" and self._currentFileId:
71  #print self._currentFileData
72  filename = self._currentFileData.split(":")[-1].strip()
73  #print filename, self._currentFileId
74  self.patch.files.append((filename, int(self._currentFileId)))
75  self._currentFileId = None
76  self._currentFileData = ""
77 
def validate_patch.SavannahParser.handle_starttag (   self,
  tag,
  attrs 
)

Definition at line 53 of file validate_patch.py.

53  def handle_starttag(self, tag, attrs):
54  attrs = dict(attrs)
55  if tag == "html":
56  # new file: new patch data
57  self.patch = PatchData()
58  elif tag == "span":
59  if attrs.get("id", None) == self.__attachments_id__:
60  self._parsingAttachments = 1
61  elif self._parsingAttachments:
62  self._parsingAttachments += 1
63  elif (self._parsingAttachments
64  and tag == "a"
65  and "file_id=" in attrs.get("href", "")):
66  self._currentFileId = attrs["href"].split("file_id=")[-1]
def handle_starttag(self, tag, attrs)

Member Data Documentation

string validate_patch.SavannahParser.__attachments_id__ = "hidsubpartcontentattached"
staticprivate

Definition at line 40 of file validate_patch.py.

validate_patch.SavannahParser._currentFileData
private

Definition at line 49 of file validate_patch.py.

validate_patch.SavannahParser._currentFileId
private

Definition at line 48 of file validate_patch.py.

validate_patch.SavannahParser._parsingAttachments
private

Definition at line 47 of file validate_patch.py.

validate_patch.SavannahParser.patch

Definition at line 44 of file validate_patch.py.


The documentation for this class was generated from the following file: