Tony Mack | f593dba | 2013-03-24 13:17:43 -0400 | [diff] [blame] | 1 | from PLC.Slices import Slices |
| 2 | from models import Slice |
| 3 | |
| 4 | class SliceImporter: |
| 5 | |
| 6 | def __init__(self, importer): |
| 7 | self.importer = importer |
| 8 | self.slices = {} |
| 9 | |
| 10 | def run(self): |
| 11 | slices = Slices(self.importer.api) |
| 12 | db_slices = Slice.objects.all() |
| 13 | slice_names = [s['name'] for s in db_slices] |
| 14 | for slice in slices: |
| 15 | if slice['name'] not in slice_names: |
| 16 | new_slices = Slice(name=slice['name'], |
| 17 | instantiation=slice['instantiation'], |
| 18 | omf_friendly = False, |
| 19 | description = slice['description'], |
| 20 | slice_url = slice['url']) |
| 21 | new_slice.save(); |
| 22 | self.slices[slice['slice_id']] = slice |
| 23 | |
| 24 | |
| 25 | |