How to use wrapped_function method in pytractor

Best Python code snippet using pytractor_python

registry.py

Source:registry.py Github

copy

Full Screen

...25 def __init__(self, subscription_point):26 self.subscription_point = subscription_point27 28 def __call__(self, function):29 def wrapped_function(*args):30 return function(*args)31 setattr(wrapped_function, '_keys', self.subscription_point._keys)32 setattr(wrapped_function, '_path', self.subscription_point._path)33 setattr(wrapped_function, '_schema_descriptor', self.subscription_point._current_descriptor)34 return wrapped_function35def pre_commit(function):36 '''37 Annotation for pre_commit functions.38 '''39 def wrapped_function(*args):40 return function(*args)41 setattr(wrapped_function, '_group_wide', True)42 setattr(wrapped_function, '_pre_commit', True)43 return wrapped_function44def abort(function):45 '''46 Annotation for abort functions.47 '''48 def wrapped_function(*args):49 return function(*args)50 setattr(wrapped_function, '_group_wide', True)51 setattr(wrapped_function, '_abort', True)52 return wrapped_function53def commit(function):54 '''55 Annotation for commit functions.56 '''57 def wrapped_function(*args):58 return function(*args)59 setattr(wrapped_function, '_group_wide', True)60 setattr(wrapped_function, '_commit', True)61 return wrapped_function62def cached_member_data(function):63 '''64 Annotation for the function that returns the list of cached member data.65 '''66 def wrapped_function(*args):67 return function(*args)68 setattr(wrapped_function, '_cached_member_data', True)69 return wrapped_function70class subscribe(PathAnnotation):71 '''72 Annotation for a subscription pre_commit.73 '''74 def __init__(self, subscription_point):75 super(__class__, self).__init__(subscription_point)76 def __call__(self, function):77 wrapped_function = super(__class__, self).__call__(function)78 setattr(wrapped_function, '_group_wide', True)79 setattr(wrapped_function, '_subscribe', True)80 return wrapped_function...

Full Screen

Full Screen

privacyInfo.py

Source:privacyInfo.py Github

copy

Full Screen

...23 self.url = url24 # 目前不需要主方法提供具体的返回, 通过继承了返回25 def __call__(self, func):26 @wraps(func)27 def wrapped_function(*args, **kwargs):28 log.warning('未定义方法,什么都不会做')29 return func(*args, **kwargs)30 return wrapped_function31 def token(self):32 # 获取soa管控的动态token33 def soatoken(appid=self.appid, token=self.token, url=self.url):34 data = {35 'appId': appid,36 'credential': base64.b64encode(token.encode('utf-8')).decode('utf-8'),37 }38 response = requests.post(url=url, json=data)39 result = json.loads(response.text)40 status = result.get('status')41 statusCode = result.get('status').get('statusCode')42 errorMsg = status.get('errorMsg')43 if statusCode == 'EXCEPION' or result['result'] == None:44 print('获取Token失败! 返回失败信息: ', errorMsg)45 return result['result']46 return soatoken()47 def getPrivateValue(self, **kwargs):48 name = None49 phone = None50 address = None51 if 'name' in kwargs:52 name = kwargs['name']53 if 'phone' in kwargs:54 phone = kwargs['phone']55 if 'address' in kwargs:56 address = kwargs['address']57 theToken = mainEntry.token(self)58 url = r'http://kweuat.huawei.com/ppc/common/privacy/data/batch/upsert?appid=' + self.appid59 header = {'AppId': self.appid, 'Content-Type': 'application/json', 'Authorization': theToken}60 result = {}61 if name is not None and name != '':62 name_data = {"itemList": [{"channelId": self.appid,"countryCode": "CN","plainText": name,"type": "SENDER_NAME"}],"respFieldConfig": {"respFieldList": ["ID","ANONYMIZED","HASHKEY"]}}63 response = requests.post(url=url, headers=header, json=name_data)64 respJson = json.loads(response.text)65 itemList = respJson.get('result').get('itemList')66 result['name'] = itemList[0]67 if phone is not None and phone != '':68 phone_data = {"itemList": [{"channelId": self.appid,"countryCode": "CN","plainText": phone,"type": "SENDER_PHONE"}],"respFieldConfig": {"respFieldList": ["ID","ANONYMIZED","HASHKEY"]}}69 response = requests.post(url=url, headers=header, json=phone_data)70 respJson = json.loads(response.text)71 itemList = respJson.get('result').get('itemList')72 result['phone'] = itemList[0]73 if address is not None and address != '':74 address_data = {"itemList": [{"channelId": self.appid,"countryCode": "CN","plainText": address,"type": "SENDER_ADDRESS"}],"respFieldConfig": {"respFieldList": ["ID","ANONYMIZED","HASHKEY"]}}75 response = requests.post(url=url, headers=header, json=address_data)76 respJson = json.loads(response.text)77 itemList = respJson.get('result').get('itemList')78 result['address'] = itemList[0]79 return result80# 修饰符 - 将名称加密为密文后返回展示81class name(mainEntry):82 def __call__(self, func):83 @wraps(func)84 def wrapped_function(*args, **kwargs):85 name = func(*args)86 return mainEntry.getPrivateValue(self, name=name)87 return wrapped_function88# 修饰符 - 将电话加密为密文后返回展示89class phone(mainEntry):90 def __call__(self, func):91 @wraps(func)92 def wrapped_function(*args, **kwargs):93 phone = func(*args)94 return mainEntry.getPrivateValue(self, phone=phone)95 return wrapped_function96# 修饰符 - 将地址加密为密文后返回展示97class address(mainEntry):98 def __call__(self, func):99 @wraps(func)100 def wrapped_function(*args, **kwargs):101 address = func(*args)102 return mainEntry.getPrivateValue(self, address=address)...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

...19 """20 Preserve dummy channel dim.2122 """23 def wrapped_function(img, *args, **kwargs):24 shape = img.shape25 result = func(img, *args, **kwargs)26 if len(shape) == 3 and shape[-1] == 1 and len(result.shape) == 2:27 result = np.expand_dims(result, axis=-1)28 return result2930 return wrapped_function3132def preserve_mask_channel_dim(func):33 def wrapped_function(img, *args, **kwargs):34 shape = img.shape35 if len(shape) == 2:36 img = np.expand_dims(img, axis=-1)37 result = func(img, *args, **kwargs)38 result = np.squeeze(result)39 else:40 result = func(img, *args, **kwargs)41 return result4243 return wrapped_function444546def preserve_shape(func):47 """48 Preserve shape of the image4950 """51 def wrapped_function(img, *args, **kwargs):52 shape = img.shape53 result = func(img, *args, **kwargs)54 result = result.reshape(shape)55 return result5657 return wrapped_function585960def is_rgb_image(image):61 return len(image.shape) == 3 and image.shape[-1] == 3626364def is_grayscale_image(image):65 return (len(image.shape) == 2) or (len(image.shape) == 3 and image.shape[-1] == 1)666768def clip(img, dtype, maxval):69 return np.clip(img, 0, maxval).astype(dtype)707172def clipped(func):73 @wraps(func)74 def wrapped_function(img, *args, **kwargs):75 dtype = img.dtype76 maxval = MAX_VALUES_BY_DTYPE.get(dtype, 1.0)77 return clip(func(img, *args, **kwargs), dtype, maxval)78 ...

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