Merge "Static methods should be @staticmethods"

This commit is contained in:
Jenkins 2016-02-17 02:23:28 +00:00 committed by Gerrit Code Review
commit 87f4a27337

View File

@ -389,11 +389,12 @@ def _parse_remove_values(argvish):
class Commands(object):
@staticmethod
def unknown():
print('Unknown command: %s' % argv[2])
exit(EXIT_ERROR)
@staticmethod
def create():
"""
swift-ring-builder <builder_file> create <part_power> <replicas>
@ -417,6 +418,7 @@ swift-ring-builder <builder_file> create <part_power> <replicas>
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def default():
"""
swift-ring-builder <builder_file>
@ -482,6 +484,7 @@ swift-ring-builder <builder_file>
dev['meta']))
exit(EXIT_SUCCESS)
@staticmethod
def search():
"""
swift-ring-builder <builder_file> search <search-value>
@ -532,6 +535,7 @@ swift-ring-builder <builder_file> search
dev['meta']))
exit(EXIT_SUCCESS)
@staticmethod
def list_parts():
"""
swift-ring-builder <builder_file> list_parts <search-value> [<search-value>] ..
@ -581,6 +585,7 @@ swift-ring-builder <builder_file> list_parts
print('%9d %7d' % (partition, count))
exit(EXIT_SUCCESS)
@staticmethod
def add():
"""
swift-ring-builder <builder_file> add
@ -631,6 +636,7 @@ swift-ring-builder <builder_file> add
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def set_weight():
"""
swift-ring-builder <builder_file> set_weight <search-value> <weight>
@ -663,6 +669,7 @@ swift-ring-builder <builder_file> set_weight
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def set_info():
"""
swift-ring-builder <builder_file> set_info
@ -708,6 +715,7 @@ swift-ring-builder <builder_file> set_info
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def remove():
"""
swift-ring-builder <builder_file> remove <search-value> [search-value ...]
@ -773,6 +781,7 @@ swift-ring-builder <builder_file> search
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def rebalance():
"""
swift-ring-builder <builder_file> rebalance [options]
@ -885,6 +894,7 @@ swift-ring-builder <builder_file> rebalance [options]
builder.save(builder_file)
exit(status)
@staticmethod
def dispersion():
"""
swift-ring-builder <builder_file> dispersion <search_filter> [options]
@ -979,6 +989,7 @@ swift-ring-builder <builder_file> dispersion <search_filter> [options]
print(template % args)
exit(status)
@staticmethod
def validate():
"""
swift-ring-builder <builder_file> validate
@ -987,6 +998,7 @@ swift-ring-builder <builder_file> validate
builder.validate()
exit(EXIT_SUCCESS)
@staticmethod
def write_ring():
"""
swift-ring-builder <builder_file> write_ring
@ -1008,6 +1020,7 @@ swift-ring-builder <builder_file> write_ring
ring_data.save(ring_file)
exit(EXIT_SUCCESS)
@staticmethod
def write_builder():
"""
swift-ring-builder <ring_file> write_builder [min_part_hours]
@ -1054,6 +1067,7 @@ swift-ring-builder <ring_file> write_builder [min_part_hours]
builder.devs[dev_id]['parts'] += 1
builder.save(builder_file)
@staticmethod
def pretend_min_part_hours_passed():
"""
swift-ring-builder <builder_file> pretend_min_part_hours_passed
@ -1072,6 +1086,7 @@ swift-ring-builder <builder_file> pretend_min_part_hours_passed
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def set_min_part_hours():
"""
swift-ring-builder <builder_file> set_min_part_hours <hours>
@ -1088,6 +1103,7 @@ swift-ring-builder <builder_file> set_min_part_hours <hours>
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def set_replicas():
"""
swift-ring-builder <builder_file> set_replicas <replicas>
@ -1120,6 +1136,7 @@ swift-ring-builder <builder_file> set_replicas <replicas>
builder.save(builder_file)
exit(EXIT_SUCCESS)
@staticmethod
def set_overload():
"""
swift-ring-builder <builder_file> set_overload <overload>[%]
@ -1176,11 +1193,12 @@ def main(arguments=None):
globals())
print(Commands.default.__doc__.strip())
print()
cmds = [c for c, f in Commands.__dict__.items()
if f.__doc__ and not c.startswith('_') and c != 'default']
cmds = [c for c in dir(Commands)
if getattr(Commands, c).__doc__ and not c.startswith('_') and
c != 'default']
cmds.sort()
for cmd in cmds:
print(Commands.__dict__[cmd].__doc__.strip())
print(getattr(Commands, cmd).__doc__.strip())
print()
print(parse_search_value.__doc__.strip())
print()
@ -1225,9 +1243,9 @@ def main(arguments=None):
if argv[0].endswith('-safe'):
try:
with lock_parent_directory(abspath(builder_file), 15):
Commands.__dict__.get(command, Commands.unknown.__func__)()
getattr(Commands, command, Commands.unknown)()
except exceptions.LockTimeout:
print("Ring/builder dir currently locked.")
exit(2)
else:
Commands.__dict__.get(command, Commands.unknown.__func__)()
getattr(Commands, command, Commands.unknown)()