Best Python code snippet using molecule_python
list-branch-pr
Source:list-branch-pr  
...231    parser = ArgumentParser(description=__doc__, epilog="""\232    Some options are required only when the corresponding environment variable233    is not set. In case both are given, the command-line option overrides the234    environment variable.""")235    def add_env_arg(short_name, long_name, env_var, vtype=str, **kwargs):236        """Add an argument that falls back to an environment variable."""237        if "help" in kwargs:238            kwargs["help"] += (239                " (required if %(var)s is empty; default %(var)s=%(value)s)"240                % {"var": env_var, "value": os.environ.get(env_var, "")})241        # Ignore empty values from the environment!242        if os.environ.get(env_var):243            env_value = os.environ[env_var]244            try:245                typed_env_value = vtype(env_value)246            except ValueError:247                # Fall through if the value is of the incorrect type. If we248                # raised an error here, command-line options couldn't override249                # invalid values from the environment. Instead, falling through250                # makes the cmd-line option required, which is what we want.251                pass252            else:253                parser.add_argument(254                    short_name, long_name, required=False, type=vtype,255                    default=typed_env_value, **kwargs)256                return257        parser.add_argument(258            short_name, long_name, required=True, type=vtype, **kwargs)259    parser.add_argument(260        "--definitions-dir", metavar="DIR",261        default=os.path.join("ali-bot", "ci", "repo-config"),262        help=("directory where .env files are located in a hierarchy; expects "263              "a directory structure of the form DIR/ROLE/CONTAINER/*.env "264              "(default %(default)s)"))265    parser.add_argument(266        "-b", "--show-base-branch", action="store_true",267        help=("Also consider checks on the latest commit of each repo's base "268              "branch."))269    add_env_arg("-i", "--worker-index", "WORKER_INDEX", vtype=int,270                help="Index for the current worker")271    add_env_arg("-n", "--worker-pool-size", "WORKERS_POOL_SIZE", vtype=int,272                help="Total number of workers")273    add_env_arg("-r", "--mesos-role", "MESOS_ROLE",274                help="Mesos role of the current worker")275    add_env_arg("-c", "--container-name", "CUR_CONTAINER",276                help="Short name of the container we're running in, e.g. slc8")277    parser.add_argument(278        "-s", "--config-suffix", metavar="SUFFIX",279        default=os.environ.get("ALIBOT_CONFIG_SUFFIX", ""),280        help=("Suffix to disambiguate which .env files should be chosen for the"281              " current Mesos role and container (default ALIBOT_CONFIG_SUFFIX="282              "%(default)s or empty if undefined). If %(metavar)s starts with a"283              " dash, use -s=%(metavar)s instead of -s %(metavar)s."))284    return parser.parse_args()285QUERY = gql("""\286query statuses(287  $repoOwner: String!288  $repoName: String!289  $baseBranch: String!...ansible_playbook.py
Source:ansible_playbook.py  
...99        :return: None100        """101        if value:102            self._cli[name] = value103    def add_env_arg(self, name, value):104        """105        Add argument to environment passed to ansible-playbook and returns \106        None.107        :param name: A string containing the name of argument to be added.108        :param value: The value of argument to be added.109        :return: None110        """...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
