Updated Arabic Translation by Djihed Afifi.
[straw.git] / src / lib / OPMLExport.py
blob72507bad81767e71f5dbf0a621e6a8762ca7bfa8
1 """ OPMLExport.py
2 """
4 __copyright__ = "Copyright (c) 2002-2005 Free Software Foundation, Inc."
5 __license__ = """
6 Straw is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2 of the License, or (at your option) any later
9 version.
11 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 Place - Suite 330, Boston, MA 02111-1307, USA. """
20 import pygtk
21 pygtk.require('2.0')
22 import gnomevfs
23 import OPML
25 def export(title, list, fname):
26 opml = OPML.OPML()
27 opml['title'] = title
28 for feed in list:
29 o = OPML.Outline()
30 o['text'] = feed.title.encode('utf-8')
31 o['description'] = feed.channel_description.encode('utf-8')
32 o['htmlUrl'] = feed.channel_link
33 o['language'] = 'unknown'
34 o['title'] = feed.channel_title.encode('utf-8')
35 o['type'] = 'rss'
36 o['version'] = 'RSS'
37 o['xmlUrl'] = feed.access_info[0]
38 opml.outlines.append(o)
39 f = gnomevfs.create(fname, gnomevfs.OPEN_WRITE, 0)
40 f.write('<?xml version="1.0"?>\n')
41 opml.output(f)
42 f.close()