Converts the Quil program to a readable string.

        :param allow_placeholders: Whether to complain if the program contains placeholders.
770105
def _out(self, allow_placeholders):
        
        return '\n'.join(itertools.chain(
            (dg.out() for dg in self._defined_gates),
            (instr.out(allow_placeholders=allow_placeholders) for instr in self.instructions),
            [''],
        ))
1097318
def safe_trim(qty_as_string):
    '''
    
    '''
    qty_formatted = qty_as_string
    if '.' in qty_as_string:
        # only affect numbers with decimals
        while True:
            if qty_formatted[-1] == '0' and qty_formatted[-2] != '.':
                qty_formatted = qty_formatted[:-1]
            else:
                break

    return qty_formatted
19316
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        return spaces + ', '.join(v.pretty_str() for v in self.variables)
1318806
def format_and_strip(template, params, strip_string=strip_string):
    
    chunks = template.split(u"%s")
    if not chunks:
        raise ValueError("No formatting placeholders found")

    params = list(reversed(params))
    rv_remarks = []
    rv_original_length = 0
    rv_length = 0
    rv = []

    def realign_remark(remark):
        return [
            (rv_length + x if isinstance(x, int_types) and i < 4 else x)
            for i, x in enumerate(remark)
        ]

    for chunk in chunks[:-1]:
        rv.append(chunk)
        rv_length += len(chunk)
        rv_original_length += len(chunk)
        if not params:
            raise ValueError("Not enough params.")
        param = params.pop()

        stripped_param = strip_string(param)
        if isinstance(stripped_param, AnnotatedValue):
            rv_remarks.extend(
                realign_remark(remark) for remark in stripped_param.metadata["rem"]
            )
            stripped_param = stripped_param.value

        rv_original_length += len(param)
        rv_length += len(stripped_param)
        rv.append(stripped_param)

    rv.append(chunks[-1])
    rv_length += len(chunks[-1])
    rv_original_length += len(chunks[-1])

    rv = u"".join(rv)
    assert len(rv) == rv_length

    if not rv_remarks:
        return rv

    return AnnotatedValue(
        value=rv, metadata={"len": rv_original_length, "rem": rv_remarks}
    )
263396
def fill_placeholders (out)
      re = Regexp.new('%' + @replacement_hash + '%(\d+)%')
      out.gsub re do |m|
        m.gsub!(re, "\\1")
        @placeholders[m.to_i]
      end
    end
263455
function parsePlaceHolders( divId, str ) {
  //TODO
  var pmd = moduleConfig[ divId ];
  log( "Pong-Form",  "Start value: "+ str );
  if ( pmd.fieldGroups != null ) {
    for ( var i = 0; i < pmd.fieldGroups.length; i++ ) {
      var grp = pmd.fieldGroups[i];
      for ( var j = 0; j < grp.columns.length; j++ ) {
        var col = grp.columns[j];
        for ( var k = 0; k < col.formFields.length; k++ ) {
          var field = col.formFields[k];
          if ( field.type == 'text' ) {
            str = str.replace( '${'+field.id+'}', $( '#'+divId+field.id ).val() );
          }
        }
      }
    }
  }
  log( "Pong-Form", "Processed value: "+ str );
  return str;
}
746119
def replace_placeholders(path: Path, properties: Dict[str, str]):
    ''''''

    with open(path, encoding='utf8') as file:
        file_content = Template(file.read())

    with open(path, 'w', encoding='utf8') as file:
        file.write(file_content.safe_substitute(properties))
344628
def description_with_permitted str
			permitted_s = permitted.map do |p|
				case p
				when $stdout   then '<stdout>'
				when $stdin    then '<stdin>'
				when $stderr   then '<stderr>'
				else
					p.to_s
				end
			end.join(', ')

			permword = str.end_with?('.') ? 'Permitted' : 'permitted'
			return "#{str} (#{permword}: #{permitted_s})"
		end
1084153
def get_placeholder_formats_list(self, format_string):
        
        placeholders = []
        # Tokenize the format string and process them
        for token in self.tokens(format_string):
            if token.group("placeholder"):
                placeholders.append((token.group("key"), token.group("format")))
        return placeholders
249667
def get_placeholders(self, format_string):
        
        placeholders = set()
        # Tokenize the format string and process them
        for token in self.tokens(format_string):
            if token.group("placeholder"):
                placeholders.add(token.group("key"))
            elif token.group("command"):
                # get any placeholders used in commands
                commands = dict(parse_qsl(token.group("command")))
                # placeholders only used in `if`
                if_ = commands.get("if")
                if if_:
                    placeholders.add(Condition(if_).variable)
        return placeholders
155546
def str(name, default=None, allow_none=False, fallback=None):
    
    value = read(name, default, allow_none, fallback=fallback)
    if value is None and allow_none:
        return None
    else:
        return builtins.str(value).strip()
1002595
def _get_placeholder_arg(arg_name, placeholder):
    
    if placeholder is None:
        raise RuntimeWarning(u"placeholder object is None")
    elif isinstance(placeholder, Placeholder):
        return placeholder
    elif isinstance(placeholder, Manager):
        manager = placeholder
        try:
            parent_object = manager.instance  # read RelatedManager code
        except AttributeError:
            parent_object = None

        try:
            placeholder = manager.all()[0]
            if parent_object is not None:
                placeholder.parent = parent_object  # Fill GFK cache
            return placeholder
        except IndexError:
            raise RuntimeWarning(u"No placeholders found for query '{0}.all.0'".format(arg_name))
    else:
        raise ValueError(u"The field '{0}' does not refer to a placeholder object!".format(arg_name))
1142693
def get_printable(iterable):
    
    if iterable:
        return ''.join(i for i in iterable if i in string.printable)
    return ''
1290989
def DEFINE_string(flag_name, default_value, docstring, required=False):  # pylint: disable=invalid-name
    
    _define_helper(flag_name, default_value, docstring, str, required)
1332816
def parse_placeholder(parser, token):
    """"""
    params = {}

    bits = token.split_contents()
    count = len(bits)
    error_string = '%r tag requires at least one argument' % bits[0]
    if count <= 1:
        raise TemplateSyntaxError(error_string)
    try:
        name = unescape_string_literal(bits[1])
    except ValueError:
        name = bits[1]
    remaining = bits[2:]
    simple_options = ['parsed', 'inherited', 'untranslated', 'shared', 'block']
    param_options = ['as', 'on', 'with', 'section']
    all_options = simple_options + param_options
    while remaining:
        bit = remaining[0]
        if bit not in all_options:
            raise TemplateSyntaxError(
                "%r is not an correct option for a placeholder" % bit)
        if bit in param_options:
            if len(remaining) < 2:
                raise TemplateSyntaxError(
                    "Placeholder option '%s' need a parameter" % bit)
            if bit == 'as':
                params['as_varname'] = remaining[1]
            if bit == 'with':
                params['widget'] = remaining[1]
            if bit == 'on':
                params['page'] = remaining[1]
            if bit == 'section':
                params['section'] = unescape_string_literal(remaining[1])
            remaining = remaining[2:]
        elif bit == 'parsed':
            params['parsed'] = True
            remaining = remaining[1:]
        elif bit == 'inherited':
            params['inherited'] = True
            remaining = remaining[1:]
        elif bit == 'untranslated':
            params['untranslated'] = True
            remaining = remaining[1:]
        elif bit == 'shared':
            params['shared'] = True
            remaining = remaining[1:]
        elif bit == 'block':
            remaining = remaining[1:]
            nodelist = parser.parse(('endplaceholder',))
            parser.delete_first_token()
            params['nodelist'] = nodelist

    return name, params
749286
function qstring (val) {
  var str = String(val)

  // no need to quote tokens
  if (TOKEN_REGEXP.test(str)) {
    return str
  }

  if (str.length > 0 && !TEXT_REGEXP.test(str)) {
    throw new TypeError('invalid parameter value')
  }

  return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
}
846451
def path_placeholders(self):
        

        parser = string.Formatter()
        return [placeholder_name for _, placeholder_name, _, _ in parser.parse(self.path) if placeholder_name]