How to use get_help method in pypom_form

Best Python code snippet using pypom_form_python

itom_jedilib.py

Source:itom_jedilib.py Github

copy

Full Screen

...138 doc = self.sample_notypehints139 p = "temp.py"140 141 # multiline comment -> no help142 h = jedilib.get_help(doc, 0, 15, path=p)143 self.assertEqual(len(h), 0)144 145 # empty line -> no help146 h = jedilib.get_help(doc, 1, 0, path=p)147 self.assertEqual(len(h), 0)148 149 # import itom150 h = jedilib.get_help(doc, 2, 3, path=p) # import is nothing151 self.assertEqual(len(h), 0)152 h = jedilib.get_help(doc, 2, 9, path=p) # itom is a module153 self.assertEqual(h[0][0], "module itom")154 self.assertTrue("Module itom" in h[0][1][0])155 156 # __version__ string157 h1 = jedilib.get_help(doc, 5, 3, path=p) # __version__ variable -> help158 self.assertEqual(h1, [('__version__ = "2.0.0"', ['__version__: str'])])159 h2 = jedilib.get_help(doc, 5, 14, path=p) # equal sign (keyword) -> no help160 self.assertEqual(len(h2), 0)161 h3 = jedilib.get_help(doc, 5, 18, path=p) # version string -> no help162 self.assertEqual(len(h3), 0)163 164 # meth1_nodocstr165 h = jedilib.get_help(doc, 8, 1, path=p) # keyword -> no help166 self.assertEqual(len(h), 0)167 h = jedilib.get_help(doc, 8, 12, path=p) # method itself -> help168 self.assertEqual(h, [('def meth1_nodocstr', ['meth1_nodocstr()'])])169 170 # meth1_nodocstr, content171 h = jedilib.get_help(doc, 9, 15, path=p) # int number172 self.assertEqual(h[0][0], 'instance int')173 self.assertTrue("int([x]) -> integer\n" in h[0][1][0])174 h = jedilib.get_help(doc, 9, 13, path=p) # keyword + -> no help175 self.assertEqual(len(h), 0)176 h = jedilib.get_help(doc, 9, 6, path=p) # var, no typehints, rettype None177 self.assertEqual(h, [('var = 2 + 3', ['var: None'])])178 h = jedilib.get_help(doc, 10, 6, path=p) # var, no typehints, one expr: type: int179 self.assertEqual(h, [('var2 = 3', ['var2: int'])])180 181 # meth1_docstr182 h = jedilib.get_help(doc, 14, 1, path=p) # keyword -> no help183 self.assertEqual(len(h), 0)184 h = jedilib.get_help(doc, 14, 12, path=p) # method itself -> help185 self.assertEqual(186 h, 187 [('def meth1_docstr',188 ['meth1_docstr()\n\nReturns the float result of 2 + 3.'])189 ]190 )191 192 # meth2_nodocstr193 h = jedilib.get_help(doc, 20, 14, path=p) # signature194 self.assertEqual(h, [('def meth2_nodocstr', ['meth2_nodocstr(arg1, arg2=4.0)'])])195 196 h = jedilib.get_help(doc, 20, 22, path=p) # arg1197 h2 = jedilib.get_help(doc, 21, 11, path=p) # the same arg1198 self.assertEqual(h, [('param arg1', ['param arg1'])])199 self.assertEqual(h, h2)200 201 h = jedilib.get_help(doc, 20, 28, path=p) # arg2202 h2 = jedilib.get_help(doc, 21, 18, path=p) # the same arg2203 self.assertEqual(h, [('param arg2=4.0', ['param arg2=4.0'])])204 self.assertEqual(h, h2)205 206 h = jedilib.get_help(doc, 26, 14, path=p) # dobj3.shape, word 'dobj3'207 self.assertEqual(h, [('dobj3 = dobj.reshape([3, 2])', ['dobj3: dataObject'])])208 h = jedilib.get_help(doc, 26, 19, path=p) # dobj3.shape, word 'shape'209 if jedi.__version__ > "0.18.0":210 self._assertOneHelpEntry(h, "def shape", "shape: tuple\n\ntuple of int : Gets the shape", True)211 else:212 self._assertOneHelpEntry(h, "def shape", "shape: tuple", True)213 214 # main code part215 h = jedilib.get_help(doc, 131, 8, path=p) # comment -> no help216 self.assertEqual(len(h), 0)217 218 h = jedilib.get_help(doc, 132, 7, path=p) # pathes = ... -> help219 self.assertEqual(h, [('pathes = sys.path', ['pathes: List[str]'])])220 221 h = jedilib.get_help(doc, 132, 15, path=p) # pathes = sys... -> help222 self._assertOneHelpEntry(h, "module sys", "Module sys\n\nThis module")223 224 h = jedilib.get_help(doc, 137, 7, path=p) # result1225 self.assertEqual(h, [('result1 = meth1_nodocstr()', ['result1: float'])])226 h = jedilib.get_help(doc, 137, 14, path=p) # meth1_nodocstr()227 self.assertEqual(h, [('def meth1_nodocstr', ['meth1_nodocstr()'])])228 229 h = jedilib.get_help(doc, 138, 7, path=p) # result2230 self.assertEqual(h, [('result2 = meth1_docstr()', ['result2: float'])])231 h = jedilib.get_help(doc, 138, 14, path=p) # meth1_docstr()232 self.assertEqual(h, [('def meth1_docstr', 233 ['meth1_docstr()\n\nReturns the float result of 2 + 3.'])])234 235 h = jedilib.get_help(doc, 139, 7, path=p) # result3236 self.assertEqual(h, [('result3 = meth2_nodocstr(-3)', ['result3: None'])])237 h = jedilib.get_help(doc, 139, 14, path=p) # meth2_nodocstr()238 self.assertEqual(h, 239 [('def meth2_nodocstr', 240 ['meth2_nodocstr(arg1, arg2=4.0)'])])241 242 h = jedilib.get_help(doc, 140, 7, path=p) # result4243 self.assertEqual(h, [('result4 = meth2_docstr(7)', ['result4: None'])])244 h = jedilib.get_help(doc, 140, 14, path=p) # meth2_docstr()245 self.assertEqual(246 h, 247 [('def meth2_docstr', 248 ['meth2_docstr(arg1, arg2=4.0)\n\nPrints the values of both arguments.']249 )])250 251 h = jedilib.get_help(doc, 141, 7, path=p) # result5252 self.assertEqual(253 h, 254 [('result5 = meth3_docstr(2, 3.0, "hello", [b"test", 3])', 255 ['result5: List[Union[float, int]]'])])256 h = jedilib.get_help(doc, 141, 14, path=p) # meth3_docstr()257 self.assertEqual(258 h, 259 [('def meth3_docstr', 260 ['meth3_docstr(arg1, arg2, *args)\n\nReturns a list of all unwrapped arguments.'])])261 262 h = jedilib.get_help(doc, 143, 7, path=p) # mycls1263 self.assertEqual(h, [('mycls1 = MyClass(6, 7)', ['mycls1: MyClass'])])264 265 h = jedilib.get_help(doc, 152, 7, path=p) # mycls1266 self.assertEqual(h, [('mycls1 = MyClassDocStr(6, 7)', ['mycls1: MyClassDocStr'])])267 def test_recursionAbility(self):268 """Check by an example, that the maximum recursion limit value, indicated269 in itomJediLib.py can be fullfilled by this itom / Python setup. This270 test is inspired by check_recursionlimit.py, a tool script of Python.271 If the test fails, the application usually crashes.272 """273 class RecursiveBlowup2:274 def __repr__(self):275 return repr(self)276 277 def func_repr():278 return repr(RecursiveBlowup2())279 ...

