From 576383413263430afc80fa7b2e289e145f87b5a4 Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Mon, 20 Nov 2017 18:48:32 -0800 Subject: [PATCH] create setup.py and ttbp package --- setup.py | 30 +++++++++++ ttbp/__init__.py | 0 {bin => ttbp}/_ttbp.py | 0 ttbp/chatter.py | 69 ++++++++++++++++++++++++ {bin => ttbp}/config/banner-beta.txt | 0 {bin => ttbp}/config/banner.txt | 0 {bin => ttbp}/config/defaults/footer.txt | 0 {bin => ttbp}/config/defaults/header.txt | 0 {bin => ttbp}/config/defaults/style.css | 0 {bin => ttbp}/core.py | 0 {bin => ttbp}/ttbp.py | 10 ++-- {bin => ttbp}/update.py | 0 {bin => ttbp}/util.py | 0 13 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 setup.py create mode 100644 ttbp/__init__.py rename {bin => ttbp}/_ttbp.py (100%) create mode 100644 ttbp/chatter.py rename {bin => ttbp}/config/banner-beta.txt (100%) rename {bin => ttbp}/config/banner.txt (100%) rename {bin => ttbp}/config/defaults/footer.txt (100%) rename {bin => ttbp}/config/defaults/header.txt (100%) rename {bin => ttbp}/config/defaults/style.css (100%) rename {bin => ttbp}/core.py (100%) rename {bin => ttbp}/ttbp.py (99%) rename {bin => ttbp}/update.py (100%) rename {bin => ttbp}/util.py (100%) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..da9d421 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup( + name='ttbp', + version='0.10.0', + description='command line social blogging tool used on tilde.town', + url='https://github.com/modgethanc/ttbp', + author='~endorphant', + author_email='endorphant@tilde.town', + license='MIT', + classifiers=[ + 'Topic :: Artistic Software', + 'License :: OSI Approved :: MIT License', + ], + keywords='blog', + packages=['ttbp'], + install_requires = [ + 'inflect==0.2.5', + 'mistune==0.8.1' + ], + include_package_data = True, + entry_points = { + 'console_scripts': [ + 'feels = ttbp.ttbp:start', + 'ttbp = ttbp.ttbp:start', + ] + }, +) diff --git a/ttbp/__init__.py b/ttbp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/_ttbp.py b/ttbp/_ttbp.py similarity index 100% rename from bin/_ttbp.py rename to ttbp/_ttbp.py diff --git a/ttbp/chatter.py b/ttbp/chatter.py new file mode 100644 index 0000000..ed2bbda --- /dev/null +++ b/ttbp/chatter.py @@ -0,0 +1,69 @@ +import json +import os +import random + +DEFAULT_LANG = { + "greet":[ + "hi", + "hey", + "howdy", + "good morning", + "good afternoon", + "good day", + "good evening", + "welcome back", + "nice to see you" + ], + "bye":[ + "see you later, space cowboy", + "bye, townie", + "until next time, friend", + "come back whenever" + ], + "friend":[ + "friend", + "pal", + "buddy", + "townie" + ], + "months":{ + "01":"january", + "02":"february", + "03":"march", + "04":"april", + "05":"may", + "06":"june", + "07":"july", + "08":"august", + "09":"september", + "10":"october", + "11":"november", + "12":"december" + } +} + +if os.path.exists("/home/endorphant/lib/python/chatterlib.json"): + with open("/home/endorphant/lib/python/chatterlib.json", 'r') as f: + LANG = json.load(f) +else: + LANG = DEFAULT_LANG + +def say(keyword): + ''' + takes a keyword and randomly returns from language dictionary to match that keyword + + returns None if keyword doesn't exist + + TODO: validate keyword? + ''' + + return random.choice(LANG.get(keyword)) + +def month(num): + ''' + takes a MM and returns lovercase full name of that month + + TODO: validate num? + ''' + + return LANG["months"].get(num) diff --git a/bin/config/banner-beta.txt b/ttbp/config/banner-beta.txt similarity index 100% rename from bin/config/banner-beta.txt rename to ttbp/config/banner-beta.txt diff --git a/bin/config/banner.txt b/ttbp/config/banner.txt similarity index 100% rename from bin/config/banner.txt rename to ttbp/config/banner.txt diff --git a/bin/config/defaults/footer.txt b/ttbp/config/defaults/footer.txt similarity index 100% rename from bin/config/defaults/footer.txt rename to ttbp/config/defaults/footer.txt diff --git a/bin/config/defaults/header.txt b/ttbp/config/defaults/header.txt similarity index 100% rename from bin/config/defaults/header.txt rename to ttbp/config/defaults/header.txt diff --git a/bin/config/defaults/style.css b/ttbp/config/defaults/style.css similarity index 100% rename from bin/config/defaults/style.css rename to ttbp/config/defaults/style.css diff --git a/bin/core.py b/ttbp/core.py similarity index 100% rename from bin/core.py rename to ttbp/core.py diff --git a/bin/ttbp.py b/ttbp/ttbp.py similarity index 99% rename from bin/ttbp.py rename to ttbp/ttbp.py index bcfc0a5..28b8231 100644 --- a/bin/ttbp.py +++ b/ttbp/ttbp.py @@ -31,6 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. the complete codebase is available at: https://github.com/modgethanc/ttbp ''' +from __future__ import absolute_import import os import random @@ -41,12 +42,13 @@ import json from email.mime.text import MIMEText; import re -import core -import chatter import inflect -import util -__version__ = "0.9.2" +from . import core +from . import chatter +from . import util + +__version__ = "0.10.0" __author__ = "endorphant