title: Python compare differences in XML.Etree and file and folder names in directory listings
body: <p>I'm using Python to compare my flickr photos to my local harddrive photo directories. </p>
  
  <p>In order to do this, I'm using OAuth in Python and getting an etree listing of each folder/album I have in flickr. The folder/album contents on flickr 'should' match my local copy directory. </p>
  
  <p>I'd like my script to tell me when there are items not in my photo listing on my local drive and flickr (and vice versa). </p>
  
  <p>The 'title' field of the flickr photos should be the same as the filename on Linux and directory names on Linux will/should match the album names on flickr. That is currently how I have it set up.</p>
  
  <p>I'm wondering what would be the best and most efficient way to compare these item lists in Python (etree node items vs <code>os.listdir()</code> items)? </p>
  
  <p>I'd rather not get into using <code>sort()</code> in bash to sort any piped output to filenames unless necessary. I'd like to keep everything in Python if possible as I'm just learning it. </p>
  
  <p>I could use <code>os.listdir()</code> and compare that to the <code>XML.Etree</code> nodes returned to flickr, but what would be the best approach to do this comparison? </p>
  
  <p>Keep in mind that the lists may not be the same and may not be sorted when comparing items from flickr and Linux.</p>
  
  <p>I have the following snippet of code written to get results from flickr:</p>
  
  <pre><code>...oauth code above...
  sets = flickr.photosets.getList(user_id=user_id)
  print ("Total sets: " + sets.find('photosets').attrib['total'])
  all_sets = sets.find('photosets').findall('photoset')
  
  for each_set in all_sets:
     for node in each_set.findall('title'):
        print ("photoset: " + each_set.get('id') + ", " + node.text + ", photos: ", each_set.get('photos'))
        all_photos = flickr.photosets.getPhotos(user_id=user_id, photoset_id=each_set.get('id'))
        photos = all_photos.find('photoset')
        for photo in photos:
           print (photo.get('title'))
  </code></pre>
  
  <p>An example of the output from the above code would be:</p>
  
  <pre><code>photoset: 72157659163323894, Birthday Party - Nov 21, 2015, photos:  131
  ...
  2015:11:21-16:11:14-IMG_20151121_161114372
  2015:11:21-16:11:10-IMG_20151121_161109739
  2015:11:21-16:10:36-IMG_20151121_161035497
  2015:11:21-15:47:14-IMG_20151121_154713671
  2015:11:21-15:43:17-IMG_20151121_154317180
  2015:11:21-15:43:15-IMG_20151121_154315539
  2015:11:21-15:23:42-IMG_20151121_152342348
  2015:11:21-15:23:11-IMG_20151121_152311411
  ...
  2015:11:21-16:21:19-DSC_0603
  2015:11:21-16:21:13-DSC_0602
  2015:11:21-16:21:11-DSC_0601
  2015:11:21-16:21:09-DSC_0600
  2015:11:21-16:21:07-DSC_0599
  2015:11:21-16:21:05-DSC_0598
  2015:11:21-16:20:13-DSC_0597
  2015:11:21-16:20:09-DSC_0596
  2015:11:21-16:19:59-DSC_0595
  2015:11:21-16:19:56-DSC_0594
  2015:11:21-16:19:55-DSC_0593
  ...
  </code></pre>
  
  <p>The API for getPhotos is here: <a href="https://www.flickr.com/services/api/flickr.photosets.getPhotos.htm" rel="nofollow">https://www.flickr.com/services/api/flickr.photosets.getPhotos.htm</a> which shows some of the example xtree/XML output.</p>
  
  <p>Etree API: <a href="https://docs.python.org/2/library/xml.etree.elementtree.html" rel="nofollow">https://docs.python.org/2/library/xml.etree.elementtree.html</a></p>