{"action":"created","issue":{"url":"https://api.github.com/repos/pynag/pynag/issues/243","repository_url":"https://api.github.com/repos/pynag/pynag","labels_url":"https://api.github.com/repos/pynag/pynag/issues/243/labels{/name}","comments_url":"https://api.github.com/repos/pynag/pynag/issues/243/comments","events_url":"https://api.github.com/repos/pynag/pynag/issues/243/events","html_url":"https://github.com/pynag/pynag/issues/243","id":171193641,"number":243,"title":"Parsing timeperiods problem","user":{"login":"petrovicboban","id":13204754,"avatar_url":"https://avatars.githubusercontent.com/u/13204754?v=3","gravatar_id":"","url":"https://api.github.com/users/petrovicboban","html_url":"https://github.com/petrovicboban","followers_url":"https://api.github.com/users/petrovicboban/followers","following_url":"https://api.github.com/users/petrovicboban/following{/other_user}","gists_url":"https://api.github.com/users/petrovicboban/gists{/gist_id}","starred_url":"https://api.github.com/users/petrovicboban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petrovicboban/subscriptions","organizations_url":"https://api.github.com/users/petrovicboban/orgs","repos_url":"https://api.github.com/users/petrovicboban/repos","events_url":"https://api.github.com/users/petrovicboban/events{/privacy}","received_events_url":"https://api.github.com/users/petrovicboban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-15T15:26:49Z","updated_at":"2016-08-25T10:11:24Z","closed_at":null,"body":"This is in timeperiod config file:  \r\n```\r\ndefine timeperiod{\r\n        timeperiod_name    24x7\r\n        alias              Always\r\n        sunday             00:00-24:00\r\n        monday             00:00-24:00\r\n        tuesday            00:00-24:00\r\n        wednesday          00:00-24:00\r\n        thursday           00:00-24:00\r\n        friday             00:00-24:00\r\n        saturday           00:00-24:00\r\n}\r\n```\r\nNo tabs here, just regular whitespaces.    \r\n  \r\n  \r\nCode below:  \r\n```\r\nimport pprint\r\nfrom pynag import Model\r\n\r\npp = pprint.PrettyPrinter(indent=4)\r\nfor t in Model.Timeperiod.objects.all:\r\n    print t\r\n```\r\n\r\nproduces:\r\n\r\n```\r\ndefine timeperiod {\r\n  alias                          Always\r\n  friday             00:00-24:00 \r\n  monday             00:00-24:00 \r\n  saturday           00:00-24:00 \r\n  sunday             00:00-24:00 \r\n  thursday           00:00-24:00 \r\n  timeperiod_name                24x7\r\n  tuesday            00:00-24:00 \r\n  wednesday          00:00-24:00 \r\n}\r\n```\r\n\r\nSo, timeperiod config file is not parsed correctly where right value is non-string, which can be seen more clear using RESTloss API, which sees this timeperiod as:\r\n```\r\n  {\r\n    \"thursday           00:00-24:00\": \"\", \r\n    \"wednesday          00:00-24:00\": \"\", \r\n    \"friday             00:00-24:00\": \"\", \r\n    \"sunday             00:00-24:00\": \"\", \r\n    \"alias\": \"Always\", \r\n    \"monday             00:00-24:00\": \"\", \r\n    \"tuesday            00:00-24:00\": \"\", \r\n    \"timeperiod_name\": \"24x7\", \r\n    \"saturday           00:00-24:00\": \"\"\r\n  }\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pynag/pynag/issues/comments/242339787","html_url":"https://github.com/pynag/pynag/issues/243#issuecomment-242339787","issue_url":"https://api.github.com/repos/pynag/pynag/issues/243","id":242339787,"user":{"login":"Crapworks","id":1851528,"avatar_url":"https://avatars.githubusercontent.com/u/1851528?v=3","gravatar_id":"","url":"https://api.github.com/users/Crapworks","html_url":"https://github.com/Crapworks","followers_url":"https://api.github.com/users/Crapworks/followers","following_url":"https://api.github.com/users/Crapworks/following{/other_user}","gists_url":"https://api.github.com/users/Crapworks/gists{/gist_id}","starred_url":"https://api.github.com/users/Crapworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crapworks/subscriptions","organizations_url":"https://api.github.com/users/Crapworks/orgs","repos_url":"https://api.github.com/users/Crapworks/repos","events_url":"https://api.github.com/users/Crapworks/events{/privacy}","received_events_url":"https://api.github.com/users/Crapworks/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T10:11:23Z","updated_at":"2016-08-25T10:11:23Z","body":"Hi @palli,\r\n\r\nsince we are having some issues with [RESTlos](https://github.com/Crapworks/RESTlos) regarding this change (see: [Issue](https://github.com/Crapworks/RESTlos/issues/11)), I was wondering if there could be a quick workaround for that.\r\n\r\nLong Story Short:\r\nI am using this to get valid keys for the endpoints:\r\n```python\r\n        for endpoint in Model.all_attributes.object_definitions.keys():\r\n            self[endpoint] = Model.all_attributes.object_definitions[endpoint].keys()\r\n```\r\n\r\nI later validate POST requests like this:\r\n```python\r\n            if not attr.startswith('_') and attr not in self[endpoint]:\r\n                return {404: \"unknown attribute: %s\" % (attr, )}\r\n```\r\n\r\nThis will unfortunately not work for Timeperiods, since the don't return the weekdays as keys. Of course I could use an `if` statement evereywhere to treat Timeperoids special, but I am not really looking forward to do this ;)\r\n\r\nAny ideas for a possible abstraction layer here?\r\n\r\nRegards,\r\nChristian"}}
{"actor":{"display_login":"Crapworks"}}