Full Screen

Full Screen

filter_news.py

Source:filter_news.py Github

copy

Full Screen

...14 elif len(time) == 2:15 actual_time = time[0] + "T" + time[1]16 return actual_time17# @get_help is a help section for user which will help user to enter correct inputs18def get_help():19 with open("help.txt", "r", encoding="utf-8") as file:20 for line in file.readlines():21 print(line.strip())22# This function is for applying some initial filters to the news contents for fetching news23def initial_filter(type_of_news):24 country = category = qInTitle = domains = excludeDomains = from_date = to_date = language = ""25 sort = 326 if type_of_news == "headlines": # parameters that are only required for fetching top headlines27 country = input("Enter country code: ")28 if country.lower() == "/help": # After every input, input is compared with "/help" to make sure user29 get_help() # doesn't need any help if the input is "/help" @get_help will be called.30 category = input("Enter category of news: ")31 if category.lower() == "/help":32 get_help()33 if not country and not category: # newsapi.org doesn't allow to @sources parameter with @country and @category34 sources = input("A comma-separated or single word string of identifiers"35 " for the [news sources] or blogs you want headlines from: ")36 else:37 sources = None38 if sources:39 if sources.lower() == "/help":40 get_help()41 if type_of_news == "everything": # parameters that are only required for fetching everything42 qInTitle = input("Keywords or phrases to [search for in the article title only]. ")43 if qInTitle.lower() == "/help":44 get_help()45 q = input("Keywords or phrases to [search for in the article title and body]: ")46 if q.lower() == "/help":47 get_help()48 if type_of_news == "everything": # parameters that are only required for fetching everything49 domains = input("A comma-separated string of domains (eg bbc.co.uk, techcrunch.com,"50 " engadget.com) to restrict the search to. ")51 if domains.lower() == "/help":52 get_help()53 excludeDomains = input('A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com)'54 ' [to remove from the results]. ')55 if excludeDomains.lower() == "/help":56 get_help()57 from_date = input("A date and optional time for the oldest article allowed."58 " This should be in ISO 8601 format (e.g. 2020-10-19 or 2020-10-19 14:02:08) "59 "Default: the oldest. ")60 from_date = actual_time_format(from_date)61 if from_date.lower() == "/help":62 get_help()63 to_date = input("A date and optional time for the newest article allowed. "64 "This should be in ISO 8601 format (e.g. 2020-10-19 or 2020-10-19 14:02:08)"65 " Default: the newest ")66 to_date = actual_time_format(to_date)67 if to_date.lower() == "/help":68 get_help()69 language = input("Enter [language] for news: ")70 if language.lower() == "/help":71 get_help()72 print("The order to sort the articles in")73 for key, value in sortBy.items():74 print(f"{key} for sorting according to {value}")75 sort = input("Enter: ")76 if sort.lower() == "/help":77 get_help()78 # returning the dictionary with the parameters by which our news content is to be filtered79 if type_of_news == "headlines":80 return {"country": country, "category": category, "sources": sources, "q": q}81 elif type_of_news == "everything":82 return {83 "q": q,84 "qInTitle": qInTitle,85 "sources": sources,86 "domains": domains,87 "excludeDomains": excludeDomains,88 "from": from_date,89 "to": to_date,90 "language": language,91 "sortBy": sortBy.get(sort)92 }93def after_fetch_filter(fetched_news):94 print("\nApply some more filters \nIf you want to set a parameter, write after it, otherwise hit 'enter'\n"95 "Enter '/help' for help section\n")96 sources = input("From sources: ")97 if sources.lower() == "/help":98 get_help()99 keyword = input("Any specific keyword or phrases in title:")100 if keyword.lower() == "/help":101 get_help()102 if sources is None:103 sources = ""104 if keyword is None:105 keyword = ""106 new_article = []107 articles = fetched_news.get("articles")108 for article in articles:109 if sources in article.get("source").get("name").lower() and keyword in article.get("title"):110 new_article.append(article)111 fetched_news.update({"articles": new_article})112 return fetched_news113def initial_sources_filter():114 print("Enter details for fetching sources \nIf you want to set a parameter, write after it, otherwise hit 'enter'\n"115 "Enter '/help' for help section\n")116 category = input("Enter [category] of news sources: ")117 if category.lower() == "/help":118 get_help()119 country = input("Enter country code: ")120 if country.lower() == "/help": # After every input, input is compared with "/help" to make sure user121 get_help() # doesn't need any help if the input is "/help" @get_help will be called.122 language = input("Enter [language] for news: ")123 if language.lower() == "/help":124 get_help()125 return {"category": category, "country": country, "language": language}126if __name__ == '__main__':127 news = News("top-headlines", country="us", category="sports")...

