Code Duplication    Length = 24-25 lines in 2 locations

bbarchivist/smtputils.py 2 locations

@@ 183-207 (lines=25) @@
180
    smt.quit()
181
182
183
def send_email_tls(kwargs):
184
    """
185
    Send email through TLS.
186
187
    :param server: SMTP email server.
188
    :type server: str
189
190
    :param port: Port to use.
191
    :type port: int
192
193
    :param username: Email address.
194
    :type username: str
195
196
    :param password: Email password.
197
    :type password: str
198
199
    :param message: Message to send, with body and subject.
200
    :type message: MIMEText
201
    """
202
    smt = smtplib.SMTP(kwargs['server'], kwargs['port'])
203
    smt.ehlo()
204
    smt.starttls()
205
    smt.login(kwargs['username'], kwargs['password'])
206
    smt.sendmail(kwargs['username'], kwargs['username'], kwargs['message'].as_string())
207
    smt.quit()
208
209
210
def parse_kwargs(kwargs):
@@ 157-180 (lines=24) @@
154
        send_email_tls(payload)
155
156
157
def send_email_ssl(kwargs):
158
    """
159
    Send email through SSL.
160
161
    :param server: SMTP email server.
162
    :type server: str
163
164
    :param port: Port to use.
165
    :type port: int
166
167
    :param username: Email address.
168
    :type username: str
169
170
    :param password: Email password.
171
    :type password: str
172
173
    :param message: Message to send, with body and subject.
174
    :type message: MIMEText
175
    """
176
    smt = smtplib.SMTP_SSL(kwargs['server'], kwargs['port'])
177
    smt.ehlo()
178
    smt.login(kwargs['username'], kwargs['password'])
179
    smt.sendmail(kwargs['username'], kwargs['username'], kwargs['message'].as_string())
180
    smt.quit()
181
182
183
def send_email_tls(kwargs):