Best Python code snippet using avocado_python
xpsdatagathering.py
Source:xpsdatagathering.py
...13DEBUG = False14def _get_current_scan_number():15 scanInfo = InterfaceProvider.getCurrentScanInformationHolder().getCurrentScanInformation()16 return int(scanInfo.getScanNumber())17def _get_datadir():18 return InterfaceProvider.getPathConstructor().createFromDefaultProperty()19class IsFalsePredicate(java.util.function.Predicate):20 21 def apply(self, o):22 return not o23class ScannableXPSDataGatherer(ScannableBase):24 25 def __init__(self, name, pvroot='BL16I-CS-IOC-15:XPSG:'):26 self.name = name27 self.inputNames = ['rate', 'delay_time', 'total_time']28 self.extraNames = ['file_number']29 self.outputFormat = ['%.5f', '%.5f', '%.5f', '%i']30 self.level = 431 self.pvs = PvManager(pvroot=pvroot)32 self.pv_startacquire = LazyPVFactory.newNoCallbackBooleanFromShortPV(pvroot + 'START-ACQUIRE')33 self.pv_aquiring = LazyPVFactory.newNoCallbackBooleanFromShortPV(pvroot + 'ACQUIRING')34 35 self._rate_and_time_set_for_this_scan = False36 self._last_delay_time = -99937 self._next_file_number = -99938 39 def atScanStart(self):40 self._rate_and_time_set_for_this_scan = False41 if ENABLE_AXES_TO_ACQUIRE:42 for axis in 1, 2, 3, 4, 5 ,6:43 self.pvs['AXIS-ENABLE-0' + str(axis)].caput(TIMEOUT, True)44 self._set_dirname_and_create_directory()45 self.pvs['COUNTER'].caput(TIMEOUT, 0)46 self.pvs['FILENAME'].caput(TIMEOUT, "")47 def _set_dirname_and_create_directory(self):48 dirname = os.path.join(_get_datadir(), '%i-xps' % _get_current_scan_number())49 if len(dirname) > 39:50 raise Exception("Path exceeded 39 characters (%i): %s" % (len(dirname), dirname))51 self.pvs['DIRNAME'].caput(TIMEOUT, dirname)52 if not os.path.exists(dirname):53 os.makedirs(dirname)54 print self.name + " writing to: " + dirname55 56 def asynchronousMoveTo(self, target):57 rate, delay_time, total_time = [float(element) for element in tuple(target)]58 self._last_delay_time = delay_time59 if not self._rate_and_time_set_for_this_scan:60 self.pvs['CAPTURE-HERTZ'].caput(TIMEOUT, rate)61 self.pvs['CAPTURE-TIME'].caput(TIMEOUT, total_time)62 self._rate_and_time_set_for_this_scan = True...
cli.py
Source:cli.py
2import typing as t3import sys4if t.TYPE_CHECKING:5 from pathlib import Path6def _get_datadir(module_name: str) -> t.Optional[Path]:7 import pathlib8 from importlib.util import find_spec9 spec = find_spec(module_name)10 if spec is None:11 return None12 locations = spec.submodule_search_locations13 if locations is None:14 return None15 return pathlib.Path(locations[0]) / "data"16def init(17 *, target: str = "clikit", root: str = ".", name: t.Optional[str] = None18) -> None:19 """scaffold"""20 import logging21 import shutil22 import pathlib23 from functools import partial24 from prestring.output import setup_logging25 logger = logging.getLogger(__name__)26 setup_logging(_logger=logger)27 dirpath = _get_datadir("egoist")28 if dirpath is None:29 return30 src = dirpath / f"{target}"31 dst = pathlib.Path(root)32 name = name or "foo" # xxx33 params: t.Dict[str, str] = {"name": name or "foo", "definitions": "definitions"}34 def _copy(src: str, dst: str) -> t.Any:35 if src.endswith(".tmpl"):36 dst = str(pathlib.Path(dst).with_suffix("")).format(**params)37 if dst.endswith("definitions.py") and pathlib.Path(dst).exists():38 logger.info("[F]\t%s\t%s", "no change", dst)39 return40 if dst.endswith("__init__.py") and pathlib.Path(dst).exists():41 logger.info("[F]\t%s\t%s", "no change", dst)...
Constant.py
Source:Constant.py
1import os2from CleanUp3.Util.Singleton import Singleton3from CleanUp3.Util.Configuration import Configurations4class Constant(metaclass=Singleton):5 def __init__(self):6 self.__FILE_REAL_PATH = os.path.dirname(os.path.realpath(__file__))7 self.CONFIG = Configurations(self.__FILE_REAL_PATH+'/../conf/default.conf')8 def _get_dataDir(self):9 return self.__FILE_REAL_PATH+'/../../'+self.CONFIG.get("DIR_CONFIG", "DIR_DATA")10 def _get_param(self, model_nm : str) -> dict :11 return eval(self.CONFIG.get("FARAMS_CONFIG", model_nm))12if __name__ == '__main__':13 # __FILE_REAL_PATH = os.path.dirname(os.path.realpath(__file__))14 Constant = Constant()15 print(Constant._get_dataDir())...
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!!