How to use to_relative_path method in prospector

Best Python code snippet using prospector_python

storage.py

Source:storage.py Github

copy

Full Screen

...31 except OSError as ex:32 if ex.errno == 17:33 # Directory already exists34 return True35 log.warn('Unable to create directories: %r - (%s) %s', cls.to_relative_path(path), ex.errno, ex)36 except Exception as ex:37 log.warn('Unable to create directories: %r - (%s) %s', cls.to_relative_path(path), type(ex), ex)38 return False39 @classmethod40 def copy(cls, source, destination):41 """Copy the file at `source` to `destination`42 :type source: str43 :type destination: str44 """45 if os.path.isdir(source):46 return cls.copy_tree(source, destination)47 try:48 shutil.copy2(source, destination)49 log.debug('Copied %r to %r', cls.to_relative_path(source), cls.to_relative_path(destination))50 return True51 except Exception as ex:52 log.warn('Unable to copy %r to %r - %s', cls.to_relative_path(source), cls.to_relative_path(destination), ex)53 return False54 @classmethod55 def copy_tree(cls, source, destination):56 """Copy the directory at `source` to `destination`57 :type source: str58 :type destination: str59 """60 try:61 shutil.copytree(source, destination)62 log.debug('Copied %r to %r', cls.to_relative_path(source), cls.to_relative_path(destination))63 return True64 except Exception as ex:65 log.warn('Unable to copy %r to %r - %s', cls.to_relative_path(source), cls.to_relative_path(destination), ex)66 return False67 @classmethod68 def delete(cls, path):69 """Delete the file (at `path`)70 :type path: str71 """72 if os.path.isdir(path):73 return cls.delete_tree(path)74 try:75 os.remove(path)76 log.debug('Deleted %r', cls.to_relative_path(path))77 return True78 except Exception as ex:79 log.warn('Unable to delete file: %r - %s', cls.to_relative_path(path), ex)80 return False81 @classmethod82 def delete_tree(cls, path):83 """Delete the directory (at `path`)84 :type path: str85 """86 try:87 shutil.rmtree(path)88 log.debug('Deleted %r', cls.to_relative_path(path))89 return True90 except Exception as ex:91 log.warn('Unable to delete directory: %r - %s', cls.to_relative_path(path), ex)92 return False93 @classmethod94 def to_relative_path(cls, path):95 """Convert `path` to be relative to `StorageHelper.base_names`96 :type path: str97 """98 path_lower = path.lower()99 # Find base path100 base_path = None101 for base in cls.base_names:102 if base not in path_lower:103 continue104 base_path = path[:path_lower.find(base)]105 break106 # Check if `base_path` was found107 if not base_path:108 return path...

Full Screen

Full Screen

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