Coverage for xdcc_dl/helper.py : 21%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2016 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of xdcc-dl.
6xdcc-dl is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11xdcc-dl is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with xdcc-dl. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20from argparse import ArgumentParser
21from typing import List, Optional
22from xdcc_dl.entities.XDCCPack import XDCCPack
25def prepare_packs(packs: List[XDCCPack], location: Optional[str]):
26 """
27 Prepares the output path of a list of packs based on a location string
28 :param location: The location at which to save the packs.
29 :param packs: The packs to prepare
30 :return: None
31 """
32 if location is not None:
33 if len(packs) == 1:
34 packs[0].set_filename(location, True)
35 else:
36 # Generate unique names for each pack file
37 for i, pack in enumerate(packs):
38 pack.set_filename(location + "-" + str(i).zfill(3), True)
41def add_xdcc_argparse_arguments(parser: ArgumentParser):
42 """
43 Adds relevant command line arguments for an argument parser for xdcc-dl
44 :param parser: The parser to modify
45 :return: None
46 """
47 parser.add_argument("-s", "--server",
48 default="irc.rizon.net",
49 help="Specifies the IRC Server. "
50 "Defaults to irc.rizon.net")
51 parser.add_argument("-o", "--out",
52 help="Specifies the target file. "
53 "Defaults to the pack's file name. "
54 "When downloading multiple packs, index "
55 "numbers will be appended to the filename")
56 parser.add_argument("-t", "--throttle", default=-1,
57 help="Limits the download speed of xdcc-dl. "
58 "Append K,M or G for more convenient units")
59 parser.add_argument("--timeout", default=120, type=int,
60 help="If the download didn't start during the "
61 "specified timeout, the program will stop")
62 parser.add_argument("--fallback-channel",
63 help="Fallback channel in case a channel could not"
64 "be joined automatically using WHOIS commands")
65 parser.add_argument("--wait-time", default=0, type=int,
66 help="Waits for the specified amount of time before "
67 "sending the xdcc send request")
68 parser.add_argument("--username",
69 help="Specifies a user name for the downloader bot")
70 parser.add_argument("--channel-join-delay", type=int,
71 help="Specifies a delay in seconds for how long the"
72 "downloader should wait before connecting to"
73 "channels")