Intercepts output - single characters
515139
public void write(int b) throws IOException {
        Boolean result = (Boolean) callback.call(consoleId.get(), String.valueOf((char) b));
        if (result) {
            out.write(b);
        }
    }
73330
def _try_char(character, backup, encoding=sys.stdout.encoding):
    
    if character.encode(encoding, 'replace') == b'?':
        return backup
    else:
        return character
28958
def get_simple_output(self, stderr=STDOUT):
        
        args = shlex.split(self.cmd)
        proc = Popen(args, stdout=PIPE, stderr=stderr)
        return proc.communicate()[0].decode("utf8")
794539
def fout(self, output, newline=True):
        """"""
        if output is not None:
            self.out(self.fmt(output), newline=newline)
952808
private void stripTrailingDelimiters(StringBuilder buffer)
   {
      int index = buffer.length() - 1;

      while (index > 0 && buffer.charAt(index) == m_delimiter)
      {
         --index;
      }

      buffer.setLength(index + 1);
   }
180565
function rtrim(str, targetStr) {
    var retStr = "";
    var regStr;

    if (typeof str != "string") {
        return retStr;
    }

    if (typeof targetStr != "string" || !targetStr) {
        targetStr = "\\s";
    }

    regStr = "(.*?)" + targetStr + "*$";
    regStr = new RegExp(regStr);

    str = str.replace(regStr, "$1");
    return str;
}
460799
def limit_chars(function, *args, **kwargs):
    """"""
    output_chars_limit = args[0].reddit_session.config.output_chars_limit
    output_string = function(*args, **kwargs)
    if -1 < output_chars_limit < len(output_string):
        output_string = output_string[:output_chars_limit - 3] + '...'
    return output_string
970802
def GetWSAActionOutput(operation):
    """"""
    attr = operation.output.action
    if attr is not None:
        return attr
    targetNamespace = operation.getPortType().getTargetNamespace()
    ptName = operation.getPortType().name
    msgName = operation.output.name
    if not msgName:
        msgName = operation.name + 'Response'
    if targetNamespace.endswith('/'):
        return '%s%s/%s' %(targetNamespace, ptName, msgName)
    return '%s/%s/%s' %(targetNamespace, ptName, msgName)
4219
function encodeOutputs(outputs) {

    //Initialize buffer and offset
    let offset = 0;
    var buffer = Buffer.allocUnsafe(100000);
    //Write number of inputs
    offset += bufferutils.writeVarInt(buffer, outputs.length, offset);

    outputs.forEach((output) => {
        //Write value as 8byte integer
        offset = bufferutils.writeUInt64LE(buffer, output.value, offset);
        //Output script
        if (output.script_type) {
            switch (output.script_type) {
                case 'p2sh':
                    offset = writeScriptPayToScriptHash(output.address, buffer, offset);
                    break;
                case 'pubkeyhash':
                    offset = writeScriptPayToPubKeyHash(output.address, buffer, offset);
                    break;
                case 'lock':
                    let locktime_le_string = parseInt(output.locktime).toString(16).replace(/^(.(..)*)$/, "0$1").match(/../g).reverse().join("");
                    offset = writeScriptLockedPayToPubKeyHash(output.address, locktime_le_string, buffer, offset);
                    break;
                case 'attenuation':
                    let model = Script.deserializeAttenuationModel(output.attenuation.model);
                    if (output.attenuation.height_delta > 0)
                        model = Script.adjustAttenuationModel(model, output.attenuation.height_delta);
                    offset = writeAttenuationScript(Script.serializeAttenuationModel(model), output.attenuation.from_tx, output.attenuation.from_index, output.address, buffer, offset);
                    break;
                default:
                    throw 'Unknown script type: ' + output.script_type;
            }
        } else if (output.script) {
            let script = Script.fromASM(output.script).buffer;
            offset += bufferutils.writeVarInt(buffer, script.length, offset);
            offset += script.copy(buffer, offset);
        } else {
            throw 'Neither script not script type present';
        }

        // attachment
        offset = buffer.writeUInt32LE(output.attachment.version, offset);
        offset = buffer.writeUInt32LE(output.attachment.type, offset);

        if (output.attachment.version === Constants.ATTACHMENT.VERSION.DID) {
            offset += encodeString(buffer, output.attachment.to_did, offset);
            offset += encodeString(buffer, output.attachment.from_did, offset);
        }

        switch (output.attachment.type) {
            case Constants.ATTACHMENT.TYPE.ETP_TRANSFER:
                break;
            case Constants.ATTACHMENT.TYPE.MST:
                switch (output.attachment.status) {
                    case Constants.MST.STATUS.REGISTER:
                        offset = encodeAttachmentAssetIssue(buffer, offset, output.attachment);
                        break;
                    case Constants.MST.STATUS.TRANSFER:
                        offset = encodeAttachmentMSTTransfer(buffer, offset, output.attachment.symbol, output.attachment.quantity);
                        break;
                    default:
                        throw Error("Asset status unknown");
                }
                break;
            case Constants.ATTACHMENT.TYPE.MESSAGE:
                offset = encodeAttachmentMessage(buffer, offset, output.attachment.message);
                break;
            case Constants.ATTACHMENT.TYPE.AVATAR:
                offset = encodeAttachmentDid(buffer, offset, output.attachment);
                break;
            case Constants.ATTACHMENT.TYPE.CERT:
                offset = encodeAttachmentCert(buffer, offset, output.attachment);
                break;
            case Constants.ATTACHMENT.TYPE.MIT:
                switch (output.attachment.status) {
                    case Constants.MIT.STATUS.REGISTER:
                        offset = encodeAttachmentMITRegister(buffer, offset, output.attachment.symbol, output.attachment.content, output.attachment.address);
                        break;
                    case Constants.MIT.STATUS.TRANSFER:
                        offset = encodeAttachmentMITTransfer(buffer, offset, output.attachment.symbol, output.attachment.address);
                        break;
                    default:
                        throw Error("Asset status unknown");
                }
                break;
            default:
                throw Error("What kind of an output is that?!");
        }
    });

    return buffer.slice(0, offset);
}
997581
def do_execute(self):
        
        fname = str(self.input.payload)
        spattern = str(self.resolve_option("regexp"))
        pattern = None
        if (spattern is not None) and (spattern != ".*"):
            pattern = re.compile(spattern)
        if (pattern is None) or (pattern.match(fname)):
            os.remove(fname)
        self._output.append(self.input)
        return None
1338703
def out(s):
    

    if allow_print: 
       if con_encoding=='':
          x=sys.stdin.encoding
          if x==None: 
             b=s.encode()
          else:
             b=s.encode(x, 'ignore')
       else:
          b=s.encode(con_encoding, 'ignore')

       if sys.version_info[0]>2:
          try: # We encountered issues on ipython with Anaconda
               # and hence made this work around
             sys.stdout.buffer.write(b)
             sys.stdout.buffer.write(b'\n')
          except Exception as e: 
             print(s)
             pass
       else:
          print(b)

    sys.stdout.flush()

    return None
277864
function processZtagOutput(output) {
  return output.split('\n').reduce(function(memo, line) {
    var match, key, value;
      match = ztagRegex.exec(line);
      if(match) {
        key = match[1];
        value = match[2];
        memo[key] = value;
      }
      return memo;
  }, {});
}
654299
def output_stderr(self, text):
        ""
        binary_stderr.write(b''.join([
            self._red,
            b't=%07d' % (time.time() - self._t0),
            self._reset,
            b' ',
            text,
        ]))
        binary_stderr.flush()
