def load_comment_options(self, data=None): print(data) try: if data is None: file, _ = QFileDialog.getOpenFileName(self, 'Open file') with open(file, 'r') as f: data = f.read() self.comment_options = Comment.parse_options(data) self.__setup_ui() except ValueError: QMessageBox.information(self, 'Error', 'Parsing failed')
from comments import Comment from language import Python, CPP options = { 'filling': '=', 'filling2': '-', 'right-char': True, 'capitalize': True, 'length': 30 } lang = Python() print(Comment.gen_comment('header', lang, options)) data = """dummy text # ===================================== # ================= d ================= # ===================================== other dummy text""" print() print(Comment.parse_options(data)) data = """# ============= # # --- DUMMY --- # # ============= #""" print() print(Comment.parse_options(data))