def read_op2( self, op2_filename=None, combine=True, build_dataframe=None, skip_undefined_matrices=False, encoding=None ): """ Starts the OP2 file reading Parameters ---------- op2_filename : str (default=None -> popup) the op2_filename combine : bool; default=True True : objects are isubcase based False : objects are (isubcase, subtitle) based; will be used for superelements regardless of the option build_dataframe : bool (default=None -> True if in iPython, False otherwise) builds a pandas DataFrame for op2 objects skip_undefined_matrices : bool; default=False True : prevents matrix reading crashes encoding : str the unicode encoding (default=None; system default) """ if build_dataframe is None: build_dataframe = False if ipython_info(): build_dataframe = True if encoding is None: encoding = sys.getdefaultencoding() self.encoding = encoding self.skip_undefined_matrices = skip_undefined_matrices assert self.ask in [True, False], self.ask self.is_vectorized = True self.log.debug("combine=%s" % combine) self.log.debug("-------- reading op2 with read_mode=1 (array sizing) --------") self.read_mode = 1 self._close_op2 = False # get GUI object names, build objects, but don't read data OP2_Scalar.read_op2(self, op2_filename=op2_filename) # TODO: stuff to figure out objects # TODO: stuff to show gui of table names # TODO: clear out objects the user doesn't want self.read_mode = 2 self._close_op2 = True self.log.debug("-------- reading op2 with read_mode=2 (array filling) --------") OP2_Scalar.read_op2(self, op2_filename=self.op2_filename) self.finalize() if build_dataframe: self.build_dataframe() self.combine_results(combine=combine) self.log.debug("finished reading op2")
def read_op2(self, op2_filename=None, combine=True, build_dataframe=None, skip_undefined_matrices=False, encoding=None): """ Starts the OP2 file reading Parameters ---------- op2_filename : str (default=None -> popup) the op2_filename combine : bool; default=True True : objects are isubcase based False : objects are (isubcase, subtitle) based; will be used for superelements regardless of the option build_dataframe : bool (default=None -> True if in iPython, False otherwise) builds a pandas DataFrame for op2 objects skip_undefined_matrices : bool; default=False True : prevents matrix reading crashes encoding : str the unicode encoding (default=None; system default) """ if build_dataframe is None: build_dataframe = False if ipython_info(): build_dataframe = True if encoding is None: encoding = sys.getdefaultencoding() self.encoding = encoding self.skip_undefined_matrices = skip_undefined_matrices assert self.ask in [True, False], self.ask self.is_vectorized = True self.log.debug('combine=%s' % combine) self.log.debug('-------- reading op2 with read_mode=1 (array sizing) --------') self.read_mode = 1 self._close_op2 = False # get GUI object names, build objects, but don't read data OP2_Scalar.read_op2(self, op2_filename=op2_filename) # TODO: stuff to figure out objects # TODO: stuff to show gui of table names # TODO: clear out objects the user doesn't want self.read_mode = 2 self._close_op2 = True self.log.debug('-------- reading op2 with read_mode=2 (array filling) --------') OP2_Scalar.read_op2(self, op2_filename=self.op2_filename) self.finalize() if build_dataframe: self.build_dataframe() self.create_objects_from_matrices() self.combine_results(combine=combine) self.log.debug('finished reading op2')
def read_op2(self, op2_filename: Optional[str]=None, combine: bool=True, build_dataframe: Optional[bool]=False, skip_undefined_matrices: bool=False, encoding: Optional[str]=None) -> None: """ Starts the OP2 file reading Parameters ---------- op2_filename : str (default=None -> popup) the op2_filename combine : bool; default=True True : objects are isubcase based False : objects are (isubcase, subtitle) based; will be used for superelements regardless of the option build_dataframe : bool (default=None -> True if in iPython, False otherwise) builds a pandas DataFrame for op2 objects None: True if in iPython, False otherwise skip_undefined_matrices : bool; default=False True : prevents matrix reading crashes encoding : str the unicode encoding (default=None; system default) """ if op2_filename: check_path(op2_filename, name='op2_filename') mode = self.mode if build_dataframe is None: build_dataframe = False if ipython_info(): build_dataframe = True if encoding is None: encoding = sys.getdefaultencoding() self.encoding = encoding self.skip_undefined_matrices = skip_undefined_matrices assert self.ask in [True, False], self.ask self.is_vectorized = True self.log.debug(f'combine={combine}') msg = f'{"-"*8} reading op2 with read_mode=1 (array sizing) {"-"*8}'
from six import PY2, string_types from pyNastran.utils import ipython_info IS_TERMINAL = False if hasattr(sys.stdout, 'isatty'): # pyInstaller <= 3.1 doesn't have this IS_TERMINAL = sys.stdout.isatty() # You're running in a real terminal try: from colorama import init as colorinit, Fore # type: ignore colorinit(autoreset=True) IS_COLORAMA = True except ImportError: IS_COLORAMA = False USE_HTML = ipython_info() is not None USE_COLORAMA = IS_COLORAMA and IS_TERMINAL and not USE_HTML #print('USE_COLORAMA =', USE_COLORAMA, IS_COLORAMA, IS_TERMINAL, ipython_info()) #print('USE_HTML =', USE_HTML) if USE_COLORAMA: # if we're writing to a file def _write(typ, name, msg, encoding): _write_colorama_screen(typ, name + msg) elif USE_HTML: from IPython.core.display import display, HTML def _write(typ, name, msg, encoding): """ per: