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 reset_config_options(self):
     """Reset configuration file edit buttons."""
     self.user_config_writable = is_writable(self.user_config)
     set_edit_button(self.user_config, self.user_config_button,
                     self.user_config_filename, self.user_config_writable)
Beispiel #4
0
 def reset_config_options (self):
     """Reset configuration file edit buttons."""
     self.user_config_writable = is_writable(self.user_config)
     set_edit_button(self.user_config, self.user_config_button,
                     self.user_config_filename, self.user_config_writable)