Build a :class:`Product` instance from a filepath.
355993
def from_file(cls, filepath):
        """"""
        # Find the abinit extension.
        for i in range(len(filepath)):
            if filepath[i:] in abi_extensions():
                ext = filepath[i:]
                break
        else:
            raise ValueError("Cannot detect abinit extension in %s" % filepath)

        return cls(ext, filepath)
217125
def create_package(self, dirpath):
        """"""
        dirpath = fixpath(dirpath)
        filepath = os.path.join(dirpath, "__coconut__.py")
        with openfile(filepath, "w") as opened:
            writefile(opened, self.comp.getheader("__coconut__"))
630933
def from_file(self, path=None):
        
        if self._version is None:
            self._version = file_version(path or self.version_file)
        return self
226964
def from_name_func(cls, path:PathOrStr, fnames:FilePathList, label_func:Callable, valid_pct:float=0.2, **kwargs):
        ""
        src = ImageList(fnames, path=path).split_by_rand_pct(valid_pct)
        return cls.create_from_ll(src.label_from_func(label_func), **kwargs)
1013670
def _generate_examples(self, filepath):
    """"""
    rows_per_pair_id = collections.defaultdict(list)

    with tf.io.gfile.GFile(filepath) as f:
      reader = csv.DictReader(f, delimiter='\t', quoting=csv.QUOTE_NONE)
      for row in reader:
        rows_per_pair_id[row['pairID']].append(row)

    for rows in six.itervalues(rows_per_pair_id):
      premise = {row['language']: row['sentence1'] for row in rows}
      hypothesis = {row['language']: row['sentence2'] for row in rows}
      yield {
          'premise': premise,
          'hypothesis': hypothesis,
          'label': rows[0]['gold_label'],
      }
1153505
def from_path(cls, conn, path):
        """"""
        path = path.strip(SEP)
        full_path = os.path.join(conn.abs_root, path)
        return cls(conn, path, 0, os.path.getsize(full_path))
1170371
def from_path(path):
  
  for item in ref:
    build = ref[item]
    valid_ = build['is_valid']
    if valid_(path) is True:
      return build['builder'](path)
  raise errors.InvalidProjectStructure()
1109395
def _load_from_file(self, filename):
        """"""
        if filename in self.fdata:
            return self.fdata[filename]
        else:
            filepath = find_in_tarball(self.tarloc, filename)
            return read_from_tarball(self.tarloc, filepath)
856387
def product_path(cls, project, location, product):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/locations/{location}/products/{product}",
            project=project,
            location=location,
            product=product,
        )
746270
def _construct_module(info, target):
    """"""

    for path in paths:
        real_path = os.path.abspath(os.path.join(target, path.format(**info)))
        log("Making directory '%s'" % real_path)
        os.makedirs(real_path)

    # pprint(info)
    for item in templates.values():
        source = os.path.join('dev/templates', item[0])
        filename = os.path.abspath(
            os.path.join(target, item[1].format(**info)))
        log("Creating file from template '%s'" % filename,
            emitter='MANAGE')
        write_template_file(source, filename, info)
783099
def from_folder(cls, path:PathOrStr='.', extensions:Collection[str]=None, **kwargs)->ItemList:
        ""
        extensions = ifnone(extensions, image_extensions)
        return super().from_folder(path=path, extensions=extensions, **kwargs)
1299951
def from_file(cls, path=None):
        
        # None => use default
        if path is None:
            for path in cls.default_pathes():
                try:
                    return cls.from_file(path)
                except IOError as e:
                    logging.getLogger(__name__).debug(
                        _("Failed to read config file: {0}", exc_message(e)))
                except ImportError as e:
                    logging.getLogger(__name__).warn(
                        _("Failed to read {0!r}: {1}", path, exc_message(e)))
            return cls({})
        # False/'' => no config
        if not path:
            return cls({})
        if os.path.splitext(path)[1].lower() == '.json':
            from json import load
        else:
            from yaml import safe_load as load
        with open(path) as f:
            return cls(load(f))
1175779
def as_existing_file(self, filepath):
        """"""
        if os.path.isfile(filepath) and hasattr(self, '__file_class__'):
            return self.__file_class__(filepath)  # pylint: disable=no-member
        return self.__class__(filepath)
1200154
def create(cls, path):
        """"""
        try:
            os.makedirs(path)
        except OSError as e:
            if not e.errno == errno.EEXIST:
                raise
        cmd = [SVNADMIN, 'create', path]
        subprocess.check_call(cmd)
        return cls(path)
725621
def _generate_examples(self, images_dir_path, labels_path, setid_path,
                         split_name):
    """"""
    with tf.io.gfile.GFile(labels_path, "rb") as f:
      labels = tfds.core.lazy_imports.scipy.io.loadmat(f)["labels"][0]
    with tf.io.gfile.GFile(setid_path, "rb") as f:
      examples = tfds.core.lazy_imports.scipy.io.loadmat(f)[split_name][0]

    for image_id in examples:
      file_name = "image_%05d.jpg" % image_id
      yield {
          "image": os.path.join(images_dir_path, file_name),
          "label": labels[image_id - 1] - 1,
          "file_name": file_name,
      }
579574
def compile_classpath(self, classpath_product_key, target, extra_cp_entries=None):
    """"""

    classpath_entries = list(
      entry.path
        for entry in self.compile_classpath_entries(classpath_product_key, target, extra_cp_entries)
    )

    # Verify that all classpath entries are under the build root.
    for entry in classpath_entries:
      assert entry.startswith(get_buildroot()), \
             "Classpath entry does not start with buildroot: {}".format(entry)

    return classpath_entries
1102604
def build_from_path(package, path, dry_run=False, env='default', outfilename=DEFAULT_BUILDFILE):
    
    team, owner, pkg, subpath = parse_package(package, allow_subpath=True)

    if not os.path.exists(path):
        raise CommandException("%s does not exist." % path)

    try:
        if os.path.isdir(path):
            buildpath = os.path.join(path, outfilename)
            if os.path.exists(buildpath):
                raise CommandException(
                    "Build file already exists. Run `quilt build %r` instead." % buildpath
                )

            contents = generate_contents(path, outfilename)
            build_package_from_contents(team, owner, pkg, subpath, path, contents, dry_run=dry_run, env=env)
        else:
            build_package(team, owner, pkg, subpath, path, dry_run=dry_run, env=env)

        if not dry_run:
            print("Built %s successfully." % package)
    except BuildException as ex:
        raise CommandException("Failed to build the package: %s" % ex)