SF.net SVN: gar:[23331] csw/mgar/gar/v2/lib
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sat Apr 5 14:32:26 CEST 2014
Revision: 23331
http://sourceforge.net/p/gar/code/23331
Author: wahwah
Date: 2014-04-05 12:32:26 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
pkgdb-web: Show maintainer email in catalog timing
Catalog timing could be integrated into the main catalog endpoint. The clients
would only need to deal with the extra fields, and take up the foo|bar
formatting on themselves.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/models.py
csw/mgar/gar/v2/lib/python/representations.py
csw/mgar/gar/v2/lib/web/pkgdb_web.py
Modified: csw/mgar/gar/v2/lib/python/models.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models.py 2014-04-05 12:32:18 UTC (rev 23330)
+++ csw/mgar/gar/v2/lib/python/models.py 2014-04-05 12:32:26 UTC (rev 23331)
@@ -549,6 +549,9 @@
sqlbuilder.INNERJOINOn(None,
CatalogGenData,
Srv4FileStats.q.md5_sum==CatalogGenData.q.md5_sum),
+ sqlbuilder.INNERJOINOn(None,
+ Maintainer,
+ Srv4FileStats.q.maintainer==Maintainer.q.id),
]
where = sqlbuilder.AND(
Srv4FileInCatalog.q.osrel==sqo_osrel,
@@ -557,22 +560,23 @@
Srv4FileStats.q.use_to_generate_catalogs==True,
)
select = sqlbuilder.Select(
- ['catalogname',
- 'version_string',
- 'pkgname',
- 'basename',
+ ['catalogname', # 0
+ 'version_string', # 1
+ 'pkgname', # 2
+ 'basename', # 3
'srv4_file_stats.md5_sum', # Hardcoded table name, is it portable?
- 'size',
- 'deps',
- 'i_deps',
- 'pkginfo_name',
+ 'size', # 5
+ 'deps', # 6
+ 'i_deps', # 7
+ 'pkginfo_name', # 8
# The above columns are used to generate catalogs.
# Additional columns can be added blow.
- 'maintainer_id',
- 'mtime',
- 'created_on',
- 'created_by',
- ],
+ # 'maintainer.id', # 9
+ 'maintainer.email', # 9
+ 'mtime', # 10
+ 'created_on', # 11
+ 'created_by', # 12
+ ],
where=where,
orderBy='catalogname',
join=join)
Modified: csw/mgar/gar/v2/lib/python/representations.py
===================================================================
--- csw/mgar/gar/v2/lib/python/representations.py 2014-04-05 12:32:18 UTC (rev 23330)
+++ csw/mgar/gar/v2/lib/python/representations.py 2014-04-05 12:32:26 UTC (rev 23331)
@@ -17,9 +17,15 @@
# Full catalog entry, enough to write a line of a catalog file.
CatalogEntry = collections.namedtuple(
- 'CatalogEntry', 'catalogname version pkgname basename '
- 'md5_sum size deps category i_deps desc')
+ 'CatalogEntry',
+ ['catalogname', 'version', 'pkgname', 'basename', 'md5_sum', 'size',
+ 'deps', 'category', 'i_deps', 'desc'])
+CatalogTimingEntry = collections.namedtuple(
+ 'CatalogTimingEntry',
+ ['catalogname', 'version', 'pkgname', 'basename', 'md5_sum', 'size',
+ 'deps', 'category', 'i_deps', 'desc', 'maintainer', 'mtime', 'inserted_on', 'inserted_by'])
+
PkgmapEntry = collections.namedtuple(
'PkgmapEntry',
'line, class_, mode, owner, group, path, target, type_, '
Modified: csw/mgar/gar/v2/lib/web/pkgdb_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/pkgdb_web.py 2014-04-05 12:32:18 UTC (rev 23330)
+++ csw/mgar/gar/v2/lib/web/pkgdb_web.py 2014-04-05 12:32:26 UTC (rev 23331)
@@ -662,6 +662,12 @@
return response
+def FormatPkginstList(lst):
+ if lst:
+ return '|'.join(lst)
+ else:
+ return 'none'
+
def GetCatalogEntries(catrel_name, arch_name, osrel_name):
"""Returns a list of CatalogEntry tuples."""
try:
@@ -670,31 +676,26 @@
except sqlobject.main.SQLObjectNotFound:
raise web.notfound()
rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
- def FormatList(lst):
- if lst:
- return '|'.join(lst)
- else:
- return 'none'
- def GenCatalogEntry(row):
+ def MakeCatalogEntry(row):
i_deps = cjson.decode(row[7])
- i_deps_str = FormatList(i_deps)
+ i_deps_str = FormatPkginstList(i_deps)
deps_with_desc = cjson.decode(row[6])
deps = [x[0] for x in deps_with_desc if x[0].startswith('CSW')]
- deps_str = FormatList(deps)
+ deps_str = FormatPkginstList(deps)
entry = representations.CatalogEntry(
catalogname=row[0], # 0
version=row[1], # 1
pkgname=row[2], # 2
basename=row[3], # 3
md5_sum=row[4], # 4
- size=str(row[5]), # 5
+ size=row[5], # 5 # This needs to be an int in JSON
deps=deps_str, # 6
category="none", # 7
i_deps=i_deps_str, # 8
desc=row[8], # 9
)
return entry
- entries_list = [GenCatalogEntry(row) for row in rows]
+ entries_list = [MakeCatalogEntry(row) for row in rows]
return entries_list
@@ -709,9 +710,7 @@
entries_list = GetCatalogEntries(catrel_name, arch_name, osrel_name)
response_list = []
for entry in entries_list:
- entry_dict = entry._asdict()
- entry_dict["size"] = int(entry_dict["size"])
- response_list.append(entry_dict)
+ response_list.append(entry._asdict())
response = cjson.encode(response_list)
web.header('Content-Length', str(len(response)))
return response
@@ -745,23 +744,29 @@
except sqlobject.main.SQLObjectNotFound:
raise web.notfound()
rows = list(models.GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel))
- def PrepareForJson(row):
- # The size (5th row) is returned as a large integer, which cannot be represented
- # in JSON.
- # 'maintainer', #9
- # 'mtime', #10
- # 'created_on', #11
- # 'created_by', #12
- newrow = list(row)
- newrow[5] = int(newrow[5])
- newrow[6] = cjson.decode(newrow[6])
- newrow[7] = cjson.decode(newrow[7])
- if newrow[10]:
- newrow[10] = newrow[10].isoformat()
- if newrow[11]:
- newrow[11] = newrow[11].isoformat()
- return newrow
- rows = [PrepareForJson(x) for x in rows]
+ # Change this to return a list of dicts
+ def MakeCatalogTimingEntry(row):
+ i_deps = tuple(cjson.decode(row[7]))
+ deps_with_desc = cjson.decode(row[6])
+ deps = tuple(x[0] for x in deps_with_desc if x[0].startswith('CSW'))
+ entry = representations.CatalogTimingEntry(
+ catalogname=row[0], # 0
+ version=row[1], # 1
+ pkgname=row[2], # 2
+ basename=row[3], # 3
+ md5_sum=row[4], # 4
+ size=row[5], # 5 # This needs to be an int in JSON
+ deps=deps, # 6
+ category="none", # 7
+ i_deps=i_deps, # 8
+ desc=row[8], # 9
+ maintainer=row[9],
+ mtime=row[10].isoformat(),
+ inserted_on=row[11].isoformat(),
+ inserted_by=row[12],
+ )
+ return entry
+ rows = [MakeCatalogTimingEntry(x)._asdict() for x in rows]
response = cjson.encode(rows)
web.header('Content-Length', str(len(response)))
return response
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list