Skip to content
Permalink
Browse files

templates are how files are handled now, rawhtml is not long for this…

… world...
  • Loading branch information...
shawnmjones committed May 7, 2019
1 parent 951c0f9 commit f8cc7fcbf68d0cb901d0863a21ade4b61617f792
Showing with 55 additions and 17 deletions.
  1. +1 −0 Manifest.in
  2. +41 −15 bin/raintale_cmd
  3. +0 −1 raintale/storytellers.py
  4. +1 −1 raintale/version.py
  5. +11 −0 raiseversion.sh
  6. +1 −0 setup.py
@@ -0,0 +1 @@
include raintale/templates/*
@@ -65,6 +65,13 @@ def process_arguments(args):
* rawhtml - write raw HTML output to a file, requires -o option to specify the filename
* twitter - publish tweets containing story data, requries -c option to specify the credentials file
"""
) # TOOD: automatically list file formats based on templates

parser.add_argument('--preset', dest='storytelling_preset',
required=False, default='socialcard',
help="""The preset used for a given story, typically reflecting the
surrogate used to tell the story and the layout of the story.
"""
)

parser.add_argument('--story-template', dest='story_template',
@@ -152,27 +159,46 @@ def test_mementoembed_endpoint(url):

return status

def gather_credentials(args):
def gather_storyteller_data(args):

credentials_json = {}
storyteller_data = {}

if args.credentials_file is None:
# Use the storytelling service, even if they specify a template
if args.storyteller in storytelling_services:

if args.output_file is not None:
credentials_json["output_filename"] = args.output_file
with open(args.credentials_file) as f:
storyteller_data = load(f, Loader=Loader)

else:
logger.error("No credentials and no output file. Cannot continue...")
sys.exit(errno.EINVAL)
else:

with open(args.credentials_file) as f:
credentials_json = load(f, Loader=Loader)

if args.story_template is not None:
credentials_json['story_template'] = args.story_template
# Use the template, even if they specify another storyteller
if args.story_template is not None:

storyteller_data['story_template'] = args.story_template
storyteller_data['output_filename'] = args.output_file
args.storyteller = 'template'

else:

template_dir = "{}/templates".format(package_directory)

for filename in os.listdir(template_dir):

surrogate, fileformat = filename.split('.')

if fileformat == args.storyteller and surrogate == args.storytelling_preset:
args.storyteller = 'template'
storyteller_data['story_template'] = "{}/{}".format(template_dir, filename)
storyteller_data['output_filename'] = args.output_file
break

if 'story_template' not in storyteller_data:
logger.error("There are no storytellers of type {} with a preset of {} available, cannot continue".format(
args.storyteller, args.storytelling_preset
))
sys.exit(errno.EINVAL)

return credentials_json
return storyteller_data

def format_data(input_filename, title, collection_url, generated_by):

@@ -297,7 +323,7 @@ if __name__ == '__main__':

logger.info("Beginning raintale to tell your story.")

credentials = gather_credentials(args)
credentials = gather_storyteller_data(args)

story_data = format_data(args.input_filename, args.title, args.collection_url, args.generated_by)

@@ -399,7 +399,6 @@ def tell_story(self):


storytellers = {
"rawhtml": RawHTMLStoryTeller,
"twitter": TwitterStoryTeller,
"blogger": BloggerStoryTeller,
"template": FileTemplateStoryTeller
@@ -1,3 +1,3 @@
__appname__ = "raintale"
__appversion__ = "0.2019.05.07.163826"
__appversion__ = '0.2019.05.07.232934'
__useragent__ = "{}/{}".format(__appname__, __appversion__)
@@ -0,0 +1,11 @@
#!/bin/bash

# Update version in project
VERSION_STRING=`date -u +0.%Y.%m.%d.%H%M%S`
FILE_NAME='raintale/version.py'
# DOC_FILE_NAME='docs/source/conf.py'

# Update mementoembed version
sed -i.bak "s/^__appversion__ = .*$/__appversion__ = '$VERSION_STRING'/g" $FILE_NAME
rm $FILE_NAME.bak
# sed -i.bak "s/^release = '.*'$/release = '$VERSION_STRING'/g" $DOC_FILE_NAME
@@ -28,6 +28,7 @@
scripts=[
'bin/raintale_cmd',
],
include_package_data=True,
install_requires=[
'google-api-python-client',
'google_auth_oauthlib',

0 comments on commit f8cc7fc

Please sign in to comment.
You can’t perform that action at this time.