Best Python code snippet using fMBT_python
usesFeature.py
Source:usesFeature.py
1#! /usr/bin/python2import xml.dom.minidom as xdom3from optparse import OptionParser4# option parse5parser = OptionParser(usage="usage: %prog [options]")6parser.add_option("-l","--list",dest="autoGenList",metavar="FEATURELIST",help="get the user feature list")7(options,args) = parser.parse_args()8if len(args) != 0:9 parser.print_help()10try:11 autoList = options.autoGenList.split()12except AttributeError:13 autoList = []14# through the logical we can set the we needed autogen xml list15# TODO:we use the autoList to save the xml list16# eg, if contidion:17# autoList.append(xml)18# ...19####################################################20# uses-feature xml mapping table 21####################################################22xmlHash = {};23xmlHash["android.hardware.bluetooth"] = ["android.hardware.bluetooth"]24xmlHash["android.hardware.camera"] = ["android.hardware.camera","android.hardware.camera.autofocus"]25xmlHash["android.hardware.camera.autofocus"] = ["android.hardware.camera","android.hardware.camera.autofocus"]26xmlHash["android.hardware.location"] = ["android.hardware.location","android.hardware.location.network"]27xmlHash["android.hardware.location.gps"] = ["android.hardware.location","android.hardware.location.network","android.hardware.location.gps"]28#xmlHash["android.hardware.location.network"] = []29xmlHash["android.hardware.microphone"] = ["android.hardware.microphone"]30xmlHash["android.hardware.sensor.compass"] = ["android.hardware.sensor.compass"]31xmlHash["android.hardware.sensor.accelerometer"] = ["android.hardware.sensor.accelerometer"]32xmlHash["android.hardware.sensor.light"] = ["android.hardware.sensor.light"]33xmlHash["android.hardware.sensor.gyroscope"] = ["android.hardware.sensor.gyroscope"]34xmlHash["android.hardware.sensor.barometer"] = ["android.hardware.sensor.barometer"]35xmlHash["android.hardware.sensor.proximity"] = ["android.hardware.sensor.proximity"]36#xmlHash["android.hardware.telephony"]37xmlHash["android.hardware.telephony.cdma"] = ["android.hardware.telephony","android.hardware.telephony.cdma"]38xmlHash["android.hardware.telephony.gsm"] = ["android.hardware.telephony","android.hardware.telephony.gsm"]39xmlHash["android.hardware.touchscreen"] = ["android.hardware.touchscreen"]40xmlHash["android.hardware.touchscreen.multitouch"] = ["android.hardware.touchscreen","android.hardware.touchscreen.multitouch"]41xmlHash["android.hardware.touchscreen.multitouch.distinct"] = ["android.hardware.touchscreen","android.hardware.touchscreen.multitouch","android.hardware.touchscreen.multitouch.distinct"]42xmlHash["android.hardware.touchscreen.multitouch.jazzhand"] = ["android.hardware.touchscreen","android.hardware.touchscreen.multitouch","android.hardware.touchscreen.multitouch.distinct","android.hardware.touchscreen.multitouch.jazzhand"]43xmlHash["android.software.live_wallpaper"] = ["android.software.live_wallpaper"]44xmlHash["android.hardware.wifi"] = ["android.hardware.wifi"]45xmlHash["android.software.sip"] = ["android.software.sip"]46xmlHash["android.software.sip.voip"] = ["android.software.sip","android.software.sip.voip"]47####################################################48def autoGen(xmlName,xmlContent):49 # create document50 doc = xdom.Document()51 # create permissions node52 permissions = doc.createElement("permissions")53 doc.appendChild(permissions)54 # create feature node55 for content in xmlContent:56 feature = doc.createElement("feature")57 feature.setAttribute("name",content)58 permissions.appendChild(feature)59 xmlfile = open("%s.xml"%xmlName,"w")60 xmlfile.write(doc.toprettyxml(indent = " ",encoding="utf-8"))61 xmlfile.close()62for name in autoList:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!