release-notes/devel/xmlbeats beatconvert,NONE,1.1
Paul W. Frields (pfrields)
fedora-docs-commits at redhat.com
Sun Sep 24 19:12:44 UTC 2006
- Previous message: docs-common/common/entities de.po, 1.4, 1.5 el.po, 1.5, 1.6 en.po, 1.2, 1.3 entities-de.xml, 1.2, 1.3 entities-el.xml, 1.3, 1.4 entities-en.xml, 1.9, 1.10 entities-en_US.xml, 1.4, 1.5 entities-es.xml, 1.2, 1.3 entities-fr_FR.xml, 1.2, 1.3 entities-it.xml, 1.13, 1.14 entities-ja.xml, 1.2, 1.3 entities-ja_JP.xml, 1.3, 1.4 entities-nl.xml, 1.2, 1.3 entities-pa.xml, 1.2, 1.3 entities-pl.xml, 1.2, 1.3 entities-pt.xml, 1.4, 1.5 entities-pt_BR.xml, 1.4, 1.5 entities-ru.xml, 1.5, 1.6 entities-sv.xml, 1.2, 1.3 entities-zh_CN.xml, 1.3, 1.4 entities.pot, 1.9, 1.10 es.po, 1.4, 1.5 fr_FR.po, 1.2, 1.3 it.po, 1.17, 1.18 ja.po, 1.2, 1.3 ja_JP.po, 1.3, 1.4 nl.po, 1.3, 1.4 pa.po, 1.3, 1.4 pl.po, 1.3, 1.4 pt.po, 1.7, 1.8 pt_BR.po, 1.5, 1.6 ru.po, 1.6, 1.7 sv.po, 1.2, 1.3 zh_CN.po, 1.5, 1.6
- Next message: release-notes/devel/xmlbeats beatconvert,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: pfrields
Update of /cvs/docs/release-notes/devel/xmlbeats
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22774
Added Files:
beatconvert
Log Message:
New Python script for converting Beats from one wiki to another and then to XML
--- NEW FILE beatconvert ---
#!/usr/bin/python -tt
#
# (C) 2006 Paul W. Frields.
# This file is licensed under the GNU General Public License (GPL) v2.
import os
import sys
import urllib
import httplib
from getpass import getpass
from time import sleep
"""Take a list of Beats from the official Fedora Project wiki,
download them, and convert to DocBook using a properly outfitted
MoinMoin wiki."""
### Globals
myName = "beatconvert"
debugging = True
beatSite = "http://fedoraproject.org/wiki/"
beatDir = "Docs/Beats/"
beatUrl = beatSite + beatDir
convSite = "http://fedora-test.fedoraproject.org/"
convDir = "fedora-docs/Docs/Beats/"
convUrl = convSite + convDir
beatFolder = 'Beats'
waitTime = 10
######
def print_usage():
print "Usage:", myName, "<infile>"
print "\t<infile>: list of Beats, one per line"
if len(sys.argv) < 2:
print_usage()
sys.exit(1)
print "Using", beatUrl, "->", convUrl
try:
beatFile = open(sys.argv[1], "r")
except:
print "Problem opening file", sys.argv[1]
sys.exit(2)
beatList = [beat.rstrip('\n') for beat in beatFile.readlines()]
beatFile.close()
beatData = {}
for beat in beatList:
inUrl = ''.join((beatUrl, beat))
outUrl = ''.join((convUrl, beat))
beatData[beat] = [inUrl, outUrl]
print "Loaded", len(beatList), "beat names"
loginName = raw_input('Enter your wiki login name on the DocBook Moin: ')
password = getpass('Enter your password on the DocBook Moin: ')
conn = httplib.HTTPConnection(convSite[7:][:-1]) # hack to remove http:// /
# if debugging: conn.debuglevel = 1
print "Logging in to target wiki..."
conn.request('POST', '/fedora-docs',
urllib.urlencode({'action': 'login',
'login': 'Login',
'name': loginName,
'password': password}))
print 'Cookie monster want cookie!'
resp = conn.getresponse()
try:
cookie = resp.getheader('Set-Cookie')
cookie = cookie[:cookie.find(';')]
except:
inp = raw_input("Couldn't get a cookie. You can proceed " +
"anonymously, but results may not be\n" +
"guaranteed. Continue? [y/N]")
if inp not in ('y', 'Y'):
sys.exit(0)
# Make a folder to put the DocBook in.
try:
os.mkdir(beatFolder)
except OSError:
beatFolder = raw_input("Couldn't make a directory 'Beats' in your " +
"current location.\nSpecify a new one: ")
if beatFolder is '':
print "Quitting then."
sys.exit(0)
try:
os.mkdir(beatFolder)
except:
print "Failed, bailing."
sys.exit(5)
for beat, data in beatData.items():
print "Working on beat", beat
inUrl = data[0]
outUrl = data[1]
data.append(''.join(urllib.urlopen(inUrl+'?action=raw').readlines()))
print "Retrieved data for", beat
savetext = data[2]
submitStr = urllib.urlencode({'action': 'edit',
'editor': 'text',
'button_save': 'Save Changes',
'savetext': savetext})
print "Submitting beat", beat, "..."
conn.request('POST', ''.join(('/', convDir, beat)), submitStr,
{'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'beatconvert',
'Cookie': cookie})
resp = conn.getresponse()
# Make sure things worked OK so we don't lock ourselves out...
if resp.status != 200:
print "Submission failed. If this were a better script,",
print "there would be a fallback here."
sys.exit(6)
print "Submitted", beat
# Get the goods!
convStr = urllib.urlencode({'action': 'RenderAsDocbook'})
convUrl = data[1]
print "Retrieving XML for", beat, "at", convUrl
try:
resp = ''.join(urllib.urlopen(''.join((convUrl, '?action=RenderAsDocbook'))).readlines())
except:
print "Retrieval failed. If this were a better script,",
print "there would be a fallback here."
sys.exit(6)
print "Retrieved", beat
outXml = open(''.join((beatFolder, os.sep, beat.replace('/', ''))), "w")
outXml.write(resp)
outXml.close()
print "Wrote XML for", beat
print "Waiting for", waitTime, "seconds..."
sleep(waitTime)
conn.close()
print "*** Finished! ***"
print "Don't forget to rename and format the XML files with indenting."
- Previous message: docs-common/common/entities de.po, 1.4, 1.5 el.po, 1.5, 1.6 en.po, 1.2, 1.3 entities-de.xml, 1.2, 1.3 entities-el.xml, 1.3, 1.4 entities-en.xml, 1.9, 1.10 entities-en_US.xml, 1.4, 1.5 entities-es.xml, 1.2, 1.3 entities-fr_FR.xml, 1.2, 1.3 entities-it.xml, 1.13, 1.14 entities-ja.xml, 1.2, 1.3 entities-ja_JP.xml, 1.3, 1.4 entities-nl.xml, 1.2, 1.3 entities-pa.xml, 1.2, 1.3 entities-pl.xml, 1.2, 1.3 entities-pt.xml, 1.4, 1.5 entities-pt_BR.xml, 1.4, 1.5 entities-ru.xml, 1.5, 1.6 entities-sv.xml, 1.2, 1.3 entities-zh_CN.xml, 1.3, 1.4 entities.pot, 1.9, 1.10 es.po, 1.4, 1.5 fr_FR.po, 1.2, 1.3 it.po, 1.17, 1.18 ja.po, 1.2, 1.3 ja_JP.po, 1.3, 1.4 nl.po, 1.3, 1.4 pa.po, 1.3, 1.4 pl.po, 1.3, 1.4 pt.po, 1.7, 1.8 pt_BR.po, 1.5, 1.6 ru.po, 1.6, 1.7 sv.po, 1.2, 1.3 zh_CN.po, 1.5, 1.6
- Next message: release-notes/devel/xmlbeats beatconvert,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the docs-commits
mailing list