Best Python code snippet using prospector_python
argument.py
Source: argument.py
1# -*- coding: utf-8 -*-2"""3 The argument of hscode4"""5import os6DEFAULT_CHAPTER = '01'7DEFAULT_FILE_ROOT = os.path.join(os.environ['HOME'], 'hscode_file')8class Argument:9 """10 The argument set11 """12 def __init__(self):13 self.all_chapters = False14 self.chapter = DEFAULT_CHAPTER15 self.file_root = DEFAULT_FILE_ROOT16 self.outdated = False17 self.no_latest = False18 self.print_help = False19 self.quiet_mode = False20 self.url_proxy = None21def print_help():22 """23 Print the help info24 """25 print('åæ°å表ï¼')26 print(' --help|-h æ¥ç帮å©ä¿¡æ¯')27 print(' --search|-s [chapter] ç¬åå
·ä½ç« è(ååç¼ç å两ä½)çå
容ï¼é»è®¤01')28 print(' --all|-a ç¬åææç« èçå
容ã该å¼å
³å¼å¯æ¶ï¼--search æ æ')29 print(' --file-root [dir] ä¿åæ件çæ ¹è·¯å¾')30 print(' é»è®¤å¼[HOME]/hascode_file')31 print(' æ件åæ ¼å¼: ')32 print(' hscode_[chapter]_YYYYMMDD_HH:mm.txt')33 print(' hscode_[chapter]_latest.txt')34 print(' --no-latest ä¸çæ(æè¦çåæç)latestæ件')35 print(' --quiet|-q éé»æ¨¡å¼ï¼ä¸æå°æ¥å¿ä¿¡æ¯')36 print(' --outdated å
å«[è¿æ]æ°æ®')37 print(' --proxy|-p [proxy-url] 请æ±ä»£ç')38 print(' --proxy https://www.baidu.com?s={url}')39 print(' {url} æ¯åå§è¯·æ± url')40def parse_argv(sys_argv):41 """42 解æç³»ç»åæ°43 python hscode.py -s 8544 """45 length = len(sys_argv)46 result = Argument()47 #ãæ¯å¦å·²ç»è¯»å py åæ°48 read_py_file = False49 for i in range(0, length):50 arg = sys_argv[i]51 if not read_py_file and arg.endswith('.py'):52 read_py_file = True53 continue54 # æç´¢æ¡ä»¶åæ°55 if arg in ['-s', '--search'] and length > i + 1 and not result.all_chapters:56 i += 157 result.chapter = sys_argv[i]58 # æä»¶æ ¹ç®å½59 elif arg == '--file-root' and length > i + 1:60 i += 161 result.file_root = sys_argv[i]62 # æ¯å¦å
å«å·²è¿ææ°æ®63 elif arg == '--outdated':64 result.outdated = True65 # ä¸çæ/è¦ç latest æ件66 elif arg == '--no-latest':67 result.no_latest = True68 # ç¬åææç« è69 elif arg in ['--all', '-a']:70 result.all_chapters = True71 result.chapter = None72 # æå°å¸®å©ä¿¡æ¯73 elif arg in ['--help', '-h']:74 result.print_help = True75 # éé»æ¨¡å¼76 elif arg in ['--quiet', '-q']:77 result.quiet_mode = True78 # 代ç79 elif (arg in ['--proxy', '-p']) and length > i + 1:80 i += 181 url_proxy = sys_argv[i]82 if '{url}' in url_proxy:83 result.url_proxy = url_proxy...
test_openpy.py
Source: test_openpy.py
...9 enc, lines = openpy.detect_encoding(f.readline)10 nt.assert_equal(enc, 'iso-8859-5')11def test_read_file():12 read_specified_enc = io.open(nonascii_path, encoding='iso-8859-5').read()13 read_detected_enc = openpy.read_py_file(nonascii_path, skip_encoding_cookie=False)14 nt.assert_equal(read_detected_enc, read_specified_enc)15 assert u'coding: iso-8859-5' in read_detected_enc16 17 read_strip_enc_cookie = openpy.read_py_file(nonascii_path, skip_encoding_cookie=True)18 assert u'coding: iso-8859-5' not in read_strip_enc_cookie...
Check out the latest blogs from LambdaTest on this topic:
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Recently, I was going through some of the design patterns in Java by reading the book Head First Design Patterns by Eric Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra.
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!!