Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(type, str):
type = type.lower()
if type[0:7] == 'binary':
table_type = BINARY_TBL
elif type[0:6] == 'ascii':
table_type = ASCII_TBL
else:
raise ValueError(
"table type string should begin with 'binary' or 'ascii' "
"(case insensitive)")
else:
type = int(type)
if type not in [BINARY_TBL, ASCII_TBL]:
raise ValueError(
"table type num should be BINARY_TBL (%d) or "
"ASCII_TBL (%d)" % (BINARY_TBL, ASCII_TBL))
table_type = type
return table_type
def _extract_table_type(type):
"""
Get the numerical table type
"""
if isinstance(type, str):
type = type.lower()
if type[0:7] == 'binary':
table_type = BINARY_TBL
elif type[0:6] == 'ascii':
table_type = ASCII_TBL
else:
raise ValueError(
"table type string should begin with 'binary' or 'ascii' "
"(case insensitive)")
else:
type = int(type)
if type not in [BINARY_TBL, ASCII_TBL]:
raise ValueError(
"table type num should be BINARY_TBL (%d) or "
"ASCII_TBL (%d)" % (BINARY_TBL, ASCII_TBL))
table_type = type
return table_type
def _append_hdu_info(self, ext):
"""
internal routine
append info for indiciated extension
"""
# raised IOError if not found
hdu_type = self._FITS.movabs_hdu(ext+1)
if hdu_type == IMAGE_HDU:
hdu = ImageHDU(self._FITS, ext)
elif hdu_type == BINARY_TBL:
hdu = TableHDU(
self._FITS, ext,
lower=self.lower, upper=self.upper,
trim_strings=self.trim_strings,
vstorage=self.vstorage, case_sensitive=self.case_sensitive,
iter_row_buffer=self.iter_row_buffer,
write_bitcols=self.write_bitcols)
elif hdu_type == ASCII_TBL:
hdu = AsciiTableHDU(
self._FITS, ext,
lower=self.lower, upper=self.upper,
trim_strings=self.trim_strings,
vstorage=self.vstorage, case_sensitive=self.case_sensitive,
iter_row_buffer=self.iter_row_buffer,
write_bitcols=self.write_bitcols)
else: