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


Python XML.findtext方法代码示例

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


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

示例1: _parse_versioning_config

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def _parse_versioning_config(self, xml_bytes):
        """Parse a C{VersioningConfiguration} XML document."""
        root = XML(xml_bytes)
        mfa_delete = root.findtext("MfaDelete")
        status = root.findtext("Status")

        return VersioningConfiguration(mfa_delete=mfa_delete, status=status)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:client.py

示例2: _parse_website_config

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def _parse_website_config(self, xml_bytes):
        """Parse a C{WebsiteConfiguration} XML document."""
        root = XML(xml_bytes)
        index_suffix = root.findtext("IndexDocument/Suffix")
        error_key = root.findtext("ErrorDocument/Key")

        return WebsiteConfiguration(index_suffix, error_key)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:client.py

示例3: _parse_get_bucket

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def _parse_get_bucket(self, xml_bytes):
        root = XML(xml_bytes)
        name = root.findtext("Name")
        prefix = root.findtext("Prefix")
        marker = root.findtext("Marker")
        max_keys = root.findtext("MaxKeys")
        is_truncated = root.findtext("IsTruncated")
        contents = []

        for content_data in root.findall("Contents"):
            key = content_data.findtext("Key")
            date_text = content_data.findtext("LastModified")
            modification_date = parseTime(date_text)
            etag = content_data.findtext("ETag")
            size = content_data.findtext("Size")
            storage_class = content_data.findtext("StorageClass")
            owner_id = content_data.findtext("Owner/ID")
            owner_display_name = content_data.findtext("Owner/DisplayName")
            owner = ItemOwner(owner_id, owner_display_name)
            content_item = BucketItem(key, modification_date, etag, size,
                                      storage_class, owner)
            contents.append(content_item)

        common_prefixes = []
        for prefix_data in root.findall("CommonPrefixes"):
            common_prefixes.append(prefix_data.text)

        return BucketListing(name, prefix, marker, max_keys, is_truncated,
                             contents, common_prefixes)
开发者ID:ArtRichards,项目名称:txaws,代码行数:31,代码来源:client.py

示例4: _parse_create_snapshot

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
 def _parse_create_snapshot(self, xml_bytes):
     root = XML(xml_bytes)
     snapshot_id = root.findtext("snapshotId")
     volume_id = root.findtext("volumeId")
     status = root.findtext("status")
     start_time = root.findtext("startTime")
     start_time = datetime.strptime(start_time[:19], "%Y-%m-%dT%H:%M:%S")
     progress = root.findtext("progress")[:-1]
     progress = float(progress or "0") / 100.0
     return model.Snapshot(snapshot_id, volume_id, status, start_time, progress)
开发者ID:lzimm,项目名称:360io,代码行数:12,代码来源:client.py

示例5: import_keypair

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def import_keypair(self, xml_bytes, key_material):
        """Extract the key name and the fingerprint from the result.

        TODO: there is no corresponding method in the 2009-11-30 version
             of the ec2 wsdl. Delete this?
        """
        keypair_data = XML(xml_bytes)
        key_name = keypair_data.findtext("keyName")
        key_fingerprint = keypair_data.findtext("keyFingerprint")
        return model.Keypair(key_name, key_fingerprint, key_material)
开发者ID:antisvin,项目名称:txAWS,代码行数:12,代码来源:client.py

示例6: from_xml

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def from_xml(cls, xml_bytes):
        """
        Create an instance of this from XML bytes.

        @param xml_bytes: C{str} bytes of XML to parse
        @return: an instance of L{MultipartInitiationResponse}
        """
        root = XML(xml_bytes)
        return cls(root.findtext('Bucket'),
                   root.findtext('Key'),
                   root.findtext('UploadId'))
开发者ID:mithrandi,项目名称:txaws,代码行数:13,代码来源:model.py

示例7: create_keypair

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def create_keypair(self, xml_bytes):
        """Parse the XML returned by the C{CreateKeyPair} function.

        @param xml_bytes: XML bytes with a C{CreateKeyPairResponse} root
            element.
        @return: The L{Keypair} instance created.
        """
        keypair_data = XML(xml_bytes)
        key_name = keypair_data.findtext("keyName")
        key_fingerprint = keypair_data.findtext("keyFingerprint")
        key_material = keypair_data.findtext("keyMaterial")
        return model.Keypair(key_name, key_fingerprint, key_material)
开发者ID:antisvin,项目名称:txAWS,代码行数:14,代码来源:client.py

