@@ -71,7 +71,9 @@ async def create_product(
71
71
(
72
72
await db .execute (
73
73
select (models .Platform ).where (
74
- models .Platform .name .in_ ([platform .name for platform in payload .platforms ]),
74
+ models .Platform .name .in_ (
75
+ [platform .name for platform in payload .platforms ]
76
+ ),
75
77
),
76
78
)
77
79
)
@@ -105,7 +107,14 @@ async def create_product(
105
107
)
106
108
task_results = await asyncio .gather (* repo_tasks )
107
109
108
- for repo_name , repo_url , arch , pulp_href , export_path , is_debug in task_results :
110
+ for (
111
+ repo_name ,
112
+ repo_url ,
113
+ arch ,
114
+ pulp_href ,
115
+ export_path ,
116
+ is_debug ,
117
+ ) in task_results :
109
118
repo = models .Repository (
110
119
name = repo_name ,
111
120
url = repo_url ,
@@ -180,13 +189,21 @@ def generate_query(count=False):
180
189
selectinload (models .Product .owner ),
181
190
selectinload (models .Product .platforms ),
182
191
selectinload (models .Product .repositories ),
183
- selectinload (models .Product .roles ).selectinload (models .UserRole .actions ),
184
- selectinload (models .Product .team ).selectinload (models .Team .owner ),
192
+ selectinload (models .Product .roles ).selectinload (
193
+ models .UserRole .actions
194
+ ),
195
+ selectinload (models .Product .team ).selectinload (
196
+ models .Team .owner
197
+ ),
185
198
selectinload (models .Product .team )
186
199
.selectinload (models .Team .roles )
187
200
.selectinload (models .UserRole .actions ),
188
- selectinload (models .Product .team ).selectinload (models .Team .members ),
189
- selectinload (models .Product .team ).selectinload (models .Team .products ),
201
+ selectinload (models .Product .team ).selectinload (
202
+ models .Team .members
203
+ ),
204
+ selectinload (models .Product .team ).selectinload (
205
+ models .Team .products
206
+ ),
190
207
)
191
208
)
192
209
if count :
@@ -205,7 +222,9 @@ def generate_query(count=False):
205
222
if page_number :
206
223
return {
207
224
'products' : (await db .execute (generate_query ())).scalars ().all (),
208
- 'total_products' : (await db .execute (generate_query (count = True ))).scalar (),
225
+ 'total_products' : (
226
+ await db .execute (generate_query (count = True ))
227
+ ).scalar (),
209
228
'current_page' : page_number ,
210
229
}
211
230
if product_id or product_name :
@@ -227,7 +246,9 @@ async def remove_product(
227
246
db_product = await get_products (db , product_id = product_id )
228
247
db_user = await get_user (db , user_id = user_id )
229
248
if not can_perform (db_product , db_user , actions .DeleteProduct .name ):
230
- raise PermissionDenied (f"User has no permissions to delete the product { db_product .name } " )
249
+ raise PermissionDenied (
250
+ f"User has no permissions to delete the product { db_product .name } "
251
+ )
231
252
if not db_product :
232
253
raise DataNotFoundError (f"Product={ product_id } doesn't exist" )
233
254
active_builds_by_team_id = (
@@ -266,7 +287,8 @@ async def remove_product(
266
287
# some repos from db can be absent in pulp
267
288
# in case if you reset pulp db, but didn't reset non-pulp db
268
289
if all (
269
- product_repo .name != product_distro ['name' ] for product_distro in all_product_distros
290
+ product_repo .name != product_distro ['name' ]
291
+ for product_distro in all_product_distros
270
292
):
271
293
continue
272
294
delete_tasks .append (pulp_client .delete_by_href (product_repo .pulp_href ))
@@ -302,8 +324,12 @@ async def modify_product(
302
324
)
303
325
.options (
304
326
selectinload (models .Build .repos ),
305
- selectinload (models .Build .tasks ).selectinload (models .BuildTask .rpm_modules ),
306
- selectinload (models .Build .tasks ).selectinload (models .BuildTask .platform ),
327
+ selectinload (models .Build .tasks ).selectinload (
328
+ models .BuildTask .rpm_modules
329
+ ),
330
+ selectinload (models .Build .tasks ).selectinload (
331
+ models .BuildTask .platform
332
+ ),
307
333
),
308
334
)
309
335
@@ -314,17 +340,19 @@ async def modify_product(
314
340
)
315
341
.options (
316
342
selectinload (models .Build .repos ),
317
- selectinload (models .Build .tasks ).selectinload (models .BuildTask .rpm_modules ),
318
- selectinload (models .Build .tasks ).selectinload (models .BuildTask .platform ),
343
+ selectinload (models .Build .tasks ).selectinload (
344
+ models .BuildTask .rpm_modules
345
+ ),
346
+ selectinload (models .Build .tasks ).selectinload (
347
+ models .BuildTask .platform
348
+ ),
319
349
),
320
350
)
321
351
db_build = db_build .scalars ().first ()
322
352
323
353
if modification == 'add' :
324
354
if db_build in db_product .builds :
325
- error_msg = (
326
- f"Can't add build { build_id } to { product } as it's already part of the product"
327
- )
355
+ error_msg = f"Can't add build { build_id } to { product } as it's already part of the product"
328
356
raise ProductError (error_msg )
329
357
if modification == 'remove' :
330
358
if db_build not in db_product .builds :
@@ -339,18 +367,24 @@ async def modify_product(
339
367
perform_product_modification .send (db_build .id , db_product .id , modification )
340
368
341
369
342
- async def get_repo_product (session : AsyncSession , repository : str ) -> Optional [Product ]:
370
+ async def get_repo_product (
371
+ session : AsyncSession , repository : str
372
+ ) -> Optional [Product ]:
343
373
product_relationships = (
344
374
selectinload (Product .owner ),
345
375
selectinload (Product .roles ).selectinload (UserRole .actions ),
346
- selectinload (Product .team ).selectinload (Team .roles ).selectinload (UserRole .actions ),
376
+ selectinload (Product .team )
377
+ .selectinload (Team .roles )
378
+ .selectinload (UserRole .actions ),
347
379
)
348
380
if repository .endswith ("br" ):
349
381
result = (
350
382
(
351
383
await session .execute (
352
384
select (Build )
353
- .filter (Build .repos .any (Repository .name .ilike (f'%{ repository } ' )))
385
+ .filter (
386
+ Build .repos .any (Repository .name .ilike (f'%{ repository } ' ))
387
+ )
354
388
.options (
355
389
joinedload (Build .team )
356
390
.joinedload (Team .products )
0 commit comments