+class Project(object):
+ def __init__(self, image, width, height):
+ self.image = image
+ self.width = width
+ self.height = height
+ self.focus_points_file = ''
+
+ def save_to_file(self, path):
+ if not self.focus_points_file:
+ bn = os.path.basename(path)
+ name = os.path.splitext(bn)[0]
+ self.focus_points_file = \
+ os.path.join(os.path.dirname(path), name + '_fpf')
+
+ cp = ConfigParser()
+ cp.add_section('Project')
+ cp.set('Project', 'image', self.image)
+ cp.set('Project', 'width', self.width)
+ cp.set('Project', 'height', self.height)
+ cp.set('Project', 'focus_points', self.focus_points_file)
+
+ cp.write(open(path, 'w'))
+
+ @staticmethod
+ def parse_file(path):
+ cp = ConfigParser()
+ cp.read(path)
+
+ image = cp.get('Project', 'image')
+ width = cp.getint('Project', 'width')
+ height = cp.getint('Project', 'height')
+ x = cp.getint('Project', 'height')
+
+ proj = Project(image, width, height)
+ proj.focus_points_file = cp.get('Project', 'focus_points')
+
+ return proj
+