Index: trunk/extensions/Offline/mwimport.py |
— | — | @@ -223,8 +223,30 @@ |
224 | 224 | |
225 | 225 | |
226 | 226 | if __name__ == "__main__": |
227 | | - #op = OptionParser() |
228 | | - #op.add_option( |
| 227 | + op = OptionParser() |
| 228 | + op.add_option("-d", "--dir", dest="base_dir", |
| 229 | + help="base directory for output files") |
| 230 | + #op.add_option("-f", "--force", dest="force", action="store_true", |
| 231 | + # help="ignore processing errors") |
| 232 | + #op.add_option("-s", "--skip", dest="skip", type="int", |
| 233 | + # help="skip over this many articles before begining import") |
| 234 | + #op.add_option("--import", dest="do_sql", action="store_true", |
| 235 | + # help="run sql import script when finished with dump") |
| 236 | + #op.add_option("--no-import", dest="do_sql", action="store_false", |
| 237 | + # help="stop after dump, do not import sql") |
| 238 | + #op.add_option("--ignore-existing", dest="replace", action="store_false", |
| 239 | + # help="no not overwrite existing data") |
| 240 | + #op.add_option("--replace-existing", dest="replace", action="store_true", |
| 241 | + # help="generated sql statements will overwrite existing data") |
| 242 | + options, args = op.parse_args() |
229 | 243 | |
230 | | - p = DumpParser() |
| 244 | + if len(args) > 1: |
| 245 | + print "too many input file arguments provided: "+" ".join(args) |
| 246 | + sys.exit(-1) |
| 247 | + elif len(args) == 0 or args[0] == '-': |
| 248 | + f = sys.stdin |
| 249 | + else: |
| 250 | + f = open(args[0]) |
| 251 | + |
| 252 | + p = DumpParser(input=f, output_base=options.base_dir) |
231 | 253 | p.parse() |