MCPcopy Index your code
hub / github.com/dothinking/PyAddin / update

Method update

pyaddin/xlam/ui.py:47–65  ·  view source on GitHub ↗

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')

Source from the content-addressed store, hash-verified

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)

Callers 1

updateMethod · 0.95

Calls 2

createMethod · 0.95
AddInExceptionClass · 0.85

Tested by

no test coverage detected