Skip to content

Commit

Permalink
moves files into an 'articles' dir for #39
Browse files Browse the repository at this point in the history
  • Loading branch information
wrought committed Sep 14, 2014
1 parent 5fcedde commit c2209d0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions jats-to-mediawiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def main():
# download the file
archivefilename = wget.filename_from_url(archivefileurl)

if not os.path.exists(archivefilename):
urllib.urlretrieve(archivefileurl, archivefilename)
if not os.path.exists(destination + archivefilename):
urllib.urlretrieve(archivefileurl, destination + archivefilename)
print "\nDownloading file..."
else:
print "\nFound local file, skipping download..."
Expand All @@ -167,25 +167,24 @@ def main():
archivedirectoryname, archivefileextension = archivefilename.split(
'.tar.gz')

if not os.path.exists(archivedirectoryname):
if not os.path.exists(destination + archivedirectoryname):
print "\nExtracting " + archivedirectoryname + " ..."
tfile = tarfile.open(archivefilename, 'r:gz')
tfile.extractall('.')
tfile = tarfile.open(destination + archivefilename, 'r:gz')
tfile.extractall(destination)
else:
print "\nFound local directory, skipping extraction..."

# run xsltproc
# @TODO use list comprehension instead
for n in glob.glob(archivedirectoryname + "/*.nxml"):
for n in glob.glob(destination + archivedirectoryname + "/*.nxml"):
nxmlfilepath = n
print "\nConverting... "
print nxmlfilepath
fullnxmlfilepath = cwd + "/" + nxmlfilepath
xsltoutputfile = open(articlepmcid + ".mw.xml", 'w')
xsltoutputfile = open(destination + articlepmcid + ".mw.xml", 'w')
xslt_file = os.path.abspath(
os.path.dirname(__file__)) + '/' + 'jats-to-mediawiki.xsl'
xsltcommand = call(
['xsltproc', xslt_file, fullnxmlfilepath],
['xsltproc', xslt_file, nxmlfilepath],
stdout=xsltoutputfile)
print "\nReturning results..."
if xsltcommand == 0:
Expand Down

0 comments on commit c2209d0

Please sign in to comment.