This example shows how to retrieve property meta data from 51Degrees
on-premise device detection.
This feature can be used to get information such as the category that
a property belongs to or the possible values a property can have.
(As of the current data file. If the data file is updated,
the possible values for a property can change)
1 [List of properties
with names
and categories]
3 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support svg? :
5 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support video? :
7 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support supportstls/ssl? :
9 Does user agent Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114 support supportswebgl? :
45 from fiftyone_devicedetection_onpremise.devicedetection_onpremise_pipelinebuilder
import DeviceDetectionOnPremisePipelineBuilder
46 from fiftyone_devicedetection_examples.example_utils
import ExampleUtils
50 data_file = ExampleUtils.find_file(
"51Degrees-LiteV4.1.hash")
52 pipeline = DeviceDetectionOnPremisePipelineBuilder(
53 data_file_path = data_file,
55 performance_profile =
'MaxPerformance',
56 auto_update=
False).build()
60 properties = pipeline.get_properties()
64 for property_key, property_meta
in properties[
"device"].items():
65 print(property_key +
" of category " + property_meta[
"category"])
71 flowdata = pipeline.create_flowdata()
74 iphone_ua =
"Mozilla/5.0 (iPhone; CPU iPhone OS 11_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C114" 76 flowdata.evidence.add(
"header.user-agent", iphone_ua)
84 mediaSupport = flowdata.get_where(
"category",
"Supported Media")
86 for supportedMediaProperty, supportedValue
in mediaSupport.items():
87 print(
"Does User-Agent " + iphone_ua +
" support " + supportedMediaProperty +
"?")
88 if supportedValue.has_value():
89 print(supportedValue.value())
91 print(supportedValue.no_value_message())