Mercurial > feed2twitter
changeset 22:f610a13212fe
Adding optionparser
author | Walter Cruz <walter@waltercruz.com> |
---|---|
date | Tue, 23 Sep 2008 13:54:45 -0300 |
parents | 69179a909897 |
children | 56e57a84cb4a |
files | feed2twitter/VERSION feed2twitter/feed2twitter.egg-info/PKG-INFO feed2twitter/feed2twitter.egg-info/SOURCES.txt feed2twitter/feed2twitter.egg-info/top_level.txt feed2twitter/feed2twitter/__init__.py feed2twitter/feed2twitter/options.py feed2twitter/setup.py |
diffstat | 7 files changed, 82 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/feed2twitter/VERSION Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/VERSION Tue Sep 23 13:54:45 2008 -0300 @@ -1,1 +1,1 @@ -0.3.2 \ No newline at end of file +0.4.1.2 \ No newline at end of file
--- a/feed2twitter/feed2twitter.egg-info/PKG-INFO Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/feed2twitter.egg-info/PKG-INFO Tue Sep 23 13:54:45 2008 -0300 @@ -1,36 +1,49 @@ Metadata-Version: 1.0 Name: feed2twitter -Version: 0.1.7dev +Version: 0.4.1.2 Summary: Publish your feed items to twitter Home-page: http://www.assembla.com/spaces/feed2twitter Author: Walter Cruz Author-email: walter@waltercruz.com License: AGPL -Description: Feed2twitter updates a twitter account from a xml feed. +Description: ============ + Feed2Twitter + ============ + + Feed2twitter updates a twitter account from a xml feed. It's a free alternative to services like Twitterfeed. To install feed2twitter: - install python-twitter: - http://code.google.com/p/python-twitter/ - installfeedparser: - http://www.feedparser.org/ + + 1. install python-twitter: http://code.google.com/p/python-twitter/ - install it with: python setup.py install + 1. install feedparser: http://www.feedparser.org/ + + + Install it with: python setup.py install Running: - you need to set your feed and your twitter account. - Create a folder under the $HOME of the user that will run feed2twitter called .feed2twitter - Add a file called default.cfg, like this: + -------- + * You need to set your feed and your twitter account. + * Create a folder under the $HOME of the user that will run feed2twitter called .feed2twitter + * Add a file called default.cfg, like this: + + :: [global] url = http://example.com/rss username = twitter_user password = twitter_password + mode = text + interval = 01:00 - Run it with the command feed2twitter. It will update your twitter with your latest 5 posts, hour by hour + The url is the url for the feed that you want to publish, mode can be 'text' (140 chars of your post text) or 'title' (your post title, with a link). The interval is the interval in which the feed2twitter will publish your last posts. - Kudos to Gleicon da Silveira (http://zenmachine.wordpress.com/about/), that give me a idea of the code in a post of his blog + Run it with the command feed2twitter. It will update your twitter with your latest 5 posts, in the interval that you have set. + Kudos to Gleicon da Silveira (http://zenmachine.wordpress.com/about/), that give me a idea of the code in a post of his blog. + + You can contact me at walter@waltercruz.com. Have fun! Keywords: twitter feed Platform: UNKNOWN Classifier: Intended Audience :: Developers
--- a/feed2twitter/feed2twitter.egg-info/SOURCES.txt Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/feed2twitter.egg-info/SOURCES.txt Tue Sep 23 13:54:45 2008 -0300 @@ -1,14 +1,19 @@ +MANIFEST.in README setup.cfg setup.py +docs/default.cfg.sample +docs/license.txt +docs/release.howto feed2twitter/__init__.py +feed2twitter/options.py +feed2twitter/parsetime.py feed2twitter/readrss.py feed2twitter/tinyurl.py feed2twitter.egg-info/PKG-INFO feed2twitter.egg-info/SOURCES.txt feed2twitter.egg-info/dependency_links.txt feed2twitter.egg-info/entry_points.txt -feed2twitter.egg-info/paster_plugins.txt +feed2twitter.egg-info/not-zip-safe feed2twitter.egg-info/top_level.txt -feed2twitter.egg-info/zip-safe scripts/feed2twitter \ No newline at end of file
--- a/feed2twitter/feed2twitter.egg-info/top_level.txt Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/feed2twitter.egg-info/top_level.txt Tue Sep 23 13:54:45 2008 -0300 @@ -1,1 +1,2 @@ +docs feed2twitter
--- a/feed2twitter/feed2twitter/__init__.py Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/feed2twitter/__init__.py Tue Sep 23 13:54:45 2008 -0300 @@ -16,6 +16,7 @@ import feedparser, pickle, os, sys, twitter, urllib from ConfigParser import ConfigParser, NoOptionError +from options import Options import readrss import re import time @@ -80,10 +81,17 @@ self.twitIt(reversed(lista[:5])) def update(): + opt = Options() + options = opt.parse() conf = ConfigParser() + if options.sample_config: + from pkg_resources import resource_string + foo_config = resource_string(__name__, '../docs/default.cfg.sample') + print(foo_config) + sys.exit(1) configfile =os.path.expanduser('~/.feed2twitter/default.cfg') try: - fd = open(configfile, 'r') + fd = open(options.config_filename, 'r') except IOError: print >>sys.stderr, "File %s not found" % configfile sys.exit(2)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/feed2twitter/feed2twitter/options.py Tue Sep 23 13:54:45 2008 -0300 @@ -0,0 +1,33 @@ +# feed2twitter +# Copyright (C) 2008 Walter Cruz <walter@waltercruz.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +from optparse import OptionParser +import sys + +class Options(object): + def __init__(self): + self.parser = OptionParser() + self.parser.add_option("-c", "--config", dest="config_filename", + help="name of the file to read the settings", metavar="FILE") + self.parser.add_option("-p", "--print_sample_config", + action="store_true", dest="sample_config", default=False, + help="print a sample config file and exit") + def parse(self): + (options, args) = self.parser.parse_args() + if not options.config_filename and not options.sample_config: + self.parser.print_help() + sys.exit() + return options
--- a/feed2twitter/setup.py Wed Aug 13 15:31:22 2008 -0300 +++ b/feed2twitter/setup.py Tue Sep 23 13:54:45 2008 -0300 @@ -1,8 +1,6 @@ from setuptools import setup, find_packages -import sys, os -from os import path -v = open(path.join(path.dirname(__file__), 'VERSION')) -VERSION = v.readline().strip() +from pkg_resources import resource_string +VERSION = resource_string(__name__, 'VERSION').strip() setup(name='feed2twitter', version=VERSION, @@ -18,10 +16,11 @@ author='Walter Cruz', author_email='walter@waltercruz.com', url='http://www.assembla.com/spaces/feed2twitter', + packages=['feed2twitter','docs'], + #package_data = {'docs':['*']}, + include_package_data=True, license='AGPL', - packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - include_package_data=True, - zip_safe=True, + zip_safe=False, scripts=['scripts/feed2twitter'], install_requires=[ # -*- Extra requirements: -*-