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


Python Attributes.is_a_class_property_getter方法代码示例

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


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

示例1: __init__

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
    def __init__(self, service_name, name, procedures, documentation, sort):
        super(Class, self).__init__()
        self.service_name = service_name
        self.name = name
        self.fullname = service_name+'.'+name
        self.documentation = documentation
        self.cref = 'T:%s.%s' % (service_name, name)

        members = []
        properties = defaultdict(lambda: dict())

        for pname,pinfo in procedures.iteritems():

            #assert(Attributes.is_a_class_member(pinfo['attributes']))
            #assert(Attributes.get_class_name(pinfo['attributes']) == name)

            if Attributes.is_a_class_method(pinfo['attributes']):
                members.append(ClassMethod(service_name, name, pname, **pinfo))

            elif Attributes.is_a_class_static_method(pinfo['attributes']):
                members.append(ClassStaticMethod(service_name, name, pname, **pinfo))

            elif Attributes.is_a_class_property_accessor(pinfo['attributes']):
                propname = Attributes.get_class_property_name(pinfo['attributes'])
                proc = Procedure(service_name, pname, **pinfo)
                if Attributes.is_a_class_property_getter(pinfo['attributes']):
                    properties[propname]['getter'] = proc
                else:
                    properties[propname]['setter'] = proc

        for propname,prop in properties.iteritems():
            members.append(ClassProperty(service_name, name, propname, **prop))

        self.members = OrderedDict((member.name, member) for member in sorted(members, key=sort))
开发者ID:Kerbal007,项目名称:krpc,代码行数:36,代码来源:nodes.py

示例2: __init__

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
    def __init__(self, service_name, name, procedures, documentation):
        super(Class, self).__init__()
        self.service_name = service_name
        self.name = name
        self.fullname = service_name+'.'+name
        self.documentation = documentation
        self.cref = 'T:%s.%s' % (service_name, name)

        self.members = {}
        for pname,pinfo in procedures.items():
            if Attributes.is_a_class_member(pinfo['attributes']) and \
               Attributes.get_class_name(pinfo['attributes']) == name:
                if Attributes.is_a_class_method(pinfo['attributes']):
                    member = ClassMethod(service_name, name, pname, **pinfo)
                elif Attributes.is_a_class_static_method(pinfo['attributes']):
                    member = ClassStaticMethod(service_name, name, pname, **pinfo)
                else:
                    continue
                self.members[member.name] = member

        properties = {}
        for pname,pinfo in procedures.items():
            if Attributes.is_a_class_property_accessor(pinfo['attributes']):
                propname = Attributes.get_class_property_name(pinfo['attributes'])
                if propname not in properties:
                    properties[propname] = {}
                if Attributes.is_a_class_property_getter(pinfo['attributes']):
                    properties[propname]['getter'] = Procedure(service_name, pname, **pinfo)
                else:
                    properties[propname]['setter'] = Procedure(service_name, pname, **pinfo)
        for propname,prop in properties.items():
            prop = ClassProperty(service_name, name, propname, **prop)
            self.members[prop.name] = prop
开发者ID:artwhaley,项目名称:krpc,代码行数:35,代码来源:nodes.py

示例3: create_service

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
def create_service(client, service):
    """ Create a new service type """
    cls = type(str(service.name), (ServiceBase,), {'_client': client, '_name': service.name})

    # Add class types to service
    for cls2 in service.classes:
        cls._add_service_class(cls2)

    # Add enumeration types to service
    for enum in service.enumerations:
        cls._add_service_enumeration(enum)

    # Add procedures
    for procedure in service.procedures:
        if Attributes.is_a_procedure(procedure.attributes):
            cls._add_service_procedure(procedure)

    # Add properties
    properties = defaultdict(lambda: [None,None])
    for procedure in service.procedures:
        if Attributes.is_a_property_accessor(procedure.attributes):
            name = Attributes.get_property_name(procedure.attributes)
            if Attributes.is_a_property_getter(procedure.attributes):
                properties[name][0] = procedure
            else:
                properties[name][1] = procedure
    for name, procedures in properties.items():
        cls._add_service_property(name, procedures[0], procedures[1])

    # Add class methods
    for procedure in service.procedures:
        if Attributes.is_a_class_method(procedure.attributes):
            class_name = Attributes.get_class_name(procedure.attributes)
            method_name = Attributes.get_class_method_name(procedure.attributes)
            cls._add_service_class_method(class_name, method_name, procedure)

    # Add static class methods
    for procedure in service.procedures:
        if Attributes.is_a_class_static_method(procedure.attributes):
            class_name = Attributes.get_class_name(procedure.attributes)
            method_name = Attributes.get_class_method_name(procedure.attributes)
            cls._add_service_class_static_method(class_name, method_name, procedure)

    # Add class properties
    properties = defaultdict(lambda: [None,None])
    for procedure in service.procedures:
        if Attributes.is_a_class_property_accessor(procedure.attributes):
            class_name = Attributes.get_class_name(procedure.attributes)
            property_name = Attributes.get_class_property_name(procedure.attributes)
            key = (class_name, property_name)
            if Attributes.is_a_class_property_getter(procedure.attributes):
                properties[key][0] = procedure
            else:
                properties[key][1] = procedure
    for (class_name, property_name), procedures in properties.items():
        cls._add_service_class_property(class_name, property_name, procedures[0], procedures[1])

    return cls()
开发者ID:602p,项目名称:krpc,代码行数:60,代码来源:service.py

示例4: test_is_a_class_property_getter

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
 def test_is_a_class_property_getter(self):
     self.assertFalse(Attributes.is_a_class_property_getter([]))
     self.assertFalse(Attributes.is_a_class_property_getter(
         ['Property.Get(PropertyName)']))
     self.assertFalse(Attributes.is_a_class_property_getter(
         ['Property.Set(PropertyName)']))
     self.assertFalse(Attributes.is_a_class_property_getter(
         ['Class.Method(ServiceName.ClassName,MethodName)']))
     self.assertFalse(Attributes.is_a_class_property_getter(
         ['Class.StaticMethod(ServiceName.ClassName,MethodName)']))
     self.assertTrue(Attributes.is_a_class_property_getter(
         ['Class.Property.Get(ServiceName.ClassName,PropertyName)']))
     self.assertFalse(Attributes.is_a_class_property_getter(
         ['Class.Property.Set(ServiceName.ClassName,PropertyName)']))
开发者ID:paperclip,项目名称:krpc,代码行数:16,代码来源:test_attributes.py

示例5: generate_context

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]

#.........这里部分代码省略.........
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(
                            procedure['documentation'])
                    }
                context['properties'][property_name]['setter'] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'remote_id': procedure['id']
                }

            elif Attributes.is_a_class_method(name):
                class_name = Attributes.get_class_name(name)
                method_name = self.parse_name(
                    Attributes.get_class_member_name(name))
                params = self.generate_context_parameters(procedure)
                context['classes'][class_name]['methods'][method_name] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'remote_id': procedure['id'],
                    'parameters': params[1:],
                    'return_type': self.parse_return_type(
                        self.get_return_type(procedure)),
                    'documentation': self.parse_documentation(
                        procedure['documentation'])
                }

            elif Attributes.is_a_class_static_method(name):
                class_name = Attributes.get_class_name(name)
                cls = context['classes'][class_name]
                method_name = self.parse_name(
                    Attributes.get_class_member_name(name))
                cls['static_methods'][method_name] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'remote_id': procedure['id'],
                    'parameters': self.generate_context_parameters(
                        procedure),
                    'return_type': self.parse_return_type(
                        self.get_return_type(procedure)),
                    'documentation': self.parse_documentation(
                        procedure['documentation'])
                }

            elif Attributes.is_a_class_property_getter(name):
                class_name = Attributes.get_class_name(name)
                cls = context['classes'][class_name]
                property_name = self.parse_name(
                    Attributes.get_class_member_name(name))
                if property_name not in cls['properties']:
                    cls['properties'][property_name] = {
                        'type': self.parse_return_type(
                            self.get_return_type(procedure)),
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(
                            procedure['documentation'])
                    }
                cls['properties'][property_name]['getter'] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'remote_id': procedure['id']
                }

            elif Attributes.is_a_class_property_setter(name):
                class_name = Attributes.get_class_name(name)
                cls = context['classes'][class_name]
                property_name = self.parse_name(
                    Attributes.get_class_member_name(name))
                if property_name not in cls['properties']:
                    params = self.generate_context_parameters(procedure)
                    cls['properties'][property_name] = {
                        'type': params[1]['type'],
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(
                            procedure['documentation'])
                    }
                cls['properties'][property_name]['setter'] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'remote_id': procedure['id']
                }

        # Sort the context
        def sort_dict(x):
            return collections.OrderedDict(
                sorted(x.items(), key=lambda x: x[0]))

        context['procedures'] = sort_dict(context['procedures'])
        context['properties'] = sort_dict(context['properties'])
        context['enumerations'] = sort_dict(context['enumerations'])
        context['classes'] = sort_dict(context['classes'])
        context['exceptions'] = sort_dict(context['exceptions'])
        for cls in context['classes'].values():
            cls['methods'] = sort_dict(cls['methods'])
            cls['static_methods'] = sort_dict(cls['static_methods'])
            cls['properties'] = sort_dict(cls['properties'])

        return context
开发者ID:Loran425,项目名称:krpc,代码行数:104,代码来源:generator.py

示例6: generate_context

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
    def generate_context(self):
        procedures = {}
        properties = {}
        classes = {}
        enumerations = {}

        for name,cls in self._defs['classes'].items():
            classes[name] = {
                'methods': {},
                'static_methods': {},
                'properties': {},
                'documentation': self.parse_documentation(cls['documentation'])
            }

        for name,enumeration in self._defs['enumerations'].items():
            enumerations[name] = {
                'values': [{
                    'name': self.parse_name(x['name']),
                    'value': x['value'],
                    'documentation': self.parse_documentation(x['documentation'])
                } for x in enumeration['values']],
                'documentation': self.parse_documentation(enumeration['documentation'])
            }

        for name,procedure in self._defs['procedures'].items():

            if Attributes.is_a_procedure(procedure['attributes']):
                procedures[self.parse_name(name)] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'parameters': self.generate_context_parameters(procedure),
                    'return_type': self.parse_return_type(procedure),
                    'documentation': self.parse_documentation(procedure['documentation'])
                }

            elif Attributes.is_a_property_getter(procedure['attributes']):
                property_name = self.parse_name(Attributes.get_property_name(procedure['attributes']))
                if property_name not in properties:
                    properties[property_name] = {
                        'type': self.parse_return_type(procedure),
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(procedure['documentation'])
                    }
                properties[property_name]['getter'] = {
                    'procedure': procedure,
                    'remote_name': name
                }

            elif Attributes.is_a_property_setter(procedure['attributes']):
                property_name = self.parse_name(Attributes.get_property_name(procedure['attributes']))
                if property_name not in properties:
                    properties[property_name] = {
                        'type': self.generate_context_parameters(procedure)[0]['type'],
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(procedure['documentation'])
                    }
                properties[property_name]['setter'] = {
                    'procedure': procedure,
                    'remote_name': name
                }

            elif Attributes.is_a_class_method(procedure['attributes']):
                class_name = Attributes.get_class_name(procedure['attributes'])
                method_name = self.parse_name(Attributes.get_class_method_name(procedure['attributes']))
                classes[class_name]['methods'][method_name] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'parameters': self.generate_context_parameters(procedure)[1:],
                    'return_type': self.parse_return_type(procedure),
                    'documentation': self.parse_documentation(procedure['documentation'])
                }

            elif Attributes.is_a_class_static_method(procedure['attributes']):
                class_name = Attributes.get_class_name(procedure['attributes'])
                method_name = self.parse_name(Attributes.get_class_method_name(procedure['attributes']))
                classes[class_name]['static_methods'][method_name] = {
                    'procedure': procedure,
                    'remote_name': name,
                    'parameters': self.generate_context_parameters(procedure),
                    'return_type': self.parse_return_type(procedure),
                    'documentation': self.parse_documentation(procedure['documentation'])
                }

            elif Attributes.is_a_class_property_getter(procedure['attributes']):
                class_name = Attributes.get_class_name(procedure['attributes'])
                property_name = self.parse_name(Attributes.get_class_property_name(procedure['attributes']))
                if property_name not in classes[class_name]['properties']:
                    classes[class_name]['properties'][property_name] = {
                        'type': self.parse_return_type(procedure),
                        'getter': None,
                        'setter': None,
                        'documentation': self.parse_documentation(procedure['documentation'])
                    }
                classes[class_name]['properties'][property_name]['getter'] = {
                    'procedure': procedure,
                    'remote_name': name
                }

#.........这里部分代码省略.........
开发者ID:Kerbal007,项目名称:krpc,代码行数:103,代码来源:generator.py

示例7: generate_context

# 需要导入模块: from krpc.attributes import Attributes [as 别名]
# 或者: from krpc.attributes.Attributes import is_a_class_property_getter [as 别名]
    def generate_context(self):
        procedures = {}
        properties = {}
        classes = {}
        enumerations = {}

        for name, cls in self._defs["classes"].items():
            classes[name] = {
                "methods": {},
                "static_methods": {},
                "properties": {},
                "documentation": self.parse_documentation(cls["documentation"]),
            }

        for name, enumeration in self._defs["enumerations"].items():
            enumerations[name] = {
                "values": [
                    {
                        "name": self.parse_name(x["name"]),
                        "value": x["value"],
                        "documentation": self.parse_documentation(x["documentation"]),
                    }
                    for x in enumeration["values"]
                ],
                "documentation": self.parse_documentation(enumeration["documentation"]),
            }

        for name, procedure in self._defs["procedures"].items():

            if Attributes.is_a_procedure(procedure["attributes"]):
                procedures[self.parse_name(name)] = {
                    "procedure": procedure,
                    "remote_name": name,
                    "parameters": self.generate_context_parameters(procedure),
                    "return_type": self.parse_return_type(procedure),
                    "documentation": self.parse_documentation(procedure["documentation"]),
                }

            elif Attributes.is_a_property_getter(procedure["attributes"]):
                property_name = self.parse_name(Attributes.get_property_name(procedure["attributes"]))
                if property_name not in properties:
                    properties[property_name] = {
                        "type": self.parse_return_type(procedure),
                        "getter": None,
                        "setter": None,
                        "documentation": self.parse_documentation(procedure["documentation"]),
                    }
                properties[property_name]["getter"] = {"procedure": procedure, "remote_name": name}

            elif Attributes.is_a_property_setter(procedure["attributes"]):
                property_name = self.parse_name(Attributes.get_property_name(procedure["attributes"]))
                if property_name not in properties:
                    properties[property_name] = {
                        "type": self.generate_context_parameters(procedure)[0]["type"],
                        "getter": None,
                        "setter": None,
                        "documentation": self.parse_documentation(procedure["documentation"]),
                    }
                properties[property_name]["setter"] = {"procedure": procedure, "remote_name": name}

            elif Attributes.is_a_class_method(procedure["attributes"]):
                class_name = Attributes.get_class_name(procedure["attributes"])
                method_name = self.parse_name(Attributes.get_class_method_name(procedure["attributes"]))
                classes[class_name]["methods"][method_name] = {
                    "procedure": procedure,
                    "remote_name": name,
                    "parameters": self.generate_context_parameters(procedure)[1:],
                    "return_type": self.parse_return_type(procedure),
                    "documentation": self.parse_documentation(procedure["documentation"]),
                }

            elif Attributes.is_a_class_static_method(procedure["attributes"]):
                class_name = Attributes.get_class_name(procedure["attributes"])
                method_name = self.parse_name(Attributes.get_class_method_name(procedure["attributes"]))
                classes[class_name]["static_methods"][method_name] = {
                    "procedure": procedure,
                    "remote_name": name,
                    "parameters": self.generate_context_parameters(procedure),
                    "return_type": self.parse_return_type(procedure),
                    "documentation": self.parse_documentation(procedure["documentation"]),
                }

            elif Attributes.is_a_class_property_getter(procedure["attributes"]):
                class_name = Attributes.get_class_name(procedure["attributes"])
                property_name = self.parse_name(Attributes.get_class_property_name(procedure["attributes"]))
                if property_name not in classes[class_name]["properties"]:
                    classes[class_name]["properties"][property_name] = {
                        "type": self.parse_return_type(procedure),
                        "getter": None,
                        "setter": None,
                        "documentation": self.parse_documentation(procedure["documentation"]),
                    }
                classes[class_name]["properties"][property_name]["getter"] = {
                    "procedure": procedure,
                    "remote_name": name,
                }

            elif Attributes.is_a_class_property_setter(procedure["attributes"]):
                class_name = Attributes.get_class_name(procedure["attributes"])
                property_name = self.parse_name(Attributes.get_class_property_name(procedure["attributes"]))
#.........这里部分代码省略.........
开发者ID:artwhaley,项目名称:krpc,代码行数:103,代码来源:generator.py


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