示例8: attach_volume

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def attach_volume(self, xml_bytes):
        """Parse the XML returned by the C{AttachVolume} function.

        @param xml_bytes: XML bytes with a C{AttachVolumeResponse} root
            element.
        @return: a C{dict} with status and attach_time keys.
        """
        root = XML(xml_bytes)
        status = root.findtext("status")
        attach_time = root.findtext("attachTime")
        attach_time = datetime.strptime(
            attach_time[:19], "%Y-%m-%dT%H:%M:%S")
        return {"status": status, "attach_time": attach_time}
开发者ID:ArtRichards,项目名称:txaws,代码行数:15,代码来源:client.py

示例9: _parse_notification_config

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def _parse_notification_config(self, xml_bytes):
        """Parse a C{NotificationConfiguration} XML document."""
        root = XML(xml_bytes)
        topic = root.findtext("TopicConfiguration/Topic")
        event = root.findtext("TopicConfiguration/Event")

        return NotificationConfiguration(topic, event)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:client.py

示例10: truth_return

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def truth_return(self, xml_bytes):
        """Parse the XML for a truth value.

        @param xml_bytes: XML bytes.
        @return: True if the node contains "return" otherwise False.
        """
        root = XML(xml_bytes)
        return root.findtext("return") == "true"
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:client.py

示例11: allocate_address

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def allocate_address(self, xml_bytes):
        """Parse the XML returned by the C{AllocateAddress} function.

        @param xml_bytes: XML bytes with a C{AllocateAddress} root element.
        @return: The public ip address as a string.
        """
        address_data = XML(xml_bytes)
        return address_data.findtext("publicIp")
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:client.py

示例12: create_snapshot

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def create_snapshot(self, xml_bytes):
        """Parse the XML returned by the C{CreateSnapshot} function.

        @param xml_bytes: XML bytes with a C{CreateSnapshotResponse} root
            element.
        @return: The L{Snapshot} instance created.
        """
        root = XML(xml_bytes)
        snapshot_id = root.findtext("snapshotId")
        volume_id = root.findtext("volumeId")
        status = root.findtext("status")
        start_time = root.findtext("startTime")
        start_time = datetime.strptime(
            start_time[:19], "%Y-%m-%dT%H:%M:%S")
        progress = root.findtext("progress")[:-1]
        progress = float(progress or "0") / 100.
        return model.Snapshot(
            snapshot_id, volume_id, status, start_time, progress)
开发者ID:ArtRichards,项目名称:txaws,代码行数:20,代码来源:client.py

示例13: _parse_run_instances

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
 def _parse_run_instances(self, xml_bytes):
     """
     Parse the reservations XML payload that is returned from an AWS
     RunInstances API call.
     """
     root = XML(xml_bytes)
     # Get the security group information.
     groups = []
     for group_data in root.find("groupSet"):
         group_id = group_data.findtext("groupId")
         groups.append(group_id)
     # Create a reservation object with the parsed data.
     reservation = model.Reservation(
         reservation_id=root.findtext("reservationId"), owner_id=root.findtext("ownerId"), groups=groups
     )
     # Get the list of instances.
     instances = self._parse_instances_set(root, reservation)
     return instances
开发者ID:lzimm,项目名称:360io,代码行数:20,代码来源:client.py

示例14: _parse_create_volume

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
 def _parse_create_volume(self, xml_bytes):
     root = XML(xml_bytes)
     volume_id = root.findtext("volumeId")
     size = int(root.findtext("size"))
     status = root.findtext("status")
     create_time = root.findtext("createTime")
     availability_zone = root.findtext("availabilityZone")
     snapshot_id = root.findtext("snapshotId")
     create_time = datetime.strptime(create_time[:19], "%Y-%m-%dT%H:%M:%S")
     volume = model.Volume(volume_id, size, status, create_time, availability_zone, snapshot_id)
     return volume
开发者ID:lzimm,项目名称:360io,代码行数:13,代码来源:client.py

示例15: create_volume

# 需要导入模块: from txaws.util import XML [as 别名]
# 或者: from txaws.util.XML import findtext [as 别名]
    def create_volume(self, xml_bytes):
        """Parse the XML returned by the C{CreateVolume} function.

        @param xml_bytes: XML bytes with a C{CreateVolumeResponse} root
            element.
        @return: The L{Volume} instance created.
        """
        root = XML(xml_bytes)
        volume_id = root.findtext("volumeId")
        size = int(root.findtext("size"))
        snapshot_id = root.findtext("snapshotId")
        availability_zone = root.findtext("availabilityZone")
        status = root.findtext("status")
        create_time = root.findtext("createTime")
        create_time = datetime.strptime(
            create_time[:19], "%Y-%m-%dT%H:%M:%S")
        volume = model.Volume(
            volume_id, size, status, create_time, availability_zone,
            snapshot_id)
        return volume
开发者ID:antisvin,项目名称:txAWS,代码行数:22,代码来源:client.py


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