How to use excluded method in prospector

Best Python code snippet using prospector_python

c1_shared.py

Source:c1_shared.py Github

copy

Full Screen

1import os2import json3from typing import *4import sys5from typing import Dict, Any6sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))7import pylo8excel_doc_sheet_fingerprint_title = 'DO NOT EDIT'9excel_doc_sheet_inbound_identified_title = 'Id Inbound'10excel_doc_sheet_outbound_identified_title = 'Id Outbound'11excluded_ranges = pylo.IP4Map()12excluded_broadcast = pylo.IP4Map()13excluded_direct_services: List['pylo.DirectServiceInRule'] = []14excluded_processes: Dict[str, str] = {}15pce_listing: Dict[str, pylo.APIConnector] = {}16def load_config_file(filename='c1_config.json') -> bool:17 config_filename = filename18 if not os.path.isfile(config_filename):19 raise pylo.PyloEx("Cannot find config file '{}'".format(config_filename))20 with open(config_filename) as json_file:21 data = json.load(json_file)22 pce_listing_data = data.get('pce_listing')23 if pce_listing_data is not None:24 pce_data: Dict25 for pce_data in pce_listing_data:26 org_id = pce_data.get('org_id')27 if org_id is None:28 org_id = 129 connector = pylo.APIConnector(hostname=pce_data['fqdn'], port=pce_data['port'],30 apiuser=pce_data['api_user'], apikey=pce_data['api_key'],31 orgID=org_id, skip_ssl_cert_check=True)32 pce_listing[pce_data['name'].lower()] = connector33 excluded_ranges_data: List[str] = data.get('excluded_networks')34 if excluded_ranges_data is not None:35 if type(excluded_ranges_data) is not list:36 raise pylo.PyloEx("excluded_ranges is not a list:", excluded_ranges_data)37 for network_range in excluded_ranges_data:38 excluded_ranges.add_from_text(network_range)39 excluded_broadcast_data: List[str] = data.get('excluded_broadcast_addresses')40 if excluded_broadcast_data is not None:41 if type(excluded_broadcast_data) is not list:42 raise pylo.PyloEx("excluded_broadcast_addresses is not a list:", excluded_broadcast_data)43 for broadcast_ip in excluded_broadcast_data:44 excluded_broadcast.add_from_text(broadcast_ip)45 excluded_services_data: List[str] = data.get('excluded_services')46 if excluded_services_data is not None:47 if type(excluded_services_data) is not list:48 raise pylo.PyloEx("excluded_services is not a list:", excluded_services_data)49 for service in excluded_services_data:50 excluded_direct_services.append(pylo.DirectServiceInRule.create_from_text(service, protocol_first=False))51 excluded_processes_data: List[str] = data.get('excluded_processes')52 if excluded_processes_data is not None:53 for process in excluded_processes_data:54 excluded_processes[process] = process55 return True56def print_stats():57 print(" - PCE listing entries count: {}".format(len(pce_listing)))58 print(" - Network address exclusions entries count: {}".format(excluded_ranges.count_entries()))59 print(" - Broadcast IP manual exclusion entries count: {}".format(excluded_broadcast.count_entries()))60 print(" - Service exclusions entries count: {}".format(len(excluded_direct_services)))...

Full Screen

Full Screen

weapons.py

Source:weapons.py Github

copy

Full Screen

1from bflib.keywords.weapons import WeaponWieldKeyword2from bflib.items.weapons.base import Weapon3from bflib.restrictions.base import Restriction4from bflib.sizes import Size5class WeaponRestrictionSet(Restriction):6 __slots__ = ["included", "excluded"]7 def __init__(self, included=None, excluded=None):8 self.included = included9 self.excluded = excluded10 def can_wield(self, item):11 # It makes no sense to prevent wielding a non weapon, like a torch.12 if isinstance(item, Weapon):13 if self.included is not None:14 for included_type in self.included:15 if isinstance(item, included_type):16 return True17 return False18 if self.excluded is not None:19 for excluded_type in self.excluded:20 if isinstance(item, excluded_type):21 return False22 return True23 @classmethod24 def from_merge(cls, first, other):25 included = []26 if first.included and other.included:27 included.extend(first.included)28 included.extend(other.included)29 included = list(set(included))30 excluded = []31 if not included:32 if first.excluded or other.excluded:33 excluded.extend(first.excluded)34 excluded.extend(other.excluded)35 return cls(36 included=included,37 excluded=excluded,38 )39class WeaponSizeRestrictionSet(Restriction):40 __slots__ = ["large", "medium", "small"]41 keywords = WeaponWieldKeyword42 _priority_map = {43 keywords.CanWield: 0,44 keywords.NeedsTwoHands: 1,45 keywords.CannotWield: 246 }47 def __init__(self, large=keywords.CanWield, medium=keywords.CanWield, small=keywords.CanWield):48 self.large = large49 self.medium = medium50 self.small = small51 self.mapping = {52 Size.Small: self.small,53 Size.Medium: self.medium,54 Size.Large: self.large55 }56 def can_wield(self, item):57 keyword = self.mapping.get(item.size, self.keywords.CannotWield)58 if keyword == self.keywords.CannotWield:59 return False60 else:61 return keyword62 @classmethod63 def from_merge(cls, first, other):64 small = min(65 cls._priority_map[cls.keywords.CanWield],66 cls._priority_map[first.small],67 cls._priority_map[other.small]68 )69 medium = min(70 cls._priority_map[cls.keywords.CanWield],71 cls._priority_map[first.medium],72 cls._priority_map[other.medium]73 )74 large = min(75 cls._priority_map[cls.keywords.CanWield],76 cls._priority_map[first.large],77 cls._priority_map[other.large]78 )...

Full Screen

Full Screen

armor.py

Source:armor.py Github

copy

Full Screen

1from bflib.restrictions.base import Restriction2from bflib.items.shields.base import Shield3from bflib.items.armor.base import Armor4class ArmorRestrictionSet(Restriction):5 __slots__ = ["included", "excluded", "shields"]6 def __init__(self, included=None, excluded=None, shields=True):7 self.included = included8 self.excluded = excluded9 self.shields = shields10 @classmethod11 def from_merge(cls, first, other):12 included = []13 if first.included and other.included:14 included.extend(first.included)15 included.extend(other.included)16 included = list(set(included))17 excluded = []18 if not included:19 if first.excluded or other.excluded:20 excluded.extend(first.excluded)21 excluded.extend(other.excluded)22 return cls(23 included=included,24 excluded=excluded,25 shields=True if first.shields or other.shields else False26 )27 def can_wear(self, item):28 if not self.shields:29 if isinstance(item, Shield):30 return False31 if isinstance(item, Armor) and self.included is not None:32 for included_type in self.included:33 if isinstance(item, included_type):34 return True35 return False36 if self.excluded is not None:37 for excluded_type in self.excluded:38 if isinstance(item, excluded_type):39 return False...

Full Screen

Full Screen

classes.py

Source:classes.py Github

copy

Full Screen

1from bflib.restrictions.base import Restriction2class ClassRestrictionSet(Restriction):3 __slots__ = ["access_combined", "included", "excluded"]4 def __init__(self, included=None, excluded=None, access_combined=False):5 """6 :param included: Iterable, If Set, this restricts class selection to those defined.7 :param excluded: Iterable, If Set, this prevents defined classes to be selected.8 :param access_combined: Bool, If True, this allows the character to use combined classes.9 """10 self.included = included11 self.excluded = excluded12 self.access_combined = access_combined13 @classmethod14 def from_merge(cls, first, other):15 included = []16 if first.included and other.included:17 included.extend(first.included)18 included.extend(other.included)19 included = list(set(included))20 excluded = []21 if not included:22 if first.excluded or other.excluded:23 excluded.extend(first.excluded)24 excluded.extend(other.excluded)25 return cls(26 included=included,27 excluded=excluded,28 access_combined=True if first.shields or other.shields else False29 )30 def evaluate(self, character_class):31 if self.included and character_class not in self.included:32 return False33 if self.excluded and character_class in self.excluded:34 return False...

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