Prepend proper output prefix to output filename
500439
def _format_output(self, outfile_name, out_type):
        

        outfile_name = self._absolute(outfile_name)
        outparts = outfile_name.split("/")
        outparts[-1] = self._out_format % (out_type, outparts[-1] )

        return '/'.join(outparts)
1223689
def _append(self, sh):
        '''
        
        '''
        sh._input = self
        self._output = sh
        if self._env:
            sh._env = dict(self._env)
        if self._cwd:
            sh._cwd = self._cwd
442324
def output_filename(output_dir, key_handle, public_id):
    
    parts = [output_dir, key_handle] + pyhsm.util.group(public_id, 2)
    path = os.path.join(*parts)

    if not os.path.isdir(path):
        os.makedirs(path)

    return os.path.join(path, public_id)
815866
def _format_extname(self, ext):
        """"""
        if ext is None:
            outs = ext
        else:
            outs = '{0},{1}'.format(ext[0], ext[1])
        return outs
716952
def prep_file(url, dir)
        parts = url.split('/')
        File.join(dir, parts[-1])
      end
688500
function generateCustomOutput(outputConfig) {

			// Accesses context
			var context = prepareBaseTemplateContext();
			_.extend(context, outputConfig.context);

			// Prepares config attributes related to template filepath
			var templatePath = outputConfig.template;
			var extension = path.extname(templatePath);
			var syntax = outputConfig.syntax || '';

			// Renders template with given context
			var template = readTemplate(templatePath, syntax, extension);
			var output = renderTemplate(template, context);

			// Prepares config attributes related to destination filepath
			var dest = outputConfig.dest || o.dest;

			var filepath;
			var destParent;
			var destName;

			if (path.extname(dest) === '') {
				// If user specifies a directory, filename should be same as template
				destParent = dest;
				destName = path.basename(outputConfig.template);
				filepath = path.join(dest, destName);
			}
			else {
				// If user specifies a file, that is our filepath
				destParent = path.dirname(dest);
				filepath = dest;
			}

			// Ensure existence of parent directory and output to file as desired
			mkdirp.sync(destParent);
			fs.writeFileSync(filepath, output);
		}
1357885
def file_prepender(filename):
    
    with open_file(filename, 'r+') as f:
        content = f.read()
        f.seek(0, 0)
        f.write(molecule_prepender(content))
1273113
def output_prefixdata_code(prefixdata, outfilename, module_prefix, varprefix, per_locale, chunks):
    
    sorted_keys = sorted(prefixdata.keys())
    total_keys = len(sorted_keys)
    if chunks == -1:
        chunk_size = PREFIXDATA_CHUNK_SIZE
        total_chunks = int(math.ceil(total_keys / float(chunk_size)))
    else:
        chunk_size = int(math.ceil(total_keys / float(chunks)))
        total_chunks = chunks

    outdirname = os.path.dirname(outfilename)
    longest_prefix = 0
    for chunk_num in range(total_chunks):
        chunk_index = chunk_size * chunk_num
        chunk_keys = sorted_keys[chunk_index:chunk_index + chunk_size]
        chunk_data = {}
        for key in chunk_keys:
            chunk_data[key] = prefixdata[key]
        chunk_file = os.path.join(outdirname, 'data%d.py' % chunk_num)
        chunk_longest = output_prefixdata_chunk(
            chunk_data, chunk_file, module_prefix, per_locale)
        if chunk_longest > longest_prefix:
            longest_prefix = chunk_longest

    with open(outfilename, "w") as outfile:
        if per_locale:
            prnt(PREFIXDATA_LOCALE_FILE_PROLOG % {'module': module_prefix}, file=outfile)
        else:
            prnt(PREFIXDATA_FILE_PROLOG % {'module': module_prefix}, file=outfile)
        prnt(COPYRIGHT_NOTICE, file=outfile)
        prnt("%s_DATA = {}" % varprefix, file=outfile)
        for chunk_num in range(total_chunks):
            prnt("from .data%d import data" % chunk_num, file=outfile)
            prnt("%s_DATA.update(data)" % varprefix, file=outfile)
        prnt("del data", file=outfile)
        prnt("%s_LONGEST_PREFIX = %d" % (varprefix, longest_prefix), file=outfile)
