Best Python code snippet using fMBT_python
dependencycorpusreader.py
Source: dependencycorpusreader.py
...23 :return: the given file(s) as a single string.24 :rtype: str25 """26 result = []27 for fileid, encoding in self.abspaths(fileids, include_encoding=True):28 if isinstance(fileid, PathPointer):29 result.append(fileid.open(encoding=encoding).read())30 else:31 with codecs.open(fileid, "r", encoding) as fp:32 result.append(fp.read())33 return concat(result)34 def words(self, fileids=None):35 return concat([DependencyCorpusView(fileid, False, False, False, encoding=enc)36 for fileid, enc in self.abspaths(fileids, include_encoding=True)])37 def tagged_words(self, fileids=None):38 return concat([DependencyCorpusView(fileid, True, False, False, encoding=enc)39 for fileid, enc in self.abspaths(fileids, include_encoding=True)])40 def sents(self, fileids=None):41 return concat([DependencyCorpusView(fileid, False, True, False, encoding=enc)42 for fileid, enc in self.abspaths(fileids, include_encoding=True)])43 def tagged_sents(self, fileids=None):44 return concat([DependencyCorpusView(fileid, True, True, False, encoding=enc)45 for fileid, enc in self.abspaths(fileids, include_encoding=True)])46 def parsed_sents(self, fileids=None):47 sents=concat([DependencyCorpusView(fileid, False, True, True, encoding=enc)48 for fileid, enc in self.abspaths(fileids, include_encoding=True)])49 return [DependencyGraph(sent) for sent in sents]50class DependencyCorpusView(StreamBackedCorpusView):51 _DOCSTART = '-DOCSTART- -DOCSTART- O\n' #dokumentu hasiera definitzen da52 def __init__(self, corpus_file, tagged, group_by_sent, dependencies,53 chunk_types=None, encoding='utf8'):54 self._tagged = tagged55 self._dependencies = dependencies56 self._group_by_sent = group_by_sent57 self._chunk_types = chunk_types58 StreamBackedCorpusView.__init__(self, corpus_file, encoding=encoding)59 def read_block(self, stream):60 # Read the next sentence.61 sent = read_blankline_block(stream)[0].strip()62 # Strip off the docstart marker, if present....
files.py
Source: files.py
1#!/bin/env/python2import os3# ------------------------------- Filesystem4def ls():5 return os.listdir('.')6def isHidden(path):7 filename = os.path.basename(path)8 return filename.startswith('.')9def isVisible(path):10 return not isHidden(path)11def joinPaths(dir, contents):12 return map(lambda f: os.path.join(dir, f), contents)13def filesInDirMatching(dir, prefix=None, suffix=None, absPaths=False,14 onlyFiles=False, onlyDirs=False):15 files = os.listdir(dir)16 if prefix:17 files = filter(lambda f: f.startswith(prefix), files)18 if suffix:19 files = filter(lambda f: f.endswith(suffix), files)20 if onlyFiles or onlyDirs:21 paths = joinPaths(dir, files)22 if onlyFiles:23 newFiles = []24 for f, path in zip(files, paths):25 if os.path.isfile(path):26 newFiles.append(f)27 files = newFiles28 if onlyDirs:29 newFiles = []30 for f, path in zip(files, paths):31 if os.path.isdir(path):32 newFiles.append(f)33 files = newFiles34 if absPaths:35 files = joinPaths(dir, files)36 return files37def listSubdirs(dir, startswith=None, endswith=None, absPaths=False):38 return filesInDirMatching(dir, startswith, endswith, absPaths,39 onlyDirs=True)40def listFilesInDir(dir, startswith=None, endswith=None, absPaths=False):41 return filesInDirMatching(dir, startswith, endswith, absPaths,42 onlyFiles=True)43def listHiddenFilesInDir(dir, startswith=None, endswith=None, absPaths=False):44 contents = filesInDirMatching(dir, startswith, endswith, absPaths,45 onlyFiles=True)46 return filter(isHidden, contents)47def listVisibleFilesInDir(dir, startswith=None, endswith=None, absPaths=False):48 contents = filesInDirMatching(dir, startswith, endswith, absPaths,49 onlyFiles=True)50 return filter(isVisible, contents)51def ensureDirExists(dir):52 if not os.path.exists(dir):53 os.makedirs(dir)54def basename(f, noexts=False):55 name = os.path.basename(f)56 if noexts:57 name = name.split('.')[0]...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.
Sometimes, in our test code, we need to handle actions that apparently could not be done automatically. For example, some mouse actions such as context click, double click, drag and drop, mouse movements, and some special key down and key up actions. These specific actions could be crucial depending on the project context.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
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!!