How to use get_optional method in toolium

Best Python code snippet using toolium_python

CaseSettings.py

Source:CaseSettings.py Github

copy

Full Screen

...94 cf.set("speeds", "depth", self.depthspeed)95 cf.set("speeds", "depthrange", self.depthspeedrange)96 with open(filename,'w') as cfd:97 cf.write(cfd)98 def get_optional(self, cfgetter, section, option, default):99 try:100 return cfgetter(section, option)101 except ConfigParser.NoOptionError:102 return default103 def read(self, filename):104 cf = ConfigParser.ConfigParser()105 cf.read(filename)106 get_optional = self.get_optional107 if not cf.has_section("paths"):108 raise Exception("File has no ""paths"" section")109 try:110 self.basename = cf.get("paths", "basename")111 self.particles = cf.get("paths", "particles")112 self.output = cf.get("paths", "output")113 except Exception as e:114 print e115 return False116 if cf.has_section("settings"):117 self.mode = get_optional(cf.getint, "settings", "dimensions", self.mode)118 self.ptsteps = get_optional(cf.getint, "settings", "particle_steps", self.ptsteps)119 self.prefix = get_optional(cf.get, "settings", "prefix", self.prefix)120 self.zthreshold = get_optional(cf.getfloat, "settings", "threshold", self.zthreshold)121 self.nthreshold = get_optional(cf.getfloat, "settings", "noise_threshold", self.nthreshold)122 self.foodweight = get_optional(cf.getfloat, "settings", "food_weight", self.foodweight)123 if cf.has_section("indexes"):124 self.z = get_optional(cf.getint, "settings", "z", self.z)125 self.u = get_optional(cf.getint, "settings", "u", self.u)126 self.v = get_optional(cf.getint, "settings", "v", self.v)127 self.w = get_optional(cf.getint, "settings", "w", self.w)128 self.noise = get_optional(cf.getint, "settings", "noise", self.noise)129 self.depth = get_optional(cf.getint, "settings", "depth", self.depth)130 self.fish = get_optional(cf.getint, "settings", "fish", self.fish)131 if cf.has_section("scaling"):132 self.scaling = s2vector(cf.get("scaling", "fish"))133 if cf.has_section("speeds"):134 self.defaultspeed = get_optional(cf.getfloat, "speeds", "default", self.defaultspeed)135 self.defaultspeedrange = get_optional(cf.getfloat, "speeds", "defaultrange", self.defaultspeedrange)136 self.defaultydamp = get_optional(cf.getfloat, "speeds", "ydamping", self.defaultydamp)137 self.noisespeed = get_optional(cf.getfloat, "speeds", "noise", self.noisespeed)138 self.noisespeedrange = get_optional(cf.getfloat, "speeds", "noiserange", self.noisespeedrange)139 self.depthspeed = get_optional(cf.getfloat, "speeds", "depth", self.depthspeed)140 self.depthspeedrange = get_optional(cf.getfloat, "speeds", "depthrange", self.depthspeedrange)141 def __str__(self):142 rv = []143 for i in vars(self):144 rv.append(".%s = %s" % (i, getattr(self,i)))145 return "\n".join(rv)146 def validate(self):147 """ Validate mode, ptsteps, indices and check outputpath exists """148 if not (self.mode == 2 or self.mode == 3):149 raise Exception("Invalid number of dimensions")150 if self.ptsteps == 0:151 self.ptsteps = 1152 if self.ptsteps < 1 and not self.ptsteps == -1:153 raise Exception("Invalid number of particle timesteps given")154 if self.z < 0:...

Full Screen

Full Screen

archiveorg.py

Source:archiveorg.py Github

copy

Full Screen

...65 else:66 # HTML5 media fallback67 info = self._parse_html5_media_entries(url, webpage, video_id)[0]68 info['id'] = video_id69 def get_optional(metadata, field):70 return metadata.get(field, [None])[0]71 metadata = self._download_json(72 'http://archive.org/details/' + video_id, video_id, query={73 'output': 'json',74 })['metadata']75 info.update({76 'title': get_optional(metadata, 'title') or info.get('title'),77 'description': clean_html(get_optional(metadata, 'description')),78 })79 if info.get('_type') != 'playlist':80 creator = get_optional(metadata, 'creator')81 info.update({82 'creator': creator,83 'release_date': unified_strdate(get_optional(metadata, 'date')),84 'uploader': get_optional(metadata, 'publisher') or creator,85 'timestamp': unified_timestamp(get_optional(metadata, 'publicdate')),86 'language': get_optional(metadata, 'language'),87 })...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful