devartis / passbook

Python library to create Apple Passbook (.pkpass) files

Home Page:http://www.devartis.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No return value for _createZip

XMLSDK opened this issue · comments

Should def _createZip(self, pass_json, manifest, signature, zip_file=None): return zf?

Not so sure, since self.zip_file is never accessed.

If you pass zip_file as a parameter _createZip will write to that file, otherwise it will create a pass.pkpass file.
The method could be cleaner with a refactor, but as it is you don't need a return value is you use the zip_file parameter.

The problem is this create method needs return value of _createZip:

    # Creates the actual .pkpass file
    def create(self, certificate, key, wwdr_certificate, password, zip_file=None):
        pass_json = self._createPassJson()
        manifest = self._createManifest(pass_json)
        signature = self._createSignature(manifest, certificate, key, wwdr_certificate, password)
        if not zip_file:
            zip_file = StringIO()
        self.zip_file = self._createZip(pass_json, manifest, signature, zip_file=zip_file)
        return zip_file```

I removed the unnecessary assignment. create method expects a parameter if you want to specify the pkpass location, otherwise you can use the returned file buffer.