@classmethod
    def get_field_options(cls,
                          table,
                          fieldname,
                          parent=None,
                          show_uids=False,
                          hierarchy=False):
        """
            Get options of a field as <select>

            @param table: the Table
            @param fieldname: the Field name
            @param parent: the parent element in the tree
            @param show_uids: include UUIDs in foreign key options
            @param hierarchy: include parent ID in foreign key options (if
                              the lookup table is hierarchical)
        """

        # Get the field options
        options = None
        try:
            field = table[fieldname]
        except AttributeError:
            pass
        else:
            requires = field.requires
            if requires:
                if not isinstance(requires, (list, tuple)):
                    requires = [requires]
                requires = requires[0]
                if isinstance(requires, IS_EMPTY_OR):
                    requires = requires.other
                try:
                    options = requires.options()
                except AttributeError:
                    pass

        TAG = cls.TAG
        if options:

            ATTRIBUTE = cls.ATTRIBUTE
            UID = cls.UID

            SubElement = etree.SubElement

            # Create the <select> element
            if parent is not None:
                select = SubElement(parent, TAG.select)
            else:
                select = etree.Element(TAG.select)

            # Set name and id attributes for the <select> element
            select.set(ATTRIBUTE.name, fieldname)
            select.set(ATTRIBUTE.id, "%s_%s" % (table._tablename, fieldname))

            # Extract uids and parents if required
            uids = {}
            parents = {}
            if show_uids or hierarchy:

                ids = set(int(o[0]) for o in options if str(o[0]).isdigit())
                ktablename, key = s3_get_foreign_key(field, m2m=False)[:2]
                try:
                    ktable = current.s3db[ktablename]
                except AttributeError:
                    pass
                else:
                    if show_uids:
                        query = ktable[key].belongs(ids)
                        rows = current.db(query).select(ktable[key],
                                                        ktable[UID])
                        for row in rows:
                            uids[str(row[key])] = row[UID]
                    if hierarchy:
                        from s3hierarchy import S3Hierarchy
                        h = S3Hierarchy(ktablename)
                        if h.config:
                            for _id in ids:
                                parents[str(_id)] = h.parent(_id)

            # Build the XML
            OPTION = TAG.option
            VALUE = ATTRIBUTE.value
            PARENT = ATTRIBUTE.parent

            for value, text in options:

                # Create <option> element
                option = SubElement(select, OPTION)
                option.text = s3_unicode(s3_strip_markup(text))

                attr = option.attrib

                # Add value-attribute
                value = s3_unicode(value)
                attr[VALUE] = value

                # Add uuid-attribute, if required
                if show_uids and value in uids:
                    uid = uids[value]
                    if uid:
                        attr[UID] = uid

                # Add parent-attribute, if required
                if hierarchy and parents in value:
                    p = parents[value]
                    if p:
                        attr[PARENT] = str(p)

        elif parent is not None:
            select = None

        else:
            select = etree.Element(TAG.select)

        return select

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3xml.py/S3XML.get_field_options/swapped operands of `in`