boto / boto

For the latest version of boto, see https://github.com/boto/boto3 -- Python interface to Amazon Web Services
http://docs.pythonboto.org/
Other
6.48k stars 2.26k forks source link

Switch to new-style classes #1918

Closed glasserc closed 10 years ago

glasserc commented 10 years ago

Most classes in boto are old-style, meaning that super calls are implemented using Class.method(self), instead of the more modern super(Class, self).method(). Old-style classes are deprecated and no longer supported in Python 3, and are always surprising to experienced Python programmers.

toastdriven commented 10 years ago

I've been meaning to do this for months & just haven't gotten there, but I'd love to bite this off. Assigning to me.

toastdriven commented 10 years ago

The following is a list of places we use old-style classes:

auth.py:        class Faker:
cloudformation/template.py:class Template:
cloudformation/template.py:class TemplateParameter:
cloudfront/identity.py:class OriginAccessIdentity:
cloudfront/identity.py:class OriginAccessIdentityConfig:
cloudfront/identity.py:class OriginAccessIdentitySummary:
cloudfront/signers.py:class Signer:
ec2/group.py:class Group:
ec2/image.py:class ImageAttribute:
ec2/instance.py:class ConsoleOutput:
ec2/snapshot.py:class SnapshotAttribute:
ec2/volume.py:class VolumeAttribute:
exception.py:class ConsoleOutput:
exception.py:class _EC2Error:
gs/bucketlistresultset.py:class VersionedBucketListResultSet:
gs/connection.py:class Location:
gs/user.py:class User:
mturk/connection.py:class BaseAutoResultElement:
mturk/layoutparam.py:class LayoutParameters:
mturk/notification.py:class NotificationMessage:
mturk/notification.py:class Event:
mturk/price.py:class Price:
mturk/qualification.py:class Qualifications:
mturk/question.py:class XMLTemplate:
pyami/scriptbase.py:class ScriptBase:
roboto/awsqueryrequest.py:class Encoder:
s3/acl.py:class Policy:
s3/acl.py:class ACL:
s3/acl.py:class Grant:
s3/bucket.py:class S3WebsiteEndpointTranslate:
s3/bucketlistresultset.py:class BucketListResultSet:
s3/bucketlistresultset.py:class VersionedBucketListResultSet:
s3/bucketlistresultset.py:class MultiPartUploadListResultSet:
s3/bucketlogging.py:class BucketLogging:
s3/connection.py:class Location:
s3/deletemarker.py:class DeleteMarker:
s3/user.py:class User:
sdb/db/manager/xmlmanager.py:class XMLConverter:
sdb/domain.py:class Domain:
sdb/domain.py:class DomainMetaData:
sdb/queryresultset.py:class QueryResultSet:
services/result.py:class ResultProcessor:
services/submit.py:class Submitter:
sqs/message.py:class RawMessage:
sqs/queue.py:class Queue:
swf/layer1_decisions.py:class Layer1Decisions:

I have a branch started to convert these. Once I have these changed & tests are passing, I'll submit a PR & link it up here.

glasserc commented 10 years ago

You might also want to convert old-style super calls to new-style ones. I can open another issue for that if you'd like.

toastdriven commented 10 years ago

Slightly less trivial to cover all of those. The list of places:

boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: HmacKeys.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: HmacKeys.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: HmacKeys.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: HmacKeys.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, host, config, provider)
boto/auth.py: AuthHandler.__init__(self, *args, **kw)
boto/connection.py: httplib.HTTPResponse.__init__(self, *args, **kwargs)
boto/connection.py: self._cached_response = httplib.HTTPResponse.read(self)
boto/connection.py: return httplib.HTTPResponse.read(self, amt)
boto/connection.py: AWSAuthConnection.__init__(self, host, aws_access_key_id,
boto/exception.py: StandardError.__init__(self, reason, *args)
boto/exception.py: StandardError.__init__(self, status, reason, body, *args)
boto/exception.py: BotoServerError.__init__(self, status, reason, body)
boto/exception.py: return BotoServerError.endElement(self, name, value, connection)
boto/exception.py: BotoServerError.__init__(self, status, reason, body)
boto/exception.py: return BotoServerError.startElement(self, name, attrs, connection)
boto/exception.py: return BotoServerError.endElement(self, name, value, connection)
boto/exception.py: BotoServerError._cleanupParsedProperties(self)
boto/exception.py: BotoClientError.__init__(self, reason, message)
boto/exception.py: BotoServerError.__init__(self, status, reason, body)
boto/exception.py: return BotoServerError.startElement(self, name, attrs, connection)
boto/exception.py: return BotoServerError.endElement(self, name, value, connection)
boto/exception.py: BotoServerError._cleanupParsedProperties(self)
boto/exception.py: BotoServerError.__init__(self, status, reason, body)
boto/exception.py: BotoServerError._cleanupParsedProperties(self)
boto/exception.py: Exception.__init__(self, message)
boto/exception.py: Exception.__init__(self, message)
boto/exception.py: Exception.__init__(self, message)
boto/exception.py: Exception.__init__(self, message)
boto/exception.py: Exception.__init__(self, message, disposition)
boto/exception.py: Exception.__init__(self, message, disposition)
boto/exception.py: Exception.__init__(self, message)
boto/https_connection.py: httplib.HTTPException.__init__(self)
boto/https_connection.py: httplib.HTTPConnection.__init__(self, host, port, strict, **kwargs)
boto/utils.py: logging.handlers.SMTPHandler.__init__(self, mailhost, fromaddr,
boto/beanstalk/layer1.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/cloudformation/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/cloudfront/__init__.py: AWSAuthConnection.__init__(self, host,
boto/cloudfront/distribution.py: DistributionConfig.__init__(self, connection=connection,
boto/cloudfront/distribution.py: Distribution.__init__(self, connection, config, domain_name,
boto/cloudfront/distribution.py: return Distribution.startElement(self, name, attrs, connection)
boto/cloudfront/object.py: Key.__init__(self, bucket, name=name)
boto/cloudfront/object.py: return Object.url(self, scheme)
boto/cloudtrail/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/contrib/ymlmessage.py: Message.__init__(self, queue, body)
boto/datapipeline/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/directconnect/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/dynamodb/layer1.py: AWSAuthConnection.__init__(self, self.region.endpoint,
boto/dynamodb/layer2.py: return Table.create_from_schema(self, name, schema)
boto/dynamodb2/fields.py: IncludeIndex.__init__(self, *args, **kwargs)
boto/dynamodb2/fields.py: GlobalBaseIndexField.__init__(self, *args, **kwargs)
boto/dynamodb2/fields.py: schema_data = IncludeIndex.schema(self)
boto/dynamodb2/fields.py: schema_data.update(GlobalBaseIndexField.schema(self))
boto/dynamodb2/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/ec2/address.py: EC2Object.__init__(self, connection)
boto/ec2/bundleinstance.py: EC2Object.__init__(self, connection)
boto/ec2/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/ec2/ec2object.py: EC2Object.__init__(self, connection)
boto/ec2/image.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/image.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/instance.py: EC2Object.__init__(self, connection)
boto/ec2/instance.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/instance.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/keypair.py: EC2Object.__init__(self, connection)
boto/ec2/launchspecification.py: EC2Object.__init__(self, connection)
boto/ec2/networkinterface.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/networkinterface.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/placementgroup.py: EC2Object.__init__(self, connection)
boto/ec2/regioninfo.py: RegionInfo.__init__(self, connection, name, endpoint,
boto/ec2/reservedinstance.py: EC2Object.__init__(self, connection)
boto/ec2/reservedinstance.py: ReservedInstancesOffering.__init__(self, connection, id, instance_type,
boto/ec2/reservedinstance.py: ReservedInstancesOffering.endElement(self, name, value, connection)
boto/ec2/securitygroup.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/securitygroup.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/snapshot.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/spotdatafeedsubscription.py: EC2Object.__init__(self, connection)
boto/ec2/spotinstancerequest.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/spotinstancerequest.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/spotpricehistory.py: EC2Object.__init__(self, connection)
boto/ec2/vmtype.py: EC2Object.__init__(self, connection)
boto/ec2/volume.py: TaggedEC2Object.__init__(self, connection)
boto/ec2/volume.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/zone.py: EC2Object.__init__(self, connection)
boto/ecs/__init__.py: AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
boto/ecs/item.py: ResponseGroup.__init__(self, connection, "Item")
boto/ecs/item.py: ResponseGroup.__init__(self, connection, "Items")
boto/ecs/item.py: return ResponseGroup.to_xml(self)
boto/elasticache/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/elastictranscoder/layer1.py: AWSAuthConnection.__init__(self, **kwargs)
boto/emr/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/emr/step.py: JarStep.__init__(self, name, self.ScriptRunnerJar, **kw)
boto/emr/step.py: ScriptRunnerStep.__init__(self, self.InstallPigName, step_args=step_args)
boto/emr/step.py: ScriptRunnerStep.__init__(self, name, step_args=step_args)
boto/emr/step.py: ScriptRunnerStep.__init__(self, self.InstallHiveName,
boto/emr/step.py: ScriptRunnerStep.__init__(self, name, step_args=step_args)
boto/fps/connection.py: AWSQueryConnection.__init__(self, *args, **kw)
boto/fps/response.py: Response.endElement(self, name, value, connection)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: ResponseElement.endElement(self, name, value, connection)
boto/fps/response.py: return AmountCollection.startElement(self, name, attrs, connection)
boto/fps/response.py: return Response.startElement(self, name, attrs, connection)
boto/fps/response.py: return Response.startElement(self, name, attrs, connection)
boto/fps/response.py: return Response.startElement(self, name, attrs, connection)
boto/fps/response.py: return Response.startElement(self, name, attrs, connection)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: ResponseElement.__init__(self, *args, **kw)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: ResponseElement.__init__(self, *args, **kw)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/fps/response.py: ResponseElement.__init__(self, *args, **kw)
boto/fps/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/glacier/layer1.py: AWSAuthConnection.__init__(self, region.endpoint,
boto/glacier/layer1.py: response = AWSAuthConnection.make_request(self, verb, uri,
boto/gs/connection.py: S3Connection.__init__(self, gs_access_key_id, gs_secret_access_key,
boto/iam/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/kinesis/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/manage/server.py: Model.__init__(self, id, **kw)
boto/manage/server.py: Model.put(self)
boto/manage/server.py: Model.delete(self)
boto/manage/task.py: Model.__init__(self, id, **kw)
boto/manage/volume.py: Model.delete(self)
boto/mashups/server.py: Model.__init__(self, id, **kw)
boto/mturk/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/mturk/connection.py: BaseAutoResultElement.__init__(self, connection)
boto/mturk/connection.py: BaseAutoResultElement.endElement(self, name, value, connection)
boto/mturk/connection.py: BaseAutoResultElement.__init__(self, connection)
boto/mturk/connection.py: BaseAutoResultElement.endElement(self, name, value, connection)
boto/mturk/connection.py: BaseAutoResultElement.__init__(self, connection)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="00000000000000000000", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="00000000000000000070", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="000000000000000000E0", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="000000000000000000L0", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="00000000000000000071", comparator=comparator, integer_value=None, required_to_preview=required_to_preview)
boto/mturk/qualification.py: Requirement.__init__(self, qualification_type_id="00000000000000000060", comparator=comparator, integer_value=integer_value, required_to_preview=required_to_preview)
boto/mws/connection.py: AWSQueryConnection.__init__(self, *args, **kw)
boto/mws/response.py: DeclarativeType.__init__(self, *args, **kw)
boto/mws/response.py: Element.__init__(self, *args, member=ElementList(**kw))
boto/mws/response.py: Element.__init__(self, _hint=_hint)
boto/mws/response.py: Element.__init__(self, *args, member=member)
boto/mws/response.py: Element.teardown(self, *args, **kw)
boto/mws/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/mws/response.py: Response.__init__(self, *args, **kw)
boto/mws/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/mws/response.py: ResponseElement.endElement(self, name, value, connection)
boto/mws/response.py: return ResponseElement.startElement(self, name, attrs, connection)
boto/mws/response.py: ResponseElement.endElement(self, name, value, connection)
boto/mws/response.py: ResponseElement.endElement(self, name, value, connection)
boto/mws/response.py: AttributeSet.__init__(self, *args, **kw)
boto/mws/response.py: ResponseElement.__init__(self, *args, **kw)
boto/opsworks/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/pyami/bootstrap.py: ScriptBase.__init__(self)
boto/pyami/config.py: ConfigParser.SafeConfigParser.__init__(self, {'working_dir' : '/mnt/pyami',
boto/pyami/config.py: val = ConfigParser.SafeConfigParser.get(self, section, name)
boto/pyami/config.py: val = ConfigParser.SafeConfigParser.getint(self, section, name)
boto/pyami/config.py: val = ConfigParser.SafeConfigParser.getfloat(self, section, name)
boto/pyami/copybot.py: ScriptBase.__init__(self)
boto/rds/__init__.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/rds/regioninfo.py: RegionInfo.__init__(self, connection, name, endpoint,
boto/redshift/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/roboto/awsqueryrequest.py: boto.exception.BotoClientError.__init__(self, s)
boto/roboto/awsqueryrequest.py: boto.exception.BotoClientError.__init__(self, s)
boto/roboto/awsqueryrequest.py: boto.exception.BotoClientError.__init__(self, s)
boto/roboto/awsqueryservice.py: boto.exception.BotoClientError.__init__(self, s)
boto/roboto/awsqueryservice.py: boto.connection.AWSQueryConnection.__init__(self, **self.args)
boto/roboto/param.py: return Converter.convert(self, value)
boto/route53/connection.py: AWSAuthConnection.__init__(self, host,
boto/route53/connection.py: return AWSAuthConnection.make_request(self, action, path,
boto/route53/record.py: ResultSet.__init__(self, [('ResourceRecordSet', Record)])
boto/route53/record.py: return ResultSet.endElement(self, name, value, connection)
boto/route53/record.py: results = ResultSet.__iter__(self)
boto/s3/bucket.py: l.append(S3WebsiteEndpointTranslate.translate_region(self.get_location()))
boto/s3/connection.py: AWSAuthConnection.__init__(self, host,
boto/sdb/connection.py: threading.Thread.__init__(self, name=name)
boto/sdb/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/sdb/domain.py: Thread.__init__(self)
boto/sdb/regioninfo.py: RegionInfo.__init__(self, connection, name, endpoint,
boto/services/service.py: ScriptBase.__init__(self, config_file)
boto/services/servicedef.py: Config.__init__(self, config_file)
boto/services/servicedef.py: script = Config.get(self, 'Pyami', 'scripts')
boto/services/servicedef.py: return Config.get(self, self.name, name, default)
boto/services/servicedef.py: return Config.has_option(self, self.name, option)
boto/services/servicedef.py: val = Config.get(self, self.name, option)
boto/services/servicedef.py: val = Config.get(self, self.name, option)
boto/services/sonofmmm.py: Service.__init__(self, config_file)
boto/services/sonofmmm.py: Service.shutdown(self)
boto/ses/connection.py: AWSAuthConnection.__init__(self, self.region.endpoint,
boto/sns/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/sqs/bigmessage.py: RawMessage.__init__(self, queue, body)
boto/sqs/bigmessage.py: RawMessage.delete(self)
boto/sqs/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/sqs/message.py: Message.__init__(self, queue, body)
boto/sqs/message.py: return MHMessage.decode(self, value)
boto/sqs/message.py: value = MHMessage.encode(self, value)
boto/sqs/regioninfo.py: RegionInfo.__init__(self, connection, name, endpoint,
boto/sts/connection.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/support/layer1.py: AWSQueryConnection.__init__(self, **kwargs)
boto/swf/layer1.py: AWSAuthConnection.__init__(self, self.region.endpoint,
boto/vpc/customergateway.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/dhcpoptions.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/dhcpoptions.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/vpc/internetgateway.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/networkacl.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/routetable.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/subnet.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/vpc.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/vpnconnection.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/vpngateway.py: TaggedEC2Object.__init__(self, connection)
boto/vpc/vpngateway.py: retval = TaggedEC2Object.startElement(self, name, attrs, connection)
boto/ec2/autoscale/__init__.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/ec2/cloudwatch/__init__.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/ec2/elb/__init__.py: AWSQueryConnection.__init__(self, aws_access_key_id,
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required,
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required,
boto/sdb/db/property.py: StringProperty.__init__(self, verbose_name, name, default, required,
boto/sdb/db/property.py: value = StringProperty.get_value_for_datastore(self, model_instance)
boto/sdb/db/property.py: Property.__set__(self, obj, value)
boto/sdb/db/property.py: return self.data_type(StringProperty.__get__(self, obj, objtype), hashfunc=self.hashfunc)
boto/sdb/db/property.py: value = Property.validate(self, value)
boto/sdb/db/property.py: Property.__set__(self, obj, value)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required,
boto/sdb/db/property.py: value = Property.__get__(self, obj, objtype)
boto/sdb/db/property.py: value = Property.get_value_for_datastore(self, model_instance)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: value = Property.validate(self, value)
boto/sdb/db/property.py: return Property.__set__(self, obj, value)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: value = Property.validate(self, value)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: value = Property.validate(self, value)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: return Property.default_value(self)
boto/sdb/db/property.py: return Property.get_value_for_datastore(self, model_instance)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: return Property.default_value(self)
boto/sdb/db/property.py: val = Property.get_value_for_datastore(self, model_instance)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required, validator, choices, unique)
boto/sdb/db/property.py: Property.__property_config__(self, model_class, property_name)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default, required,
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default=default, required=True, **kwds)
boto/sdb/db/property.py: Property.__init__(self, verbose_name, name, default=default, required=True, **kwds)
boto/pyami/installers/ubuntu/ebs.py: Installer.__init__(self, config_file)
glasserc commented 10 years ago

Yikes, I'd hate to see the awk command that generated that :)

toastdriven commented 10 years ago

No awk, just a little Python. :grinning: https://gist.github.com/toastdriven/8051408