Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.5
- import os
- import ConfigParser
- programsPath = "/usr/share/applications/hildon"
- countFile = "~/.appCounter"
- #functions
- def getProgramFiles(path):
- files = []
- for filename in os.listdir(path):
- files.append(filename)
- return files
- def getCountConfig(file):
- config = ConfigParser.RawConfigParser()
- if os.path.isfile(file) == False:
- config.add_section('Counts')
- with open(file,'w') as fileh:
- config.write(fileh)
- config.read(file)
- items = config.items('Counts')
- return items
- def getProgramInfo(file,counts=0):
- config = ConfigParser.RawConfigParser()
- onfig.read(file)
- items = config.items('Desktop Entry')
- items['counts'] = counts
- return items
- def getAllPrograms(path,files,counts):
- programs = {}
- for file in files:
- progams.append(getProgramInfo(path+file,counts[file]))
- return programs
- #code
- counts = getCountConfig(countFile)
- files = getProgramFiles(programsPath)
- print files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement