Skip to content

Commit 70ddf5d

Browse files
committed
Simplify statement for key comprehension
1 parent 07fea90 commit 70ddf5d

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

dbbackup/management/commands/dbbackup.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class Command(BaseDbBackupCommand):
2626
make_option(
2727
"-d",
2828
"--database",
29-
help="Database(s) to backup specified by key separated by"
30-
" commas(default: all)",
29+
help="Database(s) to backup specified by key separated by commas(default: all)",
3130
),
3231
make_option(
3332
"-s",
@@ -48,18 +47,14 @@ class Command(BaseDbBackupCommand):
4847
default=False,
4948
help="Encrypt the backup files",
5049
),
51-
make_option(
52-
"-o", "--output-filename", default=None, help="Specify filename on storage"
53-
),
50+
make_option("-o", "--output-filename", default=None, help="Specify filename on storage"),
5451
make_option(
5552
"-O",
5653
"--output-path",
5754
default=None,
5855
help="Specify where to store on local filesystem",
5956
),
60-
make_option(
61-
"-x", "--exclude-tables", default=None, help="Exclude tables from backup"
62-
),
57+
make_option("-x", "--exclude-tables", default=None, help="Exclude tables from backup"),
6358
make_option(
6459
"-n",
6560
"--schema",
@@ -92,9 +87,7 @@ def handle(self, **options):
9287
for database_key in self._get_database_keys():
9388
self.connector = get_connector(database_key)
9489
if self.connector and self.exclude_tables:
95-
self.connector.exclude.extend(
96-
list(self.exclude_tables.replace(" ", "").split(","))
97-
)
90+
self.connector.exclude.extend(list(self.exclude_tables.replace(" ", "").split(",")))
9891
database = self.connector.settings
9992
try:
10093
self._save_new_backup(database)
@@ -106,16 +99,15 @@ def handle(self, **options):
10699
def _get_database_keys(self):
107100
"""
108101
Get the list of database keys to backup.
109-
102+
110103
Returns the databases specified by the -d/--database option,
111104
or falls back to the DBBACKUP_DATABASES setting if no option is provided.
112105
"""
113106
if self.database:
114107
# Split by comma and filter out empty strings to prevent
115108
# get_connector('') from being called, which would fall back
116109
# to the 'default' database and ignore DBBACKUP_DATABASES
117-
keys = [key.strip() for key in self.database.split(",")]
118-
return [key for key in keys if key]
110+
return [key.strip() for key in self.database.split(",") if key.strip()]
119111
return settings.DATABASES
120112

121113
def _save_new_backup(self, database):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ lint.extend-ignore = []
221221
addopts = ["--strict-config", "--strict-markers"]
222222

223223
[tool.coverage]
224-
paths.source = ["dbbackup"]
225224
run.relative_files = true
226225
run.branch = true
227226
run.parallel = true
228227
run.source = ["dbbackup/"]
228+
paths.source = ["dbbackup/"]
229229
report.show_missing = true

0 commit comments

Comments
 (0)