def _encode_flag_arg_for_globals(val): """Returns an encoded flag value for Python globals interface. Flags destined for globals within a Python module are encoded using standard YAML encoding. Decoding must be handled using standard YAML decoding. """ return flag_util.format_flag(val)
def _format_float(f): """Formats float for compare. Uses `flag_util.format_flag` instead of Python's float formatting to avoid rounding - esp values like `0.9999999` which should not be represented as `1.000000`. """ return flag_util.format_flag(f, truncate_floats=6)
def flag_assign(name, val): return "%s=%s" % (name, flag_util.format_flag(val))
def __str__(self): if self._str is None: self._str = flag_util.format_flag(self._value, truncate_floats=True, shorten_paths=True) return self._str