#! /usr/bin/env python # -*- coding: utf8 -*- # # Copyright (C) 2018 The Mana World 2 # Author: Jonatas N. (Jesusalva) import datetime date=str(datetime.date.today()) fulldate=str(datetime.datetime.utcnow().isoformat()) #date="2018-10-06" #fulldate="2018-10-06T20:30:20.663750" # Open file (Dt) and export to "old". (Src) is current news dt=open("nf_main.xml", "r") old=[] for line in dt: old.append(line) dt.close() dt=open("nf_main.xml", "w") src=open("../update/news.txt", "r") # Read news and prepare header ns=open("../update/news.txt", "r") # Function to markup it, and strip new lines def markup(r): r=r.replace('##0', '') r=r.replace('##1', '') r=r.replace('##2', '') r=r.replace('##3', '') r=r.replace('##4', '') r=r.replace('##5', '') r=r.replace('##6', '') r=r.replace('##7', '') r=r.replace('##8', '') r=r.replace('##9', '') r=r.replace('##B', '') r=r.replace('##b', '') r=r.replace('[@@', '') r=r.replace('@@]', '') return r def nn(r): return r.replace('\n', '') # Write the news, and close that file dt.write(' \n') for i in src: if ('##0 Actual Release: ##1' in i): dt.write('\ '+nn(i.replace('##0 Actual Release: ##1',''))+'\n\ \n\ '+fulldate+'\n\ tag:tmw2.org,'+date+'\n\ '+markup(i)+'

\n') dt.write("]]>
\n
") dt.write('\n\n') for i in old: dt.write(i) src.close() dt.close() # Open main file as (Dt) and read from (Ns) dt=open("feed.xml", "w") ns=open("nf_main.xml", "r") # headers dt.write('\ \n\ \n\ TMW2\n\ \n\ \n\ ') dt.write(' '+fulldate+'\n') dt.write('\ https://tmw2.org\n\ \n\ TMW2 Project\n\ admin@tmw2.org\n\ \n\ ') # Write data for i in ns: dt.write(i) # close dt.write('\n') dt.close() ns.close()