def main_loop(): dm.gui() # I dont use DiGraphs now, so I cut it temporarily. I will still live this as a commands option # graph_type = input('Please specify graph type(graph/digraph): >>') # dm.process_graph_type(graph_type) dm.process_graph_type('g') while s.whileBool: print('Enter command. \'help\' for help') raw_input = input('>>') process_raw_input(raw_input) if s.successfulCommand: s.successfulCommand = False dm.draw_graph() s.plt.show() s.plt.ion() s.plt.pause(0.001) if s.requires_saving: s.requires_saving = False now = s.datetime.datetime.now() file_name = s.filename + now.strftime( "-%m-%d-%Y--%H-%M-%S") + '.png' # file_plus_path = str(s.pathlib.Path(__file__).parent.parent.absolute()) + '\\images\\' + file_name # file_plus_path = str(s.pathlib.Path(__file__).parent.parent.absolute()) + '\\' + file_name # file_plus_path = str(s.abspath(s.getsourcefile(lambda:0))).replace(s.basename(__file__), '') + file_name file_plus_path = str(s.getcwd()) + '\\' + file_name s.plt.savefig(file_plus_path) print(str(file_plus_path) + ' was saved.') if s.requires_saving_json: s.requires_saving_json = False now = s.datetime.datetime.now() file_name = s.filename + now.strftime( "-%m-%d-%Y--%H-%M-%S") + '.json' # file_plus_path = str(s.pathlib.Path(__file__).parent.parent.absolute()) + '\\saved_graphs\\' + file_name # file_plus_path = str(s.pathlib.Path(__file__).parent.parent.absolute()) + '\\' + file_name # file_plus_path = str(s.abspath(s.getsourcefile(lambda:0))).replace(s.basename(__file__), '') + file_name file_plus_path = str(s.getcwd()) + '\\' + file_name f = open(file_plus_path, 'a') f.write(s.json.dumps(s.json_graph.node_link_data(s.graph))) f.close() print(str(file_plus_path) + ' was saved.') if s.requires_saving_gexf: s.requires_saving_gexf = False now = s.datetime.datetime.now() file_name = s.filename + now.strftime( "-%m-%d-%Y--%H-%M-%S") + '.gexf' # file_plus_path = str(s.pathlib.Path(__file__).parent.parent.absolute()) + '\\saved_graphs\\' + file_name # file_plus_path = str(s.abspath(s.getsourcefile(lambda:0))).replace(s.basename(__file__), '') + file_name file_plus_path = str(s.getcwd()) + '\\' + file_name s.nx.write_gexf(s.graph, file_plus_path) print(str(file_plus_path) + ' was saved.')
def save_gexf(self, raw_input): list = raw_input.split(' ') if len(list) == 3: s.filename = list[2] s.successfulCommand = True now = s.datetime.datetime.now() file_name = s.filename + now.strftime("-%m-%d-%Y--%H-%M-%S") + '.gexf' file_plus_path = str(s.getcwd()) + '\\' + file_name s.nx.write_gexf(s.graph, file_plus_path) s.cust_print(self, (str(file_plus_path) + ' was saved.')) else: s.cust_print(self, ('Improper command caught in save gexf: ' + raw_input))
def save_json(self, raw_input): list = raw_input.split(' ') if len(list) == 3: s.filename = list[2] s.successfulCommand = True now = s.datetime.datetime.now() file_name = s.filename + now.strftime("-%m-%d-%Y--%H-%M-%S") + '.json' file_plus_path = str(s.getcwd()) + '\\' + file_name f = open(file_plus_path, 'a') f.write(s.json.dumps(s.json_graph.node_link_data(s.graph))) f.close() s.cust_print(self, (str(file_plus_path) + ' was saved.')) else: s.cust_print(self, ('Improper command caught in save json: ' + raw_input))