99Requires Python 2.1, recommends 2.3.
1010"""
1111
12- __authors__ = [
"Scott James Remnant <[email protected] >" ,
13- "Jeff Waugh <[email protected] >" ]
12+ __authors__ = [
"Scott James Remnant <[email protected] >" ,
"Jeff Waugh <[email protected] >" ]
1413__license__ = "Python"
1514
1615
17- import os
18- import sys
16+ import configparser
1917import locale
18+ import os
2019import socket
21- import configparser
20+ import sys
2221from urllib .parse import urljoin
2322
2423import planet
2524
26-
2725# Default configuration file path
2826CONFIG_FILE = "config.ini"
2927
3028# Defaults for the [Planet] config section
3129PLANET_NAME = "Unconfigured Planet"
3230PLANET_LINK = "Unconfigured Planet"
3331PLANET_FEED = None
34- OWNER_NAME = "Anonymous Coward"
32+ OWNER_NAME = "Anonymous Coward"
3533OWNER_EMAIL = ""
36- LOG_LEVEL = "WARNING"
37- FEED_TIMEOUT = 20 # seconds
34+ LOG_LEVEL = "WARNING"
35+ FEED_TIMEOUT = 20 # seconds
3836
3937# Default template file list
4038TEMPLATE_FILES = "examples/basic/planet.html.tmpl"
4139
4240
43-
4441def config_get (config , section , option , default = None , raw = 0 , vars = None ):
4542 """Get a value from the configuration, with a default."""
4643 if config .has_option (section , option ):
4744 return config .get (section , option , raw = raw , vars = None )
4845 else :
4946 return default
5047
48+
5149def main ():
5250 config_file = CONFIG_FILE
5351 offline = 0
@@ -81,24 +79,23 @@ def main():
8179 sys .exit (1 )
8280
8381 # Read the [Planet] config section
84- planet_name = config_get (config , "Planet" , "name" , PLANET_NAME )
85- planet_link = config_get (config , "Planet" , "link" , PLANET_LINK )
86- planet_feed = config_get (config , "Planet" , "feed" , PLANET_FEED )
87- owner_name = config_get (config , "Planet" , "owner_name" , OWNER_NAME )
82+ planet_name = config_get (config , "Planet" , "name" , PLANET_NAME )
83+ planet_link = config_get (config , "Planet" , "link" , PLANET_LINK )
84+ planet_feed = config_get (config , "Planet" , "feed" , PLANET_FEED )
85+ owner_name = config_get (config , "Planet" , "owner_name" , OWNER_NAME )
8886 owner_email = config_get (config , "Planet" , "owner_email" , OWNER_EMAIL )
8987 if verbose :
9088 log_level = "DEBUG"
9189 else :
92- log_level = config_get (config , "Planet" , "log_level" , LOG_LEVEL )
93- feed_timeout = config_get (config , "Planet" , "feed_timeout" , FEED_TIMEOUT )
94- template_files = config_get (config , "Planet" , "template_files" ,
95- TEMPLATE_FILES ).split (" " )
90+ log_level = config_get (config , "Planet" , "log_level" , LOG_LEVEL )
91+ feed_timeout = config_get (config , "Planet" , "feed_timeout" , FEED_TIMEOUT )
92+ template_files = config_get (config , "Planet" , "template_files" , TEMPLATE_FILES ).split (" " )
9693
9794 # Default feed to the first feed for which there is a template
9895 if not planet_feed :
9996 for template_file in template_files :
10097 name = os .path .splitext (os .path .basename (template_file ))[0 ]
101- if name .find (' atom' ) >= 0 or name .find (' rss' ) >= 0 :
98+ if name .find (" atom" ) >= 0 or name .find (" rss" ) >= 0 :
10299 planet_feed = urljoin (planet_link , name )
103100 break
104101
@@ -107,7 +104,7 @@ def main():
107104 # The user can specify more than one locale (separated by ":") as
108105 # fallbacks.
109106 locale_ok = False
110- for user_locale in config .get ("Planet" , "locale" ).split (':' ):
107+ for user_locale in config .get ("Planet" , "locale" ).split (":" ):
111108 user_locale = user_locale .strip ()
112109 try :
113110 locale .setlocale (locale .LC_ALL , user_locale )
@@ -144,10 +141,8 @@ def main():
144141 my_planet = planet .Planet (config )
145142 my_planet .run (planet_name , planet_link , template_files , offline )
146143
147- my_planet .generate_all_files (template_files , planet_name ,
148- planet_link , planet_feed , owner_name , owner_email )
144+ my_planet .generate_all_files (template_files , planet_name , planet_link , planet_feed , owner_name , owner_email )
149145
150146
151147if __name__ == "__main__" :
152148 main ()
153-
0 commit comments