Full Screen

Full Screen

generate_docs.py

Source:generate_docs.py Github

copy

Full Screen

...5import textwrap6from typing import Optional7from jinja2 import Environment, FileSystemLoader8from pipx.main import __version__9def get_help(pipxcmd: Optional[str]) -> str:10 if pipxcmd:11 cmd = ["pipx", pipxcmd, "--help"]12 else:13 cmd = ["pipx", "--help"]14 helptext = (15 subprocess.run(cmd, stdout=subprocess.PIPE, check=True)16 .stdout.decode()17 .replace(os.path.expanduser("~"), "~")18 )19 return f"""20```21{" ".join(cmd)}22{helptext}23```24"""25params = {26 "usage": get_help(None),27 "runpip": get_help("runpip"),28 "install": get_help("install"),29 "upgrade": get_help("upgrade"),30 "upgradeall": get_help("upgrade-all"),31 "inject": get_help("inject"),32 "uninstall": get_help("uninstall"),33 "uninstallall": get_help("uninstall-all"),34 "reinstallall": get_help("reinstall-all"),35 "list": get_help("list"),36 "run": get_help("run"),37 "version": __version__,38}39warning = textwrap.dedent(40 """41 <!---42 Do not edit this file. This file was rendered from the43 templates/ directory.44 See Contributing for how to update this file.45 --->46 """47).lstrip()48env = Environment(loader=FileSystemLoader("templates"))49with open("docs/docs.md", "w") as f:50 f.write(warning)...

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