Update current add-in ribbon with specified CustomUI.xml. Args: custom_ui_filename (str): full path to CustomUI.xml defining the ribbon UI.
(self, custom_ui_filename:str='CustomUI.xml')
| 45 | |
| 46 | |
| 47 | def update(self, custom_ui_filename:str='CustomUI.xml'): |
| 48 | '''Update current add-in ribbon with specified CustomUI.xml. |
| 49 | |
| 50 | Args: |
| 51 | custom_ui_filename (str): full path to CustomUI.xml defining the ribbon UI. |
| 52 | ''' |
| 53 | if not os.path.exists(self.xlam_file): |
| 54 | raise AddInException(f'Not find add-in file: {self.xlam_file}.') |
| 55 | |
| 56 | # rename: name.xlam -> name.zip |
| 57 | zip_file = os.path.join(self.path, '{0}.zip'.format(self.name)) |
| 58 | shutil.move(self.xlam_file, zip_file) |
| 59 | |
| 60 | # unpack: name.zip -> name/ |
| 61 | xml_path = os.path.join(self.path, self.name) |
| 62 | shutil.unpack_archive(zip_file, xml_path) |
| 63 | |
| 64 | # recreate: update current template files with new CustomUI.xml |
| 65 | self.create(xml_path, custom_ui_filename) |
no test coverage detected