Give a label to each filename depending on its folder.
15157
def label_from_folder(self, label_cls:Callable=None, **kwargs)->'LabelList':
        ""
        return self.label_from_func(func=lambda o: (o.parts if isinstance(o, Path) else o.split(os.path.sep))[-2],
                                    label_cls=label_cls, **kwargs)
314136
def pretty_filename(filename):
    ''''''
    try:
        a = os.path.abspath(filename)
        r = os.path.relpath(filename)
    except ValueError:
        # Catch relpath exception. Happens, because it can not produce relative path
        # if wroking directory is on different drive.
        a = r = filename
    return a if '..' in r else r
901314
def check_labels_file_header(filename):
  """"""
  with tf.gfile.Open(filename, 'rb') as f:
    magic = read32(f)
    read32(f)  # num_items, unused
    if magic != 2049:
      raise ValueError('Invalid magic number %d in MNIST file %s' % (magic,
                                                                     f.name))
708408
def tag(self, path, name):
    '''
      
    '''

    if not path[len(path) - 1] == '/':
      path += '/'

    config = self.get_config()
    folder = self.find_folder({
      'path' : path
    }, config)

    if not folder:
      raise custom_errors.FileNotInConfig(path)

    old_name = folder['label']
    folder['label'] = name
    
    dir_config = self.adapter.get_dir_config(path)
    dir_config['label'] = name
    self.adapter.set_dir_config(dir_config)

    self.set_config(config)
    # self.restart

    return old_name
584842
def bind_path(self, name, folder):
        """"""
        if not len(name) or name[0] != '/' or name[-1] != '/':
            raise ValueError(
                "name must start and end with '/': {0}".format(name))
        self._folder_masks.insert(0, (name, folder))
189888
def funname(file):
    """"""
    if isinstance(file, str):
        files = [file]
    else:
        files = file
    bases = [os.path.basename(f) for f in files]
    names = [os.path.splitext(b)[0] for b in bases]
    if isinstance(file, str):
        return names[0]
    else:
        return names
115082
def classify_name(filename)
      filename.to_s.split("_").map{ |i| i[0...1].upcase + i[1..-1] }.join
    end
634001
def files(self):
    """"""
    all_files = set()
    for label in self.filesets:
      all_files.update(self.filesets[label])
    return all_files
48846
def _set_filename(self, fn):
        """"""
        try:
            self.filename = self.fs = self.fn = os.path.abspath(fn.name)
        except AttributeError:
            self.filename = self.fs = self.fn = os.path.abspath(fn)
580704
def names(cls):
        """"""
        if not cls._files:
            for f in os.listdir(cls._image_path):
                if(not f.startswith('.') and
                   os.path.isfile(os.path.join(cls._image_path, f))):
                    cls._files.append(os.path.splitext(f)[0])

        return cls._files
378613
def labels(self):
        
        return [
            name for name in os.listdir(self.root)
            if os.path.isdir(os.path.join(self.root, name))
        ]
139634
def include(d, e):
    """"""

    return (d, [f for f in glob.glob('%s/%s' % (d, e)) if os.path.isfile(f)])
231567
def namelist(self):
        """"""
        l = []
        for data in self.filelist:
            l.append(data.filename)
        return l
1061256
def MakeDestinationKey(directory, filename):
  """"""
  return utils.SmartStr(utils.JoinPath(directory, filename)).lstrip("/")
766661
def _GetFileNames(self):
    """"""
    if self._zip:
      return self._zip.namelist()
    else:
      return os.listdir(self._path)
299069
def each
      Dir["#{path}/[a-z]*"].each do |dir|
        if File.directory?(dir)
          yield Spec.new(File.basename(dir), dir, label)
        end
      end
    end
1309931
def tags(cls, filename, namespace=None):
        """"""
        return cls._raster_opener(filename).tags(ns=namespace)