• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2020 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Common utility functions."""
8
9DEFAULT_OBJECT_NUMBER = 1238
10DEFAULT_BAD_OBJECT_NUMBER = 23
11OBJECTS_FILE = 'objects.txt'
12WORKING_SET_FILE = 'working_set.txt'
13
14
15def ReadWorkingSet():
16  working_set = []
17  with open(WORKING_SET_FILE, 'r', encoding='utf-8') as f:
18    for l in f:
19      working_set.append(int(l))
20  return working_set
21
22
23def WriteWorkingSet(working_set):
24  with open(WORKING_SET_FILE, 'w', encoding='utf-8') as f:
25    for o in working_set:
26      f.write('{0}\n'.format(o))
27
28
29def ReadObjectsFile():
30  objects_file = []
31  with open(OBJECTS_FILE, 'r', encoding='utf-8') as f:
32    for l in f:
33      objects_file.append(int(l))
34  return objects_file
35
36
37def ReadObjectIndex(filename):
38  object_index = []
39  with open(filename, 'r', encoding='utf-8') as f:
40    for o in f:
41      object_index.append(int(o))
42  return object_index
43