From eaeb70d4f9ee994508a926fdf19202337fe3d868 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Tue, 6 Mar 2018 12:01:44 -0800 Subject: [PATCH] Remove trailing spaces in activities.json. I suspect editors like to strip out this trailing whitespace (e.g., from #53) which activities.py then readds when manipulating the JSON (in #66). We'll avoid the churn (and annoyance) by not having the trailing whitespace at all. This sets the separators as described in the documentation at https://docs.python.org/2/library/json.html to avoid trailing whitespace when using indent. It also consolidates the JSON-writing configuration into a single place by creating a single JSONEncoder object. --- activities.json | 144 ++++++++++++++++++++++++------------------------ activities.py | 11 ++-- 2 files changed, 78 insertions(+), 77 deletions(-) diff --git a/activities.json b/activities.json index 79d0be5f..58235a8d 100644 --- a/activities.json +++ b/activities.json @@ -1,90 +1,90 @@ [ { - "ciuName": null, - "description": "This document specifies how a server can send an HTTP request/ response pair, known as an exchange, with signatures that vouch for that exchange's authenticity. These signatures can be verified against an origin's certificate to establish that the exchange is authoritative for an origin even if it was transferred over a connection that isn't. The signatures can also be used in other ways described in the appendices. These signatures contain countermeasures against downgrade and protocol-confusion attacks.", - "mozBugUrl": null, - "mozPosition": "harmful", - "mozPositionDetail": "Mozilla has concerns about the shift in the web security model required for handling web-packaged information. Specifically, the ability for an origin to act on behalf of another without a client ever contacting the authoritative server is worrisome, as is the removal of a guarantee of confidentiality from the web security model (the host serving the web package has access to plain text). We recognise that the use cases satisfied by web packaging are useful, and would be likely to support an approach that enabled such use cases so long as the foregoing concerns could be addressed.", - "mozPositionIssue": 29, - "org": "IETF", - "title": "Signed HTTP Exchanges", + "ciuName": null, + "description": "This document specifies how a server can send an HTTP request/ response pair, known as an exchange, with signatures that vouch for that exchange's authenticity. These signatures can be verified against an origin's certificate to establish that the exchange is authoritative for an origin even if it was transferred over a connection that isn't. The signatures can also be used in other ways described in the appendices. These signatures contain countermeasures against downgrade and protocol-confusion attacks.", + "mozBugUrl": null, + "mozPosition": "harmful", + "mozPositionDetail": "Mozilla has concerns about the shift in the web security model required for handling web-packaged information. Specifically, the ability for an origin to act on behalf of another without a client ever contacting the authoritative server is worrisome, as is the removal of a guarantee of confidentiality from the web security model (the host serving the web package has access to plain text). We recognise that the use cases satisfied by web packaging are useful, and would be likely to support an approach that enabled such use cases so long as the foregoing concerns could be addressed.", + "mozPositionIssue": 29, + "org": "IETF", + "title": "Signed HTTP Exchanges", "url": "https://tools.ietf.org/html/draft-yasskin-http-origin-signed-responses" - }, + }, { - "ciuName": null, - "description": "This document describes a common data model and API for the Web of Things. The Web Thing Description provides a vocabulary for describing physical devices connected to the World Wide Web in a machine readable format with a default JSON encoding. The Web Thing REST API and Web Thing WebSocket API allow a web client to access the properties of devices, request the execution of actions and subscribe to events representing a change in state. Some basic Web Thing Types are provided and additional types can be defined using semantic extensions with JSON-LD. In addition to this specification there is a note on Web Thing API Protocol Bindings which proposes non-normative bindings of the Web Thing API to various existing IoT protocols. There is also a document describing Web of Things Integration Patterns which provides advice on different design patterns for integrating connected devices with the Web of Things, and where each pattern is most appropriate.", - "mozBugUrl": null, - "mozPosition": "worth prototyping", - "mozPositionDetail": null, - "mozPositionIssue": 44, - "org": "W3C", - "title": "Web Thing API", + "ciuName": null, + "description": "This document describes a common data model and API for the Web of Things. The Web Thing Description provides a vocabulary for describing physical devices connected to the World Wide Web in a machine readable format with a default JSON encoding. The Web Thing REST API and Web Thing WebSocket API allow a web client to access the properties of devices, request the execution of actions and subscribe to events representing a change in state. Some basic Web Thing Types are provided and additional types can be defined using semantic extensions with JSON-LD. In addition to this specification there is a note on Web Thing API Protocol Bindings which proposes non-normative bindings of the Web Thing API to various existing IoT protocols. There is also a document describing Web of Things Integration Patterns which provides advice on different design patterns for integrating connected devices with the Web of Things, and where each pattern is most appropriate.", + "mozBugUrl": null, + "mozPosition": "worth prototyping", + "mozPositionDetail": null, + "mozPositionIssue": 44, + "org": "W3C", + "title": "Web Thing API", "url": "https://iot.mozilla.org/wot/" - }, + }, { - "ciuName": null, - "description": "This specification defines the ::part() and ::theme() pseudo-elements on shadow hosts, allowing shadow hosts to selectively expose chosen elements from their shadow tree to the outside page for styling purposes.", - "mozBugUrl": null, - "mozPosition": "worth prototyping", - "mozPositionDetail": null, - "mozPositionIssue": 59, - "org": "W3C", - "title": "CSS Shadow Parts", + "ciuName": null, + "description": "This specification defines the ::part() and ::theme() pseudo-elements on shadow hosts, allowing shadow hosts to selectively expose chosen elements from their shadow tree to the outside page for styling purposes.", + "mozBugUrl": null, + "mozPosition": "worth prototyping", + "mozPositionDetail": null, + "mozPositionIssue": 59, + "org": "W3C", + "title": "CSS Shadow Parts", "url": "http://drafts.csswg.org/css-shadow-parts" - }, + }, { - "ciuName": "midi", - "description": "This specification defines an API supporting the MIDI (Musical Instrument Digital Interface) protocol, enabling web applications to enumerate and select MIDI input and output devices on the client system and send and receive MIDI messages. It is intended to enable non-music MIDI applications as well as music ones, by providing low-level access to the MIDI devices available on the users' systems.", - "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=836897", - "mozPosition": "under consideration", - "mozPositionDetail": null, - "mozPositionIssue": 58, - "org": "W3C", - "title": "Web MIDI API", + "ciuName": "midi", + "description": "This specification defines an API supporting the MIDI (Musical Instrument Digital Interface) protocol, enabling web applications to enumerate and select MIDI input and output devices on the client system and send and receive MIDI messages. It is intended to enable non-music MIDI applications as well as music ones, by providing low-level access to the MIDI devices available on the users' systems.", + "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=836897", + "mozPosition": "under consideration", + "mozPositionDetail": null, + "mozPositionIssue": 58, + "org": "W3C", + "title": "Web MIDI API", "url": "https://webaudio.github.io/web-midi-api" - }, + }, { - "ciuName": "web-share", - "description": "This specification defines an API for sharing text, links and other content to an arbitrary destination of the user's choice.The available share targets are not specified here; they are provided by the user agent. They could, for example, be apps, websites or contacts.", - "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=1312422", - "mozPosition": "under consideration", - "mozPositionDetail": null, - "mozPositionIssue": 27, - "org": "W3C", - "title": "Web Share API", + "ciuName": "web-share", + "description": "This specification defines an API for sharing text, links and other content to an arbitrary destination of the user's choice.The available share targets are not specified here; they are provided by the user agent. They could, for example, be apps, websites or contacts.", + "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=1312422", + "mozPosition": "under consideration", + "mozPositionDetail": null, + "mozPositionIssue": 27, + "org": "W3C", + "title": "Web Share API", "url": "https://wicg.github.io/web-share" - }, + }, { - "ciuName": null, - "description": "This specification defines an API that allows websites to declare themselves asweb share targets, which can receive shared content from either the Web Share API, or system events (e.g., shares from native apps).This is a similar mechanism to navigator.registerProtocolHandler, in that it works by registering the website with the user agent, to later be invoked from another site or native application via the user agent (possibly at the discretion of the user). The difference is that registerProtocolHandler registers the handler via a programmatic API, whereas a Web Share Target is declared in the Web App Manifest, to be registered at a time of the user agent or user's choosing.", - "mozBugUrl": null, - "mozPosition": "under consideration", - "mozPositionDetail": null, - "mozPositionIssue": 27, - "org": "W3C", - "title": "Web Share Target API", + "ciuName": null, + "description": "This specification defines an API that allows websites to declare themselves asweb share targets, which can receive shared content from either the Web Share API, or system events (e.g., shares from native apps).This is a similar mechanism to navigator.registerProtocolHandler, in that it works by registering the website with the user agent, to later be invoked from another site or native application via the user agent (possibly at the discretion of the user). The difference is that registerProtocolHandler registers the handler via a programmatic API, whereas a Web Share Target is declared in the Web App Manifest, to be registered at a time of the user agent or user's choosing.", + "mozBugUrl": null, + "mozPosition": "under consideration", + "mozPositionDetail": null, + "mozPositionIssue": 27, + "org": "W3C", + "title": "Web Share Target API", "url": "https://wicg.github.io/web-share-target" - }, + }, { - "ciuName": null, - "description": "This specification defines a mechanism that allows developers to selectively enable and disable use of various browser features and APIs.", - "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=1390801", - "mozPosition": "under consideration", - "mozPositionDetail": null, - "mozPositionIssue": 24, - "org": "W3C", - "title": "Feature Policy", + "ciuName": null, + "description": "This specification defines a mechanism that allows developers to selectively enable and disable use of various browser features and APIs.", + "mozBugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=1390801", + "mozPosition": "under consideration", + "mozPositionDetail": null, + "mozPositionIssue": 24, + "org": "W3C", + "title": "Feature Policy", "url": "https://wicg.github.io/feature-policy" - }, + }, { - "ciuName": "permissions-api", - "description": "The Permissions Standard defines common infrastructure for other specifications that need to interact with browser permissions. It also defines an API to allow web applications to query and request changes to the status of a given permission.", - "mozBugUrl": null, - "mozPosition": "under consideration", - "mozPositionDetail": null, - "mozPositionIssue": 19, - "org": "W3C", - "title": "Permissions", + "ciuName": "permissions-api", + "description": "The Permissions Standard defines common infrastructure for other specifications that need to interact with browser permissions. It also defines an API to allow web applications to query and request changes to the status of a given permission.", + "mozBugUrl": null, + "mozPosition": "under consideration", + "mozPositionDetail": null, + "mozPositionIssue": 19, + "org": "W3C", + "title": "Permissions", "url": "https://w3c.github.io/permissions" } -] +] \ No newline at end of file diff --git a/activities.py b/activities.py index 8b4e4625..7b8f242b 100755 --- a/activities.py +++ b/activities.py @@ -37,6 +37,9 @@ OWNER = "mozilla" REPO = "standards-positions" +# Use a single encoder object so that we set it up with the single correct configuration for +# writing activities.json. +JSON_ENCODER = json.JSONEncoder(sort_keys=True, indent=2, separators=(',', ': ')) class UrlType(object): "indicates a URL." @@ -49,7 +52,6 @@ class ActivitiesJson(object): """ A JSON file for activity tracking. """ - json_indent = 2 expected_entry_items = [ # (name, required?, type) ("cui_name", False, StringType), ("title", True, StringType), @@ -90,7 +92,7 @@ def save(self): "Save self.data into self.filename" try: with open(self.filename, 'w') as wfh: - json.dump(self.data, wfh, indent=self.json_indent, sort_keys=True) + wfh.write(JSON_ENCODER.encode(self.data)) except (OSError, IOError, ValueError) as why: sys.stderr.write("* ERROR: Can't write %s: %s\n" % (self.filename, why)) sys.exit(1) @@ -167,14 +169,13 @@ def validate_entry(self, entry, title=None): return errors def __str__(self): - return json.dumps(self.data, indent=self.json_indent, sort_keys=True) + return JSON_ENCODER.encode(self.data) class SpecEntry(object): """ Represents an entry for a single specification. """ - json_indent = 2 def __init__(self, spec_url): self.orig_url = spec_url self.data = { @@ -259,7 +260,7 @@ def create_issue(self): sys.stderr.write("* Created Github Issue %s\n" % issue_num) def __str__(self): - return json.dumps(self.data, indent=self.json_indent, sort_keys=True) + return JSON_ENCODER.encode(self.data) class BetterUrl(Exception):