def convert(self): """Converts all wakaba post tables to chieftain WakabaPost table.""" print "Initializing wakaba bans" for i in self.get_bans(): WakabaBan(**i).save() for i, p in enumerate(self.get_posts()): self.convert_post(p) print_flush("Initialized post {}".format(i)) print "\nInitialized {} posts. Trying to convert them...".format(i)
def convert_posts(self, start=0, first_post=False): filter_args = {"parent": 0} if first_post else {"parent__gt": 0} posts = WakabaPost.objects.filter(**filter_args).order_by("id")[start:] for i, p in enumerate(posts): i += start if first_post: i = "f{}".format(i) print_flush("Converting post {}".format(i)) try: self.convert_post(p, first_post) except ConvertError as e: print "\nFailed to convert post {}: {}".format(i, e) print "\n"