Best Python code snippet using autotest_python
source.py
Source: source.py
...80 # compose absolute URL if relative "href" found81 url = urlparse.urljoin(self.url, value)82 if self.pattern.match(url):83 self.links.append(url)84 def get_ahref_list(self, url, pattern):85 self.reset(url, pattern)86 self.feed(urllib2.urlopen(url).read())87 self.close()88 return self.links89class url_source(source):90 """91 A simple URL based source that parses HTML to find references to92 kernel files.93 """94 _extension_pattern = re.compile(r'.*\.[^/.]+$')95 def __init__(self, database, prefix):96 super(url_source, self).__init__(database)97 self.prefix = prefix98 self.urls = []99 def add_url(self, url, pattern):100 """101 Add a URL path to a HTML document with links to kernel files.102 :param url: URL path to a HTML file with links to kernel files103 (can be either an absolute URL or one relative to self.prefix)104 :param pattern: regex pattern to filter kernel files links out of105 all othe links found in the HTML document106 """107 # if it does not have an extension then it's a directory and it needs108 # a trailing '/'. NOTE: there are some false positives such as109 # directories named "v2.6" where ".6" will be assumed to be extension.110 # In order for these to work the caller must provide a trailing /111 if url[-1:] != '/' and not self._extension_pattern.match(url):112 url = url + '/'113 self.urls.append((url, re.compile(pattern)))114 @staticmethod115 def _get_item(url):116 """117 Get a database.item object by fetching relevant HTTP information118 from the document pointed to by the given url.119 """120 try:121 info = urllib2.urlopen(url).info()122 except IOError, err:123 # file is referenced but does not exist124 print 'WARNING: %s' % err125 return None126 size = info.get('content-length')127 if size:128 size = int(size)129 else:130 size = -1131 timestamp = int(time.mktime(info.getdate('date')))132 if not timestamp:133 timestamp = 0134 return database.item(url, size, timestamp)135 def get_new_files(self):136 parser = _ahref_parser()137 files = {}138 for url, pattern in self.urls:139 links = parser.get_ahref_list(urlparse.urljoin(self.prefix, url),140 pattern)141 for link in links:142 item = self._get_item(link)143 if item:144 files[item.name] = item145 return self._get_new_files(files)146class directory_source(source):147 """148 Source that finds kernel files by listing the contents of a directory.149 """150 def __init__(self, database, path):151 """152 Initialize a directory_source instance.153 :param database: Persistent database with known kernels information....
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
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. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!