devartis / passbook

Python library to create Apple Passbook (.pkpass) files
http://www.devartis.com/
MIT License
272 stars 108 forks source link

No return value for _createZip #21

Closed XMLSDK closed 11 years ago

XMLSDK commented 11 years ago

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

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

fara commented 11 years ago

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.

XMLSDK commented 11 years ago

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```
fara commented 11 years ago

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.