2 Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 This program and the accompanying materials are made available under the
5 terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 and is available at http://www.eclipse.org/legal/epl-v10.html
8 Created on Jan 24, 2014
16 class FileLoaderTools():
18 Tool class provides the static methods for load files
19 with expected format for testing in ODL_TESTs
21 log = logging.getLogger( 'FileLoaderTools' )
24 def load_file_to_string( path_to_file ):
26 Primary use for loading the xml files as a string
31 with open( path_to_file ) as f:
32 output_string = f.read()
34 FileLoaderTools.log.error( 'cannot find {}: {}'.format( path_to_file, e.strerror ), exc_info = True )
39 def load_file_to_dict( path_to_file ):
41 Primary use for loading the csv files as dictionaries
46 with open( path_to_file ) as f:
47 dictionary = dict( line.strip().split( ';' ) for line in f
48 if not line.startswith( '#' ) )
50 FileLoaderTools.log.error( 'cannot find {}: {}'.format( path_to_file, e.strerror ), exc_info = True )