utils Package¶
This is the pyNastran.utils.rst file.
gui_choices Module¶
gui_io Module¶
- pyNastran.utils.gui_io.load_file_dialog(Title, wx_wildcard, qt_wildcard, dirname='')[source]¶
creates a load file dialog in wx or PyQt4/PySide
log Module¶
- class pyNastran.utils.log.SimpleLogger(level='debug', log_func=<function stderr_logging at 0x7ff6186662a8>)[source]¶
Bases: object
Simple logger object. In future might be changed to use Python logging module. Two levels are supported: ‘debug’ and ‘info’. Info level discards debug messages, ‘debug’ level displays all messages.
Note
Logging module is currently not supported because I don’t know how to repoint the log file if the program is called a second time. Poor logging can result in:
- double logging to a single file
- all longging going to one file
This is really only an issue when calling logging multiple times, such as in an optimization loop or testing.
Parameters: - level – level of logging: ‘info’ or ‘debug’
- log_func – funtion that will be used to print log. It should take one argument: string that is produces by a logger. Default: print messages to stderr using @see stderr_logging function.
- msg_typ(typ, msg)[source]¶
Log message of a given type :param typ: type of a message (e.g. INFO) :param msg: message to be logged
- pyNastran.utils.log.get_logger(log=None, level='debug')[source]¶
This function is useful as it will instantiate a simpleLogger object if log=None. :param log: a logger object or None :param level: level of logging: ‘info’ or ‘debug’
- pyNastran.utils.log.get_logger2(log=None, debug=True)[source]¶
This function is useful as it will instantiate a SimpleLogger object if log=None. :param log: a python logging module object;
if log is set, debug is ignored and uses the settings the logging object hasParameters: debug – used to set the logger if no logger is passed in True: logs debug/info/error messages False: logs info/error messages None: logs error messages Returns log: log or a SimpleLogger
mathematics Module¶
dev Module¶
- pyNastran.utils.dev.get_files_of_type(dirname, extension='.txt', maxSize=100.0)[source]¶
Gets the list of all the files with a given extension in the specified directory
Parameters: - dirname – the directory name
- extension – list of filetypes to get (default=’.txt’)
- maxSize – size in MB for max file size
Returns: list of all the files with a given extension in the specified directory
- pyNastran.utils.dev.list_print(lst, float_fmt='%-4.2f')[source]¶
Prints a list, numpy array, or numpy matrix in an abbreviated format. Supported element types: None, string, numbers. Useful for debugging.
Parameters: lst – list, numpy array or numpy matrix Returns: the clean string representation of the object
__init__ Module¶
- pyNastran.utils.__init__.__object_attr(obj, mode, attr_type)[source]¶
list object attributes of a given type
- pyNastran.utils.__init__.is_binary_file(filename)[source]¶
Return true if the given filename is binary.
Raises: IOError if the file cannot be opened. Returns: True if filename is a binary file (contains null byte) and False otherwise. Based on the idea (.. seealso:: http://bytes.com/topic/python/answers/21222-determine-file-type-binary-text) that file is binary if it contains null.
Warning
this may not work for unicode.
- pyNastran.utils.__init__.object_attributes(obj, mode='public')[source]¶
List the names of attributes of a class as strings. Returns public attributes as default.
Parameters: - obj – the object for checking
- mode – defines what kind of attributes will be listed * “public” - names that do not begin with underscore * “private” - names that begin with single underscore * “both” - private and public * “all” - all attributes that are defined for the object
Returns: sorted list of the names of attributes of a given type or None if the mode is wrong
- pyNastran.utils.__init__.object_methods(obj, mode='public')[source]¶
List the names of methods of a class as strings. Returns public methods as default.
Parameters: - obj – the object for checking
- mode – defines what kind of methods will be listed * “public” - names that do not begin with underscore * “private” - names that begin with single underscore * “both” - private and public * “all” - all methods that are defined for the object
Returns: sorted list of the names of methods of a given type or None if the mode is wrong
- pyNastran.utils.__init__.print_bad_path(path)[source]¶
Prints information about the existence (access possibility) of the parts of the given path. Useful for debugging when the path to a given file is wrong.
Parameters: path – path to check Returns: string with informations whether access to parts of the path is possible