Skip to content

Commit f55c0c2

Browse files
committed
Cleanup code
1 parent d1bbf89 commit f55c0c2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

phpmyadmin_sql_backup.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
# Christoph Haunschmidt 2016-03
2525

2626
import argparse
27+
import datetime
2728
import os
2829
import re
2930
import sys
30-
import datetime
3131

3232
import grab
3333

34-
3534
__version__ = '2016-03-12.3'
3635

3736
CONTENT_DISPOSITION_FILENAME_RE = re.compile(r'^.*filename="(?P<filename>[^"]+)".*$')
@@ -40,7 +39,7 @@
4039

4140
def download_sql_backup(url, user, password, dry_run=False, overwrite_existing=False, prepend_date=True, basename=None,
4241
output_directory=os.getcwd(), exclude_dbs=None, compression='none', prefix_format=None,
43-
timeout=60, http_auth=None, **kwargs):
42+
timeout=60, http_auth=None):
4443
prefix_format = prefix_format or DEFAULT_PREFIX_FORMAT
4544
exclude_dbs = exclude_dbs.split(',') or []
4645
encoding = '' if compression == 'gzip' else 'gzip'
@@ -65,7 +64,7 @@ def download_sql_backup(url, user, password, dry_run=False, overwrite_existing=F
6564
dbs_to_dump = [db_name for db_name in dbs_available if db_name not in exclude_dbs]
6665
if not dbs_to_dump:
6766
print('Warning: no databases to dump (databases available: "{}")'.format('", "'.join(dbs_available)),
68-
file=sys.stderr)
67+
file=sys.stderr)
6968

7069
file_response = g.submit(
7170
extra_post=[('db_select[]', db_name) for db_name in dbs_to_dump] + [('compression', compression)])
@@ -108,27 +107,28 @@ def download_sql_backup(url, user, password, dry_run=False, overwrite_existing=F
108107
parser.add_argument('user', metavar='USERNAME', help='phpMyAdmin login username')
109108
parser.add_argument('password', metavar='PASSWORD', help='phpMyAdmin login password')
110109
parser.add_argument('-o', '--output-directory', default=os.getcwd(),
111-
help='output directory for the SQL dump file (default: the current working directory)')
110+
help='output directory for the SQL dump file (default: the current working directory)')
112111
parser.add_argument('-p', '--prepend-date', action='store_true', default=False,
113-
help='prepend current UTC date & time to the filename; see the --prefix-format option for custom formatting')
112+
help='prepend current UTC date & time to the filename; see the --prefix-format option for custom formatting')
114113
parser.add_argument('-e', '--exclude-dbs', default='',
115-
help='comma-separated list of database names to exclude from the dump')
114+
help='comma-separated list of database names to exclude from the dump')
116115
parser.add_argument('--compression', default='none', choices=['none', 'zip', 'gzip', 'bzip2'],
117-
help='compression method for the output file - must be supported by the server (default: %(default)s)')
116+
help='compression method for the output file - must be supported by the server (default: %(default)s)')
118117
parser.add_argument('--basename', default=None,
119-
help='the desired basename (without extension) of the SQL dump file (default: the name given by phpMyAdmin); '
120-
'you can also set an empty basename "" in combination with --prepend-date and --prefix-format')
118+
help='the desired basename (without extension) of the SQL dump file (default: the name given by phpMyAdmin); '
119+
'you can also set an empty basename "" in combination with --prepend-date and --prefix-format')
121120
parser.add_argument('--timeout', type=int, default=60,
122-
help='timeout in seconds for the requests (default: %(default)s)')
121+
help='timeout in seconds for the requests (default: %(default)s)')
123122
parser.add_argument('--overwrite-existing', action='store_true', default=False,
124-
help='overwrite existing SQL dump files (instead of appending a number to the name)')
123+
help='overwrite existing SQL dump files (instead of appending a number to the name)')
125124
parser.add_argument('--prefix-format', default='',
126-
help=str('the prefix format for --prepend-date (default: "{}"); in Python\'s strftime format. '
127-
'Must be used with --prepend-date to be in effect'.format(DEFAULT_PREFIX_FORMAT.replace('%', '%%'))))
125+
help=str('the prefix format for --prepend-date (default: "{}"); in Python\'s strftime format. '
126+
'Must be used with --prepend-date to be in effect'.format(
127+
DEFAULT_PREFIX_FORMAT.replace('%', '%%'))))
128128
parser.add_argument('--dry-run', action='store_true', default=False,
129-
help='dry run, do not actually download any file')
129+
help='dry run, do not actually download any file')
130130
parser.add_argument('--http-auth', default=None,
131-
help='Basic http authentication, using format "username:password"')
131+
help='Basic http authentication, using format "username:password"')
132132

133133
args = parser.parse_args()
134134

@@ -143,4 +143,4 @@ def download_sql_backup(url, user, password, dry_run=False, overwrite_existing=F
143143
sys.exit(1)
144144

145145
print('{} saved SQL dump to: {}'.format(('Would have' if args.dry_run else 'Successfully'), dump_fn),
146-
file=sys.stdout)
146+
file=sys.stdout)

0 commit comments

Comments
 (0)