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


Python DotDict.update方法代码示例

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


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

示例1: lookup_associations

# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update [as 别名]
 def lookup_associations(self, classname):
     from pyon.util.config import Config
     from pyon.util.containers import DotDict
     Predicates = DotDict()
     Predicates.update(Config(["res/config/associations.yml"]).data['PredicateTypes'])
     output = {}
     for key in Predicates:
         domain = str(Predicates[key]["domain"])
         range = str(Predicates[key]["range"])
         if classname in domain:
             output[key] = Predicates[key]
         if classname in range:
             output[key] = Predicates[key]
     return output
开发者ID:oldpatricka,项目名称:pyon,代码行数:16,代码来源:object_model_generator.py

示例2: __init__

# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update [as 别名]

#.........这里部分代码省略.........
            row[0] = obj_types.get(row[1], "")
        # The following was requested by Karen S: Need to associate a persistent identifier for a known
        # object type, attribute name combination
        objattr_ids = {}
        objid_filename = "res/config/object_attribute_ids.csv"
        try:
            if os.path.exists(objid_filename):
                with open(objid_filename, "rU") as csvfile:
                    idreader = csv.DictReader(csvfile, delimiter=',')
                    for row in idreader:
                        oname, aname, refid = row['YML Resource Type'], row['YML Name'], row['__pk_ResourceAttribute_ID']
                        objattr_ids[(oname, aname)] = refid

                for row in self.csv_attributes_row_entries:
                    row[3] = objattr_ids.get((row[1], row[2]), "")
        except Exception as ex:
            print "ERROR reading object/attribute mapping file", objid_filename, ex

        print " Writing object attribute csv to '" + objectattrscsvfile + "'"
        csv_file = csv.writer(open(objectattrscsvfile, 'wb'), delimiter=',',
            quotechar='"', quoting=csv.QUOTE_ALL)
        csv_file.writerow(["object class", "object type", "attribute name", "ref id", "attribute type", "attribute default", "description"])
        csv_file.writerows(self.csv_attributes_row_entries)

    def _lookup_associations(self, classname):
        """
        Returns dict of associations for given object type (not base types)
        """
        from pyon.util.config import Config
        from pyon.util.containers import DotDict
        if not self._associations:
            self._associations = DotDict()
            assoc_defs = Config(["res/config/associations.yml"]).data['AssociationDefinitions']
            self._associations.update((ad['predicate'], ad) for ad in assoc_defs)
        output = {}
        for key in self._associations:
            domain = str(self._associations[key]["domain"])
            range = str(self._associations[key]["range"])
            if classname in domain or classname in range:
                output[key] = self._associations[key]
        return output

    # Determine if class is object or resource or event
    def _get_class_type(self, clzzname):
        while clzzname != "IonObjectBase":
            if clzzname == "Resource":
                return "resource"
            elif clzzname == "Event":
                return "event"
            clzzname = self.class_args_dict[clzzname]["extends"]
        return "object"

    def convert_val(self, value):
        """
        Recursively generates right hand value for a class attribute.
        """
        if isinstance(value, list):
            outline = '['
            first_time = True
            for val in value:
                if first_time:
                    first_time = False
                else:
                    outline += ", "
                outline += self.convert_val(val)
            outline += ']'
开发者ID:swarbhanu,项目名称:pyon,代码行数:70,代码来源:object_model_generator.py

示例3: DotDict

# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import update [as 别名]
ObjectTypes = DotDict()
OT = ObjectTypes

# Resource Types
ResourceTypes = DotDict()
RT = ResourceTypes

# Predicate Types
Predicates = DotDict()
PredicateType = DotDict()
PRED = PredicateType

# Association Types, don't confuse with predicate type!
AssociationTypes = ['H2H', 'R2R', 'H2R', 'R2H']
AssociationType = DotDict()
AssociationType.update(zip(AssociationTypes, AssociationTypes))
AT = AssociationType

#Compound Associations
CompoundAssociations = DotDict()


# Life cycle states
LifeCycleStates = DotDict()
LCS = LifeCycleStates
LCS_NONE = "NONE"

# Life cycle events
LCE = DotDict()

lcs_workflow_defs = {}
开发者ID:swarbhanu,项目名称:pyon,代码行数:33,代码来源:resource.py


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