]> jfr.im git - z_archive/twitter.git/commitdiff
Misc fixes for unicode
authormverdone <redacted>
Tue, 8 Apr 2008 03:01:46 +0000 (03:01 +0000)
committermverdone <redacted>
Tue, 8 Apr 2008 03:01:46 +0000 (03:01 +0000)
git-svn-id: http://svn.mike.verdone.ca/pyprojects/twitter/trunk@157 d723f978-dc38-0410-87ed-da353333cdcc

setup.py
twitter.egg-info/PKG-INFO
twitter.egg-info/SOURCES.txt
twitter/cmdline.py

index 2c3af7be550594de48200692002a15f208ca07ea..681aec8b4e9c8f7ef2d6121c40c405aca53a74a8 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,7 @@ setup(name='twitter',
       zip_safe=True,
       install_requires=[
           # -*- Extra requirements: -*-
+          "simplejson>=1.7.1",
       ],
       entry_points="""
       # -*- Entry points: -*-
index d76e05c19fe27f351ddd6f61e8238ade34871932..815dd241bb6147d7f2809aac82cbcfe2d53bf8f2 100644 (file)
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: twitter
-Version: 0.1dev-r155
+Version: 0.1dev-r156
 Summary: An API and command-line toolset for Twitter (twitter.com)
 Home-page: http://mike.verdone.ca/twitter/
 Author: Mike Verdone
index 9846e7b423f91022b879ec191e1eb7287b5036f1..d1643e80a80530182ba4c08098847f23d98f5293 100644 (file)
@@ -9,4 +9,4 @@ twitter.egg-info/dependency_links.txt
 twitter.egg-info/entry_points.txt
 twitter.egg-info/paster_plugins.txt
 twitter.egg-info/top_level.txt
-twitter.egg-info/zip-safe
+twitter.egg-info/zip-safe
\ No newline at end of file
index 7acd06ee7a9eb1aed7b52f2cf682fa0092120296..b4459c8fbe1d3774895e1ce081d3cee9dd6bd82c 100644 (file)
@@ -32,7 +32,7 @@ options = {
 def parse_args(args, options):
     long_opts = ['email', 'password', 'help']
     short_opts = "e:p:h?"
-    opts, options['extra_args'] = getopt(args, short_opts, long_opts)
+    opts, extra_args = getopt(args, short_opts, long_opts)
     
     for opt, arg in opts:
         if opt in ('-e', '--email'):
@@ -42,11 +42,16 @@ def parse_args(args, options):
         elif opt in ('-?', '-h', '--help'):
             print __doc__
             sys.exit(0)
+    
+    if extra_args:
+        options['action'] = extra_args[0]
+    options['extra_args'] = extra_args[1:]
 
 class StatusFormatter(object):
     def __call__(self, status):
-        return u"%s: %s" %(
-            status['user']['screen_name'], status['text'])
+        return (u"%s: %s" %(
+            status['user']['screen_name'], status['text'])).encode(
+                sys.stdout.encoding, 'replace')
 
 def no_action(twitter, options):
     print >> sys.stderr, "No such action: ", options['action']
@@ -66,7 +71,8 @@ def action_public(twitter, options):
 
 def action_set_status(twitter, options):
     twitter.statuses.update(
-        status=" ".join(options['extra_args']))
+        status=(u" ".join(options['extra_args'])).encode(
+            'utf8', 'replace'))
 
 actions = {
     'friends': action_friends,
@@ -74,11 +80,11 @@ actions = {
     'set': action_set_status,
 }
 
+
 def main():
-    args = sys.argv[1:]
-    if args and args[0][0] != "-":
-        options['action'] = args[0]
-        args = args[1:]
+    return main_with_args(sys.argv[1:])
+    
+def main_with_args(args):
     parse_args(args, options)
     twitter = Twitter(options['email'], options['password'])
     action = actions.get(options['action'], no_action)