当前位置: 首页>>代码示例>>Python>>正文


Python DataIO.inputToString方法代码示例

本文整理汇总了Python中cc.tools.io.DataIO.inputToString方法的典型用法代码示例。如果您正苦于以下问题:Python DataIO.inputToString方法的具体用法?Python DataIO.inputToString怎么用?Python DataIO.inputToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.tools.io.DataIO的用法示例。


在下文中一共展示了DataIO.inputToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setCommandKey

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import inputToString [as 别名]
 def setCommandKey(self,comm_key,star,key_type,star_key=None,\
                   alternative=None,make_int=0,exp_not=0):
     
     '''
     Try setting a key in the command_list from a star instance. 
     
     If the key is unknown, it is left open and will be filled in from the 
     standard gastronoom inputfile.
     
     @param comm_key: the name of the keyword in the command list
     @type comm_key: string
     @param star: The parameter set
     @type star: Star()
     @param key_type: the type of the keyword, either 'DUST' or 'GAS' 
     @type key_type: string
     
     @keyword star_key: the name of the keyword in the star instance 
                        (minus '_%s'%key_type, which is added as well in a 
                        second attempt if the first without the addition is 
                        not found), if None, it is equal to comm_key
                        
                        (default: None)
     @type star_key: string
     @keyword alternative: a default value passed from the standard 
                           inputfile that is used if the keyword or the 
                           keyword + '_%s'%key_type is not found in Star()
                            
                           (default: None)
     @type alternative: string
     @keyword make_int: make an integer before converting to string for this
                        keyword.
                        
                        (default: 0)
     @type make_int: boolean
     @keyword exp_not: Convert to exponential notation in a string
                       
                       (default: 0)
     @type exp_not: bool
     
     @return: True if successful, otherwise False.
     @rtype: bool
     
     ''' 
     
     if star_key is None: star_key = comm_key
     try:
         self.command_list[comm_key] = \
                     DataIO.inputToString(star[star_key],make_int,exp_not)
         return True
     except KeyError: 
         try:
             self.command_list[comm_key] = \
                     DataIO.inputToString(star[star_key+ '_%s'%key_type],\
                                          make_int,exp_not)
             return True
         except KeyError:
             if alternative <> None:
                 self.command_list[comm_key] = \
                     DataIO.inputToString(alternative,make_int,exp_not)
                 return True
             else:
                 return False
开发者ID:FungKu01,项目名称:ComboCode,代码行数:64,代码来源:ModelingSession.py


注:本文中的cc.tools.io.DataIO.inputToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。