1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-28 18:39:03 +00:00

Add event-based write_nmaprun_open and write_nmaprun_close.

These allow beginning and ending an nmaprun without having to keep its
children in memory.
This commit is contained in:
david
2011-12-21 04:54:24 +00:00
parent 4ec4641ce8
commit e2d5d41b28

View File

@@ -19,6 +19,7 @@ import getopt
import sys
import time
import xml.sax
import xml.sax.saxutils
import xml.dom.minidom
verbose = False
@@ -61,6 +62,22 @@ class Scan(object):
finally:
f.close()
def write_nmaprun_open(self, writer):
attrs = {}
if self.scanner is not None:
attrs[u"scanner"] = self.scanner
if self.args is not None:
attrs[u"args"] = self.args
if self.start_date is not None:
attrs[u"start"] = "%d" % time.mktime(self.start_date.timetuple())
attrs[u"startstr"] = self.start_date.strftime("%a %b %d %H:%M:%S %Y")
if self.version is not None:
attrs[u"version"] = self.version
writer.startElement(u"nmaprun", attrs)
def write_nmaprun_close(self, writer):
writer.endElement(u"nmaprun")
def nmaprun_to_dom_fragment(self, document):
frag = document.createDocumentFragment()
elem = document.createElement(u"nmaprun")