comparison document_it.py @ 20:7299c4529b41

more improvements
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 02 Aug 2011 21:34:59 -0700
parents 493683e17eae
children 67e4becc7d49
comparison
equal deleted inserted replaced
19:493683e17eae 20:7299c4529b41
72 # TODO: include options as third segment (e.g. format=ReST) 72 # TODO: include options as third segment (e.g. format=ReST)
73 except ValueError: 73 except ValueError:
74 raise ValueError("illegal manifest line: '%s'" % line) 74 raise ValueError("illegal manifest line: '%s'" % line)
75 75
76 if '://' not in url: 76 if '://' not in url:
77 url = '%s/%s' % (baseurl, url.lstrip('/')) 77 url = '%s%s' % (baseurl, url)
78 filename = os.path.join(directory, f) 78 filename = os.path.join(directory, f)
79 if os.path.isdir(filename): 79 if os.path.isdir(filename):
80 files = all_files(filename) 80 files = all_files(filename)
81 for i in files: 81 for i in files:
82 relpath = os.path.relpath(i, filename) 82 relpath = os.path.relpath(i, filename)
83 items.append((i, '%s/%s' % (url.rstrip('/'), relpath.lstrip('/')))) 83 items.append((i, '%s%s' % (url.rstrip('/'), relpath.lstrip('/'))))
84 else: 84 else:
85 items.append((filename, url)) 85 items.append((filename, url))
86 return items 86 return items
87 87
88 def main(args=sys.argv[1:]): 88 def main(args=sys.argv[1:]):
107 parser.add_option('-o', '--dest', dest='dest', 107 parser.add_option('-o', '--dest', dest='dest',
108 default=default_dir, 108 default=default_dir,
109 help='base directory or URL of destination [DEFAULT: %default]') 109 help='base directory or URL of destination [DEFAULT: %default]')
110 parser.add_option('-u', '--user', dest='user', 110 parser.add_option('-u', '--user', dest='user',
111 help='user name') 111 help='user name')
112 parser.add_option('-p', '--password', dest='password',
113 help='user password')
112 parser.add_option('--list', dest='list', action='store_true', default=False, 114 parser.add_option('--list', dest='list', action='store_true', default=False,
113 help="list files") 115 help="list files")
114 parser.add_option('--validate', dest='validate', # TODO unused 116 parser.add_option('--validate', dest='validate', # TODO unused
115 action='store_true', default=False, 117 action='store_true', default=False,
116 help="validate the rendering but don't output") 118 help="validate the rendering but don't output")
176 f = file(dest, 'w') 178 f = file(dest, 'w')
177 buffer = markdown.Markdown().convert(file(src).read()) 179 buffer = markdown.Markdown().convert(file(src).read())
178 f.write(buffer) 180 f.write(buffer)
179 f.close() 181 f.close()
180 else: 182 else:
181 # TODO check credentials 183 # check credentials
184 assert options.user and options.password, "Please supply your --user and --password"
185
186 # upload the files
187 # XXX just use curl for now
188 import subprocess
182 for src, dest in files: 189 for src, dest in files:
183 pass 190 dest += '/contents?edittime=now'
184 raise NotImplementedError 191 print src, dest
185
186 192
187 if options.dest == default_dir: 193 if options.dest == default_dir:
188 print "Files rendered to\n%s" % default_dir 194 print "Files rendered to\n%s" % default_dir
189 195
190 if __name__ == '__main__': 196 if __name__ == '__main__':