File: crypto_docs.py

package info (click to toggle)
android-platform-libcore 10.0.0%2Br36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 85,484 kB
  • sloc: java: 846,430; ansic: 12,234; cpp: 10,616; xml: 1,581; python: 920; sh: 349; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 1,305 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

'''Utility functions for crypto doc updating tools.'''

import json


def load_json(filename):
    '''Returns an object containing the JSON data from the provided file.'''
    f = open(filename)
    # JSON doesn't allow comments, but we have some header docs in our file,
    # so strip comments out before parsing
    stripped_contents = ''
    for line in f:
        if not line.strip().startswith('#'):
            stripped_contents += line
    data = json.loads(stripped_contents)
    f.close()
    return data


def find_by_name(seq, name):
    """Returns the first element in seq with the given name."""
    for item in seq:
        if item['name'] == name:
            return item
    return None