1323956
def preprocess_files(self, prefix):
            
            if prefix is None: return
            files = ("bin/yang2dsdl", "man/man1/yang2dsdl.1",
                     "pyang/plugins/jsonxsl.py")
            regex = re.compile("^(.*)/usr/local(.*)$")
            for f in files:
                  inf = open(f)
                  cnt = inf.readlines()
                  inf.close()
                  ouf = open(f,"w")
                  for line in cnt:
                        mo = regex.search(line)
                        if mo is None:
                              ouf.write(line)
                        else:
                              ouf.write(mo.group(1) + prefix + mo.group(2) +
                                        "\n")
                  ouf.close()
1285904
public static String constructFileName(String filenamePrefix, String extension, long recordCount) {
    Preconditions.checkArgument(
        filenamePrefix.equals(M_OUTPUT_FILE_PREFIX) || filenamePrefix.equals(MR_OUTPUT_FILE_PREFIX),
        String.format("%s is not a supported prefix, which should be %s, or %s.", filenamePrefix, M_OUTPUT_FILE_PREFIX,
            MR_OUTPUT_FILE_PREFIX));
    StringBuilder sb = new StringBuilder();
    sb.append(filenamePrefix);
    sb.append(Long.toString(recordCount));
    sb.append(SEPARATOR);
    sb.append(Long.toString(System.currentTimeMillis()));
    sb.append(SEPARATOR);
    sb.append(Integer.toString(RANDOM.nextInt(Integer.MAX_VALUE)));
    sb.append(extension);
    return sb.toString();
  }
1073847
def _setup_output_file(self, output_filename, args, write_header=True):
        """"""
        # write command line into outputFile
        # (without environment variables, they are documented by benchexec)
        try:
            output_file = open(output_filename, 'w') # override existing file
        except IOError as e:
            sys.exit(e)

        if write_header:
            output_file.write(' '.join(map(util.escape_string_shell, self._build_cmdline(args)))
                              + '\n\n\n' + '-' * 80 + '\n\n\n')
            output_file.flush()

        return output_file
1006201
def add_suffix(file_path, suffix):
    """"""
    split = os.path.basename(file_path).rsplit('.', 1)
    ext = split[1]
    name = split[0]
    out = str(name + '_' + suffix + '.' + ext)
    return os.path.join(os.path.dirname(file_path), out)
513385
function(filename, template, outputInInput) {
    var basename;
    var glob;

    template = Array.isArray(template) ? filename : template;
    glob = isGlob(template);
    if (outputInInput) {
      basename = _toArray(filename.split('.').pop()) ;
    } else if (glob) {
      basename = filename.slice(glob.length, filename.length).split('.');
      basename.pop();
    } else {
      basename = filename.split('/').pop().split('.');
      basename.pop();
    }
    return basename.join('.');
  }
730870
def _prepare_output_multi(self, model):
        """"""
        model_name = model.__name__
        current_path = os.path.join(self._output_path, '{model}.{extension}'.format(
            model=model_name,
            extension=self.EXTENSION,
        ))
        self._outfile = codecs.open(current_path, 'w', encoding='utf-8')
        print('Dumping {model} to {file}'.format(model=model_name, file=current_path))
117033
def output_file_name(self):
    """"""

    safe_path = re.sub(r":|/", "_", self.source_urn.Path().lstrip("/"))
    return "results_%s%s" % (safe_path, self.output_file_extension)
1073318
def _add_suffix(file_path, suffix, sep='_', ext=None):
    """"""
    # Split file_path on last '.' to separate file_name and file_extension
    split = os.path.basename(file_path).rsplit('.', 1)

    # Use original file_extension if None is given
    ext = split[1] if not ext else ext.strip('.')

    # Rebuild new file_path with suffix
    return os.path.join(os.path.dirname(file_path), split[0] + sep + suffix + '.' + ext)
507533
def _compress_with(input_filename, output_filename, compressors):
    
    with _temporary_filenames(len(compressors)) as temp_filenames:
        results = []
        for compressor, temp_filename in zip(compressors, temp_filenames):
            results.append(_process(compressor, input_filename, temp_filename))
        best_result = min(results)
        os.rename(best_result.filename, output_filename)

        best_compressor = best_result.compressor
        if best_result.size >= os.path.getsize(input_filename):
            best_compressor = None

        if (best_compressor is not None and
                not _images_are_equal(input_filename, output_filename)):
            logging.info('Compressor "%s" generated an invalid image for "%s"',
                         best_compressor, input_filename)
            best_compressor = None

        if best_compressor is None:
            shutil.copy(input_filename, output_filename)

    logging.info('%s: best compressor for "%s"', best_compressor,
                 input_filename)