
from debuild.models import DebuildDatabaseObject, db, strtype


class Package(DebuildDatabaseObject):
    _table = "packages"

    def __init__(self, thing):
        if isinstance(thing, strtype):
            self._record = self._fetch_by_id(thing)
            if self._record is None:
                raise Exception
        else:
            self._record = thing

    def reports(self):
        return db.reports.find({"package": self._record['_id']})


from debuild.models import DebuildDatabaseObject, db, strtype
from debuild.models.report import Report


class Package(DebuildDatabaseObject):
    _table = "packages"

    def __init__(self, thing):
        if isinstance(thing, strtype):
            self._record = self._fetch_by_id(thing)
            if self._record is None:
                raise Exception
        else:
            self._record = thing

    def reports(self):
        return (Report(x) for x in
                db.reports.find({"package": self._record['_id']}))

Move to a generator thinger.
Move to a generator thinger.

  
  from debuild.models import DebuildDatabaseObject, db, strtype
+ from debuild.models.report import Report
  
  
  class Package(DebuildDatabaseObject):
      _table = "packages"
  
      def __init__(self, thing):
          if isinstance(thing, strtype):
              self._record = self._fetch_by_id(thing)
              if self._record is None:
                  raise Exception
          else:
              self._record = thing
  
      def reports(self):
+         return (Report(x) for x in
-         return db.reports.find({"package": self._record['_id']})
+                 db.reports.find({"package": self._record['_id']}))
  
Move to a generator thinger.
## Code Before:

from debuild.models import DebuildDatabaseObject, db, strtype


class Package(DebuildDatabaseObject):
    _table = "packages"

    def __init__(self, thing):
        if isinstance(thing, strtype):
            self._record = self._fetch_by_id(thing)
            if self._record is None:
                raise Exception
        else:
            self._record = thing

    def reports(self):
        return db.reports.find({"package": self._record['_id']})

## Instruction:
Move to a generator thinger.
## Code After:

from debuild.models import DebuildDatabaseObject, db, strtype
from debuild.models.report import Report


class Package(DebuildDatabaseObject):
    _table = "packages"

    def __init__(self, thing):
        if isinstance(thing, strtype):
            self._record = self._fetch_by_id(thing)
            if self._record is None:
                raise Exception
        else:
            self._record = thing

    def reports(self):
        return (Report(x) for x in
                db.reports.find({"package": self._record['_id']}))
