most commands moved into cogs
This commit is contained in:
@@ -7,27 +7,23 @@ class ListGenerator:
|
||||
def __init__(self, path: str = None):
|
||||
self.path = path
|
||||
self.list: list = self._lister(self.path)
|
||||
self._size = len(self.list)
|
||||
try:
|
||||
self._size = len(self.list)
|
||||
except TypeError:
|
||||
pass
|
||||
self._current_index = 0
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.path:
|
||||
return self.name
|
||||
else:
|
||||
return 'Audio iter generator'
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.list[self._current_index]
|
||||
return 'Audio iter generator'
|
||||
|
||||
@classmethod
|
||||
def _lister(cls, path) -> list:
|
||||
_dict: list = []
|
||||
_list: list = []
|
||||
try:
|
||||
for _files in os.walk(path):
|
||||
_dict.extend(_files)
|
||||
for f in os.walk(path):
|
||||
_list.extend(f)
|
||||
break
|
||||
return _dict[2]
|
||||
return sorted(_list[2])
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
@@ -40,16 +36,17 @@ class ListGenerator:
|
||||
|
||||
|
||||
class _FileAttrs:
|
||||
def __init__(self, name, path, type):
|
||||
def __init__(self, name, path, type, exc):
|
||||
self.name = name
|
||||
self.path = path
|
||||
self.type = type
|
||||
self.mimetype = type
|
||||
self.exc = exc
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return f'<File attrs name={self.name} path={self.path} type=<{self.type}> >'
|
||||
return f'<File attrs name={self.name} path={self.path} exc={self.exc} type=<{self.mimetype}> >'
|
||||
|
||||
|
||||
class _ListGenerationIter:
|
||||
@@ -70,12 +67,21 @@ class _ListGenerationIter:
|
||||
guess = mimetypes.guess_type(f'{self._path}/{self._list[self._current_index]}')[0]
|
||||
return guess
|
||||
|
||||
@property
|
||||
def _exc(self) -> str:
|
||||
try:
|
||||
_ret = self._list[self._current_index].split('.')[-1]
|
||||
except AttributeError:
|
||||
_ret = None
|
||||
return _ret
|
||||
|
||||
def __next__(self):
|
||||
if self._current_index < self._size:
|
||||
_name = self._list[self._current_index]
|
||||
_path = self._path
|
||||
_type = self.type
|
||||
_type = self._type
|
||||
_exc = self._exc
|
||||
self._current_index += 1
|
||||
memb = _FileAttrs(_name, _path, _type)
|
||||
memb = _FileAttrs(_name, _path, _type, _exc)
|
||||
return memb
|
||||
raise StopIteration
|
||||
|
||||
Reference in New Issue
Block a user