Changeset f1550c8
- Timestamp:
- May 19, 2010 2:01:16 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- f9c2f63
- Parents:
- d743d60
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/topdl.py
rd743d60 rf1550c8 483 483 484 484 class parser: 485 def __init__(self ):485 def __init__(self, top): 486 486 self.stack = [ ] 487 487 self.chars = "" … … 490 490 self.current = { } 491 491 self.in_cdata = False 492 self.in_top = False 493 self.top = top 492 494 493 495 def start_element(self, name, attrs): … … 495 497 self.have_chars = False 496 498 self.key = str(name) 497 self.stack.append((self.current, self.key)) 498 self.current = { } 499 500 if name == self.top: 501 self.in_top = True 502 503 if self.in_top: 504 self.stack.append((self.current, self.key)) 505 self.current = { } 499 506 500 507 def end_element(self, name): 501 if self.have_chars: 502 self.chars = self.chars.strip() 503 if len(self.chars) >0: 504 addit = self.chars 508 if self.in_top: 509 if self.have_chars: 510 self.chars = self.chars.strip() 511 if len(self.chars) >0: 512 addit = self.chars 513 else: 514 addit = self.current 505 515 else: 506 516 addit = self.current 507 else: 508 addit = self.current509 510 parent, key = self.stack.pop()511 if parent.has_key(key):512 if isinstance(parent[key], list):513 parent[key].append(addit)517 518 parent, key = self.stack.pop() 519 if parent.has_key(key): 520 if isinstance(parent[key], list): 521 parent[key].append(addit) 522 else: 523 parent[key] = [parent[key], addit] 514 524 else: 515 parent[key] = [parent[key], addit] 516 else: 517 parent[key] = addit 518 self.current = parent 519 self.key = key 525 parent[key] = addit 526 self.current = parent 527 self.key = key 520 528 521 529 self.chars = "" 522 530 self.have_chars = False 523 531 532 if name == self.top: 533 self.in_top= False 534 524 535 def char_data(self, data): 525 self.have_chars = True 526 self.chars += data 527 528 p = parser() 536 if self.in_top: 537 self.have_chars = True 538 self.chars += data 539 540 p = parser(top=top) 529 541 xp = xml.parsers.expat.ParserCreate() 530 542
Note: See TracChangeset
for help on using the changeset viewer.