All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def handle_starttag
 
def handle_endtag
 
def handle_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 
42  def __init__(self):
43  HTMLParser.__init__(self)
44  # data collected
45  self.patch = None
46 
47  # parsing flags and temporary data
48  self._parsingAttachments = 0 # depth of span tag in the attachment block
49  self._currentFileId = None
50  self._currentFileData = ""
51 
52  # temporary storage

Member Function Documentation

def validate_patch.SavannahParser.handle_data (   self,
  data 
)

Definition at line 78 of file validate_patch.py.

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

Definition at line 67 of file validate_patch.py.

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

Definition at line 53 of file validate_patch.py.

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

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: