MCPcopy Create free account
hub / github.com/dothinking/PyAddin / init

Method init

pyaddin/main.py:11–41  ·  view source on GitHub ↗

Create template project with specified name under current path. Args: name (str) : the name of add-in to create (without the suffix ``.xlam``). vba (bool): create VBA add-in only if True, otherwise VBA-Python addin by default. quiet (bool): perfor

(name:str, vba:bool=False, quiet:bool=True)

Source from the content-addressed store, hash-verified

9
10 @staticmethod
11 def init(name:str, vba:bool=False, quiet:bool=True):
12 '''Create template project with specified name under current path.
13
14 Args:
15 name (str) : the name of add-in to create (without the suffix ``.xlam``).
16 vba (bool): create VBA add-in only if True, otherwise VBA-Python addin by default.
17 quiet (bool): perform the process in the background if True.
18 '''
19 # new project
20 work_path = os.getcwd()
21 project_path = os.path.join(work_path, name)
22 if os.path.exists(project_path):
23 logging.error(f'Project {name} already existed.')
24 return
25 os.mkdir(project_path)
26
27 # template UI file
28 ui_file = os.path.join(RESOURCE_PATH, CUSTOM_UI)
29 shutil.copy(ui_file, project_path)
30
31 # template add-in based on UI template
32 filename = os.path.join(project_path, f'{name}.xlam')
33 addin = Addin(xlam_file=filename, visible=not quiet)
34
35 try:
36 addin.create(vba_only=vba)
37 except Exception as e:
38 logging.error(e)
39 addin.close()
40 else:
41 if quiet: addin.close()
42
43
44 @staticmethod

Callers

nothing calls this directly

Calls 3

createMethod · 0.95
closeMethod · 0.95
AddinClass · 0.85

Tested by

no test coverage detected