OpenQuizz
Une application de gestion des contenus pédagogiques
File Class Reference
Inheritance diagram for File:
Collaboration diagram for File:

Public Member Functions

def __init__ (self, mode="r", encoding=None, errors="strict", lazy=None, atomic=False)
 
def resolve_lazy_flag (self, value)
 
def convert (self, value, param, ctx)
 
- Public Member Functions inherited from ParamType
def __call__ (self, value, param=None, ctx=None)
 
def get_metavar (self, param)
 
def get_missing_message (self, param)
 
def split_envvar_value (self, rv)
 
def fail (self, message, param=None, ctx=None)
 

Data Fields

 mode
 
 encoding
 
 errors
 
 lazy
 
 atomic
 

Static Public Attributes

string name = "filename"
 
 envvar_list_splitter = os.path.pathsep
 
- Static Public Attributes inherited from ParamType
bool is_composite = False
 
 name = None
 
 envvar_list_splitter = None
 

Detailed Description

Declares a parameter to be a file for reading or writing.  The file
is automatically closed once the context tears down (after the command
finished working).

Files can be opened for reading or writing.  The special value ``-``
indicates stdin or stdout depending on the mode.

By default, the file is opened for reading text data, but it can also be
opened in binary mode or for writing.  The encoding parameter can be used
to force a specific encoding.

The `lazy` flag controls if the file should be opened immediately or upon
first IO. The default is to be non-lazy for standard input and output
streams as well as files opened for reading, `lazy` otherwise. When opening a
file lazily for reading, it is still opened temporarily for validation, but
will not be held open until first IO. lazy is mainly useful when opening
for writing to avoid creating the file until it is needed.

Starting with Click 2.0, files can also be opened atomically in which
case all writes go into a separate file in the same folder and upon
completion the file will be moved over to the original location.  This
is useful if a file regularly read by other users is modified.

See :ref:`file-args` for more information.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  mode = "r",
  encoding = None,
  errors = "strict",
  lazy = None,
  atomic = False 
)

Member Function Documentation

◆ convert()

def convert (   self,
  value,
  param,
  ctx 
)
Converts the value.  This is not invoked for values that are
`None` (the missing value).

Reimplemented from ParamType.

◆ resolve_lazy_flag()

def resolve_lazy_flag (   self,
  value 
)

Field Documentation

◆ atomic

atomic

◆ encoding

encoding

◆ envvar_list_splitter

envvar_list_splitter = os.path.pathsep
static

◆ errors

errors

◆ lazy

lazy

◆ mode

mode

◆ name

string name = "filename"
static

The documentation for this class was generated from the following file: