Esempio n. 1
0
def main():

    print("""\
<?xml version="1.0" encoding="UTF-8"?>
<dfxml xmloutputversion="1.0">
  <creator version="1.0">
    <program>%s</program>
    <version>%s</version>
    <execution_environment>
      <command_line>%s</command_line>
    </execution_environment>
  </creator>
  <source>
    <image_filename>%s</image_filename>
  </source>\
""" % (sys.argv[0], __version__, " ".join(sys.argv), args.filename))

    xs = []
    for fi in dfxml.iter_dfxml(xmlfile=open(args.filename, "rb"), preserve_elements=True):
        logging.debug("Processing: %s" % str(fi))
        if args.cache:
            xs.append(fi.xml_element)
        else:
            logging.debug("Printing without cache: %s" % str(fi))
            print(dfxml.ET_tostring(fi.xml_element, encoding="unicode"))
    if args.cache:
        for x in xs:
            logging.debug("Printing with cache: %s" % str(fi))
            print(dfxml.ET_tostring(x, encoding="unicode"))

    print("""</dfxml>""")
Esempio n. 2
0
 def process(self,fname):
     self.prior_fname = self.current_fname
     self.current_fname = fname
     if fname.endswith("xml"):
         with open(fname,'rb') as xmlfile:
             for fi in dfxml.iter_dfxml(xmlfile, preserve_elements=True):
                 self.process_fi(fi)
     else:
         fiwalk.fiwalk_using_sax(imagefile=open(fname,'rb'), flags=fiwalk.ALLOC_ONLY, callback=self.process_fi)
Esempio n. 3
0
 def process(self, fname):
     self.prior_fname = self.current_fname
     self.current_fname = fname
     if fname.endswith("xml"):
         with open(fname, 'rb') as xmlfile:
             for fi in dfxml.iter_dfxml(xmlfile, preserve_elements=True):
                 self.process_fi(fi)
     else:
         fiwalk.fiwalk_using_sax(imagefile=open(fname, 'rb'),
                                 flags=fiwalk.ALLOC_ONLY,
                                 callback=self.process_fi)
Esempio n. 4
0
def main():
    if len(sys.argv) < 2:
        print("Usage: {} <filename.xml>".format(sys.argv[0]))
        exit(1)

    timeline = []

    for fi in dfxml.iter_dfxml( xmlfile=open(sys.argv[1],"rb") ):
        if fi.mtime()!=None: timeline.append([fi.mtime(),fi.filename()," modified"])
        if fi.crtime()!=None: timeline.append([fi.crtime(),fi.filename()," created"])
        if fi.ctime()!=None: timeline.append([fi.ctime(),fi.filename()," changed"])
        if fi.atime()!=None: timeline.append([fi.atime(),fi.filename()," accessed"])

    timeline.sort()

    for record in timeline:
        print("\t".join( map(str, record)) )
Esempio n. 5
0
def main():
    if len(sys.argv) < 2:
        print("Usage: {} <filename.xml>".format(sys.argv[0]))
        exit(1)

    timeline = []

    for fi in dfxml.iter_dfxml( xmlfile=open(sys.argv[1],"rb") ):
        if fi.mtime()!=None: timeline.append([fi.mtime(),fi.filename()," modified"])
        if fi.crtime()!=None: timeline.append([fi.crtime(),fi.filename()," created"])
        if fi.ctime()!=None: timeline.append([fi.ctime(),fi.filename()," changed"])
        if fi.atime()!=None: timeline.append([fi.atime(),fi.filename()," accessed"])

    timeline.sort()

    for record in timeline:
        print("\t".join( map(str, record)) )
Esempio n. 6
0
def main():

    print("""\
<?xml version="1.0" encoding="UTF-8"?>
<dfxml
  xmlns="%s"
  xmlns:delta="%s"
  version="1.1.0">
  <creator>
    <program>%s</program>
    <version>%s</version>
    <execution_environment>
      <command_line>%s</command_line>
    </execution_environment>
  </creator>
  <source>
    <image_filename>%s</image_filename>
  </source>\
""" % (dfxml.XMLNS_DFXML, dfxml.XMLNS_DELTA, sys.argv[0], __version__,
       " ".join(sys.argv), args.filename))

    ET.register_namespace("delta", dfxml.XMLNS_DELTA)

    xs = []
    for fi in dfxml.iter_dfxml(xmlfile=open(args.filename, "rb"),
                               preserve_elements=True):
        _logger.debug("Processing: %s" % str(fi))
        if args.cache:
            xs.append(fi.xml_element)
        else:
            _logger.debug("Printing without cache: %s" % str(fi))
            print(dfxml.ET_tostring(fi.xml_element, encoding="unicode"))
    if args.cache:
        for x in xs:
            _logger.debug("Printing with cache: %s" % str(fi))
            print(dfxml.ET_tostring(x, encoding="unicode"))

    print("""</dfxml>""")
Esempio n. 7
0
def main():

    print("""\
<?xml version="1.0" encoding="UTF-8"?>
<dfxml
  xmlns="%s"
  xmlns:delta="%s"
  version="1.2.0">
  <metadata/>
  <creator>
    <program>%s</program>
    <version>%s</version>
    <execution_environment>
      <command_line>%s</command_line>
    </execution_environment>
  </creator>
  <source>
    <image_filename>%s</image_filename>
  </source>\
""" % (dfxml.XMLNS_DFXML, dfxml.XMLNS_DELTA, sys.argv[0], __version__, " ".join(sys.argv), args.filename))

    ET.register_namespace("delta", dfxml.XMLNS_DELTA)

    xs = []
    for fi in dfxml.iter_dfxml(xmlfile=open(args.filename, "rb"), preserve_elements=True):
        _logger.debug("Processing: %s" % str(fi))
        if args.cache:
            xs.append(fi.xml_element)
        else:
            _logger.debug("Printing without cache: %s" % str(fi))
            print(dfxml.ET_tostring(fi.xml_element, encoding="unicode"))
    if args.cache:
        for x in xs:
            _logger.debug("Printing with cache: %s" % str(fi))
            print(dfxml.ET_tostring(x, encoding="unicode"))

    print("""</dfxml>""")