Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def convert(self, outfile, sheetid=1):
"""outfile - path to file or filehandle"""
if sheetid > 0:
self._convert(sheetid, outfile)
else:
if isinstance(outfile, str):
if not os.path.exists(outfile):
os.makedirs(outfile)
elif os.path.isfile(outfile):
raise OutFileAlreadyExistsException("File " + str(outfile) + " already exists!")
for s in self.workbook.sheets:
sheetname = s['name']
sheetstate = s['state']
# filter hidden sheets
if sheetstate in ('hidden', 'veryHidden') and self.options['exclude_hidden_sheets']:
continue
# filter sheets by include pattern
include_sheet_pattern = self.options['include_sheet_pattern']
if type(include_sheet_pattern) == type(""): # optparser lib fix
include_sheet_pattern = [include_sheet_pattern]
if len(include_sheet_pattern) > 0:
include = False
for pattern in include_sheet_pattern:
include = pattern and len(pattern) > 0 and re.match(pattern, sheetname)