• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python2
2"""Common utility functions."""
3
4DEFAULT_OBJECT_NUMBER = 1238
5DEFAULT_BAD_OBJECT_NUMBER = 23
6OBJECTS_FILE = 'objects.txt'
7WORKING_SET_FILE = 'working_set.txt'
8
9
10def ReadWorkingSet():
11  working_set = []
12  f = open(WORKING_SET_FILE, 'r')
13  for l in f:
14    working_set.append(int(l))
15  f.close()
16  return working_set
17
18
19def WriteWorkingSet(working_set):
20  f = open(WORKING_SET_FILE, 'w')
21  for o in working_set:
22    f.write('{0}\n'.format(o))
23  f.close()
24
25
26def ReadObjectsFile():
27  objects_file = []
28  f = open(OBJECTS_FILE, 'r')
29  for l in f:
30    objects_file.append(int(l))
31  f.close()
32  return objects_file
33
34
35def ReadObjectIndex(filename):
36  object_index = []
37  f = open(filename, 'r')
38  for o in f:
39    object_index.append(int(o))
40  f.close()
41  return object_index
42