Commits

Doug Hellmann  committed 33cac47

pep8 fixes

  • Participants
  • Parent commits ebb695b

Comments (0)

Files changed (2)

File rst2marsedit/main.py

 
 import codecs
 import optparse
-import os
 import string
 import subprocess
 import tempfile
 
 SCRIPT_TEMPLATE_NAME = 'SendToMarsEdit.applescript'
 
+
 def main():
     parser = optparse.OptionParser('%prog <infile>')
     parser.add_option('-b', '--blog',
 
     if not args:
         parser.error('Please specify an input rst file')
-    
+
     rst_file = args[0]
 
     # Convert RST to HTML
     try:
-        rst2html = subprocess.Popen(['rst2html.py', '--no-generator', '--initial-header-level=4',
-                                     rst_file],
-                                    stdout=subprocess.PIPE)
+        rst2html = subprocess.Popen(
+            ['rst2html.py', '--no-generator', '--initial-header-level=4',
+             rst_file],
+            stdout=subprocess.PIPE,
+            )
         html = rst2html.communicate()[0]
         if not html:
             raise ValueError('No HTML produced by rst2html.py')
     body = soup.find('body')
     [h1.extract() for h1 in body.findAll('h1')]
     content = ''.join(unicode(c) for c in body.contents).strip()
-                    
+
     # Get the title of the article
     title = ''.join(unicode(c) for c in soup.find('title').contents)
 
         f.flush()
 
         # Build the AppleScript file from the template
-        script_file = tempfile.NamedTemporaryFile(mode='w', suffix='.applescript')
+        script_file = tempfile.NamedTemporaryFile(mode='w',
+                                                  suffix='.applescript',
+                                                  )
         try:
             script_template = string.Template(
                 pkg_resources.resource_string(__name__, SCRIPT_TEMPLATE_NAME)
                 blog_instruction = ''
 
             script_body = script_template.safe_substitute(
-                categories = ', '.join('"%s"' % t for t in options.tags),
-                blog_instruction = blog_instruction,
+                categories=', '.join('"%s"' % t for t in options.tags),
+                blog_instruction=blog_instruction,
                 )
             script_file.write(script_body)
             script_file.flush()
 
             # Open a new blog entry in MarsEdit
-            mars = subprocess.Popen(['osascript', script_file.name, f.name, title])
+            mars = subprocess.Popen(
+                ['osascript', script_file.name, f.name, title],
+                )
             mars.communicate()
         finally:
             script_file.close()
 except IOError:
     long_description = ''
 
-################################################################################
+###############################################################################
 # find_package_data is an Ian Bicking creation.
 
 # Provided as an attribute, so you can append to these instead
 standard_exclude_directories = ('.*', 'CVS', '_darcs', './build',
                                 './dist', 'EGG-INFO', '*.egg-info')
 
+
 def find_package_data(
     where='.', package='',
     exclude=standard_exclude,
 
     Note patterns use wildcards, or can be exact paths (including
     leading ``./``), and all searching is case-insensitive.
-    
+
     This function is by Ian Bicking.
     """
 
                         new_package = package + '.' + name
                     stack.append((fn, '', new_package, False))
                 else:
-                    stack.append((fn, prefix + name + '/', package, only_in_packages))
+                    stack.append((fn,
+                                  prefix + name + '/',
+                                  package,
+                                  only_in_packages))
             elif package or not only_in_packages:
                 # is a file
                 bad_name = False
                         break
                 if bad_name:
                     continue
-                out.setdefault(package, []).append(prefix+name)
+                out.setdefault(package, []).append(prefix + name)
     return out
-################################################################################
+###############################################################################
     
 
 setup(
-    name = PROJECT,
-    version = VERSION,
-    
-    description = 'Convert rst input to HTML suitable for use with MarsEdit',
-    long_description = long_description,
-    
-    author = 'Doug Hellmann',
-    author_email = 'doug.hellmann@gmail.com',
+    name=PROJECT,
+    version=VERSION,
 
-    url = 'http://www.doughellmann.com/projects/%s/' % PROJECT,
-    download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \
-                    (PROJECT, VERSION),
+    description='Convert rst input to HTML suitable for use with MarsEdit',
+    long_description=long_description,
 
-    classifiers = [ 'Development Status :: 5 - Production/Stable',
-                    'License :: OSI Approved :: BSD License',
-                    'Programming Language :: Python',
-                    'Intended Audience :: Developers',
-                    'Intended Audience :: End Users/Desktop',
-                    'Environment :: Console',
-                    'Topic :: Documentation',
-                    'Topic :: Text Processing :: Markup :: HTML',
-                    ],
+    author='Doug Hellmann',
+    author_email='doug.hellmann@gmail.com',
 
-    platforms = ['Any'],
+    url='http://www.doughellmann.com/projects/%s/' % PROJECT,
+    download_url='http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \
+        (PROJECT, VERSION),
+
+    classifiers=['Development Status :: 5 - Production/Stable',
+                 'License :: OSI Approved :: BSD License',
+                 'Programming Language :: Python',
+                 'Intended Audience :: Developers',
+                 'Intended Audience :: End Users/Desktop',
+                 'Environment :: Console',
+                 'Topic :: Documentation',
+                 'Topic :: Text Processing :: Markup :: HTML',
+                 ],
+
+    platforms=['Any'],
 
     provides=['rst2marsedit',
               ],
               'BeautifulSoup (==3.0.8)',
               ],
 
-    packages = find_packages(),
-    include_package_data = True,
+    packages=find_packages(),
+    include_package_data=True,
     # Scan the input for package information
-    # to grab any data files (text, images, etc.) 
+    # to grab any data files (text, images, etc.)
     # associated with sub-packages.
-    package_data = find_package_data(PROJECT, 
-                                     package=PROJECT,
-                                     only_in_packages=False,
-                                     ),
+    package_data=find_package_data(PROJECT,
+                                   package=PROJECT,
+                                   only_in_packages=False,
+                                   ),
 
-    entry_points = {
+    entry_points={
         'console_scripts': [
             'rst2marsedit = rst2marsedit.main:main',
             ],