File: script

package info (click to toggle)
reportbug 13.2.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,248 kB
  • sloc: python: 9,838; sh: 70; makefile: 41; lisp: 31
file content (32 lines) | stat: -rwxr-xr-x 1,012 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/python3
# -*- python -*-

import os
import re
import shlex

OUT = os.fdopen(3, 'w', encoding='utf-8', errors='backslashreplace')

envprint = False
for var in ['EDITOR', 'PAGER', 'VISUAL', 'REPORTBUGEMAIL', 'DEBEMAIL', 'EMAIL',
            'DEBFULLNAME', 'DEBNAME', 'NAME', 'INTERFACE']:
    if var in os.environ:
        if not envprint:
            print('** Environment settings:', file=OUT)
            envprint = True
        print('%s=%s' % (var, shlex.quote(os.environ[var])), file=OUT)

passwdre = re.compile(r'\s*(smtppasswd)\s+(.*)$')

USERFILE = os.path.expanduser('~/.reportbugrc')
if os.path.exists(USERFILE):
    if envprint:
        print(file=OUT)
    print('** %s:' % USERFILE, file=OUT)
    for line in open(USERFILE, 'r', encoding='utf-8', errors='backslashreplace'):
        line = line.strip()
        if line and not line.startswith('#'):
            m = passwdre.match(line)
            if m:
                line = '%s <omitted>' % m.group(1)
            print(line, file=OUT)