naf2conll/naf2conll/main.py
def can_output_to(output, batch, allow_overwriting=None):
        """
        Check whether the specified output location is legal.

        Handles batch and single file separately.

        :param output:              specified output location (may be both a
                                    directory or a file)
        :param batch:               whether the output location is for batch
                                    processing or a single file
        :param allow_overwriting:   whether to allow overwriting existing
                                    files or directories. Defaults to
                                    c.ALLOW_OVERWRITING if `None`.
        """
        if allow_overwriting is None:
            allow_overwriting = c.ALLOW_OVERWRITING

        if os.path.exists(output):
            if not allow_overwriting:
                thing = "folder" if batch else "file"
                raise ValueError(
                    "The configuration specifies overwriting is not allowed,"
                    f" but the output {thing} already exists: {output}"
                )
        else:
            # (Check if we can) create it
            if batch:
                os.makedirs(output)
                # This will keep some directories, but not the leaf one
                # that's annoying but at least we don't get a warning
                os.rmdir(output)
            else:
                open(output, 'w').close()
                os.remove(output)

        Check whether the specified output location is legal.

        Handles batch and single file separately.

        :param output:              specified output location (may be both a
                                    directory or a file)
        :param batch:               whether the output location is for batch
                                    processing or a single file
        :param allow_overwriting:   whether to allow overwriting existing
                                    files or directories. Defaults to
                                    c.ALLOW_OVERWRITING if `None`.
        
Check whether the specified output location is legal.
Handles batch and single file separately.
Check whether the specified output location is legal . Handles batch and single file separately .
def can_output_to(output, batch, allow_overwriting=None):
        if allow_overwriting is None:
            allow_overwriting = c.ALLOW_OVERWRITING
        if os.path.exists(output):
            if not allow_overwriting:
                thing = "folder" if batch else "file"
                raise ValueError(
                    "The configuration specifies overwriting is not allowed,"
                    f" but the output {thing} already exists: {output}"
                )
        else:
            if batch:
                os.makedirs(output)
                os.rmdir(output)
            else:
                open(output, 'w').close()
                os.remove(output)
def can_output_to ( output , batch , allow_overwriting = None ) : if allow_overwriting is None : allow_overwriting = c . ALLOW_OVERWRITING if os . path . exists ( output ) : if not allow_overwriting : thing = "folder" if batch else "file" raise ValueError ( "The configuration specifies overwriting is not allowed," f" but the output {thing} already exists: {output}" ) else : if batch : os . makedirs ( output ) os . rmdir ( output ) else : open ( output , 'w' ) . close ( ) os . remove ( output )
Check whether the specified output location is legal.
Check whether the specified output location is legal .
"""
        Check whether the specified output location is legal.

        Handles batch and single file separately.

        :param output:              specified output location (may be both a
                                    directory or a file)
        :param batch:               whether the output location is for batch
                                    processing or a single file
        :param allow_overwriting:   whether to allow overwriting existing
                                    files or directories. Defaults to
                                    c.ALLOW_OVERWRITING if `None`.
        """ # (Check if we can) create it # This will keep some directories, but not the leaf one # that's annoying but at least we don't get a warning
output
specified output location (may be both a
directory or a file)
specified output location ( may be both a directory or a file )
batch
whether the output location is for batch
processing or a single file
whether the output location is for batch processing or a single file
allow_overwriting
whether to allow overwriting existing
files or directories. Defaults to
c.ALLOW_OVERWRITING if `None`.
whether to allow overwriting existing files or directories . Defaults to c . ALLOW_OVERWRITING if ` None ` .