def get_submissions(user_id,
                    handle,
                    stopstalk_handle,
                    submissions,
                    site,
                    custom=False):
    """
        Get the submissions and populate the database
    """

    db = current.db
    count = 0

    if submissions == {}:
        print "0"
        return 0

    global rows

    for i in sorted(submissions[handle].iterkeys()):
        for j in sorted(submissions[handle][i].iterkeys()):
            submission = submissions[handle][i][j]
            if len(submission) == 7:
                count += 1
                row = []
                if custom:
                    row.extend(["--", user_id])
                else:
                    row.extend([user_id, "--"])

                row.extend([stopstalk_handle,
                            handle,
                            site,
                            submission[0],
                            submission[2],
                            submission[1],
                            submission[5],
                            submission[3],
                            submission[4],
                            submission[6]])

                encoded_row = []
                for x in row:
                    if isinstance(x, basestring):
                        tmp = x.encode("ascii", "ignore")

                        # @ToDo: Dirty hack! Do something with
                        #        replace and escaping quotes
                        tmp = tmp.replace("\"", "").replace("'", "")
                        if tmp == "--":
                            tmp = "NULL"
                        else:
                            tmp = u"\"" + tmp + u"\""
                        encoded_row.append(tmp)
                    else:
                        encoded_row.append(str(x))

                rows.append(u"(" + u", ".join(encoded_row) + u")")


    if count != 0:
        print (count) % "%s"
    else:
        print "0"
    return count

# ----------------------------------------------------------------------------
dataset/ETHPy150Open stopstalk/stopstalk-deployment/static/scripts/submissions3.py/get_submissions/swapped operands of `%`