upload-logs-swift: Use collections Sequence for FileList
This is implementing a Sequence, so let's use the ABC template Change-Id: I45d06fa94b20734bb423c12e0e177ea8a6f87218
This commit is contained in:
parent
9ee2aecd21
commit
e52bb01280
@ -37,12 +37,18 @@ import time
|
|||||||
import zlib
|
import zlib
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
|
||||||
import openstack
|
import openstack
|
||||||
import requests
|
import requests
|
||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import requestsexceptions
|
import requestsexceptions
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Python 3.3+
|
||||||
|
from collections.abc import Sequence
|
||||||
|
except ImportError:
|
||||||
|
from collections import Sequence
|
||||||
|
|
||||||
mimetypes.init()
|
mimetypes.init()
|
||||||
mimetypes.add_type('text/plain', '.yaml')
|
mimetypes.add_type('text/plain', '.yaml')
|
||||||
@ -175,16 +181,16 @@ class FileDetail():
|
|||||||
return '<%s %s>' % (t, self.relative_path)
|
return '<%s %s>' % (t, self.relative_path)
|
||||||
|
|
||||||
|
|
||||||
class FileList():
|
class FileList(Sequence):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.file_list = []
|
self.file_list = []
|
||||||
self.file_list.append(FileDetail(None, '', ''))
|
self.file_list.append(FileDetail(None, '', ''))
|
||||||
|
|
||||||
def __iter__(self):
|
def __getitem__(self, item):
|
||||||
return iter(self.file_list)
|
return self.file_list.__getitem__(item)
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.file_list)
|
return self.file_list.__len__()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _path_in_tree(root, path):
|
def _path_in_tree(root, path):
|
||||||
|
Loading…
Reference in New Issue
Block a user