pythonwise /

#!/usr/bin/env python

from subprocess import check_output, STDOUT, CalledProcessError
from sys import platform
import re

# password: "XXXXX"
find_passwd = re.compile('password: "([^"]+)"').search
#     "acct"<blob>=""
find_user = re.compile('"acct"<blob>="([^"]+)"').search

def find_key(fn, out):
    match = fn(out)
    return match and

def main(argv=None):
    import sys
    from argparse import ArgumentParser

    argv = argv or sys.argv

    parser = ArgumentParser(description='')
    args = parser.parse_args(argv[1:])

    if platform != 'darwin':
        raise SystemExit('error: {} works only on OSX'.format(parser.prog))

    domain = args.domain

    cmd = [
        '-s', domain,
        out = check_output(cmd, stderr=STDOUT)
    except CalledProcessError:
        raise SystemExit('error: not password for {}'.format(domain))

    user = find_key(find_user, out)
    if not user:
        raise SystemExit('error: cannot find user for {}'.format(domain))

    passwd = find_key(find_passwd, out)
    if not passwd:
        raise SystemExit('error: cannot find password for {}'.format(domain))

if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.