How to use _get_info method in avocado

Best Python code snippet using avocado_python

config.py

Source:config.py Github

copy

Full Screen

...20class Cfg:21 _info = None # class (or static) variable22 @property23 def knobs(self):24 return self._get_info().knobs25 @property26 def mqtt_host(self):27 return self._get_info().mqtt["host"]28 @property29 def mqtt_client_id(self):30 return self._get_info().mqtt["client_id"]31 @property32 def mqtt_username(self):33 return self._get_info().mqtt.get("username")34 @property35 def mqtt_password(self):36 return self._get_info().mqtt.get("password")37 @property38 def mqtt_topic(self):39 return self._get_info().cfg_globals["topic_prefix"]40 @property41 def reconnect_interval(self):42 return self._get_info().cfg_globals["reconnect_interval"]43 @property44 def poll_interval(self):45 return self._get_info().cfg_globals["poll_interval"]46 @property47 def periodic_mqtt_report(self):48 return self._get_info().cfg_globals["periodic_mqtt_report"]49 @property50 def user_agent(self):51 cfg_globals = self._get_info().cfg_globals52 return cfg_globals.get("user_agent")53 @property54 def myq_email(self):55 return self._get_info().myq["email"]56 @property57 def myq_password(self):58 return self._get_info().myq["password"]59 @property60 def alias(self):61 return self._get_info().alias62 @classmethod63 def _get_config_filename(cls):64 if len(sys.argv) > 1:65 return sys.argv[1]66 return CFG_FILENAME67 @classmethod68 def _get_info(cls):69 # https://hitchdev.com/strictyaml70 schema = Map(71 {72 Optional("knobs"): Map(73 {74 Optional("log_to_console"): Bool(),75 Optional("log_level_debug"): Bool(),76 }77 )78 | EmptyDict(),79 "globals": Map(80 {81 "topic_prefix": Str(),82 Optional(...

Full Screen

Full Screen

Paper.py

Source:Paper.py Github

copy

Full Screen

...22 self._get_authors()23 self._get_title()24 print (self._get_reference())25 return26 def _get_info(self, tag, xdoc = None):27 """28 :return:29 """30 if xdoc is None:31 xdoc = self.xdoc32 xtag = xdoc.getElementsByTagName(tag)33 if len(xtag) == 0:34 return None35 result = xtag[0].firstChild.data36 return result37 def _fetch_xml(self):38 """39 :return:40 """41 # TODO manage online fetch42 #w_root = 'https://www.ncbi.nlm.nih.gov/pubmed/{pmid}?report=xml'43 #webpage = urllib.request.urlopen(w_root.format(pmid=pmid))44 #f_webpage = webpage.read()45 #print (f_webpage)46 def _get_abstract(self):47 """48 Abstract tag <AbstractText>49 :return: None if no abstract50 """51 return self._get_info('AbstractText')52 def _get_title(self):53 """54 Title tag <ArticleTitle>55 :return: None if no abstract56 """57 return self._get_info('ArticleTitle')58 def _get_journal(self):59 """60 Title tag <ArticleTitle>61 :return: None if no abstract62 """63 return self._get_info('ISOAbbreviation')64 def _get_volume(self):65 """66 :return:67 """68 return self._get_info('Volume')69 def _get_page(self):70 """71 :return:72 """73 return self._get_info('MedlinePgn')74 def _get_year(self):75 """76 :return:77 """78 return self._get_info('Year')79 def _get_paperinfo(self):80 """81 :return:82 """83 return self._get_volume(), self._get_page(), self._get_year()84 def _get_authors(self):85 """86 :return:87 """88 xlauthors = self.xdoc.getElementsByTagName('Author')89 l_author = []90 for xauthors in xlauthors:91 lastname = self._get_info('LastName', xauthors)92 forename = self._get_info('ForeName', xauthors)93 initial = self._get_info('Initials', xauthors)94 # possibility to get the affiliation95 l_author.append([lastname, forename, initial])96 return l_author97 def _get_reference(self):98 """99 :return:100 """101 xlref = self.xdoc.getElementsByTagName('CommentsCorrections')102 if len(xlref) == 0:103 return [] # no ref104 l_ref = []105 for xref in xlref:106 ref = self._get_info('RefSource', xref)107 pmid = self._get_info('PMID', xref)108 l_ref.append ([ref, pmid])109 return l_ref110if __name__ == '__main__':111 a = Paper('28472712')112 #a._get_reference('28472712')...

Full Screen

Full Screen

ystockquote.py

Source:ystockquote.py Github

copy

Full Screen

1"""Yahoo Stock Quote module provides a Python API for retrieving stock data from Yahoo."""2import yfinance as yf3_cached_ticker = {}4def _get_info(symbol, data):5 symbol = symbol.upper()6 t = None7 if symbol in _cached_ticker:8 t = _cached_ticker[symbol]9 else:10 t = yf.Ticker(symbol)11 _cached_ticker[symbol] = t12 i = t.info13 if data in i:14 v = t.info[data]15 else:16 v = None17 return v18def _get_info_choice(symbol, data_choice):19 v = None20 for data in data_choice:21 v = _get_info(symbol, data)22 if v is not None:23 break24 return v25def get_name(symbol):26 """Full company name from symbol."""27 return _get_info(symbol, 'longName')28def get_volume(symbol):29 """Current day's trading volume in number of shares."""30 return _get_info(symbol, 'volume')31def get_price(symbol):32 """Current day's trading last price."""33 # TBD to confirm34 return _get_info(symbol, 'regularMarketPrice')35 #return _get_info(symbol, 'currentPrice')36def get_stock_exchange(symbol):37 """Return the name of the stock exchange the stock is traded."""38 return _get_info(symbol, 'exchange')39def get_52_week_high(symbol):40 """Highest price value during the last 52 weeks."""41 return _get_info(symbol, 'fiftyTwoWeekHigh')42def get_52_week_low(symbol):43 """Lowest price value during the last 52 weeks."""44 return _get_info(symbol, 'fiftyTwoWeekLow')45def get_currency(symbol):46 return _get_info(symbol, 'currency')47def get_market_cap(symbol):48 """Return the market capitalization of the given stock."""49 return _get_info_choice(symbol, ['marketCap', 'totalAssets'])50def get_dividend_yield(symbol):51 """Return the dividend yield (in %) of the stock."""52 d = _get_info_choice(53 symbol,54 [55 'yield',56 'dividendYield',57 'trailingAnnualDividendYield',58 ]59 )60 if d is not None:61 d *= 100.0 # Bring to percentage62 else:63 d = 0.064 return d65def get_price_earnings_ratio(symbol):66 """Return the P/E ratio."""...

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 avocado 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