how to compare the checksums in a list corresponding to a file path with the file path in the operat

Posted by surab on Stack Overflow See other posts from Stack Overflow or by surab
Published on 2010-05-25T20:04:29Z Indexed on 2010/05/30 4:12 UTC
Read the original article Hit count: 290

Filed under:
|
|
|

Hi all,

how to compare the checksums in a list corresponding to a file path with the file path in the operating system In Python?

import os,sys,libxml2

files=[]
sha1s=[]

doc = libxml2.parseFile('files.xml')
for path in doc.xpathEval('//File/Path'):
  files.append(path.content)
for sha1 in doc.xpathEval('//File/Hash'):
  sha1s.append(sha1.content)

for entry in zip(files,sha1s):
  print entry

the files.xml contains

<Files>
    <File>
        <Path>usr/share/doc/dialog/samples/form1</Path>
        <Type>doc</Type>
        <Size>1222</Size>
        <Uid>0</Uid>
        <Gid>0</Gid>
        <Mode>0755</Mode>
        <Hash>49744d73e8667d0e353923c0241891d46ebb9032</Hash>
    </File>
    <File>
        <Path>usr/share/doc/dialog/samples/form3</Path>
        <Type>doc</Type>
        <Size>1294</Size>
        <Uid>0</Uid>
        <Gid>0</Gid>
        <Mode>0755</Mode>
        <Hash>f30277f73e468232c59a526baf3a5ce49519b959</Hash>
    </File>
</Files>

I need to compare the sha1 checksum in between tags corresponding to the file specified in between the tags, with the same file path in base Operating system.

© Stack Overflow or respective owner

Related posts about python

Related posts about compare