Add an embedded file.
438659
public function addInline($path, $name = null, $mime = true, $encoding = true)
    {
        $cid = static::generateId($this->client());
        $filename = basename($path);
        $this->_inlines[$path] = [
            'filename'    => $name ?: $filename,
            'disposition' => 'attachment',
            'mime'        => $mime,
            'headers'     => ['Content-ID: ' . $cid]
        ];
        return $cid;
    }
844050
def attach_related_file(self, path, mimetype=None):
        """"""
        filename = os.path.basename(path)
        content = open(path, 'rb').read()
        self.attach_related(filename, content, mimetype)
1216482
def add(self, *files):
        """"""

        try:
            _run_command(("git", "add") + files)
        except CalledProcessError:
            # Only if the command fails we check if the files
            # exist, because git-add most of the time fails when
            # the provided files are not found.
            for f in files:
                if not Path(f).exists():
                    raise FileNotFoundError(f"No such file or directory: {f}")
20615
def integrate_to_file(what, filename, start_line, end_line):
    

    try:
        with open(filename) as f:
            lines = f.readlines()
    except IOError:
        lines = []

    tmp_file = tempfile.NamedTemporaryFile(delete=False)

    lines.reverse()

    # first copy before start line
    while lines:
        line = lines.pop()

        if line == start_line:
            break

        tmp_file.write(line)

    # insert content
    tmp_file.write(start_line)
    tmp_file.write(what)
    tmp_file.write(end_line)

    # skip until end line
    while lines:
        line = lines.pop()

        if line == end_line:
            break

    # copy rest
    tmp_file.writelines(lines)
    tmp_file.close()

    os.rename(tmp_file.name, filename)
986872
def add_file(file)
      @tarball.add_file(file.path, file.mode) do |tarred_file|
        tarred_file.write file.read
      end
    end
1024263
def add(image_path, file_name=None):
    """"""
    if file_name is not None:
        dst_path = os.path.join(IMG_DIR, str(Path(file_name).stem + Path(image_path).suffix))
    else:
        dst_path = IMG_DIR

    if os.path.isfile(image_path):
        shutil.copy2(image_path, dst_path)
818689
def add_fileobj(self, fname, fcontent):
        
        tar_info = tarfile.TarInfo(fname)
        if isinstance(fcontent, io.BytesIO):
            tar_info.size = len(fcontent.getvalue())
        elif isinstance(fcontent, io.StringIO):
            tar_info.size = len(fcontent.getvalue())
            fcontent = io.BytesIO(fcontent.getvalue().encode("utf8"))
        else:
            if hasattr(fcontent, "readable"):
                fcontent = fcontent
            tar_info.size = len(fcontent)
            if isinstance(fcontent, str):
                fcontent = fcontent.encode("utf8")
            fcontent = io.BytesIO(fcontent)
        self._ios_to_add[tar_info] = fcontent
353333
def add_file(self, path, compress):
        
        if not os.path.isfile(path):
            raise ValueError('{} is not a file'.format(path))
        self.fileobj.seek(self.last_offset)

        with open(path, 'rb') as f:
            flags = os.stat(path).st_mode & 0o777
            self.add_fileobj(f, path, compress, flags)
982628
def add_file(self, filename):
        """"""

        assert not self.final, 'Trying to mutate a final graph.'
        self.add_source_file(filename)
        resolved, unresolved = self.get_file_deps(filename)
        self.graph.add_node(filename)
        for f in resolved:
            self.graph.add_node(f)
            self.graph.add_edge(filename, f)
        for imp in unresolved:
            self.broken_deps[filename].add(imp)
819319
def _add(self, lines):
        '''

        '''
        lines = self._setup('ADD', lines)

        for line in lines:
            values = line.split(" ")
            frompath = values.pop(0)

            # Custom parsing for frompath

            # If it's a web address, add to install routine to get
            if frompath.startswith('http'):
                for topath in values:
                    self._parse_http(frompath, topath)

            # Add the file, and decompress in install
            elif re.search("[.](gz|gzip|bz2|xz)$", frompath.strip()):
                for topath in values:
                    self._parse_archive(frompath, topath)

            # Just add the files
            else:
                for topath in values:
                    self._add_files(frompath, topath)
492468
public void addFile(String filename) {
        synchronized (files) {
            if (!files.contains(filename)) {
                files.add(filename);
            }
        }
    }
171095
def upload(self,project, inputtemplate, sourcefile, **kwargs):
        """"""
        return self.addinputfile(project, inputtemplate,sourcefile, **kwargs)
439887
def save_as(self):
        """"""
        editorstack = self.get_current_editorstack()
        if editorstack.save_as():
            fname = editorstack.get_current_filename()
            self.__add_recent_file(fname)
678848
function includedFile(fileName) {
            var relativePath = fileName.substring(appDir.length + 1);
            var result = false;
            for (var i = 0; i < onlyIncludeList.length; i++) {
                var prefix = onlyIncludeList[i];
                if (relativePath.indexOf(prefix) === 0) {
                    result = true;
                    break;
                }
            }
            return result;
        }
1346767
def addFile(self,file):
        
        mylambda= lambda adict : { key.upper() : mylambda(adict[key]) if isinstance(adict[key],dict) else adict[key] for key in adict.keys() }
        if file.endswith('.json') :
            with open(file, 'r') as f:
                fileContent = mylambda(json.load(f))

        elif file.endswith('.ini') :
            parser  = configparser.ConfigParser()
            parser.read(file)
            fileContent = { section : { conflist[0].upper() : conflist[1] for conflist in parser.items(section) } for section in parser.sections() }
        else :
            raise FileFormatException()

        self._config = {**self._config, **mylambda(fileContent)}
653946
protected function wizardAddFile()
    {
        $this->validatePrompt('path', $this->text('Path'), 'file');
        $this->validatePrompt('entity', $this->text('Entity'), 'file');
        $this->validatePrompt('entity_id', $this->text('Entity ID'), 'file', 0);
        $this->validatePrompt('title', $this->text('Title'), 'file', '');
        $this->validatePrompt('description', $this->text('Description'), 'file', '');
        $this->validatePrompt('weight', $this->text('Weight'), 'file', 0);

        $this->validateComponent('file');
        $this->addFile();
    }
1358795
def append(self, filename, content, binary=False):
        """"""

        self._raise_if_none()
        fn = path_join(self.path, filename)

        if binary:
            flags = 'ab'
        else:
            flags = 'a'

        with open(fn, 'a') as f:
            f.write(content)
            return True