python3
This commit is contained in:
parent
1deea0e62d
commit
c37b564c7e
26
gen.py
26
gen.py
@ -113,7 +113,7 @@ content_map = {
|
|||||||
|
|
||||||
def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
||||||
|
|
||||||
print " indexing content -- " + dir_name;
|
print(" indexing content -- " + dir_name);
|
||||||
|
|
||||||
# desc_txt is a markdown file containing description
|
# desc_txt is a markdown file containing description
|
||||||
# for the project - no layout applied to it, only md
|
# for the project - no layout applied to it, only md
|
||||||
@ -124,7 +124,7 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
|||||||
desc_md = markdown.markdown(desc_file.read());
|
desc_md = markdown.markdown(desc_file.read());
|
||||||
# transform markdown
|
# transform markdown
|
||||||
except:
|
except:
|
||||||
print "error opening description file: " + desc_txt;
|
print("error opening description file: " + desc_txt);
|
||||||
desc_md = None;
|
desc_md = None;
|
||||||
#return;
|
#return;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
|||||||
index_file = open(index_txt, 'r+');
|
index_file = open(index_txt, 'r+');
|
||||||
content_index = json.loads(index_file.read());
|
content_index = json.loads(index_file.read());
|
||||||
except:
|
except:
|
||||||
print "error opening index: " + index_txt;
|
print("error opening index: " + index_txt);
|
||||||
content_index = None;
|
content_index = None;
|
||||||
#return;
|
#return;
|
||||||
|
|
||||||
@ -197,13 +197,13 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
#fix python markdown utf8 nonsense
|
# #fix python markdown utf8 nonsense
|
||||||
reload(sys);
|
# reload(sys);
|
||||||
sys.setdefaultencoding('utf8');
|
# sys.setdefaultencoding('utf8');
|
||||||
|
|
||||||
parse_args();
|
parse_args();
|
||||||
|
|
||||||
print '1/3 - Configuring';
|
print('1/3 - Configuring');
|
||||||
|
|
||||||
# main index template
|
# main index template
|
||||||
try:
|
try:
|
||||||
@ -229,7 +229,7 @@ if __name__ == '__main__':
|
|||||||
print('error creating output file. aborting...');
|
print('error creating output file. aborting...');
|
||||||
sys.exit(0);
|
sys.exit(0);
|
||||||
|
|
||||||
print '2/3 - Parsing input';
|
print('2/3 - Parsing input');
|
||||||
|
|
||||||
dirs = [d for d in os.listdir(input_dir) if not d == '_system' and os.path.isdir(os.path.join(input_dir,d))];
|
dirs = [d for d in os.listdir(input_dir) if not d == '_system' and os.path.isdir(os.path.join(input_dir,d))];
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
indx = open(indx_txt, 'r+');
|
indx = open(indx_txt, 'r+');
|
||||||
except:
|
except:
|
||||||
print "error opening index: " + indx_txt;
|
print("error opening index: " + indx_txt);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
txt = indx.read();
|
txt = indx.read();
|
||||||
@ -272,10 +272,10 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
dirutil.copy_tree(data_dir, out_data_dir);
|
dirutil.copy_tree(data_dir, out_data_dir);
|
||||||
except:
|
except:
|
||||||
print "error copying " + data_dir + " to " + out_data_dir + ". Continuing."
|
print("error copying " + data_dir + " to " + out_data_dir + ". Continuing.")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
print '3/3 - Generating ouput';
|
print('3/3 - Generating ouput');
|
||||||
|
|
||||||
html = template.read().replace('[[content]]', content);
|
html = template.read().replace('[[content]]', content);
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
dirutil.copy_tree(style_in, style_out);
|
dirutil.copy_tree(style_in, style_out);
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
print err;
|
print(err);
|
||||||
|
|
||||||
# robots.txt?
|
# robots.txt?
|
||||||
robots_in = os.path.join('.', 'robots.txt')
|
robots_in = os.path.join('.', 'robots.txt')
|
||||||
@ -302,4 +302,4 @@ if __name__ == '__main__':
|
|||||||
content_indx_template.close();
|
content_indx_template.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
print 'done.';
|
print('done.');
|
||||||
Loading…
x
Reference in New Issue
Block a user