def create_nice_cx_from_filename(filename): if os.path.isfile(filename): my_nicecx = NiceCXNetwork() with open(filename, 'rU') as file_cx: #==================================== # BUILD NICECX FROM FILE #==================================== my_nicecx.create_from_cx(json.load(file_cx)) return my_nicecx else: raise Exception('The file provided does not exist.')
def create_nice_cx_from_file(path): """ Create a NiceCXNetwork based on CX JSON from a file. :param path: the path from which the CX will be loaded :return: NiceCXNetwork """ if os.path.isfile(path): my_nicecx = NiceCXNetwork() with open(path, 'rU') as file_cx: # ==================================== # BUILD NICECX FROM FILE # ==================================== my_nicecx.create_from_cx(json.load(file_cx)) return my_nicecx else: raise Exception('The file " + path + " does not exist.')