blob: 2c6a38099fcefb6ea60854253e7fbcfc588b7760 [file] [log] [blame]
susmit shannigrahi7c5de012015-03-30 16:18:01 -06001#!/usr/bin/env python3
2
3# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
4#
5# Copyright (c) 2015, Colorado State University.
6#
7# This file is part of ndn-atmos.
8#
9# ndn-atmos is free software: you can redistribute it and/or modify it under the
10# terms of the GNU Lesser General Public License as published by the Free Software
11# Foundation, either version 3 of the License, or (at your option) any later version.
12#
13# ndn-atmos is distributed in the hope that it will be useful, but WITHOUT ANY
14# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16#
17# You should have received copies of the GNU General Public License and GNU Lesser
18# General Public License along with ndn-atmos, e.g., in COPYING.md file. If not, see
19# <http://www.gnu.org/licenses/>.
20#
21# See AUTHORS.md for complete list of ndn-atmos authors and contributors.
22
23'''Translates a netcdf filename to a NDN name'''
24
25from atmos2ndn_parser import conf_file_parser, cmd_arg_parser
26from atmos2ndn_translators import translate
27
28def argsForTranslation(dataFilepath, configPath):
29 '''this module does the actual translation calls'''
30 if __debug__:
31 print("config file '%s', data path '%s'" %(configPath, dataFilepath))
32
33 #pass the config file to parser module, which will return and object
34 #with all the mappings. The mappings tell us which name component
35 #comes from where and what should be the order of the components
36 parsedConfig = conf_file_parser.ParseConf(configPath)
37 res = parsedConfig.getMappings()
38
39 #do the translation
40 ndnName = translate.translate(parsedConfig, dataFilepath)
41 if __debug__:
42 print("NDN name in main: %s" %(ndnName))
43
44def main():
45 '''parse command line arguments, gives back configFilename and dataFilename
46 we then pass these to the subsequent modules.'''
47
48 userArgs = cmd_arg_parser.InputParser()
49 userArgs.parse()
50 configFile = userArgs.confFilepath
51 print("config file '%s', data path '%s'" %(configFile, userArgs.dataFilepath))
52 if __debug__:
53 print("config file '%s', data path '%s'" %(configFile, userArgs.dataFilepath))
54
55 #call the translator module
56 argsForTranslation(userArgs.dataFilepath, configFile)
57
58if __name__ == '__main__':
59 main()