Get alphabet and label names, union across all dirs.
337300
def _get_names(dirs):
  """"""
  alphabets = set()
  label_names = {}
  for d in dirs:
    for example in _walk_omniglot_dir(d):
      alphabet, alphabet_char_id, label, _ = example
      alphabets.add(alphabet)
      label_name = "%s_%d" % (alphabet, alphabet_char_id)
      if label in label_names:
        assert label_names[label] == label_name
      else:
        label_names[label] = label_name
  label_names = [label_names[k] for k in sorted(label_names)]
  return alphabets, label_names
321217
def _parse_data_desc(data_names, label_names, data_shapes, label_shapes):
    """"""
    data_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in data_shapes]
    _check_names_match(data_names, data_shapes, 'data', True)
    if label_shapes is not None:
        label_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in label_shapes]
        _check_names_match(label_names, label_shapes, 'label', False)
    else:
        _check_names_match(label_names, [], 'label', False)
    return data_shapes, label_shapes
809334
def dirpaths(self):
        
        parts = self.parts()
        result = [DotPath(parts[0] or '/')]
        for name in parts[1:]:
            result.append(result[-1] / name)
        return result
7580
def from_files(cls, *glyphdata_files):
        """"""
        name_mapping = {}
        alt_name_mapping = {}
        production_name_mapping = {}

        for glyphdata_file in glyphdata_files:
            glyph_data = xml.etree.ElementTree.parse(glyphdata_file).getroot()
            for glyph in glyph_data:
                glyph_name = glyph.attrib["name"]
                glyph_name_alternatives = glyph.attrib.get("altNames")
                glyph_name_production = glyph.attrib.get("production")

                name_mapping[glyph_name] = glyph.attrib
                if glyph_name_alternatives:
                    alternatives = glyph_name_alternatives.replace(" ", "").split(",")
                    for glyph_name_alternative in alternatives:
                        alt_name_mapping[glyph_name_alternative] = glyph.attrib
                if glyph_name_production:
                    production_name_mapping[glyph_name_production] = glyph.attrib

        return cls(name_mapping, alt_name_mapping, production_name_mapping)
108408
def ls_dir(base_dir):
    """"""
    return [
        os.path.join(dirpath.replace(base_dir, '', 1), f)
        for (dirpath, dirnames, files) in os.walk(base_dir)
        for f in files
    ]
1225963
def rglob(dirname, pattern, dirs=False, sort=True):
    """"""
    fns = []
    path = str(dirname)
    if os.path.isdir(path):
        fns = glob(os.path.join(escape(path), pattern))
        dns = [fn for fn 
                in [os.path.join(path, fn)
                    for fn in os.listdir(path)] 
                if os.path.isdir(fn)]
        if dirs==True:
            fns += dns
        for d in dns:
            fns += rglob(d, pattern)
        if sort==True:
            fns.sort()
    else:
        log.warn("not a directory: %r" % path)
    return fns
429356
def get_subpackages(name):
    """"""
    splist = []
    for dirpath, _dirnames, _filenames in os.walk(name):
        if osp.isfile(osp.join(dirpath, '__init__.py')):
            splist.append(".".join(dirpath.split(os.sep)))
    return splist
408150
def glob(self, filename):
        """"""
        if isinstance(filename, six.string_types):
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for matching_filename in py_glob.glob(
                    compat.as_bytes(filename))
            ]
        else:
            return [
                # Convert the filenames to string from bytes.
                compat.as_str_any(matching_filename)
                for single_filename in filename
                for matching_filename in py_glob.glob(
                    compat.as_bytes(single_filename))
            ]
1240749
def __get_labels(self):
        
        labels = []
        try:
            with self.fs.open(self.fs.join(self.path, self.LABEL_FILE),
                                'r') as file_desc:
                for line in file_desc.readlines():
                    line = line.strip()
                    (label_name, label_color) = line.split(",", 1)
                    labels.append(Label(name=label_name,
                                        color=label_color))
        except IOError:
            pass
        return labels
1075572
def ambil_teks_dalam_label(sup):
    
    return ''.join(i.strip() for i in sup.find_all(text=True, recursive=False))
315478
def get_distribution_names(self):
        
        result = set()
        for root, dirs, files in os.walk(self.base_dir):
            for fn in files:
                if self.should_include(fn, root):
                    fn = os.path.join(root, fn)
                    url = urlunparse(('file', '',
                                      pathname2url(os.path.abspath(fn)),
                                      '', '', ''))
                    info = self.convert_url_to_download_info(url, None)
                    if info:
                        result.add(info['name'])
            if not self.recursive:
                break
        return result
378613
def labels(self):
        
        return [
            name for name in os.listdir(self.root)
            if os.path.isdir(os.path.join(self.root, name))
        ]
395283
def list_names(cls):
        """"""
        response = subwrap.run(['lxc-ls'])
        output = response.std_out
        return map(str.strip, output.splitlines())
1033742
def package_files(directory):
    """"""
    paths = []
    for (path, _, file_names) in walk(directory):
        for filename in file_names:
            paths.append(join('..', path, filename))
    return paths
712687
def labels(self):
        """"""
        return tuple(_Label(label.get('id'), label.get('color'), label.text) for label
                     in self.root.iter('label'))
1345435
def dir(cls, label, children):
        """"""
        return FSEntry(label=label, children=children, type=u"Directory", use=None)
986845
def get_image_list(self, name, dir_structure='original'):
        
        assert name in ['train', 'val', 'test']
        assert dir_structure in ['original', 'train']
        add_label_to_fname = (name != 'train' and dir_structure != 'original')
        if add_label_to_fname:
            synset = self.get_synset_1000()

        fname = os.path.join(self.dir, name + '.txt')
        assert os.path.isfile(fname), fname
        with open(fname) as f:
            ret = []
            for line in f.readlines():
                name, cls = line.strip().split()
                cls = int(cls)

                if add_label_to_fname:
                    name = os.path.join(synset[cls], name)

                ret.append((name.strip(), cls))
        assert len(ret), fname
        return ret