How to use the planet.config.load function in planet

To help you get started, we’ve selected a few planet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rubys / venus / tests / capture.py View on Github external
This script captures such output.  It should be run whenever there is
a major change in the contract between stages
"""

import shutil, os, sys

# move up a directory
sys.path.insert(0, os.path.split(sys.path[0])[0])
os.chdir(sys.path[0])

# copy spider output to splice input
import planet
from planet import spider, config
planet.getLogger('CRITICAL',None)

config.load('tests/data/spider/config.ini')
spider.spiderPlanet()
if os.path.exists('tests/data/splice/cache'):
    shutil.rmtree('tests/data/splice/cache')
shutil.move('tests/work/spider/cache', 'tests/data/splice/cache')

source=open('tests/data/spider/config.ini')
dest1=open('tests/data/splice/config.ini', 'w')
dest1.write(source.read().replace('/work/spider/', '/data/splice/'))
dest1.close()

source.seek(0)
dest2=open('tests/work/apply_config.ini', 'w')
dest2.write(source.read().replace('[Planet]', '''[Planet]
output_theme = asf
output_dir = tests/work/apply'''))
dest2.close()
github rubys / venus / tests / test_filter_xslt.py View on Github external
def test_xslt_filter(self):
        config.load('tests/data/filter/translate.ini')
        testfile = 'tests/data/filter/category-one.xml'

        input = open(testfile).read()
        output = shell.run(config.filters()[0], input, mode="filter")
        dom = xml.dom.minidom.parseString(output)
        catterm = dom.getElementsByTagName('category')[0].getAttribute('term')
        self.assertEqual('OnE', catterm)
github rubys / venus / tests / test_foaf.py View on Github external
def test_recursive(self):
        config.load('tests/data/config/foaf-deep.ini')
        feeds = config.subscriptions()
        feeds.sort()
        self.assertEqual(['http://api.flickr.com/services/feeds/photos_public.gne?id=77366516@N00',
        'http://del.icio.us/rss/eliast', 'http://del.icio.us/rss/leef',
        'http://del.icio.us/rss/rubys', 'http://intertwingly.net/blog/atom.xml',
        'http://thefigtrees.net/lee/life/atom.xml',
        'http://torrez.us/feed/rdf'], feeds)
github rubys / venus / tests / test_config_csv.py View on Github external
def setUp(self):
        config.load('tests/data/config/rlist-csv.ini')
github rubys / venus / tests / test_filter_tmpl.py View on Github external
def eval_config(self, name):
        # read the test case
        try:
            testcase = open(testfiles % (name,'ini'))
            data = testcase.read()
            description, expect = self.desc_config_re.search(data).groups()
            testcase.close()
        except:
            raise RuntimeError, "can't parse %s" % name

        # map to template info
        config.load(testfiles % (name,'ini'))
        results = tmpl.template_info("")

        # verify the results
        if not self.simple_re.match(expect):
            self.assertTrue(eval(expect, results), expect)
        else:
            lhs, rhs = self.simple_re.match(expect).groups()
            self.assertEqual(eval(rhs), eval(lhs, results))
github rubys / venus / tests / test_filters.py View on Github external
def test_excerpt_lorem_ipsum_summary(self):
        testfile = 'tests/data/filter/excerpt-lorem-ipsum.xml'
        config.load('tests/data/filter/excerpt-lorem-ipsum.ini')
        config.parser.set('excerpt.py', 'target', 'atom:summary')

        output = open(testfile).read()
        for filter in config.filters():
            output = shell.run(filter, output, mode="filter")

        dom = xml.dom.minidom.parseString(output)
        excerpt = dom.getElementsByTagName('summary')[0]
        self.assertEqual(u'Lorem ipsum dolor sit amet, consectetuer ' +
            u'adipiscing elit. Nullam velit. Vivamus tincidunt, erat ' +
            u'in \u2026', excerpt.firstChild.firstChild.nodeValue)
github rubys / venus / tests / test_filter_django.py View on Github external
def test_django_date_type(self):
        config.load('tests/data/filter/django/test.ini')
        results = dj.tmpl.template_info("")
        self.assertEqual(type(results['date']), datetime.datetime)
github rubys / venus / tests / test_subconfig.py View on Github external
def setUp(self):
        config.load('tests/data/config/rlist-config.ini')
github rubys / venus / planet.py View on Github external
elif arg == "-n" or arg == "--only-if-new":
            only_if_new = 1
        elif arg == "-x" or arg == "--expunge":
            expunge = 1
        elif arg == "-d" or arg == "--debug-splice":
            debug_splice = 1
        elif arg == "--no-publish":
            no_publish = 1
        elif arg.startswith("-"):
            print >>sys.stderr, "Unknown option:", arg
            sys.exit(1)
        else:
            config_file = arg

    from planet import config
    config.load(config_file)

    if verbose:
        import planet
        planet.getLogger('DEBUG',config.log_format())

    if not offline:
        from planet import spider
        try:
            spider.spiderPlanet(only_if_new=only_if_new)
        except Exception, e:
            print e

    from planet import splice
    doc = splice.splice()

    if debug_splice:
github rubys / venus / publish.py View on Github external
#!/usr/bin/env python
# coding=utf-8
"""
Main program to run just the splice portion of planet
"""
from __future__ import print_function

import os.path
import sys

from planet import config, publish

if __name__ == '__main__':

    if len(sys.argv) == 2 and os.path.isfile(sys.argv[1]):
        config.load(sys.argv[1])
        publish.publish(config)
    else:
        print("Usage:")
        print("  python %s config.ini" % sys.argv[0])