Skip to content

Commit 92a8655

Browse files
author
Nermin Skenderovic
authored
Add option for specifying filename (#71)
1 parent 0fdf2b5 commit 92a8655

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pyasn-utils/pyasn_util_download.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
group.add_argument('--version', action='store_true')
5252
group.add_argument('--dates-from-file', '-f', action='store',
5353
help='Grab IPV4 archives for specifc dates (one date, YYYYMMDD, per line)')
54+
parser.add_argument('--filename', action='store', help="Specify name with which the file will be saved")
5455
args = parser.parse_args()
5556

5657

@@ -62,8 +63,10 @@ def ftp_download(server, remote_dir, remote_file, local_file, print_progress=Tru
6263
if print_progress:
6364
print('Downloading ftp://%s/%s/%s' % (server, remote_dir, remote_file))
6465
filesize = ftp.size(remote_file)
66+
67+
filename = args.filename if args.filename is not None else local_file
6568
# perhaps warn before overwriting file?
66-
with open(local_file, 'wb') as fp:
69+
with open(filename, 'wb') as fp:
6770
def recv(s):
6871
fp.write(s)
6972
recv.chunk += 1

0 commit comments

Comments
 (0)