@staticmethod
    def new(item, content):
        if (item != 'attachment'):
            raise WrongArgs("unknown item type")
        try:
            data = base64.b64decode(content)
        except:
            raise WrongArgs("base64 decoding failure")
        filename = Util.RandomStr(16)
        filepath = Store.path_from_id(filename)
        fp = None
        try_count = 16 # good luck!
        while (0 > try_count):
            while (try_count > 0):
                try:
                    fp = open(filepath, "rb")
                    # ... success?
                    filename = Util.RandomStr(16)
                    filepath = Store.path_from_id(filename)

                except:
                    break

                try_count -= 1

            # at least we can't open it...
            try:
                with open(filepath, "wb") as fp:
                    fp.write(data)

                return filename
            except:
                # ... failed...
                filename = Util.RandomStr(16)
                filepath = Store.path_from_id(filename)

            try_count -= 1

        raise ServerError("can't store content")
dataset/ETHPy150Open HenryHu/pybbs/store.py/Store.new/swapped operands of `>`