Replace list of cr.packages by cr.PackageIterator #7
| @ -1,6 +1,6 @@ | |||||||
| import os | import os | ||||||
| import subprocess |  | ||||||
| import time | import time | ||||||
|  | from pathlib import Path | ||||||
| 
 | 
 | ||||||
| from attr import dataclass | from attr import dataclass | ||||||
| from kobo.rpmlib import parse_nvra | from kobo.rpmlib import parse_nvra | ||||||
| @ -48,27 +48,28 @@ class KojiMock: | |||||||
|         self._modules_dir = modules_dir |         self._modules_dir = modules_dir | ||||||
|         self._packages_dir = packages_dir |         self._packages_dir = packages_dir | ||||||
| 
 | 
 | ||||||
|     def _gather_modules(self, modules_dir): |     @staticmethod | ||||||
|  |     def _gather_modules(modules_dir): | ||||||
|         modules = {} |         modules = {} | ||||||
|         for arch in os.listdir(modules_dir): |         for index, (f, arch) in enumerate( | ||||||
|             arch_dir = os.path.join( |             (sub_path.name, sub_path.parent.name) | ||||||
|                 modules_dir, |             for path in Path(modules_dir).glob('*') | ||||||
|                 arch, |             for sub_path in path.iterdir() | ||||||
|  |         ): | ||||||
|  |             parsed = parse_nvra(f) | ||||||
|  |             modules[index] = Module( | ||||||
|  |                 name=parsed['name'], | ||||||
|  |                 nvr=f, | ||||||
|  |                 version=parsed['release'], | ||||||
|  |                 context=parsed['arch'], | ||||||
|  |                 stream=parsed['version'], | ||||||
|  |                 build_id=index, | ||||||
|  |                 arch=arch, | ||||||
|             ) |             ) | ||||||
|             for index, f in enumerate(os.listdir(arch_dir)): |  | ||||||
|                 parsed = parse_nvra(f) |  | ||||||
|                 modules[index] = Module( |  | ||||||
|                     name=parsed['name'], |  | ||||||
|                     nvr=f, |  | ||||||
|                     version=parsed['release'], |  | ||||||
|                     context=parsed['arch'], |  | ||||||
|                     stream=parsed['version'], |  | ||||||
|                     build_id=index, |  | ||||||
|                     arch=arch, |  | ||||||
|                 ) |  | ||||||
|         return modules |         return modules | ||||||
| 
 | 
 | ||||||
|     def getLastEvent(self, *args, **kwargs): |     @staticmethod | ||||||
|  |     def getLastEvent(*args, **kwargs): | ||||||
|         return {'id': LAST_EVENT_ID, 'ts': LAST_EVENT_TIME} |         return {'id': LAST_EVENT_ID, 'ts': LAST_EVENT_TIME} | ||||||
| 
 | 
 | ||||||
|     def listTagged(self, tag_name, *args, **kwargs): |     def listTagged(self, tag_name, *args, **kwargs): | ||||||
| @ -111,7 +112,8 @@ class KojiMock: | |||||||
| 
 | 
 | ||||||
|         return builds |         return builds | ||||||
| 
 | 
 | ||||||
|     def getFullInheritance(self, *args, **kwargs): |     @staticmethod | ||||||
|  |     def getFullInheritance(*args, **kwargs): | ||||||
|         """ |         """ | ||||||
|         Unneeded because we use local storage. |         Unneeded because we use local storage. | ||||||
|         """ |         """ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user