Hooke(GUI)
[hooke.git] / lib / file.py
1 #!/usr/bin/env python\r
2 \r
3 '''\r
4 file.py\r
5 \r
6 File class for Hooke.\r
7 \r
8 Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)\r
9 \r
10 This program is released under the GNU General Public License version 2.\r
11 '''\r
12 \r
13 import os.path\r
14 import lib.plot\r
15 \r
16 class File(object):\r
17 \r
18     def __init__(self, filename=None, drivers=None):\r
19         self.driver = None\r
20         self.note = ''\r
21         self.plot = lib.plot.Plot()\r
22         if filename is None:\r
23             self.filename = None\r
24             self.name = None\r
25             self.path = None\r
26         else:\r
27             self.filename = filename\r
28             self.path, self.name = os.path.split(filename)\r
29 \r
30     def identify(self, drivers):\r
31         '''\r
32         identifies a curve and returns the corresponding object\r
33         '''\r
34         for driver in drivers:\r
35             current_driver = driver(self.filename)\r
36             if current_driver.is_me():\r
37                 #bring on all the driver, with its load of methods etc.\r
38                 #so we can access the whole of it.\r
39                 self.plot = current_driver.default_plots()\r
40                 self.driver = current_driver\r