Embed a new file.
505338
def embeddedFileAdd(self, buffer, name, filename=None, ufilename=None, desc=None):
        """"""

        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")


        return _fitz.Document_embeddedFileAdd(self, buffer, name, filename, ufilename, desc)
1354611
def file_new(input_params={}, always_retry=True, **kwargs):
    
    input_params_cp = Nonce.update_nonce(input_params)
    return DXHTTPRequest('/file/new', input_params_cp, always_retry=always_retry, **kwargs)
19479
def include_file(self, uri, **kwargs):
        """"""

        _include_file(self.context, uri, self._templateuri, **kwargs)
1018970
def _include_file(context, uri, calling_uri, **kwargs):
    """"""

    template = _lookup_template(context, uri, calling_uri)
    (callable_, ctx) = _populate_self_namespace(
                                context._clean_inheritance_tokens(),
                                template)
    callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
297060
def add_file(self, filename, overwrite=False):
        

        with open(filename, 'r') as fin:
            self.add(fin.read(), overwrite)
471393
def copy(self, new_fn):
        """"""
        new_file = self.__class__(fn=str(new_fn))
        new_file.write(data=self.read())
        new_file.utime(self.atime, self.mtime)
        return new_file
860227
def add_embed(self, embed):
        
        self.embeds.append(embed.__dict__ if isinstance(embed, DiscordEmbed) else embed)
1373961
def file_cmd(context, tags, archive, bundle_name, path):
    """"""
    bundle_obj = context.obj['db'].bundle(bundle_name)
    if bundle_obj is None:
        click.echo(click.style(f"unknown bundle: {bundle_name}", fg='red'))
        context.abort()
    version_obj = bundle_obj.versions[0]
    new_file = context.obj['db'].new_file(
        path=str(Path(path).absolute()),
        to_archive=archive,
        tags=[context.obj['db'].tag(tag_name) if context.obj['db'].tag(tag_name) else
              context.obj['db'].new_tag(tag_name) for tag_name in tags]
    )
    new_file.version = version_obj
    context.obj['db'].add_commit(new_file)
    click.echo(click.style(f"new file added: {new_file.path} ({new_file.id})", fg='green'))
1106556
def _muaprocessnew(self):
        """"""
        foldername = self._foldername("new")
        files = self.filesystem.listdir(foldername)
        for filename in files:
            if filename == "":
                continue
            curfilename = self._foldername(joinpath("new", filename))
            newfilename = joinpath(
                self._cur,
                "%s:2,%s" % (filename, "")
                )
            self.filesystem.rename(curfilename, newfilename)
53113
def new_file(self, path: str, checksum: str=None, to_archive: bool=False,
                 tags: List[models.Tag]=None) -> models.File:
        """"""
        new_file = self.File(path=path, checksum=checksum, to_archive=to_archive, tags=tags)
        return new_file
334617
def add_data_file(data_files, target, source):
    """"""
    for t, f in data_files:
        if t == target:
            break
    else:
        data_files.append((target, []))
        f = data_files[-1][1]
    if source not in f:
        f.append(source)
1167531
def include_file(filename):
        """"""
        if os.path.isfile(filename):
            with open(filename) as handle:
                return safe_load(handle)
        raise RuntimeError("Include file %s doesn't exist!" % filename)
791185
def append(self, newContent, keep=True):
        
        content = self.__content + newContent
        if keep:
            self.__content = content

        if self.__needsRewrite:
            """
            Replace the content of the file.
            A temporary file is used to avoid loss of data through an interrupt.
            """
            tmpFilename = self.filename + ".tmp"

            util.write_file(content, tmpFilename)

            os.rename(tmpFilename, self.filename)
        else:
            with open(self.filename, "a") as file:
                file.write(newContent)

        self.__needsRewrite = not keep
1173042
def save(self, filename):
        """"""
        with open(filename, 'w') as fp:
            fp.write(str(self))
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)
32840
def new_filename(original_filename, new_locale):
    """"""
    orig_file = Path(original_filename)
    new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name
    return new_file.abspath()
1218925
def new(self, filename=None):
        """"""
        path = (self.exec_path,)
        if self.exec_path.filetype() in ('py', 'pyw', 'pyz', self.FTYPE):
            # get the absolute path to the python-executable
            p = find_executable("python")
            path = (p, 'python') + path
        else:
            # if run in frozen env (.exe):
            # first arg if execpath of the next session:
            path += (self.exec_path,)
        if filename:
            path += ('-o', filename)
        os.spawnl(os.P_NOWAIT, *path)