Beispiel #1
0
def saveproject_msg(parent, url):
    """Save a project file and return status message."""
    title = _("Save LinkChecker project")
    func = QtGui.QFileDialog.getSaveFileName
    suggestedname = url_to_filename(url, ProjectExt)
    res = func(parent, title, suggestedname, ProjectFilter)
    if not res:
        # user canceled
        return _("Canceled saving a project file.")
    filename = unicode(res)
    d = dict(filename=filename)
    if not is_writable(filename):
        return _("Could not write project file %(filename)s.") % d
    user_config = get_user_config()
    if is_readable(user_config):
        # Copy user config to filename since this is the current
        # configuration.
        # This way it is not necessary to write the parent.config
        # dictionary back to a file.
        shutil.copy(user_config, filename)
        filter_comments = True
    else:
        # use default config (ie. do not write anything)
        filter_comments = False
    write_header(filename, filter_comments)
    parser = ProjectParser(parent.config, parent.options, parent.urlinput)
    with open(filename, 'a') as fp:
        parser.write(fp)
    return _("Project file %(filename)s saved successfully.") % d
Beispiel #2
0
def saveproject_msg(parent, url):
    """Save a project file and return status message."""
    title = _("Save LinkChecker project")
    func = QtGui.QFileDialog.getSaveFileName
    suggestedname = url_to_filename(url, ProjectExt)
    res = func(parent, title, suggestedname, ProjectFilter)
    if not res:
        # user canceled
        return _("Canceled saving a project file.")
    filename = unicode(res)
    d = dict(filename=filename)
    if not is_writable(filename):
        return _("Could not write project file %(filename)s.") % d
    user_config = get_user_config()
    if is_readable(user_config):
        # Copy user config to filename since this is the current
        # configuration.
        # This way it is not necessary to write the parent.config
        # dictionary back to a file.
        shutil.copy(user_config, filename)
        filter_comments = True
    else:
        # use default config (ie. do not write anything)
        filter_comments = False
    write_header(filename, filter_comments)
    parser = ProjectParser(parent.config, parent.options, parent.urlinput)
    with open(filename, 'a') as fp:
        parser.write(fp)
    return _("Project file %(filename)s saved successfully.") % d
Beispiel #3
0
def openproject_msg(parent):
    """Select and load a project file. Returns message to display
    which indicates if file has been loaded successful."""
    title = _("Open LinkChecker project")
    func = QtGui.QFileDialog.getOpenFileName
    directory = ""
    filename = func(parent, title, directory, ProjectFilter)
    if not filename:
        # user canceled
        return _("Canceled opening a project file.")
    if not is_readable(filename):
        return _("Could not read project file %(filename)s.") % dict(filename=filename)
    return loadproject(filename, parent.config, parent.options, parent.urlinput)
def openproject_msg(parent):
    """Select and load a project file. Returns message to display
    which indicates if file has been loaded successful."""
    title = _("Open LinkChecker project")
    func = QtGui.QFileDialog.getOpenFileName
    directory = ""
    filename = func(parent, title, directory, ProjectFilter)
    if not filename:
        # user canceled
        return _("Canceled opening a project file.")
    if not is_readable(filename):
        return _("Could not read project file %(filename)s.") % dict(
            filename=filename)
    return loadproject(parent, filename)