Projet

Général

Profil

0001-build-check-config.json-validity-during-build-38354.patch

Frédéric Péters, 10 décembre 2019 14:47

Télécharger (6,42 ko)

Voir les différences:

Subject: [PATCH] build: check config.json validity during build (#38354)

 create_themes_json.py                      | 36 ++++++++++++++++++++++
 static/alpes-maritimes-2018/config.json    |  4 +--
 static/bouches-du-rhone/config.json        |  2 +-
 static/entrouvert/config.json              |  2 +-
 static/grenoble-metropole-2019/config.json |  2 +-
 static/quimper/config.json                 |  2 +-
 static/toulouse-metropole/config.json      |  2 +-
 7 files changed, 43 insertions(+), 7 deletions(-)
create_themes_json.py
3 3
import argparse
4 4
import json
5 5
import os
6
import re
7
import sys
6 8
import xml.etree.ElementTree as ET
7 9

  
8 10
parser = argparse.ArgumentParser()
......
10 12
args = parser.parse_args()
11 13

  
12 14
# get themes
15
errors = False
13 16
themes = []
14 17
for dirname in sorted(os.listdir('static')):
15 18
    config = os.path.join('static', dirname, 'config.json')
......
28 31
    if args.overlay:
29 32
        theme['module'] = 'publik-base'
30 33
        theme['overlay'] = args.overlay
34

  
35
    # validation checks
36
    theme_color = theme['variables'].get('theme_color')
37
    if theme_color and not re.match(r'#[0-9a-fA-F]{6}$', theme_color):
38
        print('E: invalid theme color for %s (%s)' % (dirname, theme_color), file=sys.stderr)
39
        errors = True
40
    if theme.get('settings'):
41
        for settings_app in theme['settings']:
42
            if settings_app not in ('authentic2', 'combo', 'fargo', 'wcs'):
43
                print('E: unknown application key for %s (%s)' % (dirname, settings_app), file=sys.stderr)
44
                errors = True
45
                continue
46
            if settings_app == 'combo':
47
                for settings_key in theme['settings'][settings_app].keys():
48
                    if settings_key not in (
49
                         'COMBO_ASSET_SLOTS.update',
50
                         'COMBO_MAP_ATTRIBUTION',
51
                         'COMBO_MAP_DEFAULT_POSITION',
52
                         'COMBO_MAP_MAX_BOUNDS',
53
                         'COMBO_MAP_TILE_URLTEMPLATE',
54
                         'COMBO_PUBLIC_TEMPLATES.update',
55
                         'JSON_CELL_TYPES.update',
56
                         'PWA_NOTIFICATION_BADGE_URL',
57
                         'PWA_NOTIFICATION_ICON_URL',
58
                         'WCS_CATEGORY_ASSET_SLOTS',
59
                         'WCS_FORM_ASSET_SLOTS',
60
                         ):
61
                        print('E: unknown settings key for %s (%s)' % (dirname, settings_key), file=sys.stderr)
62
                        errors = True
63

  
31 64
    themes.append(theme)
32 65

  
66
if errors:
67
    sys.exit(1)
68

  
33 69
# get parameters
34 70
parameters = {'primary-color': {'type': 'color'}}
35 71
if os.path.exists('help/fr/misc-scss.page'):
static/alpes-maritimes-2018/config.json
2 2
  "label": "Alpes-Maritimes 2018",
3 3
  "settings": {
4 4
      "combo": {
5
          "COMBO_ASSET_SLOTS": {
5
          "COMBO_ASSET_SLOTS.update": {
6 6
              "social:dossiers:autonomie": {
7 7
                  "label": "Pictogramme dossier autonomie"
8 8
              },
......
10 10
                  "label": "Pictogramme dossier handicap"
11 11
              }
12 12
          },
13
          "JSON_CELL_TYPES": {
13
          "JSON_CELL_TYPES.update": {
14 14
              "desappairage": {
15 15
                  "form": [
16 16
                    {
static/bouches-du-rhone/config.json
7 7
  },
8 8
  "settings": {
9 9
      "combo": {
10
          "JSON_CELL_TYPES": {
10
          "JSON_CELL_TYPES.update": {
11 11
              "cd13_liste_des_dossiers": {
12 12
                  "cache_duration": 10,
13 13
                  "name": "Liste des dossiers",
static/entrouvert/config.json
6 6
  },
7 7
  "settings": {
8 8
    "combo": {
9
      "JSON_CELL_TYPES": {
9
      "JSON_CELL_TYPES.update": {
10 10
        "references": {
11 11
          "name": "References",
12 12
          "url": "https://gestion.entrouvert.org/api/references/",
static/grenoble-metropole-2019/config.json
17 17
              "corner1": {"lat": "45.2307", "lng": "5.6640"},
18 18
              "corner2": {"lat": "45.1179", "lng": "5.7980"}
19 19
          },
20
          "JSON_CELL_TYPES": {
20
          "JSON_CELL_TYPES.update": {
21 21
              "user": {
22 22
                  "cache_duration": 60,
23 23
                  "name": "Cellule usager",
static/quimper/config.json
22 22
      },
23 23
      "COMBO_MAP_TILE_URLTEMPLATE": "https://tiles.entrouvert.org/hdm/{z}/{x}/{y}.png",
24 24
      "COMBO_MAP_ATTRIBUTION": "&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>",
25
      "JSON_CELL_TYPES": {
25
      "JSON_CELL_TYPES.update": {
26 26
        "parkings": {
27 27
          "url": "https://places-parkings.quimper-communaute.bzh/WebServiceInfosGeolocFront.asmx/GetGeoJsonListDysplayItemByType?type=parkings",
28 28
          "name": "Parkings",
static/toulouse-metropole/config.json
7 7
  },
8 8
  "settings": {
9 9
    "combo": {
10
      "JSON_CELL_TYPES": {
10
      "JSON_CELL_TYPES.update": {
11 11
        "communes-toulouse": {
12 12
          "url": "https://data.toulouse-metropole.fr/api/records/1.0/search/?dataset=communes-de-toulouse-metropole&sort=ville&rows=100",
13 13
          "name": "Communes de Toulouse",
14
-