[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: www/sites/www-devel/extractappdata
From: Daniel Laidig <d.laidig () gmx ! de>
Date: 2010-01-29 21:57:47
Message-ID: 1264802267.945611.18942.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1082178 by laidig:
make downloading and parsing of desktop files more robust
M +24 -2 codeparser.py
M +4 -3 downloader.py
M +12 -0 parser.py
--- trunk/www/sites/www-devel/extractappdata/codeparser.py #1082177:1082178
@@ -22,6 +22,15 @@
import re, sys
+categoryMap = {
+ "Game": "Games",
+ "System": "System",
+ "Graphics": "Graphics",
+ "Education": "Education",
+ "Utility": "Utilities",
+
+}
+
class CodeParser:
strconcat = re.compile('"(?:[^"]|\\\\")*"\s*', re.DOTALL)
@@ -33,22 +42,35 @@
def extractGenericName(self, f):
regexp = re.compile(r'^GenericName=(.+)$')
+ regexp2 = re.compile(r'^Comment=(.+)$')
+ fallback = None
for line in f:
line = line[:-1]
m = regexp.match(line)
+ m2 = regexp2.match(line)
+ if m2:
+ fallback = m2.group(1)
if not m:
continue
return m.group(1)
+ return fallback
def extractCategory(self, f):
- regexp = re.compile(r'^Categories=Qt;KDE;(.+?)(;.+)?$')
+ regexp = re.compile(r'^Categories=(.+)$')
categories = None
for line in f:
line = line[:-1]
m = regexp.match(line)
if not m:
continue
- return m.group(1)
+ categories = m.group(1).split(";")
+ break
+ if not categories:
+ return None
+ for category in categories:
+ if category in categoryMap:
+ return categoryMap[category]
+ print " Error: No known category in", categories
# Contact C++ strings
def concatstr(self, param):
--- trunk/www/sites/www-devel/extractappdata/downloader.py #1082177:1082178
@@ -86,15 +86,16 @@
def recursiveDownloadSources(self, applicationName, path, codeFile, \
desktopFile): entries = self.scmDownloader.svnList(path)
+ lastPathSegment = path.split("/")[-2]
for entry in entries:
if entry[-1:] == "/":
- if entry in (applicationName+"/", "src/", "program/"):
+ if entry in (applicationName+"/", "src/", "data/", "program/", \
"gui/", lastPathSegment+"/"):
self.recursiveDownloadSources(applicationName, path+entry, \
codeFile, desktopFile) else:
- if entry in ("main.cpp", "version.h", "daboutdata.h") and codeFile \
!= None: + if entry.lower() in ("main.cpp", "version.h", \
"daboutdata.h") and codeFile != None: print " Downloading", path+entry
self.scmDownloader.svnDownload(path+entry, codeFile)
- if entry in (applicationName+".desktop") and desktopFile != None:
+ if entry.lower() in (applicationName+".desktop", \
lastPathSegment+".desktop") and desktopFile != None: print " Downloading", \
path+entry
self.scmDownloader.svnDownload(path+entry, desktopFile)
--- trunk/www/sites/www-devel/extractappdata/parser.py #1082177:1082178
@@ -21,6 +21,14 @@
from codeparser import CodeParser
import sys
+categoryFallbacks = {
+ "ktts": "Utilities",
+}
+
+genericNameFallbacks = {
+ "killbots": "",
+}
+
class Parser:
def __init__(self):
self.apps = []
@@ -57,6 +65,10 @@
genericName = self.codeParser.extractGenericName(desktopFile)
desktopFile.seek(0)
category = self.codeParser.extractCategory(desktopFile)
+ if app.name in genericNameFallbacks:
+ genericName = genericNameFallbacks[app.name]
+ if app.name in categoryFallbacks:
+ category = categoryFallbacks[app.name]
if genericName == None:
print " Failed to extract generic name for", app.name
sys.exit(1)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic