1
2
3
4 """
5 Add new attributes to a database table and update their values, or existing
6 attributes, from the original FITS headers values using the prescription
7 defined in the schema file. Note, this does not update values taken from
8 catalogue files. To do this use UpdateCatData.py.
9
10 @author: R.S. Collins
11 @org: WFAU, IfA, University of Edinburgh
12 """
13
14 from wsatools.CLI import CLI
15 import wsatools.CSV as csv
16 from wsatools.FitsToDb import AttributeUpdater
17 from wsatools.Logger import Logger
18
19
20
21 if __name__ == '__main__':
22
23 CLI.progOpts += [
24 CLI.Option('a', 'attrs',
25 'comma-separated list of existing attributes to update',
26 'LIST'),
27 CLI.Option('l', 'tables',
28 'comma-separated list of tables to update',
29 'LIST', ', '.join(AttributeUpdater.tableList)),
30 CLI.Option('o', 'only_stacks',
31 'only update attribute values of stacked frames'),
32 CLI.Option('s', 'schema',
33 'schema file to parse for table attributes',
34 'FILE', AttributeUpdater.schemaFileName)]
35
36
37 CLI.progArgs['comment'] = AttributeUpdater.comment
38
39 cli = CLI("AddColumns", "$Revision: 5194 $", __doc__)
40 Logger.isVerbose = cli.getOpt('verbose')
41 Logger.addMessage(cli.getProgDetails())
42
43 updater = AttributeUpdater(cli=cli)
44 if cli.getOpt('attrs'):
45 updater.reqAttrs = list(csv.values(cli.getOpt('attrs')))
46 updater.schemaFileName = cli.getOpt('schema')
47 updater.tableList = list(csv.values(cli.getOpt('tables')))
48 updater.doStacksOnly = cli.getOpt('only_stacks')
49 updater.run()
50
51
52
53
54
55