You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
849 B
39 lines
849 B
#!/bin/env python
|
|
""" tzgrok.py -- convert timezone data to RDF
|
|
"""
|
|
|
|
import sys, os
|
|
from os.path import join
|
|
|
|
Command = 'python fromIcal.py %s > %s'
|
|
|
|
def convert(sd, curdir, names):
|
|
srcd, dest = sd
|
|
|
|
reldir = curdir[len(srcd):]
|
|
|
|
dest = join(dest, reldir)
|
|
try:
|
|
os.mkdir(dest)
|
|
except OSError: #already exists. @@other errs use same exception?
|
|
pass
|
|
|
|
for n in names:
|
|
if n[-4:] <> '.ics': continue
|
|
|
|
out = n[:-4] + '.rdf'
|
|
|
|
cmd = Command % (join(curdir, n), join(dest, out))
|
|
print >>sys.stderr, "running: ", cmd
|
|
status = os.system(cmd)
|
|
if status <> 0:
|
|
raise IOError, "Exit status %d from command: %s" % (status, cmd)
|
|
|
|
|
|
def main(argv):
|
|
srcd, destd = argv[1:]
|
|
|
|
os.path.walk(srcd, convert, (srcd, destd))
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv)
|