reviewboard
author Gregory Szorc <gps@mozilla.com>
Thu, 05 Mar 2015 17:27:39 -0800
changeset 360505 779cf88d244327cf8dadbe15aa8b31f5281704b4
parent 360276 7db4622ae530570abaf69b6ce2ffc6b08bdaa3d8
child 691162 c33117ccdc57078b9d79199f13c8a4528bb01791
permissions -rwxr-xr-x
pash: store user in a variable; r=bkero os.getenv('USER') was used multiple times in this file. The content of the environment variable doesn't change during execution. So get the value once and store it in a variable. Also, os.environ is the preferred mechanism to access environment variables from Python. os.getenv is a low-level API into the POSIX function of the same name. The difference doesn't matter in this use case, so use the method that is more accepted by the Python community.

#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
import sys


def main(args):
    from mach.main import Mach

    m = Mach(os.getcwd())
    m.define_category('reviewboard', 'Review Board',
        'Interface with Review Board', 50)
    import vcttesting.reviewboard.mach_commands

    return m.run(args)

if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))