Mercurial > p > roundup > code
comparison scripts/import_sf.py @ 5381:0942fe89e82e
Python 3 preparation: change "x.has_key(y)" to "y in x".
(Also likewise "not in" where appropriate.) Tool-generated patch.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 22:08:17 +0000 |
| parents | 4960a2c21590 |
| children | 88dbacd11cd1 |
comparison
equal
deleted
inserted
replaced
| 5380:64c4e43fbb84 | 5381:0942fe89e82e |
|---|---|
| 83 aid, url = line.strip().split() | 83 aid, url = line.strip().split() |
| 84 urls[aid] = url | 84 urls[aid] = url |
| 85 | 85 |
| 86 for aid, fid in support.Progress('Fetching files', list(to_fetch)): | 86 for aid, fid in support.Progress('Fetching files', list(to_fetch)): |
| 87 if fid in got: continue | 87 if fid in got: continue |
| 88 if not urls.has_key(aid): | 88 if aid not in urls: |
| 89 urls[aid] = get_url(aid) | 89 urls[aid] = get_url(aid) |
| 90 f = open(os.path.join(file_dir, 'urls.txt'), 'a') | 90 f = open(os.path.join(file_dir, 'urls.txt'), 'a') |
| 91 f.write('%s %s\n'%(aid, urls[aid])) | 91 f.write('%s %s\n'%(aid, urls[aid])) |
| 92 f.close() | 92 f.close() |
| 93 url = urls[aid] + '&file_id=' + fid | 93 url = urls[aid] + '&file_id=' + fid |
| 173 else: | 173 else: |
| 174 d[name] = field.text | 174 d[name] = field.text |
| 175 | 175 |
| 176 categories.add(d['category']) | 176 categories.add(d['category']) |
| 177 | 177 |
| 178 if op.has_key('body'): | 178 if 'body' in op: |
| 179 l = d.setdefault('messages', []) | 179 l = d.setdefault('messages', []) |
| 180 l.insert(0, op) | 180 l.insert(0, op) |
| 181 | 181 |
| 182 add_files -= remove_files | 182 add_files -= remove_files |
| 183 | 183 |
| 359 row = [] | 359 row = [] |
| 360 for name in propnames: | 360 for name in propnames: |
| 361 if name == 'is retired': | 361 if name == 'is retired': |
| 362 continue | 362 continue |
| 363 prop = props[name] | 363 prop = props[name] |
| 364 if entry.has_key(name): | 364 if name in entry: |
| 365 if isinstance(prop, hyperdb.Date) or \ | 365 if isinstance(prop, hyperdb.Date) or \ |
| 366 isinstance(prop, hyperdb.Interval): | 366 isinstance(prop, hyperdb.Interval): |
| 367 row.append(repr(entry[name].get_tuple())) | 367 row.append(repr(entry[name].get_tuple())) |
| 368 elif isinstance(prop, hyperdb.Password): | 368 elif isinstance(prop, hyperdb.Password): |
| 369 row.append(repr(str(entry[name]))) | 369 row.append(repr(str(entry[name]))) |
