Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Refactor - changed logic to loop through alt sites
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisp committed Apr 8, 2022
1 parent 7f0b471 commit 507f361
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions openpype/plugins/publish/integrate_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import six
import re
import shutil
from collections import deque

from bson.objectid import ObjectId
from pymongo import DeleteOne, InsertOne
Expand Down Expand Up @@ -1199,21 +1200,23 @@ def _get_alt_site_pairs(self, conf_sites):

# transitive relationship, eg site is alternative to another which is
# alternative to nex site
loop = True
while loop:
loop = False
for site_name, alt_sites in alt_site_pairs.items():
for alt_site in alt_sites:
# safety against wrong config
# {"SFTP": {"alternative_site": "SFTP"}
if alt_site == site_name:
continue
for site_name, alt_sites in alt_site_pairs.items():
sites_queue = deque(alt_sites)
while sites_queue:
alt_site = sites_queue.popleft()

# safety against wrong config
# {"SFTP": {"alternative_site": "SFTP"}
if alt_site == site_name or alt_site not in alt_site_pairs:
continue

for alt_alt_site in alt_site_pairs.get(alt_site, []):
if ( alt_alt_site != site_name
and alt_alt_site not in alt_sites):
alt_site_pairs[site_name].append(alt_alt_site)
loop = True
for alt_alt_site in alt_site_pairs[alt_site]:
if (
alt_alt_site != site_name
and alt_alt_site not in alt_sites
):
alt_sites.append(alt_alt_site)
sites_queue.append(alt_alt_site)

return alt_site_pairs

Expand Down

0 comments on commit 507f361

Please sign in to comment.