Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_vba_wrapper(module_name, module, f):
vba = VBAWriter(f)
for svar in map(lambda attr: getattr(module, attr), dir(module)):
if hasattr(svar, '__xlfunc__'):
xlfunc = svar.__xlfunc__
xlret = xlfunc['ret']
fname = xlfunc['name']
call_in_wizard = xlfunc['call_in_wizard']
volatile = xlfunc['volatile']
ftype = 'Sub' if xlfunc['sub'] else 'Function'
func_sig = ftype + " " + fname + "("
first = True
vararg = ''
n_args = len(xlfunc['args'])
def write_vba_line(self, vba_line):
if len(vba_line) > VBAWriter.MAX_VBA_LINE_LENGTH:
separator_index = VBAWriter.get_separator_index(vba_line)
self.f.write(vba_line[:separator_index] + VBAWriter.VBA_LINE_SPLIT)
self.write_vba_line(vba_line[separator_index:])
else:
self.f.write(vba_line)
def write_vba_line(self, vba_line):
if len(vba_line) > VBAWriter.MAX_VBA_LINE_LENGTH:
separator_index = VBAWriter.get_separator_index(vba_line)
self.f.write(vba_line[:separator_index] + VBAWriter.VBA_LINE_SPLIT)
self.write_vba_line(vba_line[separator_index:])
else:
self.f.write(vba_line)
def block(self, template, **kwargs):
return VBAWriter.Block(self, template.format(**kwargs))
def write_vba_line(self, vba_line):
if len(vba_line) > VBAWriter.MAX_VBA_LINE_LENGTH:
separator_index = VBAWriter.get_separator_index(vba_line)
self.f.write(vba_line[:separator_index] + VBAWriter.VBA_LINE_SPLIT)
self.write_vba_line(vba_line[separator_index:])
else:
self.f.write(vba_line)