From aabd237656f73071a232a93cd1cc6917f0f685a0 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 18 Feb 2020 19:39:03 +0000 Subject: [PATCH] Fixed some pyflakes issues. - Legacy-Id: 17304 --- ietf/utils/management/commands/mergedata.py | 28 +++---------------- ietf/utils/management/commands/sqldumpdump.py | 6 ++-- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/ietf/utils/management/commands/mergedata.py b/ietf/utils/management/commands/mergedata.py index 5298d192c..732e2ad4b 100644 --- a/ietf/utils/management/commands/mergedata.py +++ b/ietf/utils/management/commands/mergedata.py @@ -3,44 +3,24 @@ from __future__ import absolute_import, print_function, unicode_literals -import glob -import gzip import os import warnings -import zipfile -from collections import defaultdict -from itertools import product, chain +from itertools import chain import debug # pyflakes:ignore -from django.apps import apps from django.conf import settings -from django.contrib.admin.utils import NestedObjects from django.core import serializers -from django.core.exceptions import ImproperlyConfigured -from django.core.management.base import BaseCommand, CommandError -from django.core.management.color import no_style -from django.core.management.commands.loaddata import Command as LoadCommand, SingleZipReader, humanize -from django.core.management.utils import parse_apps_and_model_labels -from django.db import DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connections, router, transaction +from django.core.management.base import CommandError +from django.core.management.commands.loaddata import Command as LoadCommand, humanize +from django.db import DatabaseError, IntegrityError, router, transaction from django.db.models import ManyToManyField -from django.utils import lru_cache -from django.utils._os import upath from django.utils.encoding import force_text -from django.utils.functional import cached_property -from django.utils.glob import glob_escape from ietf.utils.models import ForeignKey -try: - import bz2 - has_bz2 = True -except ImportError: - has_bz2 = False - - def flatten(l): if isinstance(l, list): for el in l: diff --git a/ietf/utils/management/commands/sqldumpdump.py b/ietf/utils/management/commands/sqldumpdump.py index bd577c318..a8e596330 100644 --- a/ietf/utils/management/commands/sqldumpdump.py +++ b/ietf/utils/management/commands/sqldumpdump.py @@ -6,7 +6,7 @@ import collections import io import re import sys -import warnings + from django.apps import apps from django.core import serializers @@ -110,7 +110,7 @@ class Command(DumpdataCommand): if not table in pks: pks[table] = [] fields = match.group('fields') - fields = [ f.strip("`") for f in re.split(r"(`[^`]+`)", fields) if f and not re.match(r'\s*,\s*', f)] + fields = [ f.strip("`") for f in re.split(r"(`[^`]+`)", fields) if f and not re.match(r'\s*,\s*', f)] # pyflakes:ignore values = match.group('values') values = [ v.strip("'") for v in re.split(r"(\d+|'[^']*'|NULL)", values) if v and not re.match(r'\s*,\s*', v) ] try: @@ -119,7 +119,7 @@ class Command(DumpdataCommand): pk = values[ididx] pks[table].append(pk) count += 1 - except (KeyError, ValueError) as e: + except (KeyError, ValueError): pass return pks, count