source: TI03-DataExtractor/branches/old_stuff/extractor/datasets.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/extractor/datasets.py@793
Revision 793, 1.0 KB checked in by astephen, 14 years ago (diff)

Put all the old code in the old_stuff branch.

  • Property svn:executable set to *
RevLine 
[793]1"""
2datasets.py
3===========
4
5Datasets module for the extractor package.
6
7This module holds the Datasetdb class that is used
8to hold and access information about datasets visible
9to the extractor package.
10
11Version history
12===============
13
14Version 1.0:  - 01/03/2004
15              - Ag Stephens, British Atmospheric Data Centre.
16              - First version.
17
18"""
19
20# Import required modules
21import shelve
22import os
23
24# Import global variables
25from shared_data import *
26
27
28class Datasetdb:
29 
30    def __init__(self, file=os.path.join(dataset_dir, "datasetdb")):
31        self.dict={}
32        file_obj=shelve.open(file)
33       
34        for key in file_obj.keys():
35            self.dict[key]=file_obj[key]
36
37        file_obj.close()
38 
39    def copyDict(self):
40        return self.dict
41
42    def getDatasets(self):
43        return self.dict["datasets"]
44
45    def getSubsets(self, dataset):
46        return self.dict[dataset]["subsets"]
47
48    def getVariables(self, dataset, subset):
49        return self.dict[dataset][subset]["variables"]
50
51
52
Note: See TracBrowser for help on using the repository browser.