diff --git a/.gitignore b/.gitignore index 23f0370c4d044b..061700a9604b41 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,6 @@ scratch /css/build-temp /css/dist /css/dist_last -/css/tools/cache /url/tools/IdnaTestV2.txt /webaudio/idl/* diff --git a/CODEOWNERS b/CODEOWNERS index 2372633782e226..140e0c6545b855 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,6 +1,3 @@ -# Prevent accidentially touching CSS subtree -/css/tools/apiclient/ @plinss @web-platform-tests/wpt-core-team - # Require review for changes that often need an RFC /resources/testdriver* @web-platform-tests/wpt-core-team /resources/testharness* @web-platform-tests/wpt-core-team diff --git a/css/tools/META.yml b/css/tools/META.yml deleted file mode 100644 index e08d85a38fee64..00000000000000 --- a/css/tools/META.yml +++ /dev/null @@ -1,4 +0,0 @@ -suggested_reviewers: - - plinss - - kojiishi - - jgraham diff --git a/css/tools/README.md b/css/tools/README.md deleted file mode 100644 index 8310d89d7adaab..00000000000000 --- a/css/tools/README.md +++ /dev/null @@ -1,15 +0,0 @@ -This directory contains the CSS build system. - -It is recommended that it is run with `build.sh`, as -this ensures all dependencies are installed. Note that it is not -required to build the testsuites to run tests; you can just run tests -as with any other web-platform-tests tests (see ../../docs/). - -The build system is formed of build.py in this directory, the -w3ctestlib package in w3ctestlib/, and the apiclient package in -apiclient/apiclient/. Note that apiclient exists as a separate -upstream project at https://hg.csswg.org/dev/apiclient/, and that -ideally any changes here should make it upstream. - -Warning: The CSS build system is not tested in CI at all, so don't make any -changes without ensuring that it still works locally. diff --git a/css/tools/apiclient/.gitignore b/css/tools/apiclient/.gitignore deleted file mode 100644 index d43a721ddd2fd9..00000000000000 --- a/css/tools/apiclient/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.xcodeproj -*.DS_Store -local/* -*.log -*.pyc -*.orig -uritemplate-test/* -.hg/* diff --git a/css/tools/apiclient/.hgignore b/css/tools/apiclient/.hgignore deleted file mode 100644 index 07d6d3d104de5a..00000000000000 --- a/css/tools/apiclient/.hgignore +++ /dev/null @@ -1,10 +0,0 @@ -syntax: glob -*.xcodeproj -*.DS_Store -local/* -*.log -*.pyc -*.orig -uritemplate-test/* -.git/* -._* diff --git a/css/tools/apiclient/README.md b/css/tools/apiclient/README.md deleted file mode 100644 index 6e332b852adc99..00000000000000 --- a/css/tools/apiclient/README.md +++ /dev/null @@ -1,174 +0,0 @@ -apiclient -========== - -Client class for calling http+json APIs in Python. Requires Python 2.7. - -Supports json home pages per: -http://tools.ietf.org/html/draft-nottingham-json-home-03 - - -Installation ------------- -Standard python package installation: - - python setup.py install - - -Usage ------ -Import the apiclient package and instantiate a client. - - import apiclient - - api = apiclient.APIClient('http://api.example.com') - -Call APIs: - - result = api.call('foo', var1=arg1, var2=arg2) - print result.data - - -APIClient class ---------------- -**class apiclient.APIClient(baseURI, version = None, username = None, password = None)** - -The APIClient constructor takes the base URI for the api, an optional request version identifier, username and password. - -**APIClient.baseURI** - -The base URI set in the constructor, read-only. - -**APIClient.resourceNames** - -A list of available API resource names. - -**APIClient.resource(name)** - -Get a named APIResource. - -**APIClient.setVersion(name, version)** - -Set the request version identifier for a specific resource. If not set, the default version identifier will be used. - -**APIClient.setAccept(name, mimeType)** - -Set the requested Content-Type for a specific resource. If not set, 'application/json' will be used. - -**APIClient.get(name, [kwargs])** - -Perform an HTTP GET on the named resource. Any named arguments supplied may be used in computing the actual URI to call. Returns an APIResponse or None if the resource name is not known. - -**APIClient.postForm(name, payload = None, [kwargs])** - -Perform an HTTP POST on the named resource. The payload, if present, may be either a dict or sequence of two-tuples and will be form encoded. Any named arguments supplied may be used in computing the actual URI to call. Returns an APIResponse or None if the resource name is not known. - -**APIClient.put(name, payload = None, payloadType = None, [kwargs])** - -Perform an HTTP PUT on the named resource. The payload, if present, will be sent to the server using the payloadType Content-Type. The payload must be pre-encoded and will not be processed by the APIClient. Any named arguments supplied may be used in computing the actual URI to call. Returns an APIResponse or None if the resource name is not known. - -**APIClient.patch(name, patch = None, [kwargs])** - -Perform an HTTP PATCH on the named resource. The patch, if present, will be encoded in JSON and sent to the server as a 'application/json-patch'. Any named arguments supplied may be used in computing the actual URI to call. Returns an APIResponse or None if the resource name is not known. - -**APIClient.delete(name, [kwargs])** - -Perform an HTTP DELETE on the named resource. Any named arguments supplied may be used in computing the actual URI to call. Returns an APIResponse or None if the resource name is not known. - - -APIResponse class ------------------ -**APIResponse.status** - -The HTTP status code of the response. - -**APIResponse.headers** - -A dict of HTTP response headers. - -**APIResponse.contentType** - -The Content-Type of the response. - -**APIResponse.encoding** - -The encoding of the response. - -**APIResponse.data** - -The body of the response. If the contentType is json, the data will be decoded into native objects. - - -APIResource class ------------------ -Describes the properties of an available API resource. - -**APIResource.template** - -The URITemplate used when calling the resource. - -**APIResource.variables** - -A dict of variables that may be passed to the resource. Keys are variable names, values are the URI identifier of the variable, if available (see http://tools.ietf.org/html/draft-nottingham-json-home-03#section-3.1 ). - -**APIResource.hints** - -An APIHints object describing any hints for the resource (see http://tools.ietf.org/html/draft-nottingham-json-home-03#section-4 ). - - -APIHints class --------------- -**APIHints.httpMethods** - -A list of HTTP methods the resource may be called with. - -**APIHints.formats** - -A dict of formats available for each HTTP method. Keys are HTTP methods, values are a list of Content-Types available. - -**APIHints.ranges** - -Not yet implemented. - -**APIHints.preferences** - -Not yet implemented. - -**APIHints.preconditions** - -Not yet implemented. - -**APIHints.auth** - -Not yet implemented. - -**APIHints.docs** - -A URI for documentation for the resource. - -**APIHints.status** - -The status of the resource. - - -URITemplate class ------------------ -Parses and expands URITemplates per RFC 6750 (plus a few extensions). - -**class uritemplate.URITemplate(template)** - -Construct a URITemplate. Raises exceptions if malformed. - -**URITemplate.variables** - -A set of variables available in the template. - -**URITemplate.expand([kwargs])** - -Return the expanded template substituting any passed keyword arguments. - - -Notes ------ -Resource names may be absolute URIs or relative to the base URI of the API. - - diff --git a/css/tools/apiclient/__init__.py b/css/tools/apiclient/__init__.py deleted file mode 100644 index b49652b48defa8..00000000000000 --- a/css/tools/apiclient/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 -# -# Copyright © 2013 Hewlett-Packard Development Company, L.P. -# -# This work is distributed under the W3C® Software License [1] -# in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -# - -# define package for direct inclusion when not installed - -__all__ = ['apiclient'] \ No newline at end of file diff --git a/css/tools/apiclient/apiclient/__init__.py b/css/tools/apiclient/apiclient/__init__.py deleted file mode 100644 index 9be8333de281de..00000000000000 --- a/css/tools/apiclient/apiclient/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 -# -# Copyright © 2013 Hewlett-Packard Development Company, L.P. -# -# This work is distributed under the W3C® Software License [1] -# in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -# - -__all__ = ['apiclient', 'uritemplate'] - -import apiclient diff --git a/css/tools/apiclient/apiclient/apiclient.py b/css/tools/apiclient/apiclient/apiclient.py deleted file mode 100644 index 99f30e62710e87..00000000000000 --- a/css/tools/apiclient/apiclient/apiclient.py +++ /dev/null @@ -1,283 +0,0 @@ -# coding=utf-8 -# -# Copyright © 2013 Hewlett-Packard Development Company, L.P. -# -# This work is distributed under the W3C® Software License [1] -# in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -# - -# Process URI templates per http://tools.ietf.org/html/rfc6570 - - -import urllib2 -import urlparse -import json -import base64 -import contextlib -import collections -import UserString - -import uritemplate - -class MimeType(UserString.MutableString): - def __init__(self, mimeType): - UserString.MutableString.__init__(self, mimeType) - self._type = None - self._subtype = None - self._structure = None - - slashIndex = mimeType.find('/') - if (-1 < slashIndex): - self._type = mimeType[:slashIndex] - mimeType = mimeType[slashIndex + 1:] - plusIndex = mimeType.find('+') - if (-1 < plusIndex): - self._subtype = mimeType[:plusIndex] - self._structure = mimeType[plusIndex + 1:] - else: - self._structure = mimeType - else: - self._type = mimeType - - def _update(self): - if (self._structure): - if (self._subtype): - self.data = self._type + '/' + self._subtype + '+' + self._structure - else: - self.data = self._type + '/' + self._structure - else: - self.data = self._type - - def set(self, type, structure, subtype = None): - self._type = type - self._subtype = subtype - self._structure = structure - self._update() - - @property - def type(self): - return self._type - - @type.setter - def type(self, value): - self._type = value - self._update() - - @property - def subtype(self): - return self._subtype - - @subtype.setter - def subtype(self, value): - self._subtype = value - self._update() - - @property - def structure(self): - return self._structure - - @structure.setter - def structure(self, value): - self._structure = value - self._update() - - -class APIResponse(object): - def __init__(self, response): - self.status = response.getcode() if (response) else 0 - self.headers = response.info() if (response) else {} - self.data = response.read() if (200 == self.status) else None - - if (self.data and - (('json' == self.contentType.structure) or ('json-home' == self.contentType.structure))): - try: - self.data = json.loads(self.data, object_pairs_hook = collections.OrderedDict) - except: - pass - - @property - def contentType(self): - contentType = self.headers.get('content-type') if (self.headers) else None - return MimeType(contentType.split(';')[0]) if (contentType and (';' in contentType)) else MimeType(contentType) - - @property - def encoding(self): - contentType = self.headers.get('content-type') if (self.headers) else None - if (contentType and (';' in contentType)): - encoding = contentType.split(';', 1)[1] - if ('=' in encoding): - return encoding.split('=', 1)[1].strip() - return 'utf-8' - - -class APIHints(object): - def __init__(self, data): - self.httpMethods = [method.upper() for method in data['allow'] if method] if ('allow' in data) else ['GET'] - self.formats = {} - formats = [MimeType(format) for format in data['formats']] if ('formats' in data) else [] - if (formats): - if ('GET' in self.httpMethods): - self.formats['GET'] = formats - if ('PUT' in self.httpMethods): - self.formats['PUT'] = formats - - if (('PATCH' in self.httpMethods) and ('accept-patch' in data)): - self.formats['PATCH'] = [MimeType(format) for format in data['accept-patch']] - if (('POST' in self.httpMethods) and ('accept-post' in data)): - self.formats['POST'] = [MimeType(format) for format in data['accept-post']] - - # TODO: ranges from 'accept-ranges'; preferece tokens from 'accept-prefer'; - # preconditions from 'precondition-req'; auth from 'auth-req' - self.ranges = None - self.preferences = None - self.preconditions = None - self.auth = None - - self.docs = data.get('docs') - self.status = data.get('status') - - -class APIResource(object): - def __init__(self, baseURI, uri, variables = None, hints = None): - try: - self.template = uritemplate.URITemplate(urlparse.urljoin(baseURI, uri)) - if (variables): - self.variables = {variable: urlparse.urljoin(baseURI, variables[variable]) for variable in variables} - else: - self.variables = {variable: '' for variable in self.template.variables} - self.hints = hints - except Exception as e: - self.template = uritemplate.URITemplate('') - self.variables = {} - self.hints = None - - -class APIClient(object): - def __init__(self, baseURI, version = None, username = None, password = None): - self._baseURI = baseURI - self.defaultVersion = version - self.defaultAccept = 'application/json' - self.username = username - self.password = password - self._resources = {} - self._versions = {} - self._accepts = {} - - self._loadHome() - - - @property - def baseURI(self): - return self._baseURI - - def _loadHome(self): - home = self._callURI('GET', self.baseURI, 'application/home+json, application/json-home, application/json') - if (home): - if ('application/json' == home.contentType): - for name in home.data: - apiKey = urlparse.urljoin(self.baseURI, name) - self._resources[apiKey] = APIResource(self.baseURI, home.data[name]) - elif (('application/home+json' == home.contentType) or - ('application/json-home' == home.contentType)): - resources = home.data.get('resources') - if (resources): - for name in resources: - apiKey = urlparse.urljoin(self.baseURI, name) - data = resources[name] - uri = data['href'] if ('href' in data) else data.get('href-template') - variables = data.get('href-vars') - hints = APIHints(data['hints']) if ('hints' in data) else None - self._resources[apiKey] = APIResource(self.baseURI, uri, variables, hints) - - - def relativeURI(self, uri): - if (uri.startswith(self.baseURI)): - relative = uri[len(self.baseURI):] - if (relative.startswith('/') and not self.baseURI.endswith('/')): - relative = relative[1:] - return relative - return uri - - @property - def resourceNames(self): - return [self.relativeURI(apiKey) for apiKey in self._resources] - - def resource(self, name): - return self._resources.get(urlparse.urljoin(self.baseURI, name)) - - def addResource(self, name, uri): - resource = APIResource(self.baseURI, uri) - apiKey = urlparse.urljoin(self.baseURI, name) - self._resources[apiKey] = resource - - def _accept(self, resource): - version = None - if (api and (api in self._versions)): - version = self._versions[api] - if (not version): - version = self.defaultVersion - return ('application/' + version + '+json, application/json') if (version) else 'application/json' - - def _callURI(self, method, uri, accept, payload = None, payloadType = None): - try: - request = urllib2.Request(uri, data = payload, headers = { 'Accept' : accept }) - if (self.username and self.password): - request.add_header('Authorization', b'Basic ' + base64.b64encode(self.username + b':' + self.password)) - if (payload and payloadType): - request.add_header('Content-Type', payloadType) - request.get_method = lambda: method - - with contextlib.closing(urllib2.urlopen(request)) as response: - return APIResponse(response) - except Exception as e: - pass - return None - - def _call(self, method, name, arguments, payload = None, payloadType = None): - apiKey = urlparse.urljoin(self.baseURI, name) - resource = self._resources.get(apiKey) - - if (resource): - uri = resource.template.expand(**arguments) - if (uri): - version = self._versions.get(apiKey) if (apiKey in self._versions) else self.defaultVersion - accept = MimeType(self._accepts(apiKey) if (apiKey in self._accepts) else self.defaultAccept) - if (version): - accept.subtype = version - return self._callURI(method, uri, accept, payload, payloadType) - return None - - def setVersion(self, name, version): - apiKey = urlparse.urljoin(self.baseURI, name) - self._versions[apiKey] = version - - def setAccept(self, name, mimeType): - apiKey = urlparse.urljoin(self.baseURI, name) - self._accepts[apiKey] = mimeType - - def get(self, name, **kwargs): - return self._call('GET', name, kwargs) - - def post(self, name, payload = None, payloadType = None, **kwargs): - return self._call('POST', name, kwargs, payload, payloadType) - - def postForm(self, name, payload = None, **kwargs): - return self._call('POST', name, kwargs, urllib.urlencode(payload), 'application/x-www-form-urlencoded') - - def postJSON(self, name, payload = None, **kwargs): - return self._call('POST', name, kwargs, json.dumps(payload), 'application/json') - - def put(self, name, payload = None, payloadType = None, **kwargs): - return self._call('PUT', name, kwargs, payload, payloadType) - - def patch(self, name, patch = None, **kwargs): - return self._call('PATCH', name, kwargs, json.dumps(patch), 'application/json-patch') - - def delete(self, name, **kwargs): - return self._call('DELETE', name, kwargs) - - diff --git a/css/tools/apiclient/apiclient/uritemplate.py b/css/tools/apiclient/apiclient/uritemplate.py deleted file mode 100644 index 737cbe78184d11..00000000000000 --- a/css/tools/apiclient/apiclient/uritemplate.py +++ /dev/null @@ -1,379 +0,0 @@ -# coding=utf-8 -# -# Copyright © 2013 Hewlett-Packard Development Company, L.P. -# -# This work is distributed under the W3C® Software License [1] -# in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -# - -# Process URI templates per http://tools.ietf.org/html/rfc6570 - -import re - - -class UnsupportedExpression(Exception): - def __init__(self, expression): - self.expression = expression - - def __unicode__(self): - return u'Unsopported expression: ' + self.expression - -class BadExpression(Exception): - def __init__(self, expression): - self.expression = expression - - def __unicode__(self): - return u'Bad expression: ' + self.expression - -class BadVariable(Exception): - def __init__(self, variable): - self.variable = variable - - def __unicode__(self): - return u'Bad variable: ' + self.variable - -class BadExpansion(Exception): - def __init__(self, variable): - self.variable = variable - - def __unicode__(self): - return u'Bad expansion: ' + self.variable - -class URITemplate(object): - alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - digit = '0123456789' - hexdigit = '0123456789ABCDEFabcdef' - genDelims = ':/?#[]@' - subDelims = "!$&'()*+,;=" - varstart = alpha + digit + '_' - varchar = varstart + '.' - unreserved = alpha + digit + '-._~' - reserved = genDelims + subDelims - - def __init__(self, template): - self.template = template - - self.parts = [] - parts = re.split(r'(\{[^\}]*\})', self.template) - for part in parts: - if (part): - if (('{' == part[0]) and ('}' == part[-1])): - expression = part[1:-1] - if (re.match('^([a-zA-Z0-9_]|%[0-9a-fA-F][0-9a-fA-F]).*$', expression)): - self.parts.append(SimpleExpansion(expression)) - elif ('+' == part[1]): - self.parts.append(ReservedExpansion(expression)) - elif ('#' == part[1]): - self.parts.append(FragmentExpansion(expression)) - elif ('.' == part[1]): - self.parts.append(LabelExpansion(expression)) - elif ('/' == part[1]): - self.parts.append(PathExpansion(expression)) - elif (';' == part[1]): - self.parts.append(PathStyleExpansion(expression)) - elif ('?' == part[1]): - self.parts.append(FormStyleQueryExpansion(expression)) - elif ('&' == part[1]): - self.parts.append(FormStyleQueryContinuation(expression)) - elif (part[1] in '=,!@|'): - raise UnsupportedExpression(part) - else: - raise BadExpression(part) - else: - if (('{' not in part) and ('}' not in part)): - self.parts.append(Literal(part)) - else: - raise BadExpression(part) - - @property - def variables(self): - vars = set() - for part in self.parts: - vars.update(part.variables) - return vars - - def expand(self, **kwargs): - try: - expanded = [part.expand(kwargs) for part in self.parts] - except (BadExpansion): - return None - return ''.join([expandedPart for expandedPart in expanded if (expandedPart is not None)]) - - def __str__(self): - return self.template.encode('ascii', 'replace') - - def __unicode__(self): - return unicode(self.template) - - -class Variable(object): - def __init__(self, name): - self.name = '' - self.maxLength = None - self.explode = False - self.array = False - - if (name[0:1] not in URITemplate.varstart): - raise BadVariable(name) - - if (':' in name): - name, maxLength = name.split(':', 1) - if ((0 < len(maxLength)) and (len(maxLength) < 4)): - for digit in maxLength: - if (digit not in URITemplate.digit): - raise BadVariable(name + ':' + maxLength) - self.maxLength = int(maxLength) - if (not self.maxLength): - raise BadVariable(name + ':' + maxLength) - else: - raise BadVariable(name + ':' + maxLength) - elif ('*' == name[-1]): - name = name[:-1] - self.explode = True - elif ('[]' == name[-2:]): - name = name[:-2] - self.array = True - self.explode = True - - index = 0 - while (index < len(name)): - codepoint = name[index] - if (('%' == codepoint) and - ((index + 2) < len(name)) and - (name[index + 1] in URITemplate.hexdigit) and - (name[index + 2] in URITemplate.hexdigit)): - self.name += name[index:index + 3] - index += 2 - elif (codepoint in URITemplate.varchar): - self.name += codepoint - else: - raise BadVariable(name + ((':' + self.maxLength) if (self.maxLength) else '') + ('[]' if (self.array) else ('*' if (self.explode) else ''))) - index += 1 - - -class Expression(object): - def __init__(self): - pass - - @property - def variables(self): - return [] - - def _encode(self, value, legal, pctEncoded): - output = '' - index = 0 - while (index < len(value)): - codepoint = value[index] - if (codepoint in legal): - output += codepoint - elif (pctEncoded and ('%' == codepoint) and - ((index + 2) < len(value)) and - (value[index + 1] in URITemplate.hexdigit) and - (value[index + 2] in URITemplate.hexdigit)): - output += value[index:index + 3] - index += 2 - else: - utf8 = codepoint.encode('utf8') - for byte in utf8: - output += '%' + URITemplate.hexdigit[ord(byte) / 16] + URITemplate.hexdigit[ord(byte) % 16] - index += 1 - return output - - def _uriEncodeValue(self, value): - return self._encode(value, URITemplate.unreserved, False) - - def _uriEncodeName(self, name): - return self._encode(unicode(name), URITemplate.unreserved + URITemplate.reserved, True) if (name) else '' - - def _join(self, prefix, joiner, value): - if (prefix): - return prefix + joiner + value - return value - - def _encodeStr(self, variable, name, value, prefix, joiner, first): - if (variable.maxLength): - if (not first): - raise BadExpansion(variable) - return self._join(prefix, joiner, self._uriEncodeValue(value[:variable.maxLength])) - return self._join(prefix, joiner, self._uriEncodeValue(value)) - - def _encodeDictItem(self, variable, name, key, item, delim, prefix, joiner, first): - joiner = '=' if (variable.explode) else ',' - if (variable.array): - prefix = (prefix + '[' + self._uriEncodeName(key) + ']') if (prefix and not first) else self._uriEncodeName(key) - else: - prefix = self._join(prefix, '.', self._uriEncodeName(key)) - return self._encodeVar(variable, key, item, delim, prefix, joiner, False) - - def _encodeListItem(self, variable, name, index, item, delim, prefix, joiner, first): - if (variable.array): - prefix = prefix + '[' + unicode(index) + ']' if (prefix) else '' - return self._encodeVar(variable, None, item, delim, prefix, joiner, False) - return self._encodeVar(variable, name, item, delim, prefix, '.', False) - - def _encodeVar(self, variable, name, value, delim = ',', prefix = '', joiner = '=', first = True): - if (isinstance(value, basestring)): - return self._encodeStr(variable, name, value, prefix, joiner, first) - elif (hasattr(value, 'keys') and hasattr(value, '__getitem__')): # dict-like - if (len(value)): - encodedItems = [self._encodeDictItem(variable, name, key, value[key], delim, prefix, joiner, first) for key in value.keys()] - return delim.join([item for item in encodedItems if (item is not None)]) - return None - elif (hasattr(value, '__getitem__')): # list-like - if (len(value)): - encodedItems = [self._encodeListItem(variable, name, index, item, delim, prefix, joiner, first) for index, item in enumerate(value)] - return delim.join([item for item in encodedItems if (item is not None)]) - return None - else: - return self._encodeStr(variable, name, unicode(value).lower(), prefix, joiner, first) - - def expand(self, values): - return None - - -class Literal(Expression): - def __init__(self, value): - Expression.__init__(self) - self.value = value - - def expand(self, values): - return self._encode(self.value, (URITemplate.unreserved + URITemplate.reserved), True) - - -class Expansion(Expression): - operator = '' - varJoiner = ',' - - def __init__(self, variables): - Expression.__init__(self) - self.vars = [Variable(var) for var in variables.split(',')] - - @property - def variables(self): - return [var.name for var in self.vars] - - def _expandVar(self, variable, value): - return self._encodeVar(variable, self._uriEncodeName(variable.name), value) - - def expand(self, values): - expandedVars = [] - for var in self.vars: - if ((var.name in values) and (values[var.name] is not None)): - expandedVar = self._expandVar(var, values[var.name]) - if (expandedVar is not None): - expandedVars.append(expandedVar) - if (len(expandedVars)): - expanded = self.varJoiner.join(expandedVars) - if (expanded is not None): - return self.operator + expanded - return None - - -class SimpleExpansion(Expansion): - def __init__(self, variables): - Expansion.__init__(self, variables) - - -class ReservedExpansion(Expansion): - def __init__(self, variables): - Expansion.__init__(self, variables[1:]) - - def _uriEncodeValue(self, value): - return self._encode(value, (URITemplate.unreserved + URITemplate.reserved), True) - - -class FragmentExpansion(ReservedExpansion): - operator = '#' - - def __init__(self, variables): - ReservedExpansion.__init__(self, variables) - - -class LabelExpansion(Expansion): - operator = '.' - varJoiner = '.' - - def __init__(self, variables): - Expansion.__init__(self, variables[1:]) - - def _expandVar(self, variable, value): - return self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = ('.' if variable.explode else ',')) - - -class PathExpansion(Expansion): - operator = '/' - varJoiner = '/' - - def __init__(self, variables): - Expansion.__init__(self, variables[1:]) - - def _expandVar(self, variable, value): - return self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = ('/' if variable.explode else ',')) - - -class PathStyleExpansion(Expansion): - operator = ';' - varJoiner = ';' - - def __init__(self, variables): - Expansion.__init__(self, variables[1:]) - - def _encodeStr(self, variable, name, value, prefix, joiner, first): - if (variable.array): - if (name): - prefix = prefix + '[' + name + ']' if (prefix) else name - elif (variable.explode): - prefix = self._join(prefix, '.', name) - return Expansion._encodeStr(self, variable, name, value, prefix, joiner, first) - - def _encodeDictItem(self, variable, name, key, item, delim, prefix, joiner, first): - if (variable.array): - if (name): - prefix = prefix + '[' + name + ']' if (prefix) else name - prefix = (prefix + '[' + self._uriEncodeName(key) + ']') if (prefix and not first) else self._uriEncodeName(key) - elif (variable.explode): - prefix = self._join(prefix, '.', name) if (not first) else '' - else: - prefix = self._join(prefix, '.', self._uriEncodeName(key)) - joiner = ',' - return self._encodeVar(variable, self._uriEncodeName(key) if (not variable.array) else '', item, delim, prefix, joiner, False) - - def _encodeListItem(self, variable, name, index, item, delim, prefix, joiner, first): - if (variable.array): - if (name): - prefix = prefix + '[' + name + ']' if (prefix) else name - return self._encodeVar(variable, unicode(index), item, delim, prefix, joiner, False) - return self._encodeVar(variable, name, item, delim, prefix, '=' if (variable.explode) else '.', False) - - def _expandVar(self, variable, value): - if (variable.explode): - return self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = ';') - value = self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = ',') - return (self._uriEncodeName(variable.name) + '=' + value) if (value) else variable.name - - -class FormStyleQueryExpansion(PathStyleExpansion): - operator = '?' - varJoiner = '&' - - def __init__(self, variables): - PathStyleExpansion.__init__(self, variables) - - def _expandVar(self, variable, value): - if (variable.explode): - return self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = '&') - value = self._encodeVar(variable, self._uriEncodeName(variable.name), value, delim = ',') - return (self._uriEncodeName(variable.name) + '=' + value) if (value is not None) else None - - -class FormStyleQueryContinuation(FormStyleQueryExpansion): - operator = '&' - - def __init__(self, variables): - FormStyleQueryExpansion.__init__(self, variables) - - diff --git a/css/tools/apiclient/setup.py b/css/tools/apiclient/setup.py deleted file mode 100644 index e3b0937638720e..00000000000000 --- a/css/tools/apiclient/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -from distutils.core import setup - -setup(name='apiclient', - version='0.10', - description='Client for JSPN APIs', - author='Peter Linss', - author_email='peter.linss@hp.com', - url='http://github.com/plinss/apiclient/', - packages = ['apiclient'] - ) diff --git a/css/tools/apiclient/test.py b/css/tools/apiclient/test.py deleted file mode 100755 index e485367f840280..00000000000000 --- a/css/tools/apiclient/test.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2013 Hewlett-Packard Development Company, L.P. -# -# This work is distributed under the W3C® Software License [1] -# in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -# - -from __future__ import print_function -import sys -import os -import glob -import json -import exceptions -import collections - -from apiclient import uritemplate -from apiclient import apiclient - - -def runTests(testFileSearch): - for testFilePath in glob.glob(testFileSearch): - print('Running tests from: ' + testFilePath) - with open(testFilePath) as testFile: - testData = json.load(testFile, object_pairs_hook = collections.OrderedDict) - for testSetName in testData: - print(testSetName + ':') - testSet = testData[testSetName] - vars = testSet['variables'] - for test in testSet['testcases']: - expectedResult = test[1] - try: - template = uritemplate.URITemplate(test[0]) - except Exception as e: - if (expectedResult): - print('* FAIL: "' + test[0] + '" got: None, expected "' + expectedResult + '"') - else: - print(' PASS: "' + test[0] + '" == None') - continue - - result = template.expand(**vars) - if (isinstance(expectedResult, basestring)): - if (expectedResult != result): - print('* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected "' + expectedResult + '"') - continue - elif (isinstance(expectedResult, list)): - for possibleResult in expectedResult: - if (possibleResult == result): - break - else: - print('* FAIL: "' + test[0] + '" got: "' + unicode(result) + '", expected:') - print(" or\n".join([' "' + possibleResult + '"' for possibleResult in expectedResult])) - continue - elif (not expectedResult): - if (result): - print('* FAIL "' + test[0] + '" got: "' + unicode(result) + '", expected None') - continue - else: - print('** Unknown expected result type: ' + repr(expectedResult)) - print(' PASS: "' + test[0] + '" == "' + result + '"') - -def debugHook(type, value, tb): - if hasattr(sys, 'ps1') or not sys.stderr.isatty(): - # we are in interactive mode or we don't have a tty-like - # device, so we call the default hook - sys.__excepthook__(type, value, tb) - else: - import traceback, pdb - # we are NOT in interactive mode, print the exception... - traceback.print_exception(type, value, tb) - print() - # ...then start the debugger in post-mortem mode. - pdb.pm() - - -if __name__ == "__main__": # called from the command line - sys.excepthook = debugHook - -# runTests(os.path.join('test', '*.json')) - -# runTests(os.path.join('uritemplate-test', 'spec-examples.json')) -# runTests(os.path.join('uritemplate-test', '*.json')) -### more tests @ https://github.com/uri-templates/uritemplate-test - - - github = apiclient.APIClient('https://api.github.com/', version = 'vnd.github.beta') - print(github.get('user_url', user = 'plinss').data) - -# shepherd = apiclient.APIClient('https://api.csswg.org/shepherd/', version = 'vnd.csswg.shepherd.v1') - shepherd = apiclient.APIClient('https://test.linss.com/shepherd/api', version = 'vnd.csswg.shepherd.v1') - print(shepherd.resourceNames) - specs = shepherd.resource('specifications') - print(specs.variables) -# print specs.hints.docs - print(shepherd.get('specifications', spec = 'compositing-1', anchors = False).data) - - suites = shepherd.resource('test_suites') - print(suites.variables) - print(shepherd.get('test_suites', spec = 'css-shapes-1').data) - - diff --git a/css/tools/apiclient/test/corners.json b/css/tools/apiclient/test/corners.json deleted file mode 100644 index fd0a5a80f8825e..00000000000000 --- a/css/tools/apiclient/test/corners.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "Explode Non-composite" : - { - "level": 4, - "variables": { - "token": "12345" - }, - "testcases" : [ - ["{token}", "12345"], - ["{token*}", "12345"], - ["{.token}", ".12345"], - ["{.token*}", ".12345"], - ["{/token}", "/12345"], - ["{/token*}", "/12345"], - ["{?token}", "?token=12345"], - ["{?token*}", "?token=12345"] - ] - }, - "Non-string Values" : - { - "level": 4, - "variables": { - "positive": true, - "negative": false, - "zero" : 0, - "number" : 42.24, - "list" : ["one", 2, true, false, 0], - "dict" : { "one": "1", "two": 2, "positive": true, "negative": false, "zero": 0 } - }, - "testcases" : [ - ["{positive}", "true"], - ["{positive*}", "true"], - ["{negative}", "false"], - ["{negative*}", "false"], - ["{zero}", "0"], - ["{zero*}", "0"], - ["{number}", "42.24"], - ["{number*}", "42.24"], - ["{.positive}", ".true"], - ["{.positive*}", ".true"], - ["{.negative}", ".false"], - ["{.negative*}", ".false"], - ["{.zero}", ".0"], - ["{.zero*}", ".0"], - ["{.number}", ".42.24"], - ["{.number*}", ".42.24"], - ["{/positive}", "/true"], - ["{/positive*}", "/true"], - ["{/negative}", "/false"], - ["{/negative*}", "/false"], - ["{/zero}", "/0"], - ["{/zero*}", "/0"], - ["{/number}", "/42.24"], - ["{/number*}", "/42.24"], - ["{?positive}", "?positive=true"], - ["{?positive*}", "?positive=true"], - ["{?negative}", "?negative=false"], - ["{?negative*}", "?negative=false"], - ["{?zero}", "?zero=0"], - ["{?zero*}", "?zero=0"], - ["{?number}", "?number=42.24"], - ["{?number*}", "?number=42.24"], - ["{list}", "one,2,true,false,0"], - ["{list*}", "one,2,true,false,0"], - ["{.list}", ".one,2,true,false,0"], - ["{.list*}", ".one.2.true.false.0"], - ["{/list}", "/one,2,true,false,0"], - ["{/list*}", "/one/2/true/false/0"], - ["{?list}", "?list=one,2,true,false,0"], - ["{?list*}", "?list=one&list=2&list=true&list=false&list=0"], - ["{dict}", "one,1,two,2,positive,true,negative,false,zero,0"], - ["{dict*}", "one=1,two=2,positive=true,negative=false,zero=0"], - ["{.dict}", ".one,1,two,2,positive,true,negative,false,zero,0"], - ["{.dict*}", ".one=1.two=2.positive=true.negative=false.zero=0"], - ["{/dict}", "/one,1,two,2,positive,true,negative,false,zero,0"], - ["{/dict*}", "/one=1/two=2/positive=true/negative=false/zero=0"], - ["{?dict}", "?dict=one,1,two,2,positive,true,negative,false,zero,0"], - ["{?dict*}", "?one=1&two=2&positive=true&negative=false&zero=0"] - ] - } -} diff --git a/css/tools/apiclient/test/extensions.json b/css/tools/apiclient/test/extensions.json deleted file mode 100644 index 0c493620bd63d9..00000000000000 --- a/css/tools/apiclient/test/extensions.json +++ /dev/null @@ -1,210 +0,0 @@ -{ - "Nested Structures" : - { - "level": 5, - "variables": { - "list" : ["one", "two", "three", "four"], - "dict" : {"semi": ";", "dot": ".", "comma": ","}, - "lists" : [["one", "two"], ["three"], "four"], - "dicts" : {"one": {"semi": ";", "dot": "."}, "two": {"comma": ","}}, - "mixed" : {"list": ["one", ["two", "three"]], "dict": {"one": {"semi": ";", "dot": "."}, "two": {"comma": ","}}}, - "dlist" : [{"semi": ";", "dot": "."}, {"comma": ","}] - }, - "testcases" : [ - ["{list}", "one,two,three,four"], - ["{list*}", "one,two,three,four"], - ["{?list}", "?list=one,two,three,four"], - ["{?list*}", "?list=one&list=two&list=three&list=four"], - ["{lists}", "one,two,three,four"], - ["{lists*}", "one,two,three,four"], - ["{?lists}", "?lists=one,two,three,four"], - ["{?lists*}", "?lists=one&lists=two&lists=three&lists=four"], - ["{dict}", [ - "comma,%2C,dot,.,semi,%3B", - "comma,%2C,semi,%3B,dot,.", - "dot,.,comma,%2C,semi,%3B", - "dot,.,semi,%3B,comma,%2C", - "semi,%3B,comma,%2C,dot,.", - "semi,%3B,dot,.,comma,%2C" - ]], - ["{dict*}", [ - "comma=%2C,dot=.,semi=%3B", - "comma=%2C,semi=%3B,dot=.", - "dot=.,comma=%2C,semi=%3B", - "dot=.,semi=%3B,comma=%2C", - "semi=%3B,comma=%2C,dot=.", - "semi=%3B,dot=.,comma=%2C" - ]], - ["{?dict}", [ - "?dict=comma,%2C,dot,.,semi,%3B", - "?dict=comma,%2C,semi,%3B,dot,.", - "?dict=dot,.,comma,%2C,semi,%3B", - "?dict=dot,.,semi,%3B,comma,%2C", - "?dict=semi,%3B,comma,%2C,dot,.", - "?dict=semi,%3B,dot,.,comma,%2C" - ]], - ["{?dict*}", [ - "?comma=%2C&dot=.&semi=%3B", - "?comma=%2C&semi=%3B&dot=.", - "?dot=.&comma=%2C&semi=%3B", - "?dot=.&semi=%3B&comma=%2C", - "?semi=%3B&comma=%2C&dot=.", - "?semi=%3B&dot=.&comma=%2C" - ]], - ["{dicts}", [ - "two.comma,%2C,one.dot,.,one.semi,%3B", - "two.comma,%2C,one.semi,%3B,one.dot,.", - "one.dot,.,two.comma,%2C,one.semi,%3B", - "one.dot,.,one.semi,%3B,two.comma,%2C", - "one.semi,%3B,two.comma,%2C,one.dot,.", - "one.semi,%3B,one.dot,.,two.comma,%2C" - ]], - ["{dicts*}", [ - "two.comma=%2C,one.dot=.,one.semi=%3B", - "two.comma=%2C,one.semi=%3B,one.dot=.", - "one.dot=.,two.comma=%2C,one.semi=%3B", - "one.dot=.,one.semi=%3B,two.comma=%2C", - "one.semi=%3B,two.comma=%2C,one.dot=.", - "one.semi=%3B,one.dot=.,two.comma=%2C" - ]], - ["{?dicts}", [ - "?dicts=two.comma,%2C,one.dot,.,one.semi,%3B", - "?dicts=two.comma,%2C,one.semi,%3B,one.dot,.", - "?dicts=one.dot,.,two.comma,%2C,one.semi,%3B", - "?dicts=one.dot,.,one.semi,%3B,two.comma,%2C", - "?dicts=one.semi,%3B,two.comma,%2C,one.dot,.", - "?dicts=one.semi,%3B,one.dot,.,two.comma,%2C" - ]], - ["{?dicts*}", [ - "?two.comma=%2C&one.dot=.&one.semi=%3B", - "?two.comma=%2C&one.semi=%3B&one.dot=.", - "?one.dot=.&two.comma=%2C&one.semi=%3B", - "?one.dot=.&one.semi=%3B&two.comma=%2C", - "?one.semi=%3B&two.comma=%2C&one.dot=.", - "?one.semi=%3B&one.dot=.&two.comma=%2C" - ]], - ["{mixed}", [ - "list.one,list.two,list.three,dict.two.comma,%2C,dict.one.dot,.,dict.one.semi,%3B", - "list.one,list.two,list.three,dict.two.comma,%2C,dict.one.semi,%3B,dict.one.dot,.", - "list.one,list.two,list.three,dict.one.dot,.,dict.two.comma,%2C,dict.one.semi,%3B", - "list.one,list.two,list.three,dict.one.dot,.,dict.one.semi,%3B,dict.two.comma,%2C", - "list.one,list.two,list.three,dict.one.semi,%3B,dict.two.comma,%2C,dict.one.dot,.", - "list.one,list.two,list.three,dict.one.semi,%3B,dict.one.dot,.,dict.two.comma,%2C" - ]], - ["{mixed*}", [ - "list.one,list.two,list.three,dict.two.comma=%2C,dict.one.dot=.,dict.one.semi=%3B", - "list.one,list.two,list.three,dict.two.comma=%2C,dict.one.semi=%3B,dict.one.dot=.", - "list.one,list.two,list.three,dict.one.dot=.,dict.two.comma=%2C,dict.one.semi=%3B", - "list.one,list.two,list.three,dict.one.dot=.,dict.one.semi=%3B,dict.two.comma=%2C", - "list.one,list.two,list.three,dict.one.semi=%3B,dict.two.comma=%2C,dict.one.dot=.", - "list.one,list.two,list.three,dict.one.semi=%3B,dict.one.dot=.,dict.two.comma=%2C" - ]], - ["{?mixed}", [ - "?mixed=list.one,list.two,list.three,dict.two.comma,%2C,dict.one.dot,.,dict.one.semi,%3B", - "?mixed=list.one,list.two,list.three,dict.two.comma,%2C,dict.one.semi,%3B,dict.one.dot,.", - "?mixed=list.one,list.two,list.three,dict.one.dot,.,dict.two.comma,%2C,dict.one.semi,%3B", - "?mixed=list.one,list.two,list.three,dict.one.dot,.,dict.one.semi,%3B,dict.two.comma,%2C", - "?mixed=list.one,list.two,list.three,dict.one.semi,%3B,dict.two.comma,%2C,dict.one.dot,.", - "?mixed=list.one,list.two,list.three,dict.one.semi,%3B,dict.one.dot,.,dict.two.comma,%2C" - ]], - ["{?mixed*}", [ - "?list=one&list=two&list=three&dict.two.comma=%2C&dict.one.dot=.&dict.one.semi=%3B", - "?list=one&list=two&list=three&dict.two.comma,%2C&dict.one.semi=%3B&dict.one.dot=.", - "?list=one&list=two&list=three&dict.one.dot=.&dict.two.comma=%2C&dict.one.semi=%3B", - "?list=one&list=two&list=three&dict.one.dot=.&dict.one.semi=%3B&dict.two.comma=%2C", - "?list=one&list=two&list=three&dict.one.semi=%3B&dict.two.comma=%2C&dict.one.dot=.", - "?list=one&list=two&list=three&dict.one.semi=%3B&dict.one.dot=.&dict.two.comma=%2C" - ]], - ["{dlist}", [ - "dot,.,semi,%3B,comma,%2C", - "semi,%3B,dot,.,comma,%2C" - ]], - ["{dlist*}", [ - "dot=.,semi=%3B,comma=%2C", - "semi=%3B,dot=.,comma=%2C" - ]], - ["{?dlist}", [ - "?dlist=dot,.,semi,%3B,comma,%2C", - "?dlist=semi,%3B,dot,.,comma,%2C" - ]], - ["{?dlist*}", [ - "?dlist.dot=.&dlist.semi=%3B&dlist.comma=%2C", - "?dlist.semi=%3B&dlist.dot=.&dlist.comma=%2C" - ]] - ] - }, - "Array Modifier" : - { - "level": 5, - "variables": { - "list" : ["one", "two", "three", "four"], - "dict" : {"semi": ";", "dot": ".", "comma": ","}, - "lists" : [["one", "two"], ["three"], "four"], - "dicts" : {"one": {"semi": ";", "dot": "."}, "two": {"comma": ","}}, - "mixed" : {"list": ["one", ["two", "three"]], "dict": {"one": {"semi": ";", "dot": "."}, "two": {"comma": ","}}}, - "dlist" : [{"semi": ";", "dot": "."}, {"comma": ","}] - }, - "testcases" : [ - ["{list[]}", "one,two,three,four"], - ["{?list[]}", "?list[0]=one&list[1]=two&list[2]=three&list[3]=four"], - ["{lists[]}", "one,two,three,four"], - ["{?lists[]}", "?lists[0][0]=one&lists[0][1]=two&lists[1][0]=three&lists[2]=four"], - ["{dict[]}", [ - "comma=%2C,dot=.,semi=%3B", - "comma=%2C,semi=%3B,dot=.", - "dot=.,comma=%2C,semi=%3B", - "dot=.,semi=%3B,comma=%2C", - "semi=%3B,comma=%2C,dot=.", - "semi=%3B,dot=.,comma=%2C" - ]], - ["{?dict[]}", [ - "?comma=%2C&dot=.&semi=%3B", - "?comma=%2C&semi=%3B&dot=.", - "?dot=.&comma=%2C&semi=%3B", - "?dot=.&semi=%3B&comma=%2C", - "?semi=%3B&comma=%2C&dot=.", - "?semi=%3B&dot=.&comma=%2C" - ]], - ["{dicts[]}", [ - "two[comma]=%2C,one[dot]=.,one[semi]=%3B", - "two[comma]=%2C,one[semi]=%3B,one[dot]=.", - "one[dot]=.,two[comma]=%2C,one[semi]=%3B", - "one[dot]=.,one[semi]=%3B,two[comma]=%2C", - "one[semi]=%3B,two[comma]=%2C,one[dot]=.", - "one[semi]=%3B,one[dot]=.,two[comma]=%2C" - ]], - ["{?dicts[]}", [ - "?two[comma]=%2C&one[dot]=.&one[semi]=%3B", - "?two[comma]=%2C&one[semi]=%3B&one[dot]=.", - "?one[dot]=.&two[comma]=%2C&one[semi]=%3B", - "?one[dot]=.&one[semi]=%3B&two[comma]=%2C", - "?one[semi]=%3B&two[comma]=%2C&one[dot]=.", - "?one[semi]=%3B&one[dot]=.&two[comma]=%2C" - ]], - ["{mixed[]}", [ - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[two][comma]=%2C,dict[one][dot]=.,dict[one][semi]=%3B", - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[two][comma]=%2C,dict[one][semi]=%3B,dict[one][dot]=.", - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[one][dot]=.,dict[two][comma]=%2C,dict[one][semi]=%3B", - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[one][dot]=.,dict[one][semi]=%3B,dict[two][comma]=%2C", - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[one][semi]=%3B,dict[two][comma]=%2C,dict[one][dot]=.", - "list[0]=one,list[1][0]=two,list[1][1]=three,dict[one][semi]=%3B,dict[one][dot]=.,dict[two][comma]=%2C" - ]], - ["{?mixed[]}", [ - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[two][comma]=%2C&dict[one][dot]=.&dict[one][semi]=%3B", - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[two][comma]=%2C&dict[one][semi]=%3B&dict[one][dot]=.", - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[one][dot]=.&dict[two][comma]=%2C&dict[one][semi]=%3B", - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[one][dot]=.&dict[one][semi]=%3B&dict[two][comma]=%2C", - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[one][semi]=%3B&dict[two][comma]=%2C&dict[one][dot]=.", - "?list[0]=one&list[1][0]=two&list[1][1]=three&dict[one][semi]=%3B&dict[one][dot]=.&dict[two][comma]=%2C" - ]], - ["{dlist[]}", [ - "dot=.,semi=%3B,comma=%2C", - "semi=%3B,dot=.,comma=%2C" - ]], - ["{?dlist[]}", [ - "?dlist[0][dot]=.&dlist[0][semi]=%3B&dlist[1][comma]=%2C", - "?dlist[0][semi]=%3B&dlist[0][dot]=.&dlist[1][comma]=%2C" - ]] - ] - } -} diff --git a/css/tools/build.py b/css/tools/build.py deleted file mode 100644 index 9bbc2a5e7532c0..00000000000000 --- a/css/tools/build.py +++ /dev/null @@ -1,386 +0,0 @@ -#!/usr/bin/env python - -# CSS Test Suite Build Script -# Copyright 2011 Hewlett-Packard Development Company, L.P. -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -import sys -import os -import json -import optparse -import shutil -from collections import defaultdict -from apiclient import apiclient -from w3ctestlib import Sources, Utils, Suite, Indexer -from mercurial import ui - - - -class Builder(object): - def __init__(self, ui, outputPath, backupPath, ignorePaths, onlyCache): - self.reset(onlyCache) - self.ui = ui - self.skipDirs = ('support') - self.rawDirs = {'other-formats': 'other'} - self.sourceTree = Sources.SourceTree() - self.sourceCache = Sources.SourceCache(self.sourceTree) - self.cacheDir = 'tools/cache' - self.outputPath = outputPath.rstrip('/') if (outputPath) else 'dist' - self.backupPath = backupPath.rstrip('/') if (backupPath) else None - self.ignorePaths = [path.rstrip('/') for path in ignorePaths] if (ignorePaths) else [] - self.workPath = 'build-temp' - self.ignorePaths += (self.outputPath, self.backupPath, self.workPath) - - def reset(self, onlyCache): - self.useCacheOnly = onlyCache - self.shepherd = apiclient.apiclient.APIClient('https://api.csswg.org/shepherd/', version = 'vnd.csswg.shepherd.v1') if (not onlyCache) else None - self.cacheData = False - self.testSuiteData = {} - self.specificationData = {} - self.flagData = {} - self.specNames = {} - self.specAnchors = {} - self.buildSuiteNames = [] - self.buildSpecNames = {} - self.testSuites = {} - - - def _loadShepherdData(self, apiName, description, **kwargs): - self.ui.status("Loading ", description, " information\n") - cacheFile = os.path.join(self.cacheDir, apiName + '.json') - if (not self.useCacheOnly or (not os.path.exists(cacheFile))): - result = self.shepherd.get(apiName, **kwargs) - if (result and (200 == result.status)): - data = {} - for name in result.data: # trim leading _ - data[name[1:]] = result.data[name] - with open(cacheFile, 'w') as file: - json.dump(data, file) - return data - self.ui.status("Shepherd API call failed, result: ", result.status if result else 'None', "\n") - if (os.path.exists(cacheFile)): - self.ui.status("Loading cached data.\n") - try: - with open(cacheFile, 'r') as file: - return json.load(file) - except: - pass - return None - - def _addAnchors(self, anchors, specName): - for anchor in anchors: - self.specAnchors[specName].add(anchor['uri'].lower()) - if ('children' in anchor): - self._addAnchors(anchor['children'], specName) - - def _normalizeScheme(self, url): - if (url and url.startswith('http:')): - return 'https:' + url[5:] - return url - - def getSpecName(self, url): - if (not self.specNames): - for specName in self.specificationData: - specData = self.specificationData[specName] - officialURL = self._normalizeScheme(specData.get('base_uri')) - if (officialURL): - if (officialURL.endswith('/')): - officialURL = officialURL[:-1] - self.specNames[officialURL.lower()] = specName - draftURL = self._normalizeScheme(specData.get('draft_uri')) - if (draftURL): - if (draftURL.endswith('/')): - draftURL = draftURL[:-1] - self.specNames[draftURL.lower()] = specName - self.specAnchors[specName] = set() - if ('anchors' in specData): - self._addAnchors(specData['anchors'], specName) - if ('draft_anchors' in specData): - self._addAnchors(specData['draft_anchors'], specName) - - url = self._normalizeScheme(url.lower()) - for specURL in self.specNames: - if (url.startswith(specURL) and - ((url == specURL) or - url.startswith(specURL + '/') or - url.startswith(specURL + '#'))): - anchorURL = url[len(specURL):] - if (anchorURL.startswith('/')): - anchorURL = anchorURL[1:] - specName = self.specNames[specURL] - if (anchorURL in self.specAnchors[specName]): - return (specName, anchorURL) - return (specName, None) - return (None, None) - - def gatherTests(self, dir): - dirName = os.path.basename(dir) - if (dirName in self.skipDirs): - return - - self.ui.note("Scanning directory: ", dir, "\n") - suiteFileNames = defaultdict(set) - for fileName in Utils.listfiles(dir): - filePath = os.path.join(dir, fileName) - if not self.sourceTree.isTestCase(filePath): - continue - - source = self.sourceCache.generateSource(filePath, fileName) - if not source.isTest(): - continue - - try: - metaData = source.getMetadata(True) - except Exception as error: - self.ui.warn("Exception parsing '", filePath, "': ", error, "\n") - continue - - if not metaData: - if (source.errors): - self.ui.warn("Error parsing '", filePath, "': ", ' '.join(source.errors), "\n") - else: - self.ui.warn("No metadata available for '", filePath, "'\n") - continue - - for specURL in metaData['links']: - specName, anchorURL = self.getSpecName(specURL) - if not specName: - self.ui.note("Unknown specification URL: ", specURL, "\n in: ", filePath, "\n") - continue - - if not specName in self.buildSpecNames: - continue - - if not anchorURL: - self.ui.warn("Test links to unknown specification anchor: ", specURL, "\n in: ", filePath, "\n") - continue - - for testSuiteName in self.buildSpecNames[specName]: - formats = self.testSuiteData[testSuiteName].get('formats') - if (formats): - for formatName in formats: - if (((formatName) in self.formatData) and - (self.formatData[formatName].get('mime_type') == source.mimetype)): - suiteFileNames[testSuiteName].add(fileName) - break - else: - self.ui.note("Test not in acceptable format: ", source.mimetype, "\n for: ", filePath, "\n") - - for testSuiteName in suiteFileNames: - if (dirName in self.rawDirs): - self.testSuites[testSuiteName].addRaw(dir, self.rawDirs[dirName]) - else: - self.testSuites[testSuiteName].addTestsByList(dir, suiteFileNames[testSuiteName]) - - for subDir in Utils.listdirs(dir): - subDirPath = os.path.join(dir, subDir) - if (not (self.sourceTree.isIgnoredDir(subDirPath) or (subDirPath in self.ignorePaths))): - self.gatherTests(subDirPath) - - - def _findSections(self, baseURL, anchors, sectionData, parentSectionName = ''): - if (anchors): - for anchor in anchors: - if ('section' in anchor): - sectionData.append((baseURL + anchor['uri'], anchor['name'], - anchor['title'] if 'title' in anchor else 'Untitled')) - else: - sectionData.append((baseURL + anchor['uri'], parentSectionName + '.#' + anchor['name'], None)) - if ('children' in anchor): - self._findSections(baseURL, anchor['children'], sectionData, anchor['name']) - return sectionData - - def getSections(self, specName): - specData = self.specificationData[specName] - specURL = specData['base_uri'] if ('base_uri' in specData) else specData.get('draft_uri') - anchorData = specData['anchors'] if ('anchors' in specData) else specData['draft_anchors'] - sectionData = [] - self._findSections(specURL, anchorData, sectionData) - return sectionData - - def _user(self, user): - if (user): - data = user['full_name'] - if ('organization' in user): - data += ', ' + user['organization'] - if ('uri' in user): - data += ', ' + user['uri'] - elif ('email' in user): - data += ', <' + user['email'].replace('@', ' @') + '>' - return data - return 'None Yet' - - def getSuiteData(self): - data = {} - for testSuiteName in self.testSuiteData: - testSuiteData = self.testSuiteData[testSuiteName] - specData = self.specificationData[testSuiteData['specs'][0]] - data[testSuiteName] = { - 'title': testSuiteData['title'] if ('title' in testSuiteData) else 'Untitled', - 'spec': specData['title'] if ('title' in specData) else specData['name'], - 'specroot': specData['base_uri'] if ('base_uri' in specData) else specData.get('draft_uri'), - 'draftroot': specData['draft_uri'] if ('draft_uri' in specData) else specData.get('base_uri'), - 'owner': self._user(testSuiteData['owners'][0] if ('owners' in testSuiteData) else None), - 'harness': testSuiteName, - 'status': testSuiteData['status'] if ('status' in testSuiteData) else 'Unknown' - } - return data - - def getFlags(self): - data = {} - for flag in self.flagData: - flagData = self.flagData[flag] - data[flag] = { - 'title': flagData['description'] if ('description' in flagData) else 'Unknown', - 'abbr': flagData['title'] if ('title' in flagData) else flag - } - return data - - - def build(self, testSuiteNames): - try: - os.makedirs(self.cacheDir) - except: - pass - self.testSuiteData = self._loadShepherdData('test_suites', 'test suite', repo = 'css') - if (not self.testSuiteData): - self.ui.warn("ERROR: Unable to load test suite information.\n") - return -1 - if (testSuiteNames): - self.buildSuiteNames = [] - for testSuiteName in testSuiteNames: - if (testSuiteName in self.testSuiteData): - self.buildSuiteNames.append(testSuiteName) - else: - self.ui.status("Unknown test suite: ", testSuiteName, "\n") - else: - self.buildSuiteNames = [testSuiteName for testSuiteName in self.testSuiteData if self.testSuiteData[testSuiteName].get('build')] - - self.buildSpecNames = defaultdict(list) - if (self.buildSuiteNames): - self.specificationData = self._loadShepherdData('specifications', 'specification', anchors = True, draft = True) - if (not self.specificationData): - self.ui.warn("ERROR: Unable to load specification information.\n") - return -2 - for testSuiteName in self.buildSuiteNames: - specNames = self.testSuiteData[testSuiteName].get('specs') - if (specNames): - for specName in specNames: - if (specName in self.specificationData): - self.buildSpecNames[specName].append(testSuiteName) - else: - self.ui.warn("WARNING: Test suite '", testSuiteName, "' references unknown specification: '", specName, "'.\n") - else: - self.ui.warn("ERROR: Test suite '", testSuiteName, "' does not have target specifications.\n") - return -6 - else: - self.ui.status("No test suites identified\n") - return 0 - - if (not self.buildSpecNames): - self.ui.status("No target specifications identified\n") - return -3 - - self.flagData = self._loadShepherdData('test_flags', 'test flag') - if (not self.flagData): - self.ui.warn("ERROR: Unable to load flag information\n") - return -4 - - self.formatData = self._loadShepherdData('test_formats', 'test format') - if (not self.formatData): - self.ui.warn("ERROR: Unable to load format information\n") - return -5 - - - self.buildSuiteNames.sort() - - for testSuiteName in self.buildSuiteNames: - data = self.testSuiteData[testSuiteName] - specData = self.specificationData[data['specs'][0]] - specURL = specData['base_uri'] if ('base_uri' in specData) else specData.get('draft_uri') - draftURL = specData['draft_uri'] if ('draft_uri' in specData) else specData.get('base_uri') - self.testSuites[testSuiteName] = Suite.TestSuite(testSuiteName, data['title'], specURL, draftURL, self.sourceCache, self.ui) # XXX need to support multiple specs - if ('formats' in data): - self.testSuites[testSuiteName].setFormats(data['formats']) - - self.ui.status("Scanning test files\n") - - for dir in Utils.listdirs('.'): - if (not (self.sourceTree.isIgnoredDir(dir) or (dir in self.ignorePaths))): - self.gatherTests(dir) - - - if (os.path.exists(self.workPath)): - self.ui.note("Clearing work path: ", self.workPath, "\n") - shutil.rmtree(self.workPath) - - suiteData = self.getSuiteData() - flagData = self.getFlags() - templatePath = os.path.join('tools', 'templates') - for testSuiteName in self.buildSuiteNames: - testSuite = self.testSuites[testSuiteName] - self.ui.status("Building ", testSuiteName, "\n") - specSections = self.getSections(self.testSuiteData[testSuiteName]['specs'][0]) - indexer = Indexer.Indexer(testSuite, specSections, suiteData, flagData, True, - templatePathList = [templatePath], - extraData = {'devel' : False, 'official' : True }) - workPath = os.path.join(self.workPath, testSuiteName) - testSuite.buildInto(workPath, indexer) - - # move from work path to output path - for testSuiteName in self.buildSuiteNames: - workPath = os.path.join(self.workPath, testSuiteName) - outputPath = os.path.join(self.outputPath, testSuiteName) - backupPath = os.path.join(self.backupPath, testSuiteName) if (self.backupPath) else None - if (os.path.exists(workPath)): - if (os.path.exists(outputPath)): - if (backupPath): - if (os.path.exists(backupPath)): - self.ui.note("Removing ", backupPath, "\n") - shutil.rmtree(backupPath) # delete old backup - self.ui.note("Backing up ", outputPath, " to ", backupPath, "\n") - shutil.move(outputPath, backupPath) # backup old output - else: - self.ui.note("Removing ", outputPath, "\n") - shutil.rmtree(outputPath) # no backups, delete old output - self.ui.note("Moving ", workPath, " to ", outputPath, "\n") - shutil.move(workPath, outputPath) - if (os.path.exists(self.workPath)): - shutil.rmtree(self.workPath) - return 0 - - - -if __name__ == "__main__": # called from the command line - parser = optparse.OptionParser(usage = "usage: %prog [options] test_suite [...]") - parser.add_option("-q", "--quiet", - action = "store_true", dest = "quiet", default = False, - help = "don't print status messages to stdout") - parser.add_option("-d", "--debug", - action = "store_true", dest = "debug", default = False, - help = "print detailed debugging information to stdout") - parser.add_option("-v", "--verbose", - action = "store_true", dest = "verbose", default = False, - help = "print more detailed debugging information to stdout") - parser.add_option("-o", "--output", dest = "output", metavar = "OUTPUT_PATH", - help = "Path to build into (default 'dist')") - parser.add_option("-b", "--backup", dest = "backup", metavar = "BACKUP_PATH", - help = "Path to preserve old version to") - parser.add_option("-i", "--ignore", - action = "append", dest = "ignore", metavar = "IGNORE_PATH", - help = "Ignore files in this path") - parser.add_option("-c", "--cache", - action = "store_true", dest = "cache", default = False, - help = "use cached test suite and specification data only") - (options, args) = parser.parse_args() - - - ui = ui.ui() - ui.setconfig('ui', 'debug', str(options.debug)) - ui.setconfig('ui', 'quiet', str(options.quiet)) - ui.setconfig('ui', 'verbose', str(options.verbose)) - - builder = Builder(ui, options.output, options.backup, options.ignore, options.cache) - result = builder.build(args) - quit(result) diff --git a/css/tools/build.sh b/css/tools/build.sh deleted file mode 100755 index 326fe632a8c093..00000000000000 --- a/css/tools/build.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env sh -set -ex - -SCRIPT_DIR=$(cd $(dirname "$0") && pwd -P) - -main() { - cd $SCRIPT_DIR - - if [ -z $VENV ]; then - VENV=_virtualenv - fi - - # Create the virtualenv - if [ ! -d $VENV ]; then - if [ -z $PYTHON ]; then - command -v python - if [ $? -eq 0 ]; then - if [ `python -c 'import sys; print(sys.version[0:3])'` == "2.7" ]; then - PYTHON=python - fi - fi - fi - - if [ -z $PYTHON ]; then - command -v python2 - if [ $? -eq 0 ]; then - PYTHON=python2 - fi - fi - - if [ -z $PYTHON ]; then - echo "Please ensure Python 2.7 is installed" - exit 1 - fi - - # The maximum Unicode code point is U+10FFFF = 1114111 - if [ `$PYTHON -c 'import sys; print(sys.maxunicode)'` != "1114111" ]; then - echo "UCS-4 support for Python is required" - exit 1 - fi - - virtualenv -p $PYTHON $VENV || { echo "Please ensure virtualenv is installed"; exit 2; } - fi - - # Install dependencies - $VENV/bin/pip install -r requirements.txt - - # Run the build script - $VENV/bin/python build.py "$@" -} - -main "$@" diff --git a/css/tools/requirements.txt b/css/tools/requirements.txt deleted file mode 100644 index 1dd5c6e8384310..00000000000000 --- a/css/tools/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Warning: The CSS build system is not tested in CI at all, so do not bump these -# dependencies without making sure that the build script still works. -Template-Python==0.1.post1 -html5lib==1.1 -lxml==4.9.1 -mercurial==4.6.1 -six==1.16.0 -webencodings==0.5.1 diff --git a/css/tools/w3ctestlib/.hgignore b/css/tools/w3ctestlib/.hgignore deleted file mode 100644 index 26c289322375ef..00000000000000 --- a/css/tools/w3ctestlib/.hgignore +++ /dev/null @@ -1,7 +0,0 @@ -syntax: glob - -*.xcodeproj -*.DS_Store -*.pyc -*.svn -*.directory diff --git a/css/tools/w3ctestlib/Groups.py b/css/tools/w3ctestlib/Groups.py deleted file mode 100644 index 192ae9b6fdffd0..00000000000000 --- a/css/tools/w3ctestlib/Groups.py +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/python -# CSS Test Suite Manipulation Library -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -import shutil -import filecmp -import os.path -import Utils -from os.path import exists, join -from Sources import SourceCache, SourceSet, ConfigSource, ReftestManifest -from Utils import listfiles - -excludeDirs = ['CVS', '.svn', '.hg'] - -class TestGroup: - """Base class for test groups. Should never be used directly. - """ - - @staticmethod - def combine(groupA, groupB): - """Merge TestGroup `groupB` into `groupA`. Return the result of the merge. - Can accept none as arguments. - """ - if groupA and groupB: - groupA.merge(groupB) - return groupA or groupB - - def __init__(self, sourceCache, importDir, name=None, title=None, ui = None, **kwargs): - """Initialize with: - SourceCache `sourceCache` - Group name `name`, which must be a possible directory name or None - Directory path `importDir`, whose context is imported into the group - Option: Tuple of support directory names `supportDirNames` defaults - to ('support',). - Kwarg: File path manifestPath relative to `importDir` that - identifies the reftest manifest file (usually called 'reftest.list'). - Kwarg: File path manifestDest as destination (relative) path for - the reftest manifest file. Defaults to value of manifestPath. - If manifest provided, assumes that only the files listed in the manifest, - the .htaccess files in its parent directory, and the `importDir`'s - .htaccess file and support directory are relevant to the test suite. - """ - assert exists(importDir), "Directory to import %s does not exist" % importDir - - # Save name - self.name = name - self.title = title - - self.ui = ui - - sourceTree = sourceCache.sourceTree - - # Load htaccess - htapath = join(importDir, '.htaccess') - self.htaccess = ConfigSource(sourceTree, htapath, '.htaccess') \ - if exists(htapath) else None - - # Load support files - self.support = SourceSet(sourceCache) - supportDirNames = kwargs.get('supportDirNames', ('support',)) - for supportName in supportDirNames: - supportDir = join(importDir, supportName) - if exists(supportDir): - for (root, dirs, files) in os.walk(supportDir): - for dir in excludeDirs: - if dir in dirs: - dirs.remove(dir) - for name in files: - sourcepath = join(root, name) - relpath = Utils.relpath(sourcepath, importDir) - self.support.add(sourcepath, relpath, self.ui) - - # Load tests - self.tests = SourceSet(sourceCache) - self.refs = SourceSet(sourceCache) - - # Read manifest - manifestPath = kwargs.get('manifestPath', None) - manifestDest = kwargs.get('manifestDest', manifestPath) - if (manifestPath): - self.manifest = ReftestManifest(join(importDir, manifestPath), manifestDest) - - # Import tests - for (testSrc, refSrc), (testRel, refRel), refType in self.manifest: - test = sourceCache.generateSource(testSrc, testRel) - ref = sourceCache.generateSource(refSrc, refRel) - test.addReference(ref, refType) - self.tests.addSource(test, self.ui) - else: - self.manifest = None - # Import tests - fileNameList = [] - if kwargs.get('selfTestExt'): - fileNameList += listfiles(importDir, kwargs['selfTestExt']) - if kwargs.get('selfTestList'): - fileNameList += kwargs['selfTestList'] - for fileName in fileNameList: - filePath = join(importDir, fileName) - if sourceTree.isTestCase(filePath): - test = sourceCache.generateSource(filePath, fileName) - if (test.isTest()): - self.tests.addSource(test, self.ui) - - for test in self.tests.iter(): - if (test.isReftest()): - usedRefs = {} - usedRefs[test.sourcepath] = '==' - def loadReferences(source): # XXX need to verify refType for mutual exclusion (ie: a == b != a) - for refSrcPath, refRelPath, refType in source.getReferencePaths(): - if (exists(refSrcPath)): - ref = sourceCache.generateSource(refSrcPath, refRelPath) - source.addReference(ref) - if (refSrcPath not in usedRefs): - usedRefs[refSrcPath] = refType - if (ref not in self.tests): - self.refs.addSource(ref, self.ui) - loadReferences(ref) - else: - ui.warn("Missing Reference file: ", refSrcPath, "\n referenced from: ", source.sourcepath, "\n") - loadReferences(test) - - - def sourceCache(self): - return self.support.sourceCache - - def count(self): - """Returns number of tests. - """ - return len(self.tests) - - def iterTests(self): - return self.tests.iter() - - def _initFrom(self, group=None): - """Initialize with data from TestGroup `group`.""" - # copy - self.name = group.name if group else None - self.title = group.title if group else None - self.htaccess = group.htaccess if group else None - self.support = group.support if group else None - self.tests = group.tests if group else None - - def merge(self, other): - """Merge Group `other`'s contents into this Group and clear its contents. - """ - assert isinstance(other, TestGroup), \ - "Expected Group instance, got %s" % type(other) - if self.htaccess and other.htaccess: - self.htaccess.append(other.htaccess) - else: - self.htaccess = self.htaccess or other.htaccess - other.htaccess = None - - self.support = SourceSet.combine(self.support, other.support, self.ui) - other.support = None - - self.tests = SourceSet.combine(self.tests, other.tests, self.ui) - other.tests = None - - self.refs = SourceSet.combine(self.refs, other.refs, self.ui) - other.refs = None - if self.manifest and other.manifest: - self.manifest.append(other.manifest) - else: - self.manifest = self.manifest or other.manifest - other.manifest = None - - - def build(self, format): - """Build Group's contents through OutputFormat `format`. - """ - format.setSubDir(self.name) - - # Write .htaccess - if self.htaccess: - format.write(self.htaccess) - - # Write support files - format.convert = False # XXX hack turn off format conversion - self.support.write(format) - format.convert = True # XXX undo hack - - # Write tests - self.tests.adjustContentPaths(format) - self.tests.write(format) - - # Write refs - self.refs.write(format) - if self.manifest: - format.write(self.manifest) - - # copy support files to reference directory (XXX temp until proper support path fixup) - formatDir = format.destDir() - supportDir = join(formatDir, 'support') - referenceDir = join(formatDir, 'reference') - if exists(supportDir) and exists(referenceDir): - shutil.copytree(supportDir, join(referenceDir, 'support')) - - format.setSubDir() - diff --git a/css/tools/w3ctestlib/HTMLSerializer.py b/css/tools/w3ctestlib/HTMLSerializer.py deleted file mode 100644 index 7f73bc17ec8bbd..00000000000000 --- a/css/tools/w3ctestlib/HTMLSerializer.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/python -# CSS Test Source Manipulation Library -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# additions by peter.linss@hp.com copyright 2013 Hewlett-Packard -# Licensed under BSD 3-Clause: - -import lxml -from lxml import etree -import htmlentitydefs -import copy - - -class HTMLSerializer(object): - - gXMLns = 'http://www.w3.org/XML/1998/namespace' - gHTMLns = 'http://www.w3.org/1999/xhtml' - - gDefaultNamespaces = {'http://www.w3.org/XML/1998/namespace': 'xmlns', - 'http://www.w3.org/2000/xmlns/': 'xmlns', - 'http://www.w3.org/1999/xlink': 'xlink'} - - gVoidElements = frozenset(( - 'base', - 'command', - 'event-source', - 'link', - 'meta', - 'hr', - 'br', - 'img', - 'embed', - 'param', - 'area', - 'col', - 'input', - 'source' - )) - - gCDataElements = frozenset(( - 'style', - 'script' - )) - - gInvisibleChars = frozenset( - # ASCII control chars - range(0x0, 0x9) + range(0xB, 0xD) + range(0xE, 0x20) + - # Other control chars - # fixed-width spaces, zero-width marks, bidi marks - range(0x2000, 0x2010) + - # LS, PS, bidi control codes - range(0x2028, 0x2030) + - # nbsp, mathsp, ideosp, WJ, interlinear - [0x00A0, 0x205F, 0x3000, 0x2060, 0xFFF9, 0xFFFA, 0xFFFB] - ) - - gXMLEscapes = frozenset(gInvisibleChars | - frozenset((ord('&'), ord('<'), ord('>')))) - - gXMLEntityNames = {'"': 'quot', '&': 'amp', "'": 'apos', '<': 'lt', '>': 'gt'} - - gDocTypes = { - 'html': '', - 'html4': - '', - 'html4-transitional': - '', - 'html4-frameset': - '', - 'svg11': - '', - 'svg11-tiny': - '', - 'xhtml10': - '', - 'xhtml10-transitional': - '', - 'xhtml10-frameset': - '', - 'xhtml11': - '', - 'xhtml-basic11': - '' - } - - - def __init__(self): - self._reset() - - def _reset(self, xhtml = False): - self.mOutput = u'' - self.mXHTML = xhtml - - def _output(self, *args): - for arg in args: - self.mOutput += unicode(arg) - - def _escape(self, text, escapeChars): - # This algorithm is O(MN) for M len(text) and N num escapable - # But it doesn't modify the text when N is zero (common case) and - # N is expected to be small (usually 1 or 2) in most other cases. - escapable = set() - for char in text: - if ord(char) in escapeChars: - escapable.add(char) - for char in escapable: - if (self.mXHTML): - name = self.gXMLEntityNames.get(char) - else: - name = htmlentitydefs.codepoint2name.get(ord(char)) - escape = u'&%s;' % name if name else u'&#x%X;' % ord(char) - text = text.replace(char, escape) - return text - - def _escapeXML(self, text): - return self._escape(text, self.gXMLEscapes) - - def _escapeInvisible(self, text): - return self._escape(text, self.gInvisibleChars) - - def _serializeElement(self, element, namespacePrefixes): - qName = etree.QName(element) - attrs = element.attrib.items() # in tree order - - if (not namespacePrefixes): - namespacePrefixes = self.gDefaultNamespaces - - if (self.mXHTML): - namespacePrefixes = copy.copy(namespacePrefixes) - for attr, value in attrs: - attrQName = etree.QName(attr) - if (self.gXMLns == attrQName.namespace): - namespacePrefixes[value] = attrQName.localname - elif ('xmlns' == attrQName.localname): - namespacePrefixes[value] = '' - - if (self.mXHTML and qName.namespace and namespacePrefixes[qName.namespace]): - self._output('<', namespacePrefixes[qName.namespace], ':', qName.localname) - else: - self._output('<', qName.localname) - - for attr, value in attrs: - attrQName = etree.QName(attr) - if ((attrQName.namespace == self.gXMLns) and ('lang' == attrQName.localname)): - if (self.mXHTML): - attr = 'xml:lang' - else: - attr = 'lang' - elif (attrQName.namespace and namespacePrefixes[attrQName.namespace]): - attr = namespacePrefixes[attrQName.namespace] + ':' + attrQName.localname - else: - attr = attrQName.localname - - self._output(' ', attr, '=') - value = value.replace('&', '&') - if (self.mXHTML): - value = value.replace('<', '<') - - if (('"' in value) and ("'" not in value)): - self._output("'", self._escapeInvisible(value), "'") - else: - self._output('"', self._escapeInvisible(value.replace('"', '"')), '"') - - if ((qName.namespace == self.gHTMLns) and (qName.localname in self.gVoidElements)): - if (self.mXHTML): - self._output(' />') - else: - self._output('>') - else: - self._output('>') - - if (None != element.text): - if ((qName.namespace == self.gHTMLns) and (qName.localname in self.gCDataElements)): - if (self.mXHTML): - self._output(self._escapeXML(element.text)) # or self._output('') - else: - self._output(element.text) - else: - self._output(self._escapeXML(element.text)) - - for child in list(element): - self._serializeNode(child, namespacePrefixes) - - self._output('') - - if (None != element.tail): - self._output(self._escapeXML(element.tail)) - - def _serializeEntity(self, entity): - self._output(entity.text) - if (None != entity.tail): - self._output(self._escapeXML(entity.tail)) - - def _serializePI(self, pi): - if (self.mXHTML): - self._output('') - else: - raise Exception("Processing Instructions can't be converted to HTML") - if (None != pi.tail): - self._output(self._escapeXML(pi.tail)) - - def _serializeComment(self, comment): - self._output('') # XXX escape comment? - if (None != comment.tail): - self._output(self._escapeXML(comment.tail)) - - def _serializeNode(self, node, namespacePrefixes = None): - if (isinstance(node, etree._Entity)): - self._serializeEntity(node) - elif (isinstance(node, etree._ProcessingInstruction)): - self._serializePI(node) - elif (isinstance(node, etree._Comment)): - self._serializeComment(node) - else: - self._serializeElement(node, namespacePrefixes) - - - def _serializeTree(self, tree): - root = tree.getroot() - preceding = [node for node in root.itersiblings(preceding = True)] - preceding.reverse() - for node in preceding: - self._serializeNode(node) - self._serializeNode(root) - for node in root.itersiblings(): - self._serializeNode(node) - - def _serializeDoctype(self, tree, doctype, default): - if (doctype): - self._output(self.gDocTypes[doctype], '\n') - else: - if (hasattr(tree, 'docinfo') and tree.docinfo and tree.docinfo.doctype): - doctypeSearch = tree.docinfo.doctype.lower() - for doctype in self.gDocTypes: - if (self.gDocTypes[doctype].lower() == doctypeSearch): - break - else: - doctype = None - if (self.mXHTML): - if ('html' == doctype): - doctype = 'xhtml10' - elif ('html4' == doctype): - doctype = 'xhtml10' - elif ('html4-transitional' == doctype): - doctype = 'xhtml10-transitional' - elif ('html4-frameset' == doctype): - doctype = 'xhtml10-frameset' - else: - if ('xhtml10' == doctype): - doctype = 'html4' - elif ('xhtml10-transitional' == doctype): - doctype = 'html4-transitional' - elif ('xhtml10-frameset' == doctype): - doctype = 'html4-frameset' - elif ('xhtml11' == doctype): - doctype = 'html4' - if (doctype): - self._output(self.gDocTypes[doctype], '\n') - else: - self._output(tree.docinfo.doctype, '\n') - else: - self._output(self.gDocTypes[default], '\n') - - - def serializeHTML(self, tree, doctype = None): - self._reset() - self._serializeDoctype(tree, doctype, 'html') - self._serializeTree(tree) - return self.mOutput - - def serializeXHTML(self, tree, doctype = None): - self._reset(True) - # XXX ' - -# Define contains vmethod for Template Toolkit -from template.stash import list_op -@list_op("contains") -def list_contains(l, x): - return x in l - -import sys -import re -import os -import codecs -from os.path import join, exists, abspath -from template import Template -import w3ctestlib -from Utils import listfiles, escapeToNamedASCII -from OutputFormats import ExtensionMap -import shutil - -class Section: - def __init__(self, uri, title, numstr): - self.uri = uri - self.title = title - self.numstr = numstr - self.tests = [] - def __cmp__(self, other): - return cmp(self.natsortkey(), other.natsortkey()) - def chapterNum(self): - return self.numstr.partition('.')[0] - def natsortkey(self): - chunks = self.numstr.partition('.#')[0].split('.') - for index in range(len(chunks)): - if chunks[index].isdigit(): - # wrap in tuple with '0' to explicitly specify numbers come first - chunks[index] = (0, int(chunks[index])) - else: - chunks[index] = (1, chunks[index]) - return (chunks, self.numstr) - -class Indexer: - - def __init__(self, suite, sections, suites, flags, splitChapter=False, templatePathList=None, - extraData=None, overviewTmplNames=None, overviewCopyExts=('.css', 'htaccess')): - """Initialize indexer with TestSuite `suite` toc data file - `tocDataPath` and additional template paths in list `templatePathList`. - - The toc data file should be list of tab-separated records, one - per line, of each spec section's uri, number/letter, and title. - `splitChapter` selects a single page index if False, chapter - indicies if True. - `extraData` can be a dictionary whose data gets passed to the templates. - `overviewCopyExts` lists file extensions that should be found - and copied from the template path into the main build directory. - The default value is ['.css', 'htaccess']. - `overviewTemplateNames` lists template names that should be - processed from the template path into the main build directory. - The '.tmpl' extension, if any, is stripped from the output filename. - The default value is ['index.htm.tmpl', 'index.xht.tmpl', 'testinfo.data.tmpl'] - """ - self.suite = suite - self.splitChapter = splitChapter - self.extraData = extraData - self.overviewCopyExtPat = re.compile('.*(%s)$' % '|'.join(overviewCopyExts)) - self.overviewTmplNames = overviewTmplNames if overviewTmplNames is not None \ - else ['index.htm.tmpl', 'index.xht.tmpl', 'testinfo.data.tmpl', - 'implementation-report-TEMPLATE.data.tmpl'] - - # Initialize template engine - self.templatePath = [join(w3ctestlib.__path__[0], 'templates')] - if templatePathList: - self.templatePath.extend(templatePathList) - self.templatePath = [abspath(path) for path in self.templatePath] - self.tt = Template({ - 'INCLUDE_PATH': self.templatePath, - 'ENCODING' : 'utf-8', - 'PRE_CHOMP' : 1, - 'POST_CHOMP' : 0, - }) - - # Load toc data - self.sections = {} - for uri, numstr, title in sections: - uri = intern(uri.encode('utf-8')) - uriKey = intern(self._normalizeScheme(uri)) - numstr = escapeToNamedASCII(numstr) - title = escapeToNamedASCII(title) if title else None - self.sections[uriKey] = Section(uri, title, numstr) - - self.suites = suites - self.flags = flags - - # Initialize storage - self.errors = {} - self.contributors = {} - self.alltests = [] - - def _normalizeScheme(self, uri): - if (uri and uri.startswith('http:')): - return 'https:' + uri[5:] - return uri - - def indexGroup(self, group): - for test in group.iterTests(): - data = test.getMetadata() - if data: # Shallow copy for template output - data = dict(data) - data['file'] = '/'.join((group.name, test.relpath)) \ - if group.name else test.relpath - if (data['scripttest']): - data['flags'].append(intern('script')) - self.alltests.append(data) - for uri in data['links']: - uri = self._normalizeScheme(uri) - uri = uri.replace(self._normalizeScheme(self.suite.draftroot), self._normalizeScheme(self.suite.specroot)) - if self.sections.has_key(uri): - testlist = self.sections[uri].tests.append(data) - for credit in data['credits']: - self.contributors[credit[0]] = credit[1] - else: - self.errors[test.sourcepath] = test.errors - - def __writeTemplate(self, template, data, outfile): - o = self.tt.process(template, data) - with open(outfile, 'w') as f: - f.write(o.encode('utf-8')) - - def writeOverview(self, destDir, errorOut=sys.stderr, addTests=[]): - """Write format-agnostic pages such as test suite overview pages, - test data files, and error reports. - - Indexed errors are reported to errorOut, which must be either - an output handle such as sys.stderr, a tuple of - (template filename string, output filename string) - or None to suppress error output. - - `addTests` is a list of additional test paths, relative to the - overview root; it is intended for indexing raw tests - """ - - # Set common values - data = self.extraData.copy() - data['suitetitle'] = self.suite.title - data['suite'] = self.suite.name - data['specroot'] = self.suite.specroot - data['draftroot'] = self.suite.draftroot - data['contributors'] = self.contributors - data['tests'] = self.alltests - data['extmap'] = ExtensionMap({'.xht':'', '.html':'', '.htm':'', '.svg':''}) - data['formats'] = self.suite.formats - data['addtests'] = addTests - data['suites'] = self.suites - data['flagInfo'] = self.flags - data['formatInfo'] = { 'html4': { 'report': True, 'path': 'html4', 'ext': 'htm', 'filter': 'nonHTML'}, - 'html5': { 'report': True, 'path': 'html', 'ext': 'htm', 'filter': 'nonHTML' }, - 'xhtml1': { 'report': True, 'path': 'xhtml1', 'ext': 'xht', 'filter': 'HTMLonly' }, - 'xhtml1print': { 'report': False, 'path': 'xhtml1print', 'ext': 'xht', 'filter': 'HTMLonly' }, - 'svg': { 'report': True, 'path': 'svg', 'ext': 'svg', 'filter': 'HTMLonly' } - } - - # Copy simple copy files - for tmplDir in reversed(self.templatePath): - files = listfiles(tmplDir) - for file in files: - if self.overviewCopyExtPat.match(file): - shutil.copy(join(tmplDir, file), join(destDir, file)) - - # Generate indexes - for tmpl in self.overviewTmplNames: - out = tmpl[0:-5] if tmpl.endswith('.tmpl') else tmpl - self.__writeTemplate(tmpl, data, join(destDir, out)) - - # Report errors - if (self.errors): - if type(errorOut) is type(('tmpl','out')): - data['errors'] = errors - self.__writeTemplate(errorOut[0], data, join(destDir, errorOut[1])) - else: - sys.stdout.flush() - for errorLocation in self.errors: - print >> errorOut, "Error in %s: %s" % \ - (errorLocation, ' '.join([str(error) for error in self.errors[errorLocation]])) - - def writeIndex(self, format): - """Write indices into test suite build output through format `format`. - """ - - # Set common values - data = self.extraData.copy() - data['suitetitle'] = self.suite.title - data['suite'] = self.suite.name - data['specroot'] = self.suite.specroot - data['draftroot'] = self.suite.draftroot - - data['indexext'] = format.indexExt - data['isXML'] = format.indexExt.startswith('.x') - data['formatdir'] = format.formatDirName - data['extmap'] = format.extMap - data['tests'] = self.alltests - data['suites'] = self.suites - data['flagInfo'] = self.flags - - # Generate indices: - - # Reftest indices - self.__writeTemplate('reftest-toc.tmpl', data, - format.dest('reftest-toc%s' % format.indexExt)) - self.__writeTemplate('reftest.tmpl', data, - format.dest('reftest.list')) - - # Table of Contents - sectionlist = sorted(self.sections.values()) - if self.splitChapter: - # Split sectionlist into chapters - chapters = [] - lastChapNum = '$' # some nonmatching initial char - chap = None - for section in sectionlist: - if (section.title and (section.chapterNum() != lastChapNum)): - lastChapNum = section.chapterNum() - chap = section - chap.sections = [] - chap.testcount = 0 - chap.testnames = set() - chapters.append(chap) - chap.testnames.update([test['name'] for test in section.tests]) - chap.testcount = len(chap.testnames) - chap.sections.append(section) - - # Generate main toc - data['chapters'] = chapters - self.__writeTemplate('chapter-toc.tmpl', data, - format.dest('toc%s' % format.indexExt)) - del data['chapters'] - - # Generate chapter tocs - for chap in chapters: - data['chaptertitle'] = chap.title - data['testcount'] = chap.testcount - data['sections'] = chap.sections - self.__writeTemplate('test-toc.tmpl', data, format.dest('chapter-%s%s' \ - % (chap.numstr, format.indexExt))) - - else: # not splitChapter - data['chapters'] = sectionlist - self.__writeTemplate('test-toc.tmpl', data, - format.dest('toc%s' % format.indexExt)) - del data['chapters'] diff --git a/css/tools/w3ctestlib/OutputFormats.py b/css/tools/w3ctestlib/OutputFormats.py deleted file mode 100644 index 084e66d02f20bf..00000000000000 --- a/css/tools/w3ctestlib/OutputFormats.py +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/python -# CSS Test Source Manipulation Library -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -import re -import os -from os.path import join, exists, splitext, dirname, basename -from Sources import XHTMLSource, HTMLSource, SVGSource, SourceTree - -class ExtensionMap: - """ Given a file extension mapping (e.g. {'.xht' : '.htm'}), provides - a translate function for paths. - """ - def __init__(self, extMap): - self.extMap = extMap - - def translate(self, path): - for ext in self.extMap: - if path.endswith(ext): - return splitext(path)[0] + self.extMap[ext] - return path - -class BasicFormat: - """Base class. A Format manages all the conversions and location - transformations (e.g. subdirectory for all tests in that format) - associated with a test suite format. - - The base class implementation performs no conversions or - format-specific location transformations.""" - formatDirName = None - indexExt = '.htm' - convert = True # XXX hack to supress format conversion in support dirs, need to clean up output code to make this cleaner - - def __init__(self, destroot, sourceTree, extMap=None, outputDirName=None): - """Creates format root of the output tree. `destroot` is the root path - of the output tree. - - extMap provides a file extension mapping, e.g. {'.xht' : '.htm'} - """ - self.root = join(destroot, outputDirName) if outputDirName else destroot - self.sourceTree = sourceTree - self.formatDirName = outputDirName - if not exists(self.root): - os.makedirs(self.root) - self.extMap = ExtensionMap(extMap or {}) - self.subdir = None - - def setSubDir(self, name=None): - """Sets format to write into group subdirectory `name`. - """ - self.subdir = name - - def destDir(self): - return join(self.root, self.subdir) if self.subdir else self.root - - def dest(self, relpath): - """Returns final destination of relpath in this format and ensures that the - parent directory exists.""" - # Translate path - if (self.convert): - relpath = self.extMap.translate(relpath) - if (self.sourceTree.isReferenceAnywhere(relpath)): - relpath = join('reference', basename(relpath)) - # XXX when forcing support files into support path, need to account for support/support - dest = join(self.root, self.subdir, relpath) if self.subdir \ - else join(self.root, relpath) - # Ensure parent - parent = dirname(dest) - if not exists(parent): - os.makedirs(parent) - - return dest - - def write(self, source): - """Write FileSource to destination, following all necessary - conversion methods.""" - source.write(self, source) - - testTransform = False - # def testTransform(self, outputString, source) if needed - -class XHTMLFormat(BasicFormat): - """Base class for XHTML test suite format. Builds into 'xhtml1' subfolder - of root. - """ - indexExt = '.xht' - - def __init__(self, destroot, sourceTree, extMap=None, outputDirName='xhtml1'): - if not extMap: - extMap = {'.htm' : '.xht', '.html' : '.xht', '.xhtml' : '.xht' } - BasicFormat.__init__(self, destroot, sourceTree, extMap, outputDirName) - - def write(self, source): - # skip HTMLonly tests - if hasattr(source, 'hasFlag') and source.hasFlag('HTMLonly'): - return - if isinstance(source, HTMLSource) and self.convert: - source.write(self, source.serializeXHTML()) - else: - source.write(self) - -class HTMLFormat(BasicFormat): - """Base class for HTML test suite format. Builds into 'html4' subfolder - of root. - """ - - def __init__(self, destroot, sourceTree, extMap=None, outputDirName='html4'): - if not extMap: - extMap = {'.xht' : '.htm', '.xhtml' : '.htm', '.html' : '.htm' } - BasicFormat.__init__(self, destroot, sourceTree, extMap, outputDirName) - - def write(self, source): - # skip nonHTML tests - if hasattr(source, 'hasFlag') and source.hasFlag('nonHTML'): - return - if isinstance(source, XHTMLSource) and self.convert: - source.write(self, source.serializeHTML()) - else: - source.write(self) - - -class HTML5Format(HTMLFormat): - def __init__(self, destroot, sourceTree, extMap=None, outputDirName='html'): - HTMLFormat.__init__(self, destroot, sourceTree, extMap, outputDirName) - - def write(self, source): - # skip nonHTML tests - if hasattr(source, 'hasFlag') and source.hasFlag('nonHTML'): - return - if isinstance(source, XHTMLSource) and self.convert: - source.write(self, source.serializeHTML()) - else: - source.write(self) - - -class SVGFormat(BasicFormat): - def __init__(self, destroot, sourceTree, extMap=None, outputDirName='svg'): - if not extMap: - extMap = {'.svg' : '.svg' } - BasicFormat.__init__(self, destroot, sourceTree, extMap, outputDirName) - - def write(self, source): - # skip non SVG tests - if isinstance(source, SVGSource): - source.write(self) - - -class XHTMLPrintFormat(XHTMLFormat): - """Base class for XHTML Print test suite format. Builds into 'xhtml1print' - subfolder of root. - """ - - def __init__(self, destroot, sourceTree, testSuiteName, extMap=None, outputDirName='xhtml1print'): - if not extMap: - extMap = {'.htm' : '.xht', '.html' : '.xht', '.xhtml' : '.xht' } - BasicFormat.__init__(self, destroot, sourceTree, extMap, outputDirName) - self.testSuiteName = testSuiteName - - def write(self, source): - if (isinstance(source, XHTMLSource)): - if not source.hasFlag('HTMLonly'): - source.write(self, self.testTransform(source)) - else: - XHTMLFormat.write(self, source) - - def testTransform(self, source): - assert isinstance(source, XHTMLSource) - output = source.serializeXHTML('xhtml10') - - headermeta = {'suitename' : self.testSuiteName, - 'testid' : source.name(), - 'margin' : '', - } - if re.search('@page\s*{[^}]*@', output): - # Don't use headers and footers when page tests margin boxes - output = re.sub('(]*>)', - '\1\n' + self.__htmlstart % headermeta, - output); - output = re.sub('(]*>)', - '\1\n' + self.__htmlend % headermeta, - output); - else: - # add margin rule only when @page statement does not exist - if not re.search('@page', output): - headermeta['margin'] = self.__margin - output = re.sub('', - '\n ' % \ - (self.__css % headermeta), - output); - return output; - - # template bits - __margin = 'margin: 7%;'; - __font = 'font: italic 8pt sans-serif; color: gray;' - __css = """ - @page { %s - %%(margin)s - counter-increment: page; - @top-left { content: "%%(suitename)s"; } - @top-right { content: "Test %%(testid)s"; } - @bottom-right { content: counter(page); } - } -""" % __font - __htmlstart = '

Start of %%(suitename)s %%(testid)s.

' % __font - __htmlend = '

End of %%(suitename)s %%(testid)s.

' % __font - diff --git a/css/tools/w3ctestlib/Sources.py b/css/tools/w3ctestlib/Sources.py deleted file mode 100644 index f3848030ba5136..00000000000000 --- a/css/tools/w3ctestlib/Sources.py +++ /dev/null @@ -1,1473 +0,0 @@ -#!/usr/bin/python -# CSS Test Source Manipulation Library -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -from __future__ import print_function -from os.path import basename, exists, join -import os -import filecmp -import shutil -import re -import codecs -import collections -from xml import dom -import html5lib -from html5lib import treebuilders -from lxml import etree -from lxml.etree import ParseError -from Utils import getMimeFromExt, escapeToNamedASCII, basepath, isPathInsideBase, relativeURL, assetName -import HTMLSerializer -import warnings -import hashlib - -class SourceTree(object): - """Class that manages structure of test repository source. - Temporarily hard-coded path and filename rules, this should be configurable. - """ - - def __init__(self, repository = None): - self.mTestExtensions = ['.xht', '.html', '.xhtml', '.htm', '.xml', '.svg'] - self.mReferenceExtensions = ['.xht', '.html', '.xhtml', '.htm', '.xml', '.png', '.svg'] - self.mRepository = repository - - def _splitDirs(self, dir): - if ('' == dir): - pathList = [] - elif ('/' in dir): - pathList = dir.split('/') - else: - pathList = dir.split(os.path.sep) - return pathList - - def _splitPath(self, filePath): - """split a path into a list of directory names and the file name - paths may come form the os or mercurial, which always uses '/' as the - directory separator - """ - dir, fileName = os.path.split(filePath.lower()) - return (self._splitDirs(dir), fileName) - - def isTracked(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) - - def _isApprovedPath(self, pathList): - return ((1 < len(pathList)) and ('approved' == pathList[0]) and (('support' == pathList[1]) or ('src' in pathList))) - - def isApprovedPath(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) and self._isApprovedPath(pathList) - - def _isIgnoredPath(self, pathList): - return (('.hg' in pathList) or ('.git' in pathList) or - ('.svn' in pathList) or ('cvs' in pathList) or - ('incoming' in pathList) or ('work-in-progress' in pathList) or - ('data' in pathList) or ('archive' in pathList) or - ('reports' in pathList) or ('tools' == pathList[0]) or - ('test-plan' in pathList) or ('test-plans' in pathList)) - - def _isIgnored(self, pathList, fileName): - if (pathList): # ignore files in root - return (self._isIgnoredPath(pathList) or - fileName.startswith('.directory') or ('lock' == fileName) or - ('.ds_store' == fileName) or - fileName.startswith('.hg') or fileName.startswith('.git') or - ('sections.dat' == fileName) or ('get-spec-sections.pl' == fileName)) - return True - - def isIgnored(self, filePath): - pathList, fileName = self._splitPath(filePath) - return self._isIgnored(pathList, fileName) - - def isIgnoredDir(self, dir): - pathList = self._splitDirs(dir) - return self._isIgnoredPath(pathList) - - def _isToolPath(self, pathList): - return ('tools' in pathList) - - def _isTool(self, pathList, fileName): - return self._isToolPath(pathList) - - def isTool(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) and self._isTool(pathList, fileName) - - def _isSupportPath(self, pathList): - return ('support' in pathList) - - def _isSupport(self, pathList, fileName): - return (self._isSupportPath(pathList) or - ((not self._isTool(pathList, fileName)) and - (not self._isReference(pathList, fileName)) and - (not self._isTestCase(pathList, fileName)))) - - def isSupport(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) and self._isSupport(pathList, fileName) - - def _isReferencePath(self, pathList): - return (('reftest' in pathList) or ('reference' in pathList)) - - def _isReference(self, pathList, fileName): - if ((not self._isSupportPath(pathList)) and (not self._isToolPath(pathList))): - baseName, fileExt = os.path.splitext(fileName)[:2] - if (bool(re.search('(^ref-|^notref-).+', baseName)) or - bool(re.search('.+(-ref[0-9]*$|-notref[0-9]*$)', baseName)) or - ('-ref-' in baseName) or ('-notref-' in baseName)): - return (fileExt in self.mReferenceExtensions) - if (self._isReferencePath(pathList)): - return (fileExt in self.mReferenceExtensions) - return False - - def isReference(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) and self._isReference(pathList, fileName) - - def isReferenceAnywhere(self, filePath): - pathList, fileName = self._splitPath(filePath) - return self._isReference(pathList, fileName) - - def _isTestCase(self, pathList, fileName): - if ((not self._isToolPath(pathList)) and (not self._isSupportPath(pathList)) and (not self._isReference(pathList, fileName))): - fileExt = os.path.splitext(fileName)[1] - return (fileExt in self.mTestExtensions) - return False - - def isTestCase(self, filePath): - pathList, fileName = self._splitPath(filePath) - return (not self._isIgnored(pathList, fileName)) and self._isTestCase(pathList, fileName) - - def getAssetName(self, filePath): - pathList, fileName = self._splitPath(filePath) - if (self._isReference(pathList, fileName) or self._isTestCase(pathList, fileName)): - return assetName(fileName) - return fileName.lower() # support files keep full name - - def getAssetType(self, filePath): - pathList, fileName = self._splitPath(filePath) - if (self._isReference(pathList, fileName)): - return intern('reference') - if (self._isTestCase(pathList, fileName)): - return intern('testcase') - if (self._isTool(pathList, fileName)): - return intern('tool') - return intern('support') - - -class SourceCache: - """Cache for FileSource objects. Supports one FileSource object - per sourcepath. - """ - def __init__(self, sourceTree): - self.__cache = {} - self.sourceTree = sourceTree - - def generateSource(self, sourcepath, relpath, data = None): - """Return a FileSource or derivative based on the extensionMap. - - Uses a cache to avoid creating more than one of the same object: - does not support creating two FileSources with the same sourcepath; - asserts if this is tried. (.htaccess files are not cached.) - - Cache is bypassed if loading form a change context - """ - if ((None == data) and self.__cache.has_key(sourcepath)): - source = self.__cache[sourcepath] - assert relpath == source.relpath - return source - - if basename(sourcepath) == '.htaccess': - return ConfigSource(self.sourceTree, sourcepath, relpath, data) - mime = getMimeFromExt(sourcepath) - if (mime == 'application/xhtml+xml'): - source = XHTMLSource(self.sourceTree, sourcepath, relpath, data) - elif (mime == 'text/html'): - source = HTMLSource(self.sourceTree, sourcepath, relpath, data) - elif (mime == 'image/svg+xml'): - source = SVGSource(self.sourceTree, sourcepath, relpath, data) - elif (mime == 'application/xml'): - source = XMLSource(self.sourceTree, sourcepath, relpath, data) - else: - source = FileSource(self.sourceTree, sourcepath, relpath, mime, data) - if (None == data): - self.__cache[sourcepath] = source - return source - -class SourceSet: - """Set of FileSource objects. No two FileSources of the same type in the set may - have the same name (except .htaccess files, which are merged). - """ - def __init__(self, sourceCache): - self.sourceCache = sourceCache - self.pathMap = {} # type/name -> source - - def __len__(self): - return len(self.pathMap) - - def _keyOf(self, source): - return source.type() + '/' + source.keyName() - - def __contains__(self, source): - return self._keyOf(source) in self.pathMap - - - def iter(self): - """Iterate over FileSource objects in SourceSet. - """ - return self.pathMap.itervalues() - - def addSource(self, source, ui): - """Add FileSource `source`. Throws exception if we already have - a FileSource with the same path relpath but different contents. - (ConfigSources are exempt from this requirement.) - """ - cachedSource = self.pathMap.get(self._keyOf(source)) - if not cachedSource: - self.pathMap[self._keyOf(source)] = source - else: - if source != cachedSource: - if isinstance(source, ConfigSource): - cachedSource.append(source) - else: - ui.warn("File merge mismatch %s vs %s for %s\n" % \ - (cachedSource.sourcepath, source.sourcepath, source.name())) - - def add(self, sourcepath, relpath, ui): - """Generate and add FileSource from sourceCache. Return the resulting - FileSource. - - Throws exception if we already have a FileSource with the same path - relpath but different contents. - """ - source = self.sourceCache.generateSource(sourcepath, relpath) - self.addSource(source, ui) - return source - - @staticmethod - def combine(a, b, ui): - """Merges a and b, and returns whichever one contains the merger (which - one is chosen based on merge efficiency). Can accept None as an argument. - """ - if not (a and b): - return a or b - if len(a) < len(b): - return b.merge(a, ui) - return a.merge(b, ui) - - def merge(self, other, ui): - """Merge sourceSet's contents into this SourceSet. - - Throws a RuntimeError if there's a sourceCache mismatch. - Throws an Exception if two files with the same relpath mismatch. - Returns merge result (i.e. self) - """ - if self.sourceCache is not other.sourceCache: - raise RuntimeError - - for source in other.pathMap.itervalues(): - self.addSource(source, ui) - return self - - def adjustContentPaths(self, format): - for source in self.pathMap.itervalues(): - source.adjustContentPaths(format) - - def write(self, format): - """Write files out through OutputFormat `format`. - """ - for source in self.pathMap.itervalues(): - format.write(source) - - -class StringReader(object): - """Wrapper around a string to give it a file-like api - """ - def __init__(self, string): - self.mString = string - self.mIndex = 0 - - def read(self, maxSize = None): - if (self.mIndex < len(self.mString)): - if (maxSize and (0 < maxSize)): - slice = self.mString[self.mIndex:self.mIndex + maxSize] - self.mIndex += len(slice) - return slice - else: - self.mIndex = len(self.mString) - return self.mString - return '' - - -class NamedDict(object): - def get(self, key): - if (key in self): - return self[key] - return None - - def __eq__(self, other): - for key in self.__slots__: - if (self[key] != other[key]): - return False - return True - - def __ne__(self, other): - for key in self.__slots__: - if (self[key] != other[key]): - return True - return False - - def __len__(self): - return len(self.__slots__) - - def __iter__(self): - return iter(self.__slots__) - - def __contains__(self, key): - return (key in self.__slots__) - - def copy(self): - clone = self.__class__() - for key in self.__slots__: - clone[key] = self[key] - return clone - - def keys(self): - return self.__slots__ - - def has_key(self, key): - return (key in self) - - def items(self): - return [(key, self[key]) for key in self.__slots__] - - def iteritems(self): - return iter(self.items()) - - def iterkeys(self): - return self.__iter__() - - def itervalues(self): - return iter(self.items()) - - def __str__(self): - return '{ ' + ', '.join([key + ': ' + str(self[key]) for key in self.__slots__]) + ' }' - - -class Metadata(NamedDict): - __slots__ = ('name', 'title', 'asserts', 'credits', 'reviewers', 'flags', 'links', 'references', 'revision', 'selftest', 'scripttest') - - def __init__(self, name = None, title = None, asserts = [], credits = [], reviewers = [], flags = [], links = [], - references = [], revision = None, selftest = True, scripttest = False): - self.name = name - self.title = title - self.asserts = asserts - self.credits = credits - self.reviewers = reviewers - self.flags = flags - self.links = links - self.references = references - self.revision = revision - self.selftest = selftest - self.scripttest = scripttest - - def __getitem__(self, key): - if ('name' == key): - return self.name - if ('title' == key): - return self.title - if ('asserts' == key): - return self.asserts - if ('credits' == key): - return self.credits - if ('reviewers' == key): - return self.reviewers - if ('flags' == key): - return self.flags - if ('links' == key): - return self.links - if ('references' == key): - return self.references - if ('revision' == key): - return self.revision - if ('selftest' == key): - return self.selftest - if ('scripttest' == key): - return self.scripttest - return None - - def __setitem__(self, key, value): - if ('name' == key): - self.name = value - elif ('title' == key): - self.title = value - elif ('asserts' == key): - self.asserts = value - elif ('credits' == key): - self.credits = value - elif ('reviewers' == key): - self.reviewers = value - elif ('flags' == key): - self.flags = value - elif ('links' == key): - self.links = value - elif ('references' == key): - self.references = value - elif ('revision' == key): - self.revision = value - elif ('selftest' == key): - self.selftest = value - elif ('scripttest' == key): - self.scripttest = value - else: - raise KeyError() - - -class ReferenceData(NamedDict): - __slots__ = ('name', 'type', 'relpath', 'repopath') - - def __init__(self, name = None, type = None, relpath = None, repopath = None): - self.name = name - self.type = type - self.relpath = relpath - self.repopath = repopath - - def __getitem__(self, key): - if ('name' == key): - return self.name - if ('type' == key): - return self.type - if ('relpath' == key): - return self.relpath - if ('repopath' == key): - return self.repopath - return None - - def __setitem__(self, key, value): - if ('name' == key): - self.name = value - elif ('type' == key): - self.type = value - elif ('relpath' == key): - self.relpath = value - elif ('repopath' == key): - self.repopath = value - else: - raise KeyError() - -UserData = collections.namedtuple('UserData', ('name', 'link')) - -class LineString(str): - def __new__(cls, value, line): - self = str.__new__(cls, value) - self.line = line - return self - - def lineValue(self): - return 'Line ' + str(self.line) + ': ' + str.__str__(self) if (self.line) else str.__str__(self) - - -class FileSource: - """Object representing a file. Two FileSources are equal if they represent - the same file contents. It is recommended to use a SourceCache to generate - FileSources. - """ - - def __init__(self, sourceTree, sourcepath, relpath, mimetype = None, data = None): - """Init FileSource from source path. Give it relative path relpath. - - `mimetype` should be the canonical MIME type for the file, if known. - If `mimetype` is None, guess type from file extension, defaulting to - the None key's value in extensionMap. - - `data` if provided, is a the contents of the file. Otherwise the file is read - from disk. - """ - self.sourceTree = sourceTree - self.sourcepath = sourcepath - self.relpath = relpath - self.mimetype = mimetype or getMimeFromExt(sourcepath) - self._data = data - self.errors = None - self.encoding = 'utf-8' - self.refs = {} - self.scripts = {} - self.metadata = None - self.metaSource = None - - def __eq__(self, other): - if not isinstance(other, FileSource): - return False - return self.sourcepath == other.sourcepath or \ - filecmp.cmp(self.sourcepath, other.sourcepath) - - def __ne__(self, other): - return not self == other - - def __cmp__(self, other): - return cmp(self.name(), other.name()) - - def name(self): - return self.sourceTree.getAssetName(self.sourcepath) - - def keyName(self): - if ('support' == self.type()): - return os.path.relpath(self.relpath, 'support') - return self.name() - - def type(self): - return self.sourceTree.getAssetType(self.sourcepath) - - def relativeURL(self, other): - return relativeURL(self.relpath, other.relpath) - - def data(self): - """Return file contents as a byte string.""" - if (self._data is None): - with open(self.sourcepath, 'r') as f: - self._data = f.read() - if (self._data.startswith(codecs.BOM_UTF8)): - self.encoding = 'utf-8-sig' # XXX look for other unicode BOMs - return self._data - - def unicode(self): - try: - return self.data().decode(self.encoding) - except UnicodeDecodeError: - return None - - def parse(self): - """Parses and validates FileSource data from sourcepath.""" - self.loadMetadata() - - def validate(self): - """Ensure data is loaded from sourcepath.""" - self.parse() - - def adjustContentPaths(self, format): - """Adjust any paths in file content for output format - XXX need to account for group paths""" - if (self.refs): - seenRefs = {} - seenRefs[self.sourcepath] = '==' - def adjustReferences(source): - newRefs = {} - for refName in source.refs: - refType, refPath, refNode, refSource = source.refs[refName] - if refSource: - refPath = relativeURL(format.dest(self.relpath), format.dest(refSource.relpath)) - if (refSource.sourcepath not in seenRefs): - seenRefs[refSource.sourcepath] = refType - adjustReferences(refSource) - else: - refPath = relativeURL(format.dest(self.relpath), format.dest(refPath)) - if (refPath != refNode.get('href')): - refNode.set('href', refPath) - newRefs[refName] = (refType, refPath, refNode, refSource) # update path in metadata - source.refs = newRefs - adjustReferences(self) - - if (self.scripts): # force testharness.js scripts to absolute path - for src in self.scripts: - if (src.endswith('/resources/testharness.js')): # accept relative paths to testharness.js - scriptNode = self.scripts[src] - scriptNode.set('src', '/resources/testharness.js') - elif (src.endswith('/resources/testharnessreport.js')): - scriptNode = self.scripts[src] - scriptNode.set('src', '/resources/testharnessreport.js') - - - def write(self, format): - """Writes FileSource.data() out to `self.relpath` through Format `format`.""" - data = self.data() - with open(format.dest(self.relpath), 'w') as f: - f.write(data) - if (self.metaSource): - self.metaSource.write(format) # XXX need to get output path from format, but not let it choose actual format - - def compact(self): - """Clears all cached data, preserves computed data.""" - pass - - def revision(self): - """Returns hash of the contents of this file and any related file, references, support files, etc. - XXX also needs to account for .meta file - """ - sha = hashlib.sha1() - sha.update(self.data()) - seenRefs = set(self.sourcepath) - def hashReference(source): - for refName in source.refs: - refSource = source.refs[refName][3] - if (refSource and (refSource.sourcepath not in seenRefs)): - sha.update(refSource.data()) - seenRefs.add(refSource.sourcepath) - hashReference(refSource) - hashReference(self) - return sha.hexdigest() - - def loadMetadata(self): - """Look for .meta file and load any metadata from it if present - """ - pass - - def augmentMetadata(self, next=None, prev=None, reference=None, notReference=None): - if (self.metaSource): - return self.metaSource.augmentMetadata(next, prev, reference, notReference) - return None - - # See http://wiki.csswg.org/test/css2.1/format for more info on metadata - def getMetadata(self, asUnicode = False): - """Return dictionary of test metadata. Stores list of errors - in self.errors if there are parse or metadata errors. - Data fields include: - - asserts [list of strings] - - credits [list of (name string, url string) tuples] - - reviewers [ list of (name string, url string) tuples] - - flags [list of token strings] - - links [list of url strings] - - name [string] - - title [string] - - references [list of ReferenceData per reference; None if not reftest] - - revision [revision id of last commit] - - selftest [bool] - - scripttest [bool] - Strings are given in ascii unless asUnicode==True. - """ - - self.validate() - - def encode(str): - return str if (hasattr(str, 'line')) else intern(str.encode('utf-8')) - - def escape(str, andIntern = True): - return str.encode('utf-8') if asUnicode else intern(escapeToNamedASCII(str)) if andIntern else escapeToNamedASCII(str) - - def listReferences(source, seen): - refGroups = [] - for refType, refRelPath, refNode, refSource in source.refs.values(): - if ('==' == refType): - if (refSource): - refSourcePath = refSource.sourcepath - else: - refSourcePath = os.path.normpath(join(basepath(source.sourcepath), refRelPath)) - if (refSourcePath in seen): - continue - seen.add(refSourcePath) - if (refSource): - sourceData = ReferenceData(name = self.sourceTree.getAssetName(refSourcePath), type = refType, - relpath = refRelPath, repopath = refSourcePath) - if (refSource.refs): - subRefLists = listReferences(refSource, seen.copy()) - if (subRefLists): - for subRefList in subRefLists: - refGroups.append([sourceData] + subRefList) - else: - refGroups.append([sourceData]) - else: - refGroups.append([sourceData]) - else: - sourceData = ReferenceData(name = self.sourceTree.getAssetName(refSourcePath), type = refType, - relpath = relativeURL(self.sourcepath, refSourcePath), - repopath = refSourcePath) - refGroups.append([sourceData]) - notRefs = {} - for refType, refRelPath, refNode, refSource in source.refs.values(): - if ('!=' == refType): - if (refSource): - refSourcePath = refSource.sourcepath - else: - refSourcePath = os.path.normpath(join(basepath(source.sourcepath), refRelPath)) - if (refSourcePath in seen): - continue - seen.add(refSourcePath) - if (refSource): - sourceData = ReferenceData(name = self.sourceTree.getAssetName(refSourcePath), type = refType, - relpath = refRelPath, repopath = refSourcePath) - notRefs[sourceData.name] = sourceData - if (refSource.refs): - for subRefList in listReferences(refSource, seen): - for subRefData in subRefList: - notRefs[subRefData.name] = subRefData - else: - sourceData = ReferenceData(name = self.sourceTree.getAssetName(refSourcePath), type = refType, - relpath = relativeURL(self.sourcepath, refSourcePath), - repopath = refSourcePath) - notRefs[sourceData.name] = sourceData - if (notRefs): - for refData in notRefs.values(): - refData.type = '!=' - if (refGroups): - for refGroup in refGroups: - for notRef in notRefs.values(): - for ref in refGroup: - if (ref.name == notRef.name): - break - else: - refGroup.append(notRef) - else: - refGroups.append(notRefs.values()) - return refGroups - - references = listReferences(self, set([self.sourcepath])) if (self.refs) else None - - if (self.metadata): - data = Metadata( - name = encode(self.name()), - title = escape(self.metadata['title'], False), - asserts = [escape(assertion, False) for assertion in self.metadata['asserts']], - credits = [UserData(escape(name), encode(link)) for name, link in self.metadata['credits']], - reviewers = [UserData(escape(name), encode(link)) for name, link in self.metadata['reviewers']], - flags = [encode(flag) for flag in self.metadata['flags']], - links = [encode(link) for link in self.metadata['links']], - references = references, - revision = self.revision(), - selftest = self.isSelftest(), - scripttest = self.isScripttest() - ) - return data - return None - - def addReference(self, referenceSource, match = None): - """Add reference source.""" - self.validate() - refName = referenceSource.name() - refPath = self.relativeURL(referenceSource) - if refName not in self.refs: - node = None - if match == '==': - node = self.augmentMetadata(reference=referenceSource).reference - elif match == '!=': - node = self.augmentMetadata(notReference=referenceSource).notReference - self.refs[refName] = (match, refPath, node, referenceSource) - else: - node = self.refs[refName][2] - node.set('href', refPath) - if (match): - node.set('rel', 'mismatch' if ('!=' == match) else 'match') - else: - match = self.refs[refName][0] - self.refs[refName] = (match, refPath, node, referenceSource) - - def getReferencePaths(self): - """Get list of paths to references as tuple(path, relPath, refType).""" - self.validate() - return [(os.path.join(os.path.dirname(self.sourcepath), ref[1]), - os.path.join(os.path.dirname(self.relpath), ref[1]), - ref[0]) - for ref in self.refs.values()] - - def isTest(self): - self.validate() - return bool(self.metadata) and bool(self.metadata.get('links')) - - def isReftest(self): - return self.isTest() and bool(self.refs) - - def isSelftest(self): - return self.isTest() and (not bool(self.refs)) - - def isScripttest(self): - if (self.isTest() and self.scripts): - for src in self.scripts: - if (src.endswith('/resources/testharness.js')): # accept relative paths to testharness.js - return True - return False - - def hasFlag(self, flag): - data = self.getMetadata() - if data: - return flag in data['flags'] - return False - - - -class ConfigSource(FileSource): - """Object representing a text-based configuration file. - Capable of merging multiple config-file contents. - """ - - def __init__(self, sourceTree, sourcepath, relpath, mimetype = None, data = None): - """Init ConfigSource from source path. Give it relative path relpath. - """ - FileSource.__init__(self, sourceTree, sourcepath, relpath, mimetype, data) - self.sourcepath = [sourcepath] - - def __eq__(self, other): - if not isinstance(other, ConfigSource): - return False - if self is other or self.sourcepath == other.sourcepath: - return True - if len(self.sourcepath) != len(other.sourcepath): - return False - for this, that in zip(self.sourcepath, other.sourcepath): - if not filecmp.cmp(this, that): - return False - return True - - def __ne__(self, other): - return not self == other - - def name(self): - return '.htaccess' - - def type(self): - return intern('support') - - def data(self): - """Merge contents of all config files represented by this source.""" - data = '' - for src in self.sourcepath: - with open(src) as f: - data += f.read() - data += '\n' - return data - - def getMetadata(self, asUnicode = False): - return None - - def append(self, other): - """Appends contents of ConfigSource `other` to this source. - Asserts if self.relpath != other.relpath. - """ - assert isinstance(other, ConfigSource) - assert self != other and self.relpath == other.relpath - self.sourcepath.extend(other.sourcepath) - -class ReftestFilepathError(Exception): - pass - -class ReftestManifest(ConfigSource): - """Object representing a reftest manifest file. - Iterating the ReftestManifest returns (testpath, refpath) tuples - with paths relative to the manifest. - """ - def __init__(self, sourceTree, sourcepath, relpath, data = None): - """Init ReftestManifest from source path. Give it relative path `relpath` - and load its .htaccess file. - """ - ConfigSource.__init__(self, sourceTree, sourcepath, relpath, mimetype = 'config/reftest', data = data) - - def basepath(self): - """Returns the base relpath of this reftest manifest path, i.e. - the parent of the manifest file. - """ - return basepath(self.relpath) - - baseRE = re.compile(r'^#\s*relstrip\s+(\S+)\s*') - stripRE = re.compile(r'#.*') - parseRE = re.compile(r'^\s*([=!]=)\s*(\S+)\s+(\S+)') - - def __iter__(self): - """Parse the reftest manifest files represented by this ReftestManifest - and return path information about each reftest pair as - ((test-sourcepath, ref-sourcepath), (test-relpath, ref-relpath), reftype) - Raises a ReftestFilepathError if any sources file do not exist or - if any relpaths point higher than the relpath root. - """ - striplist = [] - for src in self.sourcepath: - relbase = basepath(self.relpath) - srcbase = basepath(src) - with open(src) as f: - for line in f: - strip = self.baseRE.search(line) - if strip: - striplist.append(strip.group(1)) - line = self.stripRE.sub('', line) - m = self.parseRE.search(line) - if m: - record = ((join(srcbase, m.group(2)), join(srcbase, m.group(3))), \ - (join(relbase, m.group(2)), join(relbase, m.group(3))), \ - m.group(1)) - # for strip in striplist: - # strip relrecord - if not exists(record[0][0]): - raise ReftestFilepathError("Manifest Error in %s: " - "Reftest test file %s does not exist." \ - % (src, record[0][0])) - elif not exists(record[0][1]): - raise ReftestFilepathError("Manifest Error in %s: " - "Reftest reference file %s does not exist." \ - % (src, record[0][1])) - elif not isPathInsideBase(record[1][0]): - raise ReftestFilepathError("Manifest Error in %s: " - "Reftest test replath %s not within relpath root." \ - % (src, record[1][0])) - elif not isPathInsideBase(record[1][1]): - raise ReftestFilepathError("Manifest Error in %s: " - "Reftest test replath %s not within relpath root." \ - % (src, record[1][1])) - yield record - -import Utils # set up XML catalog -xhtmlns = '{http://www.w3.org/1999/xhtml}' -svgns = '{http://www.w3.org/2000/svg}' -xmlns = '{http://www.w3.org/XML/1998/namespace}' -xlinkns = '{http://www.w3.org/1999/xlink}' - -class XMLSource(FileSource): - """FileSource object with support reading XML trees.""" - - NodeTuple = collections.namedtuple('NodeTuple', ['next', 'prev', 'reference', 'notReference']) - - # Public Data - syntaxErrorDoc = \ - u""" - - - Syntax Error - -

The XML file contains a syntax error and could not be parsed. - Please correct it and try again.

-

The parser's error report was:

-
- - - """ - - # Private Data and Methods - __parser = etree.XMLParser(no_network=True, - # perf nightmare dtd_validation=True, - remove_comments=False, - strip_cdata=False, - resolve_entities=False) - - # Public Methods - - def __init__(self, sourceTree, sourcepath, relpath, data = None): - """Initialize XMLSource by loading from XML file `sourcepath`. - Parse errors are reported in `self.errors`, - and the source is replaced with an XHTML error message. - """ - FileSource.__init__(self, sourceTree, sourcepath, relpath, data = data) - self.tree = None - self.injectedTags = {} - - def cacheAsParseError(self, filename, e): - """Replace document with an error message.""" - errorDoc = self.syntaxErrorDoc % (filename, e) - from StringIO import StringIO - self.tree = etree.parse(StringIO(errorDoc), parser=self.__parser) - - def parse(self): - """Parse file and store any parse errors in self.errors""" - self.errors = None - try: - data = self.data() - if (data): - self.tree = etree.parse(StringReader(data), parser=self.__parser) - self.encoding = self.tree.docinfo.encoding or 'utf-8' - self.injectedTags = {} - else: - self.tree = None - self.errors = ['Empty source file'] - self.encoding = 'utf-8' - - FileSource.loadMetadata(self) - if ((not self.metadata) and self.tree and (not self.errors)): - self.extractMetadata(self.tree) - except etree.ParseError as e: - print("PARSE ERROR: " + self.sourcepath) - self.cacheAsParseError(self.sourcepath, e) - e.W3CTestLibErrorLocation = self.sourcepath - self.errors = [str(e)] - self.encoding = 'utf-8' - - def validate(self): - """Parse file if not parsed, and store any parse errors in self.errors""" - if self.tree is None: - self.parse() - - def getMeatdataContainer(self): - return self.tree.getroot().find(xhtmlns+'head') - - def injectMetadataLink(self, rel, href, tagCode = None): - """Inject (prepend) with data given inside metadata container. - Injected element is tagged with `tagCode`, which can be - used to clear it with clearInjectedTags later. - """ - self.validate() - container = self.getMeatdataContainer() - if (container): - node = etree.Element(xhtmlns+'link', {'rel': rel, 'href': href}) - node.tail = container.text - container.insert(0, node) - self.injectedTags[node] = tagCode or True - return node - return None - - def clearInjectedTags(self, tagCode = None): - """Clears all injected elements from the tree, or clears injected - elements tagged with `tagCode` if `tagCode` is given. - """ - if not self.injectedTags or not self.tree: return - for node in self.injectedTags: - node.getparent().remove(node) - del self.injectedTags[node] - - def serializeXML(self): - self.validate() - return etree.tounicode(self.tree) - - def data(self): - if ((not self.tree) or (self.metaSource)): - return FileSource.data(self) - return self.serializeXML().encode(self.encoding, 'xmlcharrefreplace') - - def unicode(self): - if ((not self.tree) or (self.metaSource)): - return FileSource.unicode(self) - return self.serializeXML() - - def write(self, format, output=None): - """Write Source through OutputFormat `format`. - Write contents as string `output` instead if specified. - """ - if not output: - output = self.unicode() - - # write - with open(format.dest(self.relpath), 'w') as f: - f.write(output.encode(self.encoding, 'xmlcharrefreplace')) - - def compact(self): - self.tree = None - - def getMetadataElements(self, tree): - container = self.getMeatdataContainer() - if (None != container): - return [node for node in container] - return None - - def extractMetadata(self, tree): - """Extract metadata from tree.""" - links = []; credits = []; reviewers = []; flags = []; asserts = []; title = '' - - def tokenMatch(token, string): - return bool(re.search('(^|\s+)%s($|\s+)' % token, string)) if (string) else False - - errors = [] - readFlags = False - metaElements = self.getMetadataElements(tree) - if (not metaElements): - errors.append("Missing element") - else: - # Scan and cache metadata - for node in metaElements: - if (node.tag == xhtmlns+'link'): - # help links - if tokenMatch('help', node.get('rel')): - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Help link missing href value.", node.sourceline)) - elif (not (link.startswith('http://') or link.startswith('https://'))): - errors.append(LineString("Help link " + link.encode('utf-8') + " must be absolute URL.", node.sourceline)) - elif (link in links): - errors.append(LineString("Duplicate help link " + link.encode('utf-8') + ".", node.sourceline)) - else: - links.append(LineString(link, node.sourceline)) - # == references - elif tokenMatch('match', node.get('rel')) or tokenMatch('reference', node.get('rel')): - refPath = node.get('href').strip() if node.get('href') else None - if (not refPath): - errors.append(LineString("Reference link missing href value.", node.sourceline)) - else: - refName = self.sourceTree.getAssetName(join(self.sourcepath, refPath)) - if (refName in self.refs): - errors.append(LineString("Reference " + refName.encode('utf-8') + " already specified.", node.sourceline)) - else: - self.refs[refName] = ('==', refPath, node, None) - # != references - elif tokenMatch('mismatch', node.get('rel')) or tokenMatch('not-reference', node.get('rel')): - refPath = node.get('href').strip() if node.get('href') else None - if (not refPath): - errors.append(LineString("Reference link missing href value.", node.sourceline)) - else: - refName = self.sourceTree.getAssetName(join(self.sourcepath, refPath)) - if (refName in self.refs): - errors.append(LineString("Reference " + refName.encode('utf-8') + " already specified.", node.sourceline)) - else: - self.refs[refName] = ('!=', refPath, node, None) - else: # may have both author and reviewer in the same link - # credits - if tokenMatch('author', node.get('rel')): - name = node.get('title') - name = name.strip() if name else name - if (not name): - errors.append(LineString("Author link missing name (title attribute).", node.sourceline)) - else: - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Author link for \"" + name.encode('utf-8') + "\" missing contact URL (http or mailto).", node.sourceline)) - else: - credits.append((name, link)) - # reviewers - if tokenMatch('reviewer', node.get('rel')): - name = node.get('title') - name = name.strip() if name else name - if (not name): - errors.append(LineString("Reviewer link missing name (title attribute).", node.sourceline)) - else: - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Reviewer link for \"" + name.encode('utf-8') + "\" missing contact URL (http or mailto).", node.sourceline)) - else: - reviewers.append((name, link)) - elif (node.tag == xhtmlns+'meta'): - metatype = node.get('name') - metatype = metatype.strip() if metatype else metatype - # requirement flags - if ('flags' == metatype): - if (readFlags): - errors.append(LineString("Flags must only be specified once.", node.sourceline)) - else: - readFlags = True - if (None == node.get('content')): - errors.append(LineString("Flags meta missing content attribute.", node.sourceline)) - else: - for flag in sorted(node.get('content').split()): - flags.append(flag) - # test assertions - elif ('assert' == metatype): - if (None == node.get('content')): - errors.append(LineString("Assert meta missing content attribute.", node.sourceline)) - else: - asserts.append(node.get('content').strip().replace('\t', ' ')) - # title - elif (node.tag == xhtmlns+'title'): - title = node.text.strip() if node.text else '' - match = re.match('(?:[^:]*)[tT]est(?:[^:]*):(.*)', title, re.DOTALL) - if (match): - title = match.group(1) - title = title.strip() - # script - elif (node.tag == xhtmlns+'script'): - src = node.get('src').strip() if node.get('src') else None - if (src): - self.scripts[src] = node - - if (asserts or credits or reviewers or flags or links or title): - self.metadata = {'asserts' : asserts, - 'credits' : credits, - 'reviewers' : reviewers, - 'flags' : flags, - 'links' : links, - 'title' : title - } - - if (errors): - if (self.errors): - self.errors += errors - else: - self.errors = errors - - - def augmentMetadata(self, next=None, prev=None, reference=None, notReference=None): - """Add extra useful metadata to the head. All arguments are optional. - * Adds next/prev links to next/prev Sources given - * Adds reference link to reference Source given - """ - self.validate() - if next: - next = self.injectMetadataLink('next', self.relativeURL(next), 'next') - if prev: - prev = self.injectMetadataLink('prev', self.relativeURL(prev), 'prev') - if reference: - reference = self.injectMetadataLink('match', self.relativeURL(reference), 'ref') - if notReference: - notReference = self.injectMetadataLink('mismatch', self.relativeURL(notReference), 'not-ref') - return self.NodeTuple(next, prev, reference, notReference) - - -class XHTMLSource(XMLSource): - """FileSource object with support for XHTML->HTML conversions.""" - - # Public Methods - - def __init__(self, sourceTree, sourcepath, relpath, data = None): - """Initialize XHTMLSource by loading from XHTML file `sourcepath`. - Parse errors are stored in `self.errors`, - and the source is replaced with an XHTML error message. - """ - XMLSource.__init__(self, sourceTree, sourcepath, relpath, data = data) - - def serializeXHTML(self, doctype = None): - return self.serializeXML() - - def serializeHTML(self, doctype = None): - self.validate() - # Serialize -# print self.relpath - serializer = HTMLSerializer.HTMLSerializer() - output = serializer.serializeHTML(self.tree, doctype) - return output - - -class SVGSource(XMLSource): - """FileSource object with support for extracting metadata from SVG.""" - - def __init__(self, sourceTree, sourcepath, relpath, data = None): - """Initialize SVGSource by loading from SVG file `sourcepath`. - Parse errors are stored in `self.errors`, - and the source is replaced with an XHTML error message. - """ - XMLSource.__init__(self, sourceTree, sourcepath, relpath, data = data) - - def getMeatdataContainer(self): - groups = self.tree.getroot().findall(svgns+'g') - for group in groups: - if ('testmeta' == group.get('id')): - return group - return None - - def extractMetadata(self, tree): - """Extract metadata from tree.""" - links = []; credits = []; reviewers = []; flags = []; asserts = []; title = '' - - def tokenMatch(token, string): - return bool(re.search('(^|\s+)%s($|\s+)' % token, string)) if (string) else False - - errors = [] - readFlags = False - metaElements = self.getMetadataElements(tree) - if (not metaElements): - errors.append("Missing element") - else: - # Scan and cache metadata - for node in metaElements: - if (node.tag == xhtmlns+'link'): - # help links - if tokenMatch('help', node.get('rel')): - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Help link missing href value.", node.sourceline)) - elif (not (link.startswith('http://') or link.startswith('https://'))): - errors.append(LineString("Help link " + link.encode('utf-8') + " must be absolute URL.", node.sourceline)) - elif (link in links): - errors.append(LineString("Duplicate help link " + link.encode('utf-8') + ".", node.sourceline)) - else: - links.append(LineString(link, node.sourceline)) - # == references - elif tokenMatch('match', node.get('rel')) or tokenMatch('reference', node.get('rel')): - refPath = node.get('href').strip() if node.get('href') else None - if (not refPath): - errors.append(LineString("Reference link missing href value.", node.sourceline)) - else: - refName = self.sourceTree.getAssetName(join(self.sourcepath, refPath)) - if (refName in self.refs): - errors.append(LineString("Reference " + refName.encode('utf-8') + " already specified.", node.sourceline)) - else: - self.refs[refName] = ('==', refPath, node, None) - # != references - elif tokenMatch('mismatch', node.get('rel')) or tokenMatch('not-reference', node.get('rel')): - refPath = node.get('href').strip() if node.get('href') else None - if (not refPath): - errors.append(LineString("Reference link missing href value.", node.sourceline)) - else: - refName = self.sourceTree.getAssetName(join(self.sourcepath, refPath)) - if (refName in self.refs): - errors.append(LineString("Reference " + refName.encode('utf-8') + " already specified.", node.sourceline)) - else: - self.refs[refName] = ('!=', refPath, node, None) - else: # may have both author and reviewer in the same link - # credits - if tokenMatch('author', node.get('rel')): - name = node.get('title') - name = name.strip() if name else name - if (not name): - errors.append(LineString("Author link missing name (title attribute).", node.sourceline)) - else: - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Author link for \"" + name.encode('utf-8') + "\" missing contact URL (http or mailto).", node.sourceline)) - else: - credits.append((name, link)) - # reviewers - if tokenMatch('reviewer', node.get('rel')): - name = node.get('title') - name = name.strip() if name else name - if (not name): - errors.append(LineString("Reviewer link missing name (title attribute).", node.sourceline)) - else: - link = node.get('href').strip() if node.get('href') else None - if (not link): - errors.append(LineString("Reviewer link for \"" + name.encode('utf-8') + "\" missing contact URL (http or mailto).", node.sourceline)) - else: - reviewers.append((name, link)) - elif (node.tag == svgns+'metadata'): - metatype = node.get('class') - metatype = metatype.strip() if metatype else metatype - # requirement flags - if ('flags' == metatype): - if (readFlags): - errors.append(LineString("Flags must only be specified once.", node.sourceline)) - else: - readFlags = True - text = node.find(svgns+'text') - flagString = text.text if (text) else node.text - if (flagString): - for flag in sorted(flagString.split()): - flags.append(flag) - elif (node.tag == svgns+'desc'): - metatype = node.get('class') - metatype = metatype.strip() if metatype else metatype - # test assertions - if ('assert' == metatype): - asserts.append(node.text.strip().replace('\t', ' ')) - # test title - elif node.tag == svgns+'title': - title = node.text.strip() if node.text else '' - match = re.match('(?:[^:]*)[tT]est(?:[^:]*):(.*)', title, re.DOTALL) - if (match): - title = match.group(1) - title = title.strip() - # script tag (XXX restricted to metadata container?) - elif (node.tag == svgns+'script'): - src = node.get('src').strip() if node.get('src') else None - if (src): - self.scripts[src] = node - - if (asserts or credits or reviewers or flags or links or title): - self.metadata = {'asserts' : asserts, - 'credits' : credits, - 'reviewers' : reviewers, - 'flags' : flags, - 'links' : links, - 'title' : title - } - if (errors): - if (self.errors): - self.errors += errors - else: - self.errors = errors - - - -class HTMLSource(XMLSource): - """FileSource object with support for HTML metadata and HTML->XHTML conversions (untested).""" - - # Private Data and Methods - __parser = html5lib.HTMLParser(tree = treebuilders.getTreeBuilder('lxml')) - - # Public Methods - - def __init__(self, sourceTree, sourcepath, relpath, data = None): - """Initialize HTMLSource by loading from HTML file `sourcepath`. - """ - XMLSource.__init__(self, sourceTree, sourcepath, relpath, data = data) - - def parse(self): - """Parse file and store any parse errors in self.errors""" - self.errors = None - try: - data = self.data() - if data: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - self.tree = self.__parser.parse(data) - self.encoding = self.__parser.documentEncoding - self.injectedTags = {} - else: - self.tree = None - self.errors = ['Empty source file'] - self.encoding = 'utf-8' - - FileSource.loadMetadata(self) - if ((not self.metadata) and self.tree and (not self.errors)): - self.extractMetadata(self.tree) - except Exception as e: - print("PARSE ERROR: " + self.sourcepath) - e.W3CTestLibErrorLocation = self.sourcepath - self.errors = [str(e)] - self.encoding = 'utf-8' - - def _injectXLinks(self, element, nodeList): - injected = False - - xlinkAttrs = ['href', 'type', 'role', 'arcrole', 'title', 'show', 'actuate'] - if (element.get('href') or element.get(xlinkns + 'href')): - for attr in xlinkAttrs: - if (element.get(xlinkns + attr)): - injected = True - if (element.get(attr)): - injected = True - value = element.get(attr) - del element.attrib[attr] - element.set(xlinkns + attr, value) - nodeList.append((element, xlinkns + attr, attr)) - - for child in element: - if (type(child.tag) == type('')): # element node - qName = etree.QName(child.tag) - if ('foreignobject' != qName.localname.lower()): - injected |= self._injectXLinks(child, nodeList) - return injected - - - def _findElements(self, namespace, elementName): - elements = self.tree.findall('.//{' + namespace + '}' + elementName) - if (self.tree.getroot().tag == '{' + namespace + '}' + elementName): - elements.insert(0, self.tree.getroot()) - return elements - - def _injectNamespace(self, elementName, prefix, namespace, doXLinks, nodeList): - attr = xmlns + prefix if (prefix) else 'xmlns' - elements = self._findElements(namespace, elementName) - for element in elements: - if not element.get(attr): - element.set(attr, namespace) - nodeList.append((element, attr, None)) - if (doXLinks): - if (self._injectXLinks(element, nodeList)): - element.set(xmlns + 'xlink', 'http://www.w3.org/1999/xlink') - nodeList.append((element, xmlns + 'xlink', None)) - - def injectNamespaces(self): - nodeList = [] - self._injectNamespace('html', None, 'http://www.w3.org/1999/xhtml', False, nodeList) - self._injectNamespace('svg', None, 'http://www.w3.org/2000/svg', True, nodeList) - self._injectNamespace('math', None, 'http://www.w3.org/1998/Math/MathML', True, nodeList) - return nodeList - - def removeNamespaces(self, nodeList): - if nodeList: - for element, attr, oldAttr in nodeList: - if (oldAttr): - value = element.get(attr) - del element.attrib[attr] - element.set(oldAttr, value) - else: - del element.attrib[attr] - - def serializeXHTML(self, doctype = None): - self.validate() - # Serialize - nodeList = self.injectNamespaces() -# print self.relpath - serializer = HTMLSerializer.HTMLSerializer() - o = serializer.serializeXHTML(self.tree, doctype) - - self.removeNamespaces(nodeList) - return o - - def serializeHTML(self, doctype = None): - self.validate() - # Serialize -# print self.relpath - serializer = HTMLSerializer.HTMLSerializer() - o = serializer.serializeHTML(self.tree, doctype) - - return o - - def data(self): - if ((not self.tree) or (self.metaSource)): - return FileSource.data(self) - return self.serializeHTML().encode(self.encoding, 'xmlcharrefreplace') - - def unicode(self): - if ((not self.tree) or (self.metaSource)): - return FileSource.unicode(self) - return self.serializeHTML() - diff --git a/css/tools/w3ctestlib/Suite.py b/css/tools/w3ctestlib/Suite.py deleted file mode 100644 index c5fa03a155fa72..00000000000000 --- a/css/tools/w3ctestlib/Suite.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python -# CSS Test Suite Manipulation Library -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -import OutputFormats -import Utils -from Groups import TestGroup, excludeDirs -from Sources import SourceTree, SourceCache -from shutil import copytree, rmtree -from os.path import join -import os -from mercurial import ui as UserInterface, hg - -class TestSuite: - """Representation of a standard CSS test suite.""" - - def __init__(self, name, title, specUri, draftUri, sourceCache = None, ui = None): - self.name = name - self.title = title - self.specroot = specUri - self.draftroot = draftUri - - self.ui = ui if ui else UserInterface.ui() - self.defaultReftestRelpath='reftest.list' - self.groups = {} - self.sourcecache = sourceCache if sourceCache else SourceCache(SourceTree(hg.repository(self.ui, '.'))) - self.formats = ('html4', 'xhtml1', 'xhtml1print') # XXX FIXME, hardcoded list is lame - self.rawgroups = {} - - def addTestsByExt(self, dir, ext, groupName='', groupTitle=''): - """Add tests from directory `dir` by file extension (via `ext`, e.g. ext='.xht'). - """ - group = TestGroup(self.sourcecache, dir, selfTestExt=ext, - name=groupName, title=groupTitle, ui = self.ui) - self.addGroup(group) - - - def addTestsByList(self, dir, filenames, groupName='', groupTitle=''): - """Add tests from directory `dir`, via file name list `filenames`. - """ - group = TestGroup(self.sourcecache, dir, selfTestList=filenames, - name=groupName, title=groupTitle, ui = self.ui) - self.addGroup(group) - - def addReftests(self, dir, manifestPath, groupName='', groupTitle=''): - """Add tests by importing context of directory `dir` and importing all - tests listed in the `reftestManifestName` manifest inside `dir`. - """ - group = TestGroup(self.sourcecache, - dir, manifestPath=manifestPath, - manifestDest=self.defaultReftestRelpath, - name=groupName, title=groupTitle, ui = self.ui) - self.addGroup(group) - - def addGroup(self, group): - """ Add CSSTestGroup `group` to store. """ - master = self.groups.get(group.name) - if master: - master.merge(group) - else: - self.groups[group.name] = group - - def addRaw(self, dir, relpath): - """Add the contents of directory `dir` to the test suite by copying - (not processing). Note this means such tests will not be indexed. - `relpath` gives the directory's path within the build destination. - """ - self.rawgroups[dir] = relpath - - def setFormats(self, formats): - self.formats = formats - - def buildInto(self, dest, indexer): - """Builds test suite through all OutputFormats into directory at path `dest` - or through OutputFormat destination `dest`, using Indexer `indexer`. - """ - if isinstance(dest, OutputFormats.BasicFormat): - formats = (dest,) - dest = dest.root - else: - formats = [] - for format in self.formats: - if (format == 'html4'): - formats.append(OutputFormats.HTMLFormat(dest, self.sourcecache.sourceTree)) - elif (format == 'html5'): - formats.append(OutputFormats.HTML5Format(dest, self.sourcecache.sourceTree)) - elif (format == 'xhtml1'): - formats.append(OutputFormats.XHTMLFormat(dest, self.sourcecache.sourceTree)) - elif (format == 'xhtml1print'): - formats.append(OutputFormats.XHTMLPrintFormat(dest, self.sourcecache.sourceTree, self.title)) - elif (format == 'svg'): - formats.append(OutputFormats.SVGFormat(dest, self.sourcecache.sourceTree)) - - for format in formats: - for group in self.groups.itervalues(): - group.build(format) - - for group in self.groups.itervalues(): - indexer.indexGroup(group) - - for format in formats: - indexer.writeIndex(format) - - - rawtests = [] - for src, relpath in self.rawgroups.items(): - copytree(src, join(dest,relpath)) - for (root, dirs, files) in os.walk(join(dest,relpath)): - for xdir in excludeDirs: - if xdir in dirs: - dirs.remove(xdir) - rmtree(join(root,xdir)) - rawtests.extend( - [join(Utils.relpath(root,dest),file) - for file in files] - ) - - rawtests.sort() - indexer.writeOverview(dest, addTests=rawtests) - diff --git a/css/tools/w3ctestlib/Utils.py b/css/tools/w3ctestlib/Utils.py deleted file mode 100644 index 065c30491c7aaa..00000000000000 --- a/css/tools/w3ctestlib/Utils.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/python -# CSS Test Suite Manipulation Library Utilities -# Initial code by fantasai, joint copyright 2010 W3C and Microsoft -# Licensed under BSD 3-Clause: - -###### XML Parsing ###### - -import os -import w3ctestlib -os.environ['XML_CATALOG_FILES'] = os.path.join(w3ctestlib.__path__[0], 'catalog/catalog.xml') - -###### File path manipulation ###### - -import os.path -from os.path import sep, pardir - -def assetName(path): - return intern(os.path.splitext(os.path.basename(path))[0].lower().encode('ascii')) - -def basepath(path): - """ Returns the path part of os.path.split. - """ - return os.path.dirname(path) - -def isPathInsideBase(path, base=''): - path = os.path.normpath(path) - if base: - base = os.path.normpath(base) - pathlist = path.split(os.path.sep) - baselist = base.split(os.path.sep) - while baselist: - p = pathlist.pop(0) - b = baselist.pop(0) - if p != b: - return False - return not pathlist[0].startswith(os.path.pardir) - return not path.startswith(os.path.pardir) - -def relpath(path, start): - """Return relative path from start to end. WARNING: this is not the - same as a relative URL; see relativeURL().""" - try: - return os.path.relpath(path, start) - except AttributeError: - # This function is copied directly from the Python 2.6 source - # code, and is therefore under a different license. - - if not path: - raise ValueError("no path specified") - start_list = os.path.abspath(start).split(sep) - path_list = os.path.abspath(path).split(sep) - if start_list[0].lower() != path_list[0].lower(): - unc_path, rest = os.path.splitunc(path) - unc_start, rest = os.path.splitunc(start) - if bool(unc_path) ^ bool(unc_start): - raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)" - % (path, start)) - else: - raise ValueError("path is on drive %s, start on drive %s" - % (path_list[0], start_list[0])) - # Work out how much of the filepath is shared by start and path. - for i in range(min(len(start_list), len(path_list))): - if start_list[i].lower() != path_list[i].lower(): - break - else: - i += 1 - - rel_list = [pardir] * (len(start_list)-i) + path_list[i:] - if not rel_list: - return os.path.curdir - return os.path.join(*rel_list) - -def relativeURL(start, end): - """ Returns relative URL from `start` to `end`. - """ -# if isPathInsideBase(end, start): -# return relpath(end, start) -# else: - return relpath(end, basepath(start)) - -def listfiles(path, ext = None): - """ Returns a list of all files in a directory. - Optionally lists only files with a given extension. - """ - try: - _,_,files = os.walk(path).next() - if (ext): - files = [fileName for fileName in files if fileName.endswith(ext)] - except StopIteration: - files = [] - return files - -def listdirs(path): - """ Returns a list of all subdirectories in a directory. - """ - try: - _,dirs,_ = os.walk(path).next() - except StopIteration: - dirs = [] - return dirs - -###### MIME types and file extensions ###### - -extensionMap = { None : 'application/octet-stream', # default - '.xht' : 'application/xhtml+xml', - '.xhtml' : 'application/xhtml+xml', - '.xml' : 'application/xml', - '.htm' : 'text/html', - '.html' : 'text/html', - '.txt' : 'text/plain', - '.jpg' : 'image/jpeg', - '.png' : 'image/png', - '.svg' : 'image/svg+xml', - } - -def getMimeFromExt(filepath): - """Convenience function: equal to extenionMap.get(ext, extensionMap[None]). - """ - if filepath.endswith('.htaccess'): - return 'config/htaccess' - ext = os.path.splitext(filepath)[1] - return extensionMap.get(ext, extensionMap[None]) - -###### Escaping ###### - -import types -from htmlentitydefs import entitydefs - -entityify = dict([c,e] for e,c in entitydefs.iteritems()) - -def escapeMarkup(data): - """Escape markup characters (&, >, <). Copied from xml.sax.saxutils. - """ - # must do ampersand first - data = data.replace("&", "&") - data = data.replace(">", ">") - data = data.replace("<", "<") - return data - -def escapeToNamedASCII(text): - """Escapes to named entities where possible and numeric-escapes non-ASCII - """ - return escapeToNamed(text).encode('ascii', 'xmlcharrefreplace') - -def escapeToNamed(text): - """Escape characters with named entities. - """ - escapable = set() - - for c in text: - if ord(c) > 127: - escapable.add(c) - if type(text) == types.UnicodeType: - for c in escapable: - cLatin = c.encode('Latin-1', 'ignore') - if (cLatin in entityify): - text = text.replace(c, "&%s;" % entityify[cLatin]) - else: - for c in escapable: - text = text.replace(c, "&%s;" % entityify[c]) - return text diff --git a/css/tools/w3ctestlib/__init__.py b/css/tools/w3ctestlib/__init__.py deleted file mode 100644 index 8ce9f985c3081d..00000000000000 --- a/css/tools/w3ctestlib/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ - - -__all__ = ['Sources', 'Groups', 'Indexer', 'Suite', 'OutputFormats', 'HTMLSerializer'] \ No newline at end of file diff --git a/css/tools/w3ctestlib/catalog/catalog.xml b/css/tools/w3ctestlib/catalog/catalog.xml deleted file mode 100644 index d9c5926235df92..00000000000000 --- a/css/tools/w3ctestlib/catalog/catalog.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml-lat1.ent b/css/tools/w3ctestlib/catalog/xhtml-lat1.ent deleted file mode 100644 index ffee223eb10566..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml-lat1.ent +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml-special.ent b/css/tools/w3ctestlib/catalog/xhtml-special.ent deleted file mode 100644 index ca358b2fec722e..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml-special.ent +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml-symbol.ent b/css/tools/w3ctestlib/catalog/xhtml-symbol.ent deleted file mode 100644 index 63c2abfa6f4503..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml-symbol.ent +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml1-frameset.dtd b/css/tools/w3ctestlib/catalog/xhtml1-frameset.dtd deleted file mode 100644 index d128f2eb7c03cd..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml1-frameset.dtd +++ /dev/null @@ -1,1235 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml1-strict.dtd b/css/tools/w3ctestlib/catalog/xhtml1-strict.dtd deleted file mode 100644 index 2927b9ece7fdf8..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml1-strict.dtd +++ /dev/null @@ -1,978 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml1-transitional.dtd b/css/tools/w3ctestlib/catalog/xhtml1-transitional.dtd deleted file mode 100644 index 628f27ac500bae..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml1-transitional.dtd +++ /dev/null @@ -1,1201 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/css/tools/w3ctestlib/catalog/xhtml11.dtd b/css/tools/w3ctestlib/catalog/xhtml11.dtd deleted file mode 100644 index 2a999b5b37ddca..00000000000000 --- a/css/tools/w3ctestlib/catalog/xhtml11.dtd +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -]]> - - - - - - -%xhtml-inlstyle.mod;]]> - - - - - - - -%xhtml-framework.mod;]]> - - - - -]]> - - - - -%xhtml-text.mod;]]> - - - - -%xhtml-hypertext.mod;]]> - - - - -%xhtml-list.mod;]]> - - - - - - -%xhtml-edit.mod;]]> - - - - -%xhtml-bdo.mod;]]> - - - - - - -%xhtml-ruby.mod;]]> - - - - -%xhtml-pres.mod;]]> - - - - -%xhtml-link.mod;]]> - - - - -%xhtml-meta.mod;]]> - - - - -%xhtml-base.mod;]]> - - - - -%xhtml-script.mod;]]> - - - - -%xhtml-style.mod;]]> - - - - -%xhtml-image.mod;]]> - - - - -%xhtml-csismap.mod;]]> - - - - -%xhtml-ssismap.mod;]]> - - - - -%xhtml-param.mod;]]> - - - - -%xhtml-object.mod;]]> - - - - -%xhtml-table.mod;]]> - - - - -%xhtml-form.mod;]]> - - - - -%xhtml-legacy.mod;]]> - - - - -%xhtml-struct.mod;]]> - - - diff --git a/css/tools/w3ctestlib/templates/chapter-toc.tmpl b/css/tools/w3ctestlib/templates/chapter-toc.tmpl deleted file mode 100644 index e1e8bc275d93b3..00000000000000 --- a/css/tools/w3ctestlib/templates/chapter-toc.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -[%# variables in this template - indexext [string, e.g. '.html'] - suitetitle [string] - specroot [uri string] - formatdir [dir name string] - chapters [list of struct] - .numstr [string, e.g. '6.1.13'] - .title [string] - .testcount [number] -%] -[% IF isXML %] - - -[% ELSE %] - - -[% END %] - - [% suitetitle %] - - - -

[% suitetitle %] By Chapter

- -

This index contains both - self-describing tests - and reftests. - A separate alphabetical reftest index - is provided for tests in reftest - format along with the reftest manifest.

- - -[% FOREACH chapter IN chapters %] - - - - -[% END %] -
- [% (chapter.numstr.match('^\d')) ? 'Chapter' : 'Appendix' +%] [%+ chapter.numstr +%] - - [%+ chapter.title +%]([% chapter.testcount +%] Tests)
- - \ No newline at end of file diff --git a/css/tools/w3ctestlib/templates/implementation-report-TEMPLATE.data.tmpl b/css/tools/w3ctestlib/templates/implementation-report-TEMPLATE.data.tmpl deleted file mode 100644 index 0231f23ba4c029..00000000000000 --- a/css/tools/w3ctestlib/templates/implementation-report-TEMPLATE.data.tmpl +++ /dev/null @@ -1,21 +0,0 @@ -# UA version OS version -# UA string (if applicable) -# http://test.csswg.org/suites/[% suite %]/DATESTAMP/ -# See http://wiki.csswg.org/test/implementation-report for instructions -testname revision result comment -[% FOREACH test IN tests.sort(name) %] -[% FOREACH format IN formats %] -[% IF formatInfo.$format.report %] -[% SET skipFormat = 0 %] -[% FOREACH flag IN test.flags %] - [% SET skipFormat = 1 IF flag == formatInfo.$format.filter %] -[% END %] -[% UNLESS skipFormat +%] -[%+ formatInfo.$format.path +%]/[% test.name +%].[% formatInfo.$format.ext +%] [%+ test.revision +%] ? -[% END %] -[% END %] -[% END %] -[% END %] -[% FOREACH test IN addtests.sort() +%] -[%+ test +%] [%+ test.revision +%] ? -[% END %] diff --git a/css/tools/w3ctestlib/templates/index.content.tmpl b/css/tools/w3ctestlib/templates/index.content.tmpl deleted file mode 100644 index e32d8fe5672100..00000000000000 --- a/css/tools/w3ctestlib/templates/index.content.tmpl +++ /dev/null @@ -1,195 +0,0 @@ -[% PROCESS "suitedata.tmpl" %] -[% IF official %] -

[% suites.$suite.title %]

-[% ELSE %] -

Unofficial [% suites.$suite.title %]

-[% END %] -
Test Coordinator:
-
[% suites.$suite.owner %]
- -

This is a [% statusNames.${suites.$suite.status}.title or "ERROR: $suite" %] - version of the [% suites.$suite.title %].

- -[% IF suites.$suite.harness != '' %] -

You can provide test data or review the testing results for this test suite:

-
Enter Data
-
Review Results
-[% END %] - - -[% IF devel %] -

This build exists to aid in test suite development and contains unreviewed - tests. The pass/fail results of these tests are not reliable - indications of conformance. -[% ELSE %] -

Some tests in the test suite may contain errors. -[% END %] - Please check the latest version of the - [% suites.$suite.spec %] specification - and its errata - before assuming a failure is due to an implementation bug and - not a test suite bug.

- -[% UNLESS official %] -

You can find the official - build of the [% suites.$suite.title %] on W3C's web site.

-[% END %] - -

[% IF suites.$suite.status != 'fin' && suites.$suite.status != 'rc' %] - In time we hope to correct all errors and extend this test suite to - cover all of [% suites.$suite.spec %]. Your help is welcome in this effort. - [% END %] - The appropriate mailing list for submitting tests and bug reports is - public-css-testsuite@w3.org.

-

- To report bugs or feedback about a specific test file, - search for the filename (without extension) in - web-platform-tests issues, - and file a new issue if necessary with suggested label "wg-css". - More information on the contribution process and test guidelines is - available on the wiki - page.

- -

Tests are currently available in these formats:

- -
-[% FOREACH format IN formats %] - [% IF format == 'html4' %] -
HTML 4.01
-
HTML 4.01 tests sent as text/html
- [% END %] - [% IF format == 'html5' %] -
HTML 5
-
HTML 5 tests sent as text/html
- [% END %] - [% IF format == 'xhtml1' %] -
XHTML 1.1
-
XHTML 1.1 tests sent as application/xhtml+xml
- [% END %] - [% IF format == 'xhtml1print' %] -
XHTML 1.1 for Printers
-
XHTML 1.1 tests with all images converted from PNG to JPEG - and formatted with headers and footers to ease testing of - embedded printer software. This is not a canonical format, - and some tests may fail due to the format conversion that - would otherwise pass in the above XHTML 1.1 format.
-
- [% END %] -[% END %] - -[% IF suite == 'css2.1' %] -

Additional tests, that do not fit in any of those formats, - are located separately:

- -
-
Other Formats
-
Tests that do not fit in the above formats because they - test a combination of CSS and a particular document language's - features and/or error recovery.
-
-[% END %] - -

Unless the test instructions explicitly indicate otherwise, - any occurrence of red in a test indicates test failure.

- -[% IF suite == 'css2.1' %] -

Note that many of the tests require the - Ahem font to be installed. - These tests are marked with the 'ahem' flag in their metadata. - Without the Ahem font installed, these tests are of no value.

-

Some of the font-related tests also require - special fonts. - These tests are marked with the 'font' flag in their metadata.

- -[% END %] -

Implementation Reports

-

An implementation report template - is available to help with creating implementation reports. See also the - explanation - of its format.

- -

Common Assumptions

- -

Most of the test suite makes the following assumptions:

-
    -
  • The X/HTML div element is assigned display: block; - and no other property declaration.
  • -
  • The X/HTML span element is assigned display: inline; - and no other property declaration.
  • -
  • The X/HTML p element is assigned display: block;
  • -
  • The X/HTML li element is assigned display: list-item;
  • -
  • The X/HTML table elements table, tbody, - tr, and td are assigned the display - values table, table-row-group, - table-row, and table-cell, respectively.
  • -
  • The device can display the sixteen color values associated with the color - keywords black, white, gray, - silver, red, green, blue, - purple, yellow, orange, teal, - fuchsia, maroon, navy, aqua, - and lime as distinct colors.
  • -
  • The UA is set to print background colors and, if it supports graphics, - background images.
  • -
  • The UA implements reasonable page-breaking behavior; e.g., it is assumed - that UAs will not break at every opportunity, but only near the end of - a page unless a page break is forced.
  • -
  • The UA implements reasonable line-breaking behavior; e.g., it is assumed - that spaces between alphanumeric characters provide line breaking - opportunities and that UAs will not break at every opportunity, but only - near the end of a line unless a line break is forced.
  • -
- -

Uncommon Assumptions

- -

In addition, some of the tests make one or more of the following - assumptions:

- -
    -
  • The device is a full-color device.
  • -
  • The device has a viewport width of at least 640px (approx).
  • -
  • The resolution of the device is 96 CSS pixels per inch.
  • -
  • The UA imposes no minimum font size.
  • -
  • The 'medium' font-size computes to 16px.
  • -
  • The initial value of 'color' is black.
  • -
  • The canvas background is white.
  • -
  • The user stylesheet is empty (except where indicated by the tests).
  • -
  • The device is interactive and uses scroll bars.
  • -
- -

The tests that need these assumptions to be true have not yet been - marked, but it is likely that we will add a way to identify these - tests in due course. Tests should avoid relying on these assumptions - unless necessary.

- -

License

- -[% IF official %] -

This test suite is licensed under both the - W3C - Test Suite License and the W3C - 3-clause BSD License. See W3C Legal's explanation - of the licenses.

-[% ELSE %] -

These tests are licensed under the BSD 3-clause - License. You may modify and distribute them under those terms. Aside - from their titles, documentation, and location they are identical to the - official tests of the same date. However, only the - official % suites.$suite.title %] - may be used as the basis for CSS conformance - claims.

-[% END %] - -

Acknowledgements

- -

Many thanks to the following for their contributions:

-
    -[%- FOREACH person = contributors.keys.sort %] - [% IF not person.match('^CSS1') %] -
  • [% person %]
  • - [% END %] -[%- END %] -
-[% IF suite == 'css2.1' %] -

...and all the contributors - to the CSS1 test suite.

-[% END %] diff --git a/css/tools/w3ctestlib/templates/index.htm.tmpl b/css/tools/w3ctestlib/templates/index.htm.tmpl deleted file mode 100644 index c29ed4a3c728d5..00000000000000 --- a/css/tools/w3ctestlib/templates/index.htm.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -[% PROCESS "suitedata.tmpl" %] - - - -[% IF official %] - [% suites.$suite.title %] -[% ELSE %] - Unofficial [% suites.$suite.title %] -[% END %] - - - - -[% INCLUDE "index.content.tmpl" %] - - - diff --git a/css/tools/w3ctestlib/templates/index.xht.tmpl b/css/tools/w3ctestlib/templates/index.xht.tmpl deleted file mode 100644 index b355544cfa5996..00000000000000 --- a/css/tools/w3ctestlib/templates/index.xht.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -[% PROCESS "suitedata.tmpl" %] - - - -[% IF official %] - [% suites.$suite.title %] -[% ELSE %] - Unofficial [% suites.$suite.title %] -[% END %] - - - - -[% INCLUDE index.content.tmpl %] - - - diff --git a/css/tools/w3ctestlib/templates/indices.css b/css/tools/w3ctestlib/templates/indices.css deleted file mode 100644 index 7bc70eeef94f32..00000000000000 --- a/css/tools/w3ctestlib/templates/indices.css +++ /dev/null @@ -1,96 +0,0 @@ -/* CSS for CSS Conformance Test Indices */ -/* Written by fantasai */ - -/* Test Tables */ - - table { - border-collapse: collapse; - } - - thead { - border-bottom: 0.2em solid; - } - - tbody { - border: thin solid; - border-style: solid none; - } - - tbody.ch { - border-top: 0.2em solid; - } - tbody.ch th { - font-weight: bold; - } - - tbody th { - border-bottom: silver dotted thin; - background: #EEE; - color: black; - font-weight: normal; - font-style: italic; - } - tbody th :link { - color: gray; - background: transparent; - } - tbody th :visited { - color: #333; - background: transparent; - } - - th, td { - padding: 0.2em; - text-align: left; - vertical-align: baseline; - } - - td { - font-size: 0.9em; - } - - /* flags */ - td abbr { - border: solid thin gray; - padding: 0 0.1em; - cursor: help; - } - td abbr:hover { - background: #ffa; - color: black; - } - - - tr:hover { - background: #F9F9F9; - color: navy; - } - - th a, - td a { - text-decoration: none; - } - th a:hover, - td a:hover, - th a:focus, - td a:focus { - text-decoration: underline; - } - - td a { - display: block; - padding-left: 2em; - text-indent: -1em; - } - .refs { - font-weight: bold; - font-size: larger; - } - .assert, .assert > li { - list-style-type: none; - font-style: italic; - color: gray; - margin: 0; - padding: 0; - text-indent: 0; - } diff --git a/css/tools/w3ctestlib/templates/reftest-toc.tmpl b/css/tools/w3ctestlib/templates/reftest-toc.tmpl deleted file mode 100644 index 91894235a49a68..00000000000000 --- a/css/tools/w3ctestlib/templates/reftest-toc.tmpl +++ /dev/null @@ -1,74 +0,0 @@ -[%# variables in this template - isXML [bool] - extmap [ExtensionMap object] - suitetitle [string] - specroot [URI of spec] - formatdir [string] - chaptitle [string] - chapdir [string] - testcount [number] - sections [list of struct] - .id [string - section number or id] - .uri [URI of section] - .tests [list of struct] - .asserts [list of strings] - .flags [list of token strings] - .links [list of uri strings] - .name [string] -%] -[% PROCESS suitedata.tmpl %] -[% IF isXML %] - - -[% formatMismatchFlag = 'HTMLonly' %] -[% ELSE %] - - -[% formatMismatchFlag = 'nonHTML' %] -[% END %] - - [% suitetitle %] Reftest Index - - - - - -

[% suitetitle %] Reftest Index

- - [% IF isXML %][% END %] - [% IF isXML %][% END %] - [% IF isXML %][% END %] - - - - - - - -[% FOREACH entry IN tests.sort('name') %] - [% IF entry.references and not entry.flags.contains(formatMismatchFlag) %] - - [% FOREACH refList IN entry.references %] - [% IF loop.first %] - - - - - - [% ELSE %] - - - - [% END %] - [% END %] - - [% END %] -[% END %] -
TestReferenceFlags
- [% entry.name %][% FOREACH ref IN refList %][% refCompMap.${ref.type} %] [% END %][% FOREACH flag IN entry.flags %][% IF flag != 'nonHTML' and flag != 'HTMLonly' %][% flagInfo.$flag.abbr %][% END %][% END %]
[% refCompMap.${ref.type} %]
- - - diff --git a/css/tools/w3ctestlib/templates/reftest.tmpl b/css/tools/w3ctestlib/templates/reftest.tmpl deleted file mode 100644 index 14b9bb6595ead5..00000000000000 --- a/css/tools/w3ctestlib/templates/reftest.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -[% FOR entry IN tests.sort('name') %] -[% IF not entry.flags.contains(formatMismatchFlag) %] -[% FOREACH refList IN entry.references %] -[%+ extmap.translate(entry.file) %] [% FOREACH ref IN refList %] [%+ ref.type %] [%+ extmap.translate(ref.relpath) %][% END %] -[% END %] -[% END %] -[% END %] diff --git a/css/tools/w3ctestlib/templates/suitedata.tmpl b/css/tools/w3ctestlib/templates/suitedata.tmpl deleted file mode 100644 index 6aae9f2ea8425d..00000000000000 --- a/css/tools/w3ctestlib/templates/suitedata.tmpl +++ /dev/null @@ -1,23 +0,0 @@ -[% refCompMap = - { '==' => '=', - '!=' => '≠' - } -%] -[% statusNames = { - 'dev' => { - 'title' => 'Development', - 'link' => 'http://www.w3.org/Style/CSS/Test/#phase-pa' }, - 'alpha' => { - 'title' => 'Alpha', - 'link' => 'http://www.w3.org/Style/CSS/Test/#phase-alpha' }, - 'beta' => { - 'title' => 'Beta', - 'link' => 'http://www.w3.org/Style/CSS/Test/#phase-beta' }, - 'rc' => { - 'title' => 'Release Candidate', - 'link' => 'http://www.w3.org/Style/CSS/Test/#phase-rc' }, - 'final' => { - 'title' => 'Final', - 'link' => 'http://www.w3.org/Style/CSS/Test/#phase-fin' }, - } -%] diff --git a/css/tools/w3ctestlib/templates/test-toc.tmpl b/css/tools/w3ctestlib/templates/test-toc.tmpl deleted file mode 100644 index ff9ffbc1b8e816..00000000000000 --- a/css/tools/w3ctestlib/templates/test-toc.tmpl +++ /dev/null @@ -1,97 +0,0 @@ -[%# variables in this template - isXML [bool] - extmap [ExtensionMap object] - suitetitle [string] - specroot [URI of spec] - formatdir [string] - chaptitle [string] - chapdir [string] - testcount [number] - sections [list of struct] - .id [string - section number or id] - .uri [URI of section] - .tests [list of struct] - .asserts [list of strings] - .flags [list of token strings] - .links [list of uri strings] - .name [string] -%] -[% PROCESS suitedata.tmpl %] -[% IF isXML %] - - -[% formatMismatchFlag = 'HTMLonly' %] -[% ELSE %] - - -[% formatMismatchFlag = 'nonHTML' %] -[% END %] - - [% chaptertitle %] - [% suitetitle %] - - - - - -

[% suitetitle %]

-[% IF chaptertitle %] -

[% chaptertitle %] ([% testcount %] tests)

-[% END %] - - [% IF isXML %][% END %] - [% IF isXML %][% END %] - [% IF isXML %][% END %] - [% IF isXML %][% END %] - - - - - - - - -[% FOREACH section IN sections %] - - [% IF section.title %] - - [% END %] - - [% FOREACH entry IN section.tests.sort('name') %] - [% FOREACH flag IN entry.flags %] - [% SET skip = 1 IF flag == formatMismatchFlag %] - [% END %] - [% UNLESS skip %] - [% primary = (entry.links.0 == section.uri) or (entry.links.0 == section.uri.replace(specroot, draftroot)) %] - - - - - - - [% END %] - [% skip = 0 %] - [% END %] - -[% END %] -
TestRefsFlagsInfo
- + - [% section.numstr +%] [%+ section.title %]
[% '' IF primary %] - [% entry.name%] - [% '' IF primary %][% FOREACH refList IN entry.references %][% FOREACH ref IN refList %][% refCompMap.${ref.type} %] [%+ END %][%+ END %][% FOREACH flag IN entry.flags %][% IF flag != 'nonHTML' and flag != 'HTMLonly' %][% flagInfo.$flag.abbr %][% END %][% END %][% entry.title | collapse | html %] - [% IF entry.asserts.size > 0 %] -
    - [% FOREACH assertion IN entry.asserts %] -
  • [% assertion | collapse | html %]
  • - [% END %] -
- [% END %] -
- - - \ No newline at end of file diff --git a/css/tools/w3ctestlib/templates/testinfo.data.tmpl b/css/tools/w3ctestlib/templates/testinfo.data.tmpl deleted file mode 100644 index d06a2a906cba17..00000000000000 --- a/css/tools/w3ctestlib/templates/testinfo.data.tmpl +++ /dev/null @@ -1,16 +0,0 @@ -id references title flags links revision credits assertion -[% FOREACH test IN tests.sort('name') %] -[%+ test.file.replace('\.[a-z]+$', '') +%] -[%- FOREACH refList IN test.references -%][%- FOREACH ref IN refList -%] -[%- '!' IF ref.type == '!=' %][% extmap.translate(ref.relpath) %][% ',' IF not loop.last() -%] -[%- END +%][% ';' IF not loop.last() -%] -[%- END +%] -[%- test.title FILTER collapse +%] -[%- test.flags.join(',') +%] -[%- test.links.join(',') +%] -[%- test.revision +%] -[%- FOREACH credit IN test.credits -%] -`[% credit.0 %]`<[% credit.1 %]>[% ',' IF not loop.last() -%] -[%- END +%] -[%- test.asserts.join(' ') FILTER collapse +%] -[% END %] diff --git a/docs/reviewing-tests/reverting.md b/docs/reviewing-tests/reverting.md index 277ccb047abb1b..d374f0558e3e3d 100644 --- a/docs/reviewing-tests/reverting.md +++ b/docs/reviewing-tests/reverting.md @@ -12,9 +12,6 @@ break things for users of web-platform-tests. Such breakage can include: * Breakage in results collections systems for results dashboards, such as [wpt.fyi](https://wpt.fyi). - * Breakage in supplemental tooling used by working groups, such as the - [CSS build system][]. - When such breakage happens, if the maintainers of the affected systems request it, pull requests to revert the original change should normally be approved and merged as soon as possible. (When the original change itself was fixing a @@ -24,5 +21,3 @@ state acceptable to everyone.) Once a revert has happened, the maintainers of the affected systems are expected to work with the original patch author to resolve the problem so that the change can be relanded. A reasonable timeframe to do so is within one week. - -[CSS build system]: https://github.com/web-platform-tests/wpt/tree/master/css/tools diff --git a/lint.ignore b/lint.ignore index cda77f4df8c7be..c01b4b418675b0 100644 --- a/lint.ignore +++ b/lint.ignore @@ -367,8 +367,6 @@ SET TIMEOUT: common/rendering-utils.js SET TIMEOUT: acid/acid3/test.html # Third party code -*: css/tools/apiclient/* -*: css/tools/w3ctestlib/* *: resources/webidl2/* *: tools/* *: */third_party/* @@ -380,9 +378,6 @@ SET TIMEOUT: acid/acid3/test.html *: resources/.gitignore *: webaudio/.gitignore -# Build system virtualenv -*: css/tools/_virtualenv/* - ## Third party data files TRAILING WHITESPACE: resources/chromium/* diff --git a/tools/lint/lint.py b/tools/lint/lint.py index f255c024952cd1..c34227078d30a8 100644 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -193,8 +193,7 @@ def check_gitignore_file(repo_root, path): return [] if (path_parts[0] in ["tools", "docs"] or - path_parts[:2] == ["resources", "webidl2"] or - path_parts[:3] == ["css", "tools", "apiclient"]): + path_parts[:2] == ["resources", "webidl2"]): return [] return [rules.GitIgnoreFile.error(path)] diff --git a/tools/lint/tests/test_path_lints.py b/tools/lint/tests/test_path_lints.py index f2cc2409f2c0ad..99c8f7dce6bd77 100644 --- a/tools/lint/tests/test_path_lints.py +++ b/tools/lint/tests/test_path_lints.py @@ -121,8 +121,7 @@ def test_tentative_directories_negative(path): "else/where/.gitignore" "elsewhere/tools/.gitignore", "elsewhere/docs/.gitignore", - "elsewhere/resources/webidl2/.gitignore", - "elsewhere/css/tools/apiclient/.gitignore"]) + "elsewhere/resources/webidl2/.gitignore"]) def test_gitignore_file(path): path = os.path.join(*path.split("/")) @@ -144,9 +143,7 @@ def test_gitignore_file(path): "docs/.gitignore" "docs/elsewhere/.gitignore", "resources/webidl2/.gitignore", - "resources/webidl2/elsewhere/.gitignore", - "css/tools/apiclient/.gitignore", - "css/tools/apiclient/elsewhere/.gitignore"]) + "resources/webidl2/elsewhere/.gitignore"]) def test_gitignore_negative(path): path = os.path.join(*path.split("/"))