tmt/utils.py
def create_file(path, content, name, force=False, mode=0o664, quiet=False):
    """ Create a new file, handle errors """
    say = log.debug if quiet else echo
    action = 'created'
    if os.path.exists(path):
        if force:
            action = 'overwritten'
        else:
            raise GeneralError("File '{}' already exists.".format(path))
    try:
        with open(path, 'w') as file_:
            file_.write(content)
        say("{} '{}' {}.".format(name.capitalize(), path, action))
    except OSError as error:
        raise GeneralError("Failed to create {} '{}' ({})".format(
            name, path, error))
 Create a new file, handle errors 
Create a new file, handle errors
Create a new file handle errors
def create_file(path, content, name, force=False, mode=0o664, quiet=False):
    say = log.debug if quiet else echo
    action = 'created'
    if os.path.exists(path):
        if force:
            action = 'overwritten'
        else:
            raise GeneralError("File '{}' already exists.".format(path))
    try:
        with open(path, 'w') as file_:
            file_.write(content)
        say("{} '{}' {}.".format(name.capitalize(), path, action))
    except OSError as error:
        raise GeneralError("Failed to create {} '{}' ({})".format(
            name, path, error))
def create_file ( path , content , name , force = False , mode = 0o664 , quiet = False ) : say = log . debug if quiet else echo action = 'created' if os . path . exists ( path ) : if force : action = 'overwritten' else : raise GeneralError ( "File '{}' already exists." . format ( path ) ) try : with open ( path , 'w' ) as file_ : file_ . write ( content ) say ( "{} '{}' {}." . format ( name . capitalize ( ) , path , action ) ) except OSError as error : raise GeneralError ( "Failed to create {} '{}' ({})" . format ( name , path , error ) )
Create a new file, handle errors
Create a new file handle errors
""" Create a new file, handle errors """
path
content
name
force
mode
quiet