home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-xdg / examples / test-desktop.py < prev    next >
Encoding:
Python Source  |  2009-03-04  |  501 b   |  32 lines

  1. #!/usr/bin/python
  2. from xdg.DesktopEntry import *
  3.  
  4. import os, sys
  5.  
  6. def checkfiles(path):
  7.     if os.path.isdir(path):
  8.         ls = os.listdir(path)
  9.         for file in ls:
  10.             checkfiles(os.path.join(path, file))
  11.     else:
  12.         entry = DesktopEntry()
  13.         try:
  14.             entry.parse(path)
  15.         except ParsingError, e:
  16.             print e
  17.             return
  18.  
  19.         entry.setLocale("C")
  20.         entry.getName()
  21.  
  22.         try:
  23.             entry.validate()
  24.         except ValidationError, e:
  25.             print e
  26.  
  27. try:
  28.     checkfiles(sys.argv[1])
  29.  
  30. except IndexError:
  31.     print("No file or directory given!")
  32.