KeyError: 'RenderingEngine_Name'
In [5]: browscap = pybrowscap.loader.csv.load_file('browscap.csv')
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-5-65bbe6dd135f> in <module>()
----> 1 browscap = pybrowscap.loader.csv.load_file('browscap.csv')
/home/.../local/lib/python2.7/site-packages/pybrowscap/loader/csv/__init__.pyc in load_file(browscap_file_path)
104 defaults = line
105 continue
--> 106 line = replace_defaults(line, defaults)
107 try:
108 ua_regex = '^{0}$'.format(re.escape(line['propertyname']))
/home/.../local/lib/python2.7/site-packages/pybrowscap/loader/csv/__init__.pyc in replace_defaults(line, defaults)
46 for feature, value in line.iteritems():
47 if value == 'default' or value == '':
---> 48 value = defaults[feature]
49 if value == 'true':
50 value = True
KeyError: 'RenderingEngine_Name'
What version of browscap.csv are you using ?
5024 (2nd Mar 2014)
Thanks, I have a look at it. It seems that there may be incopatible format changes in newest versions of browscap files.
I'm now having a similar issue with load_file, but on a different key:
Traceback (most recent call last):
...
File ".../lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
mw_instance = mw_class()
File ".../lib/python2.7/site-packages/django_pybrowscap/middleware.py", line 27, in __init__
self.browscap = load_file(settings.PYBROWSCAP_FILE_PATH)
File ".../lib/python2.7/site-packages/pybrowscap/loader/csv/__init__.py", line 106, in load_file
line = replace_defaults(line, defaults)
File ".../lib/python2.7/site-packages/pybrowscap/loader/csv/__init__.py", line 48, in replace_defaults
value = defaults[feature]
KeyError: 'Platform'
I have tried a csv of version is 5036, from Wed, 19 Nov 2014 21:12:38, as well as version 6000 from Thu, 12 Mar 2015 10:42:22 (which fails on KeyError: 'Parent').
Do you work around it by changing to a specific csv version; and If so, which version are you guys using?
update: It seems the cause is rooted around the defaults dict not being properly set before starting to iterate. Currentl cause seems to be the fact that "Parent" field is missing a value (hence it is not == line['PropertyName'] as in this condition.
update 2: I see a fix was already submitted in master, so this issue can probably be closed. Any chance the fix can make it's way into a new release on pypi (2.1?)
The fix is submitted but the tests are not passing. Can you please provide testfixes for this bugfix ? After that I am happy to make a new release.