changeset 0:159d911ad01c default tip

initial stub for bitsyapps
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 02 Nov 2010 08:05:36 -0700
parents
children
files bitsyapps/__init__.py bitsyapps/on.py setup.py
diffstat 3 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bitsyapps/__init__.py	Tue Nov 02 08:05:36 2010 -0700
@@ -0,0 +1,1 @@
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bitsyapps/on.py	Tue Nov 02 08:05:36 2010 -0700
@@ -0,0 +1,36 @@
+import os
+
+class BitsyDoc(object):
+
+  # TODO: make this work with tagging
+
+  on = 'on '
+  separator = '\n--\n\n'
+
+  def __init__(self, bitsyblog, directory):
+    self.bitsyblog = bitsyblog
+    self.directory = directory
+    assert os.path.exists(directory)
+
+  def __call__(self, blog_entry, url):
+    title = blog_entry.title()
+    if ':' in title and title.startswith(self.on):
+      subject, title = title.split(':', 1)
+      subject = subject[len(self.on):].lower()
+      full_subject = self.on + subject + ':'
+
+      # XXX single-word subjects, for now
+
+      filename = subject + '.txt'
+      filename = os.path.join(self.directory, filename)
+
+      exists = os.path.exists(filename)
+
+      f = file(filename, 'a')
+      if exists:
+        print >> f, self.separator
+
+      body = blog_entry.body.split(full_subject, 1)[-1].strip()
+
+      print >> f, body
+      f.close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Tue Nov 02 08:05:36 2010 -0700
@@ -0,0 +1,26 @@
+from setuptools import setup, find_packages
+import sys, os
+
+version = '0.0'
+
+setup(name='bitsyapps',
+      version=version,
+      description="pluggable applications for bitsyblog POST events",
+      long_description="""\
+""",
+      classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      keywords='',
+      author='Jeff Hammel',
+      author_email='jhammel@mozilla.com',
+      url='http://k0s.org/',
+      license='GPL',
+      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          # -*- Extra requirements: -*-
+      ],
+      entry_points="""
+      # -*- Entry points: -*-
+      """,
+      )