Create a new Item from a file path.

        :param repo: Repo object.
        :param path: File path.
        :param name: Name of item (to override original file name).

        :return: New Item class instance.
969538
def from_path(self, repo, path, name=None):
        
        if name is None:
            name = os.path.basename(path)
        #FIXME: hack, there has to be a better way
        return Item.from_string(repo=repo, name=name, string=open(path).read())
446929
def create(self, item, dry_run=None):
        """"""
        logger.debug('Creating new item. Item: {item} Path: {data_file}'.format(
            item=item,
            data_file=self.data_file
        ))

        items = load_file(self.client, self.bucket_name, self.data_file)
        items = append_item(self.namespace, self.version, item, items)
        save_file(self.client, self.bucket_name, self.data_file, items, dry_run=dry_run)

        return item
1040814
def from_line(cls, name, comes_from=None):
        
        url = None
        name = name.strip()
        req = None
        path = os.path.normpath(os.path.abspath(name))
        link = None

        if is_url(name):
            link = Link(name)
        elif os.path.isdir(path) and (os.path.sep in name or name.startswith('.')):
            if not is_installable_dir(path):
                raise InstallationError("Directory %r is not installable. File 'setup.py' not found.", name)
            link = Link(path_to_url(name))
        elif is_archive_file(path):
            if not os.path.isfile(path):
                logger.warn('Requirement %r looks like a filename, but the file does not exist', name)
            link = Link(path_to_url(name))

        # If the line has an egg= definition, but isn't editable, pull the requirement out.
        # Otherwise, assume the name is the req for the non URL/path/archive case.
        if link and req is None:
          url = link.url_fragment
          req = link.egg_fragment

          # Handle relative file URLs
          if link.scheme == 'file' and re.search(r'\.\./', url):
            url = path_to_url(os.path.normpath(os.path.abspath(link.path)))

        else:
          req = name

        return cls(req, comes_from, url=url)
1155254
def from_path(cls, path):
    
    if os.path.exists(path) is False:
      raise errors.InvalidPathError(path)
    return cls(path=path)
763698
def _get_or_create_config(path, prompt=True):
    
    dirname = os.path.dirname(path)
    filename = os.path.basename(path)

    try:
        os.makedirs(dirname)
    except OSError:
        pass

    try:
        with open(path, 'r+') as f:
            if os.path.isfile(path):
                puts("{0} already exists, backing up".format(colored.green(path)))
                _backup(dirname, filename)
            return yaml.load(f)
    except IOError:
        return {}
497889
function cloneRepo(item){

      var deferred = Q.defer();
      var repoURL = item.repo;
      var path = item.path;

      deleteOldFiles(path).
      then(function(){
        return performCmd(repoURL, path);
      }).then(function(success){
        return npmInstall(path, success);
      }).then(function(success){
        return bowerInstall(path, success);
      }).then(function(){
        deferred.resolve();
      });

      return deferred.promise;

    }
1295878
def import_from_path(path):
    
    if path is None:
        return

    obj = locate(path)
    if obj is None:
        raise ImportError(
            "`{}` could not be imported".format(path)
        )

    return obj
403000
def from_folder(cls, path:PathOrStr, train:PathOrStr='train', valid:PathOrStr='valid',
                    valid_pct=None, classes:Collection=None, **kwargs:Any)->'ImageDataBunch':
        ""
        path=Path(path)
        il = ImageList.from_folder(path)
        if valid_pct is None: src = il.split_by_folder(train=train, valid=valid)
        else: src = il.split_by_rand_pct(valid_pct)
        src = src.label_from_folder(classes=classes)
        return cls.create_from_ll(src, **kwargs)
630933
def from_file(self, path=None):
        
        if self._version is None:
            self._version = file_version(path or self.version_file)
        return self
1226382
def fromfile(cls, path):
        
        parser = etree.XMLParser(remove_blank_text=True)

        return cls.fromtree(etree.parse(path, parser=parser))
763031
def from_file(cls, path):

        

        with open(path, 'r', errors='replace') as f:
            return cls(f.read())
905860
private File createNewFile(String path) throws IOException {

		// In windows, pathnames with spaces are returned as %20
		if (path.contains("%20"))
			path = path.replaceAll("%20", " ");
		File newFile = new File(path);

		if (!newFile.exists() && !newFile.createNewFile()) {
			throw new BundlingProcessException("Unable to create a temporary file at " + path);
		}

		if (LOGGER.isDebugEnabled())
			LOGGER.debug("Created file: " + newFile.getCanonicalPath());
		return newFile;
	}
766730
def create_app(self, apps_path, name):
        
        app_path = os.path.join(apps_path, name.lower())

        shutil.copytree(self.app_path, app_path)

        self.update_file(app_path, '__init__.py', {
            'name': name.lower()
        })

        self.update_file(app_path, 'apps.py', {
            'name': name.lower(),
            'verbose_name': name.capitalize()
        })
836292
def create_path(path, is_dir=False):
    
    path = norm_path(path)
    path_check = path
    if not is_dir:
        path_check = os.path.dirname(path)

    does_path_exists = os.path.exists(path_check)

    if does_path_exists:
        return path

    try:
        os.makedirs(path_check)
    except OSError:
        pass

    return path
262678
def create(cls, path):
        """"""
        cmd = [HG, 'init', path]
        subprocess.check_call(cmd)
        return cls(path)
633207
def _make_path(self, items):
        '''
        '''
        for key, val in items.items():
            if not isinstance(val, basestring):
                raise TypeError, ('Value "%s" for key "%s" must be an instance'
                                  ' of basestring' % (val, key))
            items[key] = quote_plus(val)

        try:
            path = self._url_format.format(**items)
        except AttributeError:
            # Old version of python
            path = self._url_format
            for key, val in items.items():
                path = path.replace('{%s}' % key, val)
        return path
605556
def _pull(self, *, repo_path: Path=None, git_repo: Repo=None, repo: str=None, branch: str=None,
              depth: Optional[int]=None,
              reference: Optional[Path]=None
              ) -> Repo:
        
        if git_repo is not None:
            try:
                git_repo.remote().fetch(branch)
                # equivalent to git reset --hard origin/branch
                git_repo.head.reset(f"origin/{branch}", index=True, working_tree=True)
            except GitCommandError:
                raise PullError("There was an error pulling the target repository.")
            return git_repo
        else:
            kwargs: Dict[str, Any] = {}

            if depth is not None:
                kwargs["depth"] = depth

            reference = self.get_reference_repository(reference, repo)

            if reference is not None:
                kwargs["reference-if-able"] = str(reference)
                kwargs["dissociate"] = True

            try:
                return Repo.clone_from(repo, str(repo_path), branch=branch, **kwargs)
            except GitCommandError:
                raise PullError("There was an error cloning the target repository.")