Advertisement
Guest User

Untitled

a guest
May 2nd, 2010
2,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. #!/usr/bin/env python2.5
  2.  
  3. import os
  4. import ConfigParser
  5.  
  6. programsPath = "/usr/share/applications/hildon"
  7. countFile = "~/.appCounter"
  8.  
  9. #functions
  10.  
  11.  
  12. def getProgramFiles(path):
  13.     files = []
  14.     for filename in os.listdir(path):
  15.         files.append(filename)
  16.     return files
  17.  
  18. def getCountConfig(file):
  19.     config = ConfigParser.RawConfigParser()
  20.  
  21.     if os.path.isfile(file) == False:
  22.         config.add_section('Counts')
  23.         with open(file,'w') as fileh:
  24.             config.write(fileh)
  25.    
  26.     config.read(file)
  27.     items = config.items('Counts')
  28.     return items
  29.  
  30. def getProgramInfo(file,counts=0):
  31.     config = ConfigParser.RawConfigParser()
  32.     onfig.read(file)
  33.     items = config.items('Desktop Entry')
  34.     items['counts'] = counts
  35.     return items
  36.  
  37. def getAllPrograms(path,files,counts):
  38.     programs = {}
  39.     for file in files:
  40.         progams.append(getProgramInfo(path+file,counts[file]))
  41.     return programs
  42.  
  43.  
  44. #code
  45. counts = getCountConfig(countFile)
  46. files = getProgramFiles(programsPath)
  47.  
  48.  
  49.  
  50. print files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement