[Pypi-checkins] r756 - branches/tarek-pep-345-support
tarek.ziade
python-checkins at python.org
Tue Apr 13 01:11:45 CEST 2010
Author: tarek.ziade
Date: Tue Apr 13 01:11:45 2010
New Revision: 756
Modified:
branches/tarek-pep-345-support/config.ini
branches/tarek-pep-345-support/webui.py
Log:
now checking the metadata 1.2 using distutils2 checker
Modified: branches/tarek-pep-345-support/config.ini
==============================================================================
--- branches/tarek-pep-345-support/config.ini (original)
+++ branches/tarek-pep-345-support/config.ini Tue Apr 13 01:11:45 2010
@@ -1,26 +1,27 @@
[database]
name = packages
user = pypi
-files_dir = /tmp/files
-docs_dir = /tmp/docs
+files_dir = /MacDev/svn.python.org/pypi-pep345/files
+docs_dir = /MacDev/svn.python.org/pypi-pep345/docs
[webui]
mailhost = mail.commonground.com.au
adminemail = richard at commonground.com.au
-url = http://localhost/cgi-bin/pypi.cgi
+replyto = richard at commonground.com.au
+url = http://localhost:8000
pydotorg = http://www.python.org/
simple_script = /simple
files_url = http://localhost/pypi_files
-rss_file = /tmp/pypi_rss.xml
+rss_file = /MacDev/svn.python.org/pypi-pep345/pypi_rss.xml
debug_mode = yes
cheesecake_password = secret
privkey = privkey
simple_sign_script = /serversig
[logging]
-file =
-mailhost =
-fromaddr =
+file =
+mailhost =
+fromaddr =
toaddrs =
[mirrors]
Modified: branches/tarek-pep-345-support/webui.py
==============================================================================
--- branches/tarek-pep-345-support/webui.py (original)
+++ branches/tarek-pep-345-support/webui.py Tue Apr 13 01:11:45 2010
@@ -4,6 +4,7 @@
import re, zipfile, logging, pprint, sets, shutil, Cookie, subprocess
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
from distutils.util import rfc822_escape
+from distutils2.metadata import DistributionMetadata
# Importing M2Crypto patches urllib; don't let them do that
orig = urllib.URLopener.open_https.im_func
@@ -1741,6 +1742,23 @@
self.write_template('message.pt', title='Package verification',
message='Validated OK')
+ def _validate_metadata_1_2(self, data):
+ # loading the metadata into
+ # a DistributionMetadata instance
+ # so we can use its check() method
+ metadata = DistributionMetadata()
+ for key, value in data.items():
+ metadata[key] = value
+ metadata['Metadata-Version'] = '1.2'
+ missing, warnings = metadata.check()
+
+ # raising the first problem
+ if len(missing) > 0:
+ raise ValueError, '"%s" is missing' % missing[0]
+
+ if len(warnings) > 0:
+ raise ValueError, warnings[0]
+
def validate_metadata(self, data):
''' Validate the contents of the metadata.
'''
@@ -1749,7 +1767,10 @@
if not data.get('version', ''):
raise ValueError, 'Missing required field "version"'
if data.has_key('metadata_version'):
+ metadata_version = data['metadata_version']
del data['metadata_version']
+ else:
+ metadata_version = '1.0' # default
# Traditionally, package names are restricted only for
# technical reasons; / is not allowed because it may be
@@ -1775,8 +1796,10 @@
except ValueError, message:
raise ValueError, 'Bad "provides" syntax: %s'%message
- # XXX tarek todo : check PEP 345 fields
- #
+ # check PEP 345 fields
+ if metadata_version == '1.2':
+ self._validate_metadata_1_2(data)
+
# check classifiers
if data.has_key('classifiers'):
d = {}
More information about the Pypi-checkins
mailing list