diff --git a/data/model/_basequery.py b/data/model/_basequery.py index 1cc2d22aa..a04df60c3 100644 --- a/data/model/_basequery.py +++ b/data/model/_basequery.py @@ -9,10 +9,10 @@ def prefix_search(field, prefix_query): """ Returns the wildcard match for searching for the given prefix query. """ # Escape the known wildcard characters. prefix_query = (prefix_query - .replace('!', '!!') - .replace('%', '!%') - .replace('_', '!_') - .replace('[', '![')) + .replace('!', '!!') + .replace('%', '!%') + .replace('_', '!_') + .replace('[', '![')) return field ** Clause(prefix_query + '%', SQL("ESCAPE '!'")) @@ -46,8 +46,9 @@ def filter_to_repos_for_user(query, username=None, namespace=None, include_publi where_clause = (Namespace.username == namespace) if include_public: - queries.append(query.clone() - .where(Repository.visibility == get_public_repo_visibility(), where_clause)) + queries.append(query + .clone() + .where(Repository.visibility == get_public_repo_visibility(), where_clause)) if username: UserThroughTeam = User.alias() @@ -57,29 +58,32 @@ def filter_to_repos_for_user(query, username=None, namespace=None, include_publi AdminUser = User.alias() # Add repositories in which the user has permission. - queries.append(query.clone() - .switch(RepositoryPermission) - .join(User) - .where(User.username == username, where_clause)) + queries.append(query + .clone() + .switch(RepositoryPermission) + .join(User) + .where(User.username == username, where_clause)) # Add repositories in which the user is a member of a team that has permission. - queries.append(query.clone() - .switch(RepositoryPermission) - .join(Team) - .join(TeamMember) - .join(UserThroughTeam, on=(UserThroughTeam.id == TeamMember.user)) - .where(UserThroughTeam.username == username, where_clause)) + queries.append(query + .clone() + .switch(RepositoryPermission) + .join(Team) + .join(TeamMember) + .join(UserThroughTeam, on=(UserThroughTeam.id == TeamMember.user)) + .where(UserThroughTeam.username == username, where_clause)) # Add repositories under namespaces in which the user is the org admin. - queries.append(query.clone() - .switch(Repository) - .join(Org, on=(Repository.namespace_user == Org.id)) - .join(AdminTeam, on=(Org.id == AdminTeam.organization)) - .join(TeamRole, on=(AdminTeam.role == TeamRole.id)) - .switch(AdminTeam) - .join(AdminTeamMember, on=(AdminTeam.id == AdminTeamMember.team)) - .join(AdminUser, on=(AdminTeamMember.user == AdminUser.id)) - .where(AdminUser.username == username, where_clause)) + queries.append(query + .clone() + .switch(Repository) + .join(Org, on=(Repository.namespace_user == Org.id)) + .join(AdminTeam, on=(Org.id == AdminTeam.organization)) + .join(TeamRole, on=(AdminTeam.role == TeamRole.id)) + .switch(AdminTeam) + .join(AdminTeamMember, on=(AdminTeam.id == AdminTeamMember.team)) + .join(AdminUser, on=(AdminTeamMember.user == AdminUser.id)) + .where(AdminUser.username == username, where_clause)) return reduce(lambda l, r: l | r, queries) diff --git a/data/model/image.py b/data/model/image.py index d3b8082c5..e8227dfaa 100644 --- a/data/model/image.py +++ b/data/model/image.py @@ -21,11 +21,11 @@ def get_repository_image_and_deriving(docker_image_id, storage_uuid): """ try: image_found = (Image - .select() - .join(ImageStorage) - .where(Image.docker_image_id == docker_image_id, - ImageStorage.uuid == storage_uuid) - .get()) + .select() + .join(ImageStorage) + .where(Image.docker_image_id == docker_image_id, + ImageStorage.uuid == storage_uuid) + .get()) except Image.DoesNotExist: return Image.select().where(Image.id < 0) # Empty query diff --git a/util/registry/queuefile.py b/util/registry/queuefile.py index 731fb9a34..3f26ffc6b 100644 --- a/util/registry/queuefile.py +++ b/util/registry/queuefile.py @@ -1,6 +1,3 @@ -from multiprocessing import Queue -import os - class QueueFile(object): """ Class which implements a file-like interface and reads from a blocking multiprocessing queue.