def write_to_file(self, filename):
        """Write minimum needs as json to a file.

        :param filename: The file to be written to.
        :type filename: basestring, str
        """
        if not exists(dirname(filename)):
            return -1
        with open(filename, 'w') as fd:
            needs_json = json.dumps(self.minimum_needs)
            fd.write(needs_json)
        return 0
def write_to_file ( self , filename ) : if not exists ( dirname ( filename ) ) : return - 1 with open ( filename , 'w' ) as fd : needs_json = json . dumps ( self . minimum_needs ) fd . write ( needs_json ) return 0
Write minimum needs as json to a file.

        :param filename: The file to be written to.
        :type filename: basestring, str