예제 #1
0
 def bookmark_to_desktop(self, bookmark):
     # Creates .desktop file
     desktop = "[Desktop Entry]\n"
     desktop += "Version=1.0\n"
     desktop += "Encoding=UTF-8\n"
     desktop += "Name=%s\n" % bookmark.get_title()
     desktop += "Type=Link\n"
     desktop += "URL=%s\n" % bookmark.get_uri()
     desktop += "Icon=gnome-fs-bookmark\n"
     f = File.TempFile(desktop)
     f.force_new_filename(self.get_bookmark_filename(bookmark) + ".desktop")
     return f
예제 #2
0
 def bookmark_to_webloc(self, bookmark):
     # Create .webloc as used by FireFox on Mac OSX
     webloc = '<?xml version="1.0" encoding="UTF-8"?>\n'
     webloc += '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n'
     webloc += '<plist version="1.0">\n'
     webloc += '<dict>\n'
     webloc += '    <key>URL</key>\n'
     webloc += '    <string>%s</string>\n' % bookmark.get_uri()
     webloc += '</dict>\n'
     webloc += '</plist>\n'
     f = File.TempFile(webloc)
     f.force_new_filename(self.get_bookmark_filename(bookmark) + '.webloc')
     return f
예제 #3
0
def new_tempfile(contents, **kwargs):
    """
    Returns a new File onject, which has been created in the 
    system temporary directory, and that has been filled with
    contents
    
    The file is closed when it is returned
    
    @param contents: The data to write into the file
    @returns: a L{conduit.datatypes.File}
    """
    import conduit.datatypes.File as File
    return File.TempFile(contents, **kwargs)
예제 #4
0
    def tomboy_note_to_file(self, note, **kwargs):
        content = note.get_xml()
        #Old tomboy made this note, fallback to plain text
        if content == None:
            content = note.get_contents()

        #replace the following characters in the note
        #title with an underscore
        filename = note.get_title().translate(
            string.maketrans(self.ILLEGAL_TITLE_CHARS,
                             "_" * len(self.ILLEGAL_TITLE_CHARS)))
        f = File.TempFile(content)
        f.force_new_filename(filename)
        f.force_new_file_extension(self.NOTE_EXTENSION)
        return f
예제 #5
0
 def email_to_file(self, email, **kwargs):
     f = File.TempFile(email.get_email_string())
     return f
예제 #6
0
 def setting_to_file(self, setting):
     f = File.TempFile(self._to_text(setting))
     f.force_new_filename(setting.key.replace("/", "_"))
     f.force_new_file_extension(".txt")
     return f
예제 #7
0
 def note_to_file(self, note, **kwargs):
     f = File.TempFile(note.get_contents())
     f.force_new_filename(note.get_title())
     f.force_new_file_extension(".txt")
     return f