Skip to content

Instantly share code, notes, and snippets.

@mhrivnak
Last active May 20, 2016 20:22
Show Gist options
  • Save mhrivnak/eacd9dcf67e68733ae2a234e37dd695e to your computer and use it in GitHub Desktop.
Save mhrivnak/eacd9dcf67e68733ae2a234e37dd695e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python | 27 saxutils.XMLGenerator.characters(self, 'foo')
| 28 self._delivered_checksum = True
import gzip | 29 return
from xml import sax | 30 saxutils.XMLGenerator.characters(self, content)
from xml.sax import handler | 31
| 32 def endElement(self, name):
| 33 if name == 'checksum':
class MyFilter(handler.ContentHandler): | 34 self._in_checksum = False
def startElement(self, name, attrs): | 35 self._delivered_checksum = False
if name == 'location': | 36
print attrs._attrs['href'] | 37 saxutils.XMLGenerator.endElement(self, name)
| 38
| 39
with gzip.open('primary.xml.gz') as f: | 40 ts = rpmUtils.transaction.initReadOnlyTransaction()
x = sax.parse(f, MyFilter())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment