Best Python code snippet using avocado_python
fs_object.py
Source:fs_object.py  
...122        for entry in self.entries:123            if entry.is_empty:124                return entry125        return None126    def _extend_directory(self) -> None:127        current = self.first_cluster128        while current.next_cluster is not None:129            current = current.next_cluster130        new_cluster = self.fat.find_free_cluster()131        current.set_in_fat(new_cluster.id)132        current.next_cluster = new_cluster133        self.entries += self.create_entries(new_cluster)134    def chain_directory(self) -> Entry:135        self._extend_directory()136        free_entry = self.find_free_entry()137        if free_entry is None:138            raise FatalError('No more space left!')139        return free_entry140    def allocate_object(self,141                        name,142                        entity_type,143                        path_from_root=None,144                        extension=''):145        # type: (str, int, Optional[List[str]], str) -> Tuple[Cluster, Entry, Directory]146        """147        Method finds the target directory in the path148        and allocates cluster (both the record in FAT and cluster in the data region)149        and entry in the specified directory...resolver.py
Source:resolver.py  
...115            reference,116            ReferenceResolutionResult.NOTFOUND,117            info='File "%s" does not exist or is not %s' % (path, access_name))118    return True119def _extend_directory(path):120    if not os.path.isdir(path):121        return [path]122    paths = []123    # no error handling so far124    for dirpath, dirs, filenames in os.walk(path):125        dirs.sort()126        for file_name in sorted(filenames):127            # does it make sense to ignore hidden files here?128            if file_name.startswith('.'):129                continue130            pth = os.path.join(dirpath, file_name)131            paths.append(pth)132    if not paths:133        paths = [path]134    return paths135def resolve(references, hint=None, ignore_missing=True):136    resolutions = []137    hint_resolutions = []138    hint_references = {}139    if hint:140        hint_resolutions = hint.get_resolutions()141        hint_references = {r.reference: r for r in hint_resolutions}142    if not references and hint_references:143        references = hint_references.keys()144    if references:145        # should be initialized with args, to define the behavior146        # of this instance as a whole147        resolver = Resolver()148        extended_references = []149        for reference in references:150            # a reference extender is not (yet?) an extensible feature151            # here it walks directories if one is given, and extends152            # the original reference into final file paths153            extended_references.extend(_extend_directory(reference))154        for reference in extended_references:155            if reference in hint_references:156                resolutions.append(hint_references[reference])157            else:158                resolutions.extend(resolver.resolve(reference))159    # This came up from a previous method and can be refactored to improve160    # performance since that we could merge with the loop above.161    if not ignore_missing:162        missing = []163        for reference in references:164            results = [res.result for res in resolutions if165                       res.reference == reference]166            if ReferenceResolutionResult.SUCCESS not in results:167                missing.append(reference)...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!!