222392
function(stdout) {
    var char, command_index, forceflush, i, j, key, l, len, len1, line, m, module, name, newarg, ref, ref1, rule, rules, v, value;
    rules = [];
    command_index = {};
    ref = string.lines(stdout);
    for (l = 0, len = ref.length; l < len; l++) {
      line = ref[l];
      if (line.length === 0) {
        continue;
      }
      rule = {};
      i = 0;
      key = '';
      value = '';
      module = null;
      while (i <= line.length) {
        char = line[i];
        forceflush = i === line.length;
        newarg = (i === 0 && char === '-') || line.slice((i - 1), +i + 1 || 9e9) === ' -';
        if (newarg || forceflush) {
          if (value) {
            value = value.trim();
            if (key === '-m') {
              module = value;
            } else {
              if (module) {
                key = `${module}|${key}`;
              }
              if (iptables.parameters_inverted[key]) {
                key = iptables.parameters_inverted[key];
              }
              rule[key] = value;
            }
            // First key is a command
            if (iptables.commands_arguments[key]) {
              // Determine rule number
              if (Array.isArray(iptables.commands_arguments[key])) {
                rule.command = key;
                ref1 = value.split(' ');
                for (j = m = 0, len1 = ref1.length; m < len1; j = ++m) {
                  v = ref1[j];
                  rule[iptables.commands_arguments[key][j]] = v;
                }
                if (command_index[name = rule.chain] == null) {
                  command_index[name] = 0;
                }
                if (['-P', '-N'].indexOf(key) === -1) {
                  rule.rulenum = ++command_index[rule.chain];
                }
              }
            }
            key = '';
            value = '';
            if (forceflush) {
              break;
            }
          }
          key += char;
          while ((char = line[++i]) !== ' ') { // and line[i]?
            key += char;
          }
          // if iptables.parameters.indexOf(key) isnt -1
          if (iptables.parameters_inverted[key]) {
            module = null;
          }
          continue;
        }
        if (char === '"') {
          while ((char = line[++i]) !== '"') {
            value += char;
          }
          i++;
          continue;
        }
        while (char + (char = line[++i]) !== ' -' && i < line.length) {
          if (char === '-' && key === '--comment') {
            // IPTable silently remove minus sign from comment
            continue;
          }
          value += char;
        }
      }
      rules.push(rule);
    }
    return rules;
  }
310698
private static void escape(OutputAccessor out, int charToEscape) {

        out.write('\\');
        out.write('u');
        if (charToEscape > 0xFF) {
            int hi = (charToEscape >> 8) & 0xFF;
            out.write(HEX_BYTES[hi >> 4]);
            out.write(HEX_BYTES[hi & 0xF]);
            charToEscape &= 0xFF;
        } else {
            out.write((byte) '0');
            out.write((byte) '0');
        }
        // We know it's a control char, so only the last 2 chars are non-0
        out.write(HEX_BYTES[charToEscape >> 4]);
        out.write(HEX_BYTES[charToEscape & 0xF]);
    }
1122669
function truncateLogOutput(output, maxLength) {
  if (typeof(maxLength) === 'undefined') maxLength = maxOutputLength;
  if (! output) return(output);

  if (typeof(output) !== 'string') output = output.toString();
  var length = output.length;
  if ((! length) || (length < (maxLength + 3))) return(output);

  var prefix = Math.ceil((maxLength - 3)/2);
  var suffix = Math.floor((maxLength - 3)/2);
  return(output.slice(0, prefix)+ '...' +
    output.slice(length-suffix));
}
763570
function (str) {
    var output = [];
    var idx = 0;
    var c, num;

    var nextNumber = function () {
      var chars = [];

      while (/[^-\d\.]/.test(str.charAt(idx))) {
        // skip the non-digit characters
        idx++;
      }

      if ('-' === str.charAt(idx)) {
        chars.push('-');
        idx++;
      }

      while ((c = str.charAt(idx)) && /[\d\.Ee]/.test(c)) {
        chars.push(c);
        idx++;
      }

      return parseFloat(chars.join(''));
    };

    while (!isNaN(num = nextNumber())) output.push(num);

    return output;
  }