- location_config = self.Cnf.SubTree("Location::%s" % (location))
- archive_id = self.projectB.get_archive_id(location_config["Archive"])
- if archive_id == -1:
- utils.fubar("Archive '%s' for location '%s' not found."
- % (location_config["Archive"], location))
- location_type = location_config.get("type")
- if location_type == "legacy-mixed":
- c.execute(loc_add_mixed, [location, archive_id, location_config["type"]])
- elif location_type == "legacy" or location_type == "pool":
- for component in self.Cnf.SubTree("Component").List():
- component_id = self.projectB.get_component_id(component)
- c.execute(loc_add, [location, component_id, archive_id, location_type])
- else:
- utils.fubar("E: type '%s' not recognised in location %s."
- % (location_type, location))
-
- self.projectB.commit()
+ archive_name = self.Cnf.get("Location::%s::Archive" % location, "")
+ a = s.query(Archive).filter_by(archive_name=archive_name)
+ if a.count() < 1:
+ utils.fubar("E: Archive '%s' for location '%s' not found" % (archive_name, location))
+ archive_id = a.one().archive_id
+
+ location_type = self.Cnf.get("Location::%s::Type" % location, "")
+ if location_type != 'pool':
+ utils.fubar("E: type %s not recognised for location %s" % (location_type, location))
+
+ for component in self.Cnf.SubTree("Component").List():
+ c = s.query(Component).filter_by(component_name=component)
+ if c.count() < 1:
+ utils.fubar("E: Can't find component %s for location %s" % (component, location))
+ component_id = c.one().component_id
+
+ l = Location()
+ l.path = location
+ l.archive_id = archive_id
+ l.component_id = component_id
+ l.archive_type = location_type
+ s.add(l)
+
+ s.commit()