How to use on_key method in ATX

Best Python code snippet using ATX

indexes.py

Source: indexes.py Github

copy

Full Screen

...10def _setitem(doc, pre, key, on_key=identity):11 """Set an index key to True in a dictionnary."""12 if not key:13 return False14 doc[u"{}::{}".format(pre, on_key(key))] = True15 return True16def from_dex_debug(debug):17 """Extract information from a dex debug."""18 doc = dict()19 _setitem(doc, "dex::debug", debug)20 return doc21def from_dex_format(format):22 """Extract information from a dex format."""23 doc = dict()24 _setitem(doc, "dex::format", format, on_key=lower)25 return doc26def from_dex_header(header):27 """Extract information from a dex header."""28 doc = dict()...

Full Screen

Full Screen

couch.py

Source: couch.py Github

copy

Full Screen

...45 for key in gen:46 yield key.id47def head(conn, db_id, doc_key, on_key=LOWERSTRIP, on_res=IDENTITY):48 """Return True if a document exists in the database."""49 key = on_key(doc_key)50 db = conn.server[db_id]51 return on_res(key in db)52def get(conn, db_id, doc_key, on_key=LOWERSTRIP, on_doc=REMOVE_DBKEYS):53 """Return a document if it exists in the database, else a CouchError."""54 key = on_key(doc_key)55 db = conn.server[db_id]56 try:57 return on_doc(db[key])58 except couchdb.ResourceNotFound:59 raise DocumentNotFound({"db": db_id, "key": key})60def get_or_none(*args, **kwargs):61 """Return a document if it exists in the database, else return None."""62 try:63 return get(*args, **kwargs)64 except DocumentNotFound:65 return None66def raw(conn, db_id, doc_key, on_key=LOWERSTRIP, on_doc=IDENTITY):67 """Return a raw json if it exists in the database, else a CouchError. """68 key = on_key(doc_key)69 uri = "/​".join([conn.url, db_id, key])70 res = requests.get(uri)71 code = res.status_code72 if code == 404:73 raise DocumentNotFound({"db": db_id, "key": key})74 elif code != 200:75 raise CouchError("Could not retrieve JSON from: {}".format(uri))76 try:77 return res.text.strip().encode("utf-8")78 except couchdb.ResourceNotFound:79 raise DocumentNotFound({"db": db_id, "key": key})80def rawall(conn, db_id, doc_keys, on_key=LOWERSTRIP, chunk_size=2048):81 """Return a raw json if it exists in the database, else a CouchError. """82 params = {"include_docs": True}83 keys = {"keys": [on_key(k) for k in doc_keys]}84 uri = "/​".join([conn.url, db_id, "_all_docs"])85 res = requests.post(uri, json=keys, params=params, stream=True)86 if res.status_code != 200:87 raise CouchError("Could not retrieve content from: {}".format(uri))88 for chunk in res.iter_content(chunk_size=chunk_size):89 yield chunk90def put(conn, db_id, doc_key, doc, on_doc=IDENTITY, on_key=LOWERSTRIP):91 """Put a document in the database and returns its key, else a CouchError."""92 doc = on_doc(doc)93 key = on_key(doc_key)94 db = conn.server[db_id]95 try:96 db[key] = doc97 return key98 except Exception as e:99 raise CouchError({"db": db_id, "key": key, "error": str(e), "type": type(e)})100def delete(conn, db_id, doc_key, on_key=LOWERSTRIP):101 """Delete a document from the database and return True, else an Error."""102 key = on_key(doc_key)103 db = conn.server[db_id]104 doc = get(conn, db_id, key, on_doc=IDENTITY)105 if doc is None:106 return True107 try:108 db.delete(doc)109 return True110 except Exception as e:...

Full Screen

Full Screen

gui.py

Source: gui.py Github

copy

Full Screen

...5root.title('Calculator')6root.config(bg='white')7root.resizable(0,0)8# ==================== Functions =====================================9def on_key(number):10 screen.insert(END, number)11def calculate():12 ans = eval(screen.get())13 screen.delete(0, END)14 screen.insert(END, ans)15# ===================== Display ======================================16# create entry17screen= Entry(root, font=("Helvetica", 14), justify='right', width=27, bg='#736d6d',fg='white')18# place entry19screen.grid(row=0, column=0, columnspan=4, ipady=15)20# ========================== Keys ======================================21#1st row22button_bar1 = Button(root, text ="(", width=5, height=3, command=lambda:on_key('('))23button_bar1.grid(row=1, column=0)24button_bar2 = Button(root, text =")", width=5, height=3, command=lambda:on_key(')'))25button_bar2.grid(row=1, column=1)26button_module = Button(root, text ="%", width=5, height=3, command=lambda:on_key('%'))27button_module.grid(row=1, column=2)28clear_btn = Button(root, text ="AC", width=5, height=3, command=lambda:screen.delete(0, END))29clear_btn.grid(row=1, column=3)30#2nd row31button_7 = Button(root, text ="7", width=5, height=3, command=lambda:on_key('7'))32button_7.grid(row=2, column=0)33button_8 = Button(root, text ="8", width=5, height=3, command=lambda:on_key('8'))34button_8.grid(row=2, column=1)35button_9 = Button(root, text ="9", width=5, height=3, command=lambda:on_key('9'))36button_9.grid(row=2, column=2)37div_btn=Button(root, text ="÷", width=5, height=3, command=lambda:on_key('/​'))38div_btn.grid(row=2, column=3)39#3rd row40button_4 = Button(root, text ="4", width=5, height=3, command=lambda:on_key('4'))41button_4.grid(row=3, column=0)42button_5 = Button(root, text ="5", width=5, height=3, command=lambda:on_key('5'))43button_5.grid(row=3, column=1)44button_6 = Button(root, text ="6", width=5, height=3, command=lambda:on_key('6'))45button_6.grid(row=3, column=2)46mul_btn=Button(root, text ="x", width=5, height=3, command=lambda:on_key('*'))47mul_btn.grid(row=3, column=3)48#4th row49button_1 = Button(root, text ="1", width=5, height=3, command=lambda:on_key('1'))50button_1.grid(row=4, column=0)51button_2 = Button(root, text ="2", width=5, height=3, command=lambda:on_key('2'))52button_2.grid(row=4, column=1)53button_3 = Button(root, text ="3", width=5, height=3, command=lambda:on_key('3'))54button_3.grid(row=4, column=2)55sub_btn=Button(root, text ="-", width=5, height=3, command=lambda:on_key('-'))56sub_btn.grid(row=4, column=3)57#5th row58button_0 = Button(root, text ="0", width=5, height=3, command=lambda:on_key('0'))59button_0.grid(row=5, column=0)60button_float = Button(root, text =".", width=5, height=3, command=lambda:on_key('.'))61button_float.grid(row=5, column=1)62calculate_btn = Button(root, text ="=", width=5, height=3, command=calculate)63calculate_btn.grid(row=5, column=2)64sub_btn=Button(root, text ="+", width=5, height=3, command=lambda:on_key('+'))65sub_btn.grid(row=5, column=3)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Putting Together a Testing Team

As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

What is Selenium Grid & Advantages of Selenium Grid

Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

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