Create the name for a Journal file or a log file, based on the prefix and
the current date.
763701
public static String createTimestampedFilename(String filenamePrefix,
                                                   Date date) {
        SimpleDateFormat formatter =
                new SimpleDateFormat(FORMAT_JOURNAL_FILENAME_TIMESTAMP);
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        return filenamePrefix + formatter.format(date) + "Z";
    }
192035
def generate_file_name(self):
        """"""
        if not self.project:
            raise UnderDefined("project name not given")

        out_data_dir = prms.Paths.outdatadir
        project_dir = os.path.join(out_data_dir, self.project)
        file_name = "cellpy_batch_%s.json" % self.name
        self.file_name = os.path.join(project_dir, file_name)
774742
private void updateIndexName() {
        this.logIndexName = this.logIndexPrefix + "_" + SIMPLE_DATE_FORMAT.format(new Date());

        try {
            addIndex(logIndexName);
        } catch (IOException e) {
            logger.error("Failed to update log index name: {}", logIndexName, e);
        }
    }
938443
function createResourceName(share, directory, file, forSAS) {
  var encode = function(name) {
    if (name && !forSAS) {
      name = encodeURIComponent(name);
      name = name.replace(/%2F/g, '/');
      name = name.replace(/%5C/g, '/');
      name = name.replace(/\+/g, '%20');
    }
    return name;
  };

  var name = share;

  if (directory) {
    // if directory does not start with '/', add it
    if (directory[0] !== '/') {
      name += ('/');
    }

    name += encode(directory);
  } 

  if (file) {
    // if the current path does not end with '/', add it
    if (name[name.length - 1] !== '/') {
      name += ('/');
    }
    
    name += encode(file);
  }

  return path.normalize(name).replace(/\\/g, '/');
}
200560
def setLog(self, fileName, writeName=False):
        
        self.log = 1
        self.logFile = fileName
        self._logPtr = open(fileName, "w")
        if writeName:
            self._namePtr = open(fileName + ".name", "w")
718392
def generate_temporary_file(folder='/tmp', prefix='helpme', ext='json'):
    '''

    '''        
    tmp = next(tempfile._get_candidate_names())
    return '%s/%s.%s.%s' %(folder, prefix, tmp, ext)
1085634
def make_tmp_dir(prefix):
    

    # Time in ISO8601 format
    now = datetime.now().isoformat()

    # A random UUID is appended to the output directory in order to
    # avoid name collisions
    f_uuid = uuid.uuid4().hex

    # Directory name and path
    out_dir = "{out}/{p}-{now}-{uuid}".format(out=_output_dir, p=prefix,
                                              now=now, uuid=f_uuid)

    # create the actual directory
    if not _dry_run:
        os.makedirs(out_dir)
    log.msg_debug("Output directory: {out_dir}".format(out_dir=_output_dir))

    # Return a string containing the name and path of the output directory
    return out_dir
996201
private String[] buildsufix(String logname) {

        // help String array to store all combination
        String[] prefix_temp = new String[logname.length()];
        int count = 0;
        while (logname.indexOf(".") > 1) {
            // separate the name of the logger into pieces of name and separator e.g.: "org."
            String subprefix = logname.substring(0, logname.indexOf(".") + 1);
            logname = logname.replace(subprefix, "");
            if (logname.indexOf(".") > 1) {
                if (count > 0) {
                    // build different suffixes based on the pieces separated above
                    prefix_temp[count] = prefix_temp[count - 1] + subprefix;
                } else {
                    // if it's the first piece of the name only it will be set
                    prefix_temp[count] = subprefix;

                }
            }
            count++;
        }
        // if the logger name has more then one piece
        if (count >= 1) {
            // create result string array
            String[] prefix = new String[count - 1];
            // copy all different prefixes to one array with right size
            for (int i = 0; i < (count - 1); i++) {
                prefix[i] = prefix_temp[i].substring(0, prefix_temp[i].length() - 1);
            }
            // return all different prefixes
            return prefix;
        }
        // if the logger name has only one or less piece
        else {
            // return the full logger name
            String[] nullreturn = new String[1];
            nullreturn[0] = logname;
            return nullreturn;
        }
    }
219661
def _file_name(self, dtype_out_time, extension='nc'):
        """"""
        if dtype_out_time is None:
            dtype_out_time = ''
        out_lbl = utils.io.data_out_label(self.intvl_out, dtype_out_time,
                                          dtype_vert=self.dtype_out_vert)
        in_lbl = utils.io.data_in_label(self.intvl_in, self.dtype_in_time,
                                        self.dtype_in_vert)
        start_year = utils.times.infer_year(self.start_date)
        end_year = utils.times.infer_year(self.end_date)
        yr_lbl = utils.io.yr_label((start_year, end_year))
        return '.'.join(
            [self.name, out_lbl, in_lbl, self.model.name,
             self.run.name, yr_lbl, extension]
        ).replace('..', '.')
460349
def put_current_line(self, prefix='', suffix=''):
        
        return '%s#line %i "%s"%s' % (prefix, self.lex.lineno, self.filestack[-1][0], suffix)
505449
def prepare_file(filename):
    """"""
    directory = os.path.join(utils.get_project_root(), "analyzation/")
    if not os.path.exists(directory):
        os.makedirs(directory)
    workfilename = os.path.join(directory, filename)
    open(workfilename, 'w').close()  # Truncate the file
    return workfilename
235960
def create_history_filename(self):
        """"""
        if self.history_filename and not osp.isfile(self.history_filename):
            try:
                encoding.writelines(self.INITHISTORY, self.history_filename)
            except EnvironmentError:
                pass
1073093
public AsyncWork<File, IOException> createFileAsync(String prefix, String suffix) {
		return new Task.OnFile<File, IOException>(tempDir, "Create temporary file", Task.PRIORITY_NORMAL) {
			@Override
			public File run() throws IOException {
				return createFileSync(prefix, suffix);
			}
		}.start().getOutput();
	}
1065771
def _temp_filename(contents):
    
    fp = tempfile.NamedTemporaryFile(
        prefix='codequalitytmp', delete=False)
    name = fp.name
    fp.write(contents)
    fp.close()
    _files_to_cleanup.append(name)
    return name
660213
def _file_prefix(
            self):
        
        self.log.info('starting the ``_file_prefix`` method')

        if self.ra:
            now = datetime.now()
            prefix = now.strftime("%Y%m%dt%H%M%S%f_tns_conesearch_")
        elif self.name:
            prefix = self.name + "_tns_conesearch_"
        elif self.internal_name:
            prefix = self.internal_name + "_tns_conesearch_"
        elif self.discInLastDays:
            discInLastDays = str(self.discInLastDays)
            now = datetime.now()
            prefix = now.strftime(
                discInLastDays + "d_since_%Y%m%d_tns_conesearch_")

        self.log.info('completed the ``_file_prefix`` method')
        return prefix
1206531
def save_log(self, filename = None):
        
        if filename is None:
            filename = self.filename('-info.txt')
        filename = self.check_filename(filename)
        # filename = self.check_filename(filename)
        # windows can't deal with long filenames so we have to use the prefix '\\\\?\\'
        # if len(filename.split('\\\\?\\')) == 1:
        #     filename = '\\\\?\\' + filename
        with open(filename, 'w') as outfile:
            for item in self.log_data:
                outfile.write("%s\n" % item)
1212961
def new_log_filepath(self):
        ''''''
        lastlog_filename = os.path.join(self.dataflash_dir,'LASTLOG.TXT')
        if os.path.exists(lastlog_filename) and os.stat(lastlog_filename).st_size != 0:
            fh = open(lastlog_filename,'rb')
            log_cnt = int(fh.read()) + 1
            fh.close()
        else:
            log_cnt = 1

        self.lastlog_file = open(lastlog_filename,'w+b')
        self.lastlog_file.write(log_cnt.__str__())
        self.lastlog_file.close()

        return os.path.join(self.dataflash_dir, '%u.BIN' % (log_cnt,));