Kosmorro / kosmorro

A program to calculate your ephemerides.
https://kosmorro.space
GNU Affero General Public License v3.0
60 stars 7 forks source link

Cannot output in JSON format when no position is given #198

Closed Deuchnord closed 3 years ago

Deuchnord commented 3 years ago

Describe the bug When trying to output to JSON format, if no position have been given, a Python TypeError is thrown.

To Reproduce

$ kosmorro -f json
Traceback (most recent call last):
  File "/usr/bin/kosmorro", line 27, in <module>
    sys.exit(main())
  File "/usr/lib/python3.9/site-packages/_kosmorro/main.py", line 126, in main
    print(output)
  File "/usr/lib/python3.9/site-packages/_kosmorro/dumper.py", line 73, in __str__
    return self.to_string()
  File "/usr/lib/python3.9/site-packages/_kosmorro/dumper.py", line 88, in to_string
    "ephemerides": [
TypeError: 'NoneType' object is not iterable

Expected behavior A JSON output similar to the following should be output:

{
    "ephemerides": [],
    "moon_phase": {
        "phase": "WANING_GIBBOUS",
        "time": null,
        "next": {
            "phase": "LAST_QUARTER",
            "time": "2021-08-30T07:13:13.940776+00:00"
        }
    },
    "events": []
}

Your configuration (please complete the following information):

nicfb commented 3 years ago

Have you started work on this issue?

Deuchnord commented 3 years ago

Yes, I did :)