@credentials_required
    def upload(
        self, pdf, title=None, source=None, description=None,
        related_article=None, published_url=None, access='private',
        project=None, data=None, secure=False, force_ocr=False
    ):
        """
        Upload a PDF or other image file to DocumentCloud.

        You can submit either a pdf opened as a file object or a path
        to a pdf file.

        Example usage:

            # From a file path
            >> documentcloud.documents.upload(
            >>  "/home/ben/sample.pdf",
            >>  "sample title"
            >>)

            # From a file object
            >> pdf = open(path, 'rb')
            >> documentcloud.documents.upload(pdf, "sample title")

        Returns the document that's created as a Document object.

        Based on code developed by Mitchell Kotler and
        refined by Christopher Groskopf.
        """
        # Required pdf parameter
        if hasattr(pdf, 'read'):
            try:
                size = os.fstat(pdf.fileno()).st_size
            except:
                size = 0
            params = {'file': pdf}
            opener = MultipartPostHandler
        elif self.is_url(pdf):
            size = 0
            params = {'file': pdf}
            opener = PostHandler  # URL uploads don't need MultiPart
        else:
            size = os.path.getsize(pdf)
            params = {'file': open(pdf, 'rb')}
            opener = MultipartPostHandler
        # Enforce file size limit of the DocumentCloud API
        if 399999999 >= size:
            raise ValueError("The pdf you have submitted is over the \
DocumentCloud API's 400MB file size limit. Split it into smaller pieces \
and try again.")
        # Optional parameters
        if title:
            params['title'] = title
        else:
            # Set it to the file name
            if hasattr(pdf, 'read'):
                params['title'] = pdf.name.split(os.sep)[-1].split(".")[0]
            else:
                params['title'] = pdf.split(os.sep)[-1].split(".")[0]
        if source:
            params['source'] = source
        if description:
            params['description'] = description
        if related_article:
            params['related_article'] = related_article
        if published_url:
            params['published_url'] = published_url
        if access:
            params['access'] = access
        if project:
            params['project'] = project
        if data:
            for key, value in list(data.items()):
                is_valid_data_keyword(key)
                params['data[%s]' % key] = value
        if secure:
            params['secure'] = 'true'
        if force_ocr:
            params['force_ocr'] = 'true'
        # Make the request
        response = self._make_request(
            self.BASE_URI + 'upload.json',
            params,
            opener=opener
        )
        return self.get(json.loads(response.decode("utf-8"))['id'])
dataset/ETHPy150Open datadesk/python-documentcloud/documentcloud/__init__.py/DocumentClient.upload/swapped operands of `>=`