Kaydet (Commit) a8aefe53 authored tarafından Neil Schemenauer's avatar Neil Schemenauer

Don't use dir() to find instance attribute names.

üst 49417e76
...@@ -122,9 +122,7 @@ class Distribution: ...@@ -122,9 +122,7 @@ class Distribution:
# worth it. Also delegate 'get_XXX()' methods to the 'metadata' # worth it. Also delegate 'get_XXX()' methods to the 'metadata'
# object in a sneaky and underhanded (but efficient!) way. # object in a sneaky and underhanded (but efficient!) way.
self.metadata = DistributionMetadata() self.metadata = DistributionMetadata()
method_basenames = dir(self.metadata) + \ for basename in self.metadata._METHOD_BASENAMES:
['fullname', 'contact', 'contact_email']
for basename in method_basenames:
method_name = "get_" + basename method_name = "get_" + basename
setattr(self, method_name, getattr(self.metadata, method_name)) setattr(self, method_name, getattr(self.metadata, method_name))
...@@ -962,6 +960,12 @@ class DistributionMetadata: ...@@ -962,6 +960,12 @@ class DistributionMetadata:
author, and so forth. author, and so forth.
""" """
_METHOD_BASENAMES = ("name", "version", "author", "author_email",
"maintainer", "maintainer_email", "url",
"license", "description", "long_description",
"keywords", "platforms", "fullname", "contact",
"contact_email", "licence")
def __init__ (self): def __init__ (self):
self.name = None self.name = None
self.version = None self.version = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment