Create filename for the cached resampling parameters
438047
def _create_cache_filename(self, cache_dir=None, **kwargs):
        """"""
        cache_dir = cache_dir or '.'
        hash_str = self.get_hash(**kwargs)

        return os.path.join(cache_dir, 'resample_lut-' + hash_str + '.npz')
1348067
def _construct_filename(self, batchno):
        
        return os.path.join(self.dirpath,
                            "{0}.{1}".format(self.prefix, batchno))
94110
def filename(out_dir, name, undefine=False):
    """"""
    if undefine:
        prefix = 'undef_'
    else:
        prefix = ''
    return os.path.join(out_dir, '{0}{1}.hpp'.format(prefix, name.lower()))
762136
def load(filenames, prepare_data_iterator=True, batch_size=None, exclude_parameter=False, parameter_only=False):
    '''
    '''
    class Info:
        pass
    info = Info()

    proto = nnabla_pb2.NNablaProtoBuf()
    for filename in filenames:
        _, ext = os.path.splitext(filename)

        # TODO: Here is some known problems.
        #   - Even when protobuf file includes network structure,
        #     it will not loaded.
        #   - Even when prototxt file includes parameter,
        #     it will not loaded.

        if ext in ['.nntxt', '.prototxt']:
            if not parameter_only:
                with open(filename, 'rt') as f:
                    try:
                        text_format.Merge(f.read(), proto)
                    except:
                        logger.critical('Failed to read {}.'.format(filename))
                        logger.critical(
                            '2 byte characters may be used for file name or folder name.')
                        raise
            if len(proto.parameter) > 0:
                if not exclude_parameter:
                    nn.load_parameters(filename)
        elif ext in ['.protobuf', '.h5']:
            if not exclude_parameter:
                nn.load_parameters(filename)
            else:
                logger.info('Skip loading parameter.')

        elif ext == '.nnp':
            try:
                tmpdir = tempfile.mkdtemp()
                with zipfile.ZipFile(filename, 'r') as nnp:
                    for name in nnp.namelist():
                        _, ext = os.path.splitext(name)
                        if name == 'nnp_version.txt':
                            nnp.extract(name, tmpdir)
                            with open(os.path.join(tmpdir, name), 'rt') as f:
                                pass  # TODO currently do nothing with version.
                        elif ext in ['.nntxt', '.prototxt']:
                            nnp.extract(name, tmpdir)
                            if not parameter_only:
                                with open(os.path.join(tmpdir, name), 'rt') as f:
                                    text_format.Merge(f.read(), proto)
                            if len(proto.parameter) > 0:
                                if not exclude_parameter:
                                    nn.load_parameters(
                                        os.path.join(tmpdir, name))
                        elif ext in ['.protobuf', '.h5']:
                            nnp.extract(name, tmpdir)
                            if not exclude_parameter:
                                nn.load_parameters(os.path.join(tmpdir, name))
                            else:
                                logger.info('Skip loading parameter.')
            finally:
                shutil.rmtree(tmpdir)

    default_context = None
    if proto.HasField('global_config'):
        info.global_config = _global_config(proto)
        default_context = info.global_config.default_context
        if 'cuda' in default_context.backend:
            import nnabla_ext.cudnn
        elif 'cuda:float' in default_context.backend:
            try:
                import nnabla_ext.cudnn
            except:
                pass
    else:
        import nnabla_ext.cpu
        default_context = nnabla_ext.cpu.context()

    comm = current_communicator()
    if comm:
        default_context.device_id = str(comm.rank)
    if proto.HasField('training_config'):
        info.training_config = _training_config(proto)

    info.datasets = _datasets(
        proto, prepare_data_iterator if prepare_data_iterator is not None else info.training_config.max_epoch > 0)

    info.networks = _networks(proto, default_context, batch_size)

    info.optimizers = _optimizers(
        proto, default_context, info.networks, info.datasets)

    info.monitors = _monitors(
        proto, default_context, info.networks, info.datasets)

    info.executors = _executors(proto, info.networks)

    return info
612806
def stat(filename, use_cache_only=False):
    """"""
    filename = pyc2py(filename)
    if filename not in file_cache:
        if not use_cache_only: cache_file(filename)
        if filename not in file_cache:
            return None
        pass
    return file_cache[filename].stat
441013
def _filename(self, name=None, suffix=None, prefix=None):
        

        filename = ''

        if prefix:
            filename += str(prefix) + '_'

        if name:
            filename += str(name)
        else:
            filename += str(self.scene)

        if suffix:
            filename += '_' + str(suffix)

        if self.clipped:
            bounds = [tuple(self.bounds[0:2]), tuple(self.bounds[2:4])]
            polyline = PolylineCodec().encode(bounds)
            filename += '_clipped_' + polyline

        filename += '.TIF'

        return filename
242809
def get_filename(self, **kwargs):
        
        if self.filename_parser is None:
            raise RuntimeError("No filename pattern or specific filename provided")
        output_filename = self.filename_parser.compose(kwargs)
        dirname = os.path.dirname(output_filename)
        if dirname and not os.path.isdir(dirname):
            LOG.info("Creating output directory: {}".format(dirname))
            os.makedirs(dirname)
        return output_filename
50614
def gen_filename(endpoint):
    
    now = datetime.now().strftime('%Y%m%d_%H%M%S%f')[:-4]
    base = endpoint.split('://', 1)[1]
    if base.startswith('localhost:'):
        base = gethostname().split('.')[0] + base[9:]
    base = base.replace(':', '_').replace('/', '_')
    return '{}_{}.h5'.format(base, now)
189940
def writeCache(self, filename):
        """"""
        with open(filename, 'wb') as f:
            pickle.dump(self.modules, f)
28255
def cache_file(filename, reload_on_change=False, opts=default_opts):
    """"""
    filename = pyc2py(filename)
    if filename in file_cache:
        if reload_on_change: checkcache(filename)
        pass
    else:
        opts['use_linecache_lines'] = True
        update_cache(filename, opts)
        pass
    if filename in file_cache:
        return file_cache[filename].path
    else: return None
    return
294378
def _save_filename(self, ext):
        
        hash_token = abs(self.__hash__())
        return 'plotnine-save-{}.{}'.format(hash_token, ext)
39515
def substitute_filename(fn, variables):
    
    for var, value in variables.items():
        fn = fn.replace('+%s+' % var, str(value))
    return fn
1236306
def _generate_warc_filename(self, meta=False):
        ''''''
        if self._params.max_size is None:
            sequence_name = ''
        elif meta:
            sequence_name = '-meta'
        else:
            sequence_name = '-{0:05d}'.format(self._sequence_num)

        if self._params.compress:
            extension = 'warc.gz'
        else:
            extension = 'warc'

        return '{0}{1}.{2}'.format(
            self._prefix_filename, sequence_name, extension
        )
1158537
def make_tmpdir_name(base)
      t = Time.now.strftime('%Y%m%d')
      name = "#{base}#{t}-#{Process.pid}-#{rand(0x100000000).to_s(36)}"
      File.join(Dir.tmpdir, name)
    end
888206
def format_sourcefile_name(self, fileName, runSet):
        '''
        
        '''
        if fileName.startswith(runSet.common_prefix):
            fileName = fileName[len(runSet.common_prefix):]
        return fileName.ljust(runSet.max_length_of_filename + 4)
930486
def filename(self, prefix='', suffix='', extension='.py'):
        """"""
        return BASE_NAME.format(prefix, self.num, suffix, extension)
990337
def save(self, filename, wildcard='*', verbose=False):
        ''''''
        f = open(filename, mode='w')
        k = list(self.keys())
        k.sort()
        count = 0
        for p in k:
            if p and fnmatch.fnmatch(str(p).upper(), wildcard.upper()):
                f.write("%-16.16s %f\n" % (p, self.__getitem__(p)))
                count += 1
        f.close()
        if verbose:
            print("Saved %u parameters to %s" % (count, filename))