code
stringlengths
4
4.48k
docstring
stringlengths
1
6.45k
_id
stringlengths
24
24
class TestUtilFuncs(unittest.TestCase): <NEW_LINE> <INDENT> def test_coroutine(self): <NEW_LINE> <INDENT> @ReportUtils.coroutine <NEW_LINE> def test_func(*args, **kwargs): <NEW_LINE> <INDENT> pass <NEW_LINE> value = yield <NEW_LINE> yield value <NEW_LINE> <DEDENT> f = test_func() <NEW_LINE> self.assertEqual(f.send(1), 1)
Unit tests for ReportUtils module level functions
6259901e925a0f43d25e8e97
class SmartLegislator(Legislator): <NEW_LINE> <INDENT> def pickCoSponsors(self, bill): <NEW_LINE> <INDENT> cosponsors = [] <NEW_LINE> for rep in State.legislators: <NEW_LINE> <INDENT> support = binaryTreeSimilarity(self.positions[bill.main_issue], rep.positions[bill.main_issue]) <NEW_LINE> if support > 0.5: <NEW_LINE> <INDENT> cosponsors.append(rep) <NEW_LINE> <DEDENT> <DEDENT> return cosponsors
Picks co-sponsors based on similarity of the bill main issue
6259901ed164cc6175821dd4
class Renommage (class_Action.Action): <NEW_LINE> <INDENT> def __init__(self, rpt, rgl): <NEW_LINE> <INDENT> class_Action.Action.__init__(self, rpt, rgl) <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return "" <NEW_LINE> <DEDENT> def get_nom_Repertoire(self): <NEW_LINE> <INDENT> return class_Action.Action.get_nom_Repertoire(self) <NEW_LINE> <DEDENT> def get_regle(self): <NEW_LINE> <INDENT> return class_Action.Action.get_regle(self) <NEW_LINE> <DEDENT> def set_nom_Repertoire(self, rpt): <NEW_LINE> <INDENT> class_Action.Action.set_nom_Repertoire(self,rpt) <NEW_LINE> <DEDENT> def set_regle(self, rgl): <NEW_LINE> <INDENT> class_Action.Action.set_regle(self,rgl) <NEW_LINE> <DEDENT> def fichiers_to_rename(self): <NEW_LINE> <INDENT> return class_Action.Action.fichiers_to_rename(self) <NEW_LINE> <DEDENT> def avant_apres(self, fichier): <NEW_LINE> <INDENT> return class_Action.Action.avant_apres(self, fichier) <NEW_LINE> <DEDENT> def rename(self): <NEW_LINE> <INDENT> os.chdir(self.path_rep) <NEW_LINE> test = self.fichiers_to_rename() <NEW_LINE> save_apt = self.ma_regle.apartirde <NEW_LINE> cpt=0 <NEW_LINE> tmp="" <NEW_LINE> for f in test: <NEW_LINE> <INDENT> av , ap =self.avant_apres(f) <NEW_LINE> if self.ma_regle.amorce == "000": <NEW_LINE> <INDENT> if self.ma_regle.apartirde != "": <NEW_LINE> <INDENT> tmp = str(int(self.ma_regle.apartirde)+cpt) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tmp = str(cpt) <NEW_LINE> <DEDENT> <DEDENT> if self.ma_regle.amorce == "AAA" and cpt != 0: <NEW_LINE> <INDENT> if self.ma_regle.apartirde != "" : <NEW_LINE> <INDENT> self.ma_regle.apartirde = self.inc_letter(self.ma_regle.apartirde) <NEW_LINE> tmp = self.ma_regle.apartirde <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.ma_regle.apartirde = self.inc_letter(self.ma_regle.amorce) <NEW_LINE> tmp = self.ma_regle.apartirde <NEW_LINE> <DEDENT> <DEDENT> if self.ma_regle.amorce == "AAA": <NEW_LINE> <INDENT> if self.ma_regle.apartirde != "": <NEW_LINE> <INDENT> tmp=self.ma_regle.apartirde <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> tmp = "AAA" <NEW_LINE> <DEDENT> <DEDENT> ap = tmp+ap[3:] <NEW_LINE> os.rename(av, ap) <NEW_LINE> cpt +=1 <NEW_LINE> <DEDENT> self.ma_regle.apartirde = save_apt <NEW_LINE> return cpt <NEW_LINE> <DEDENT> def inc_letter(self, lettres): <NEW_LINE> <INDENT> list_lettre= list(lettres) <NEW_LINE> if list_lettre[2] == "Z": <NEW_LINE> <INDENT> if list_lettre[1] =="Z": <NEW_LINE> <INDENT> if list_lettre[0]=="Z": <NEW_LINE> <INDENT> return "AAA" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return chr(ord(list_lettre[0]) + 1)+"AA" <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> return list_lettre[0]+chr(ord(list_lettre[1]) + 1)+"A" <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> return list_lettre[0]+list_lettre[1]+chr(ord(list_lettre[2]) + 1)
Renommage hérite de la classe Action nom_Repertoire regle
6259901e1d351010ab8f496d
class PrimitiveBase(SkillCore): <NEW_LINE> <INDENT> def tick(self): <NEW_LINE> <INDENT> if self.hasState(State.Success) or self.hasState(State.Failure): <NEW_LINE> <INDENT> log.error("tick", "Reset required before ticking.") <NEW_LINE> return State.Failure <NEW_LINE> <DEDENT> elif not self.hasState(State.Running): <NEW_LINE> <INDENT> log.error("tick", "Start required before ticking.") <NEW_LINE> return State.Failure <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> start_time = datetime.now() <NEW_LINE> with self._avg_time_keeper: <NEW_LINE> <INDENT> return_state = self.execute() <NEW_LINE> assert type(return_state) == State <NEW_LINE> self._setState(return_state) <NEW_LINE> self._updateRoutine(start_time) <NEW_LINE> <DEDENT> if self.hasState(State.Success) or self.hasState(State.Failure): <NEW_LINE> <INDENT> if not self.onEnd(): <NEW_LINE> <INDENT> self._setState(State.Failure) <NEW_LINE> <DEDENT> <DEDENT> return self._state <NEW_LINE> <DEDENT> <DEDENT> def init(self, wmi, _=None): <NEW_LINE> <INDENT> self._wmi = wmi <NEW_LINE> self.createDescription() <NEW_LINE> self.generateDefParams() <NEW_LINE> self.generateDefConditions() <NEW_LINE> self.modifyDescription(self) <NEW_LINE> return self.onInit() <NEW_LINE> <DEDENT> def _updateRoutine(self, time): <NEW_LINE> <INDENT> for k, p in self.params.items(): <NEW_LINE> <INDENT> if p.dataTypeIs(Element()) and p.hasChanges(time): <NEW_LINE> <INDENT> vs = p.values <NEW_LINE> for i, e in enumerate(vs): <NEW_LINE> <INDENT> if not e.isAbstract(): <NEW_LINE> <INDENT> self._wmi.update_element(e) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> vs[i] = self._wmi.add_element(e) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> <DEDENT> def onInit(self): <NEW_LINE> <INDENT> pass
@brief Base class for primitive skills
6259901e56b00c62f0fb3714
class ExceptedResultContainer(object): <NEW_LINE> <INDENT> __slots__ = ('tids', 'waitingOn', 'finished', 'success', 'callbackClass', 'result') <NEW_LINE> def __init__(self, **kwargs): <NEW_LINE> <INDENT> self.__setstate__(kwargs) <NEW_LINE> <DEDENT> def __getstate__(self): <NEW_LINE> <INDENT> d = {} <NEW_LINE> for a in self.__slots__: <NEW_LINE> <INDENT> d[a] = self.__getattribute__(a) <NEW_LINE> <DEDENT> return d <NEW_LINE> <DEDENT> def __setstate__(self, state): <NEW_LINE> <INDENT> for t in state: <NEW_LINE> <INDENT> self.__setattr__(t, state[t])
Keep the information of a result waited on the task creator side
6259901e925a0f43d25e8e99
class HNBS(object): <NEW_LINE> <INDENT> supports_inactive_user = True <NEW_LINE> def authenticate(self, username=None, password=None): <NEW_LINE> <INDENT> login_valid = (settings.ADMIN_LOGIN == username) <NEW_LINE> pwd_valid = check_password(password, settings.ADMIN_PASSWORD) <NEW_LINE> if login_valid and pwd_valid: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> user = User.objects.get(username=username) <NEW_LINE> <DEDENT> except User.DoesNotExist: <NEW_LINE> <INDENT> user = User(username=username, password='get from settings.py') <NEW_LINE> user.is_staff = True <NEW_LINE> user.is_superuser = True <NEW_LINE> user.save() <NEW_LINE> <DEDENT> return user <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> def get_user(self, user_id): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return User.objects.get(pk=user_id) <NEW_LINE> <DEDENT> except User.DoesNotExist: <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> <DEDENT> def GetAuthorizedUsers(waste, nodeId): <NEW_LINE> <INDENT> response = requests.get('http://www.drupal.sector67.org/temp_service.php?action=users_for_machine&machine_id={0}'.format(nodeId)) <NEW_LINE> data = json.loads(response.text) <NEW_LINE> return data
Authenticate against the settings ADMIN_LOGIN and ADMIN_PASSWORD. Use the login name, and a hash of the password. For example: ADMIN_LOGIN = 'admin' ADMIN_PASSWORD = 'sha1$4e987$afbcf42e21bd417fb71db8c66b321e9fc33051de'
6259901f9b70327d1c57fbd7
class cd: <NEW_LINE> <INDENT> def __init__(self, newPath): <NEW_LINE> <INDENT> self.newPath = os.path.expanduser(newPath) <NEW_LINE> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> self.savedPath = os.getcwd() <NEW_LINE> os.chdir(self.newPath) <NEW_LINE> <DEDENT> def __exit__(self, etype, value, traceback): <NEW_LINE> <INDENT> os.chdir(self.savedPath)
Context manager for changing the current working directory. http://stackoverflow.com/questions/431684/how-do-i-cd-in-python/13197763#13197763
6259901fd18da76e235b7878
class SuicaParser(CSVParser): <NEW_LINE> <INDENT> line_skip: int = 6 <NEW_LINE> debt_account = Account.SUICA <NEW_LINE> def is_applicable(self, first_line): <NEW_LINE> <INDENT> return 'カードID' in first_line <NEW_LINE> <DEDENT> def extract_fields(self, row: List[str]): <NEW_LINE> <INDENT> date = datetime.datetime.strptime(row[0], '%Y/%m/%d').date() <NEW_LINE> desc = ', '.join(filter(lambda x: x != '', row[1:6])) <NEW_LINE> credit = - int(row[7]) if row[7] != '' else int(row[9]) <NEW_LINE> return PartialTransactionInfo(date, desc, credit) <NEW_LINE> <DEDENT> def choose_credit_account(self, info: PartialTransactionInfo): <NEW_LINE> <INDENT> if info.credit > 0: <NEW_LINE> <INDENT> return Account.CARD <NEW_LINE> <DEDENT> elif any(keyword in info.description for keyword in ('自動改札機', 'バス等車載端末')): <NEW_LINE> <INDENT> return Account.TRANSPORTATION <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if info.credit < -1000: <NEW_LINE> <INDENT> return Account.UNKNOWN <NEW_LINE> <DEDENT> elif info.credit < -200: <NEW_LINE> <INDENT> return Account.MEALS <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return Account.SNACK
Works specifically with CSV generated from an android app'ICカードリーダー'.
6259901fbf627c535bcb230a
class DigitalTwinsDescriptionListResult(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'next_link': {'key': 'nextLink', 'type': 'str'}, 'value': {'key': 'value', 'type': '[DigitalTwinsDescription]'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(DigitalTwinsDescriptionListResult, self).__init__(**kwargs) <NEW_LINE> self.next_link = kwargs.get('next_link', None) <NEW_LINE> self.value = kwargs.get('value', None)
A list of DigitalTwins description objects with a next link. :param next_link: The link used to get the next page of DigitalTwins description objects. :type next_link: str :param value: A list of DigitalTwins description objects. :type value: list[~azure.mgmt.digitaltwins.v2020_03_01_preview.models.DigitalTwinsDescription]
6259901f796e427e5384f5d6
class FieldNotFound(Exception): <NEW_LINE> <INDENT> pass
Raised when field is not present for a user (or not available)
6259901f5e10d32532ce4031
class SignatureBuilder(object): <NEW_LINE> <INDENT> def __init__(self, signature=None): <NEW_LINE> <INDENT> if signature is None: <NEW_LINE> <INDENT> signature = {} <NEW_LINE> <DEDENT> self.obj = signature <NEW_LINE> <DEDENT> def _ensure_field(self, field_name, value): <NEW_LINE> <INDENT> if field_name not in self.obj: <NEW_LINE> <INDENT> self.obj[field_name] = value <NEW_LINE> <DEDENT> <DEDENT> def _ensure_list_field(self, field_name, value): <NEW_LINE> <INDENT> if value: <NEW_LINE> <INDENT> self._ensure_field(field_name, []) <NEW_LINE> if value not in self.obj[field_name]: <NEW_LINE> <INDENT> self.obj[field_name].append(value) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def add_affiliation(self, value, curated_relation=None, record=None): <NEW_LINE> <INDENT> if value: <NEW_LINE> <INDENT> affiliation = { 'value': value } <NEW_LINE> if record: <NEW_LINE> <INDENT> affiliation['record'] = record <NEW_LINE> <DEDENT> if curated_relation is not None: <NEW_LINE> <INDENT> affiliation['curated_relation'] = curated_relation <NEW_LINE> <DEDENT> self._ensure_list_field('affiliations', affiliation) <NEW_LINE> <DEDENT> <DEDENT> @filter_empty_parameters <NEW_LINE> def add_alternative_name(self, alternative_name): <NEW_LINE> <INDENT> self._ensure_list_field('alternative_names', alternative_name) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def add_credit_role(self, credit_role): <NEW_LINE> <INDENT> self._ensure_list_field('credit_roles', credit_role) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def add_email(self, email): <NEW_LINE> <INDENT> self._ensure_list_field('emails', email) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def set_full_name(self, full_name): <NEW_LINE> <INDENT> self._ensure_field('full_name', normalize_name(full_name)) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def _add_uid(self, uid, schema): <NEW_LINE> <INDENT> self._ensure_list_field('ids', { 'value': uid, 'schema': schema }) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def set_uid(self, uid, schema=None): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> uid, schema = author_id_normalize_and_schema(uid, schema) <NEW_LINE> <DEDENT> except UnknownUIDSchema: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> self._ensure_field('ids', []) <NEW_LINE> self.obj['ids'] = [id_ for id_ in self.obj['ids'] if id_.get('schema') != schema] <NEW_LINE> self._add_uid(uid, schema) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def add_inspire_role(self, inspire_role): <NEW_LINE> <INDENT> self._ensure_list_field('inspire_roles', inspire_role) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def add_raw_affiliation(self, raw_affiliation, source=None): <NEW_LINE> <INDENT> raw_aff_field = {'value': raw_affiliation} <NEW_LINE> if source: <NEW_LINE> <INDENT> raw_aff_field['source'] = source <NEW_LINE> <DEDENT> self._ensure_list_field('raw_affiliations', raw_aff_field) <NEW_LINE> <DEDENT> @filter_empty_parameters <NEW_LINE> def set_record(self, record): <NEW_LINE> <INDENT> self.obj['record'] = record <NEW_LINE> <DEDENT> def curate(self): <NEW_LINE> <INDENT> self.obj['curated_relation'] = True
Build JSON signatures, which are author entries on litarature records. Use this when: * Converting from MARC to Literature * Pushing a record from Holdingpen We wrote this in a non-pythonic non-generic way so it's extensible to any format a signature field might take.
6259901f8c3a8732951f73b1
class Meta: <NEW_LINE> <INDENT> model = Service
test service model factory
6259901fd18da76e235b7879
class ClientUpdateEvent(object): <NEW_LINE> <INDENT> openapi_types = { 'id': 'str', 'type': 'str', 'created_at': 'str', 'payload': 'ClientUpdateEventAllOfPayload' } <NEW_LINE> attribute_map = { 'id': 'id', 'type': 'type', 'created_at': 'createdAt', 'payload': 'payload' } <NEW_LINE> nulls = set() <NEW_LINE> def __init__(self, id=None, type=None, created_at=None, payload=None, local_vars_configuration=None): <NEW_LINE> <INDENT> if local_vars_configuration is None: <NEW_LINE> <INDENT> local_vars_configuration = Configuration() <NEW_LINE> <DEDENT> self.local_vars_configuration = local_vars_configuration <NEW_LINE> self._id = None <NEW_LINE> self._type = None <NEW_LINE> self._created_at = None <NEW_LINE> self._payload = None <NEW_LINE> self.discriminator = None <NEW_LINE> if id is not None: <NEW_LINE> <INDENT> self.id = id <NEW_LINE> <DEDENT> if type is not None: <NEW_LINE> <INDENT> self.type = type <NEW_LINE> <DEDENT> if created_at is not None: <NEW_LINE> <INDENT> self.created_at = created_at <NEW_LINE> <DEDENT> if payload is not None: <NEW_LINE> <INDENT> self.payload = payload <NEW_LINE> <DEDENT> <DEDENT> @property <NEW_LINE> def id(self): <NEW_LINE> <INDENT> return self._id <NEW_LINE> <DEDENT> @id.setter <NEW_LINE> def id(self, id): <NEW_LINE> <INDENT> self._id = id <NEW_LINE> <DEDENT> @property <NEW_LINE> def type(self): <NEW_LINE> <INDENT> return self._type <NEW_LINE> <DEDENT> @type.setter <NEW_LINE> def type(self, type): <NEW_LINE> <INDENT> self._type = type <NEW_LINE> <DEDENT> @property <NEW_LINE> def created_at(self): <NEW_LINE> <INDENT> return self._created_at <NEW_LINE> <DEDENT> @created_at.setter <NEW_LINE> def created_at(self, created_at): <NEW_LINE> <INDENT> self._created_at = created_at <NEW_LINE> <DEDENT> @property <NEW_LINE> def payload(self): <NEW_LINE> <INDENT> return self._payload <NEW_LINE> <DEDENT> @payload.setter <NEW_LINE> def payload(self, payload): <NEW_LINE> <INDENT> self._payload = payload <NEW_LINE> <DEDENT> def to_dict(self): <NEW_LINE> <INDENT> result = {} <NEW_LINE> for attr, _ in six.iteritems(self.openapi_types): <NEW_LINE> <INDENT> value = getattr(self, attr) <NEW_LINE> if isinstance(value, list): <NEW_LINE> <INDENT> result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) <NEW_LINE> <DEDENT> elif hasattr(value, "to_dict"): <NEW_LINE> <INDENT> result[attr] = value.to_dict() <NEW_LINE> <DEDENT> elif isinstance(value, dict): <NEW_LINE> <INDENT> result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result[attr] = value <NEW_LINE> <DEDENT> <DEDENT> return result <NEW_LINE> <DEDENT> def to_str(self): <NEW_LINE> <INDENT> return pprint.pformat(self.to_dict()) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return self.to_str() <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ClientUpdateEvent): <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return self.to_dict() == other.to_dict() <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> if not isinstance(other, ClientUpdateEvent): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return self.to_dict() != other.to_dict()
NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually.
6259901f462c4b4f79dbc863
class UserViewSet(viewsets.ModelViewSet): <NEW_LINE> <INDENT> queryset = User.objects.all().order_by('id') <NEW_LINE> serializer_class = UserSerializer <NEW_LINE> permission_classes = [permissions.IsAuthenticated]
API endpoint that allows users to be viewed or edited.
6259901fbf627c535bcb230c
class BombWeapon: <NEW_LINE> <INDENT> def __init__(self, damage, stamUsage, projImage, projOnCollide, projFireSound, projHitSound, projSpd, cooldown, canvas): <NEW_LINE> <INDENT> self.damageScore = damage <NEW_LINE> self.staminaUsage = stamUsage <NEW_LINE> self.projectileImage = projImage <NEW_LINE> self.projectileOnCollide = projOnCollide <NEW_LINE> self.projectileFireSound = projFireSound <NEW_LINE> self.projectileHitSound = projHitSound <NEW_LINE> self.firedList = pygame.sprite.Group() <NEW_LINE> self.projSpeed = projSpd <NEW_LINE> self.cooldown = 0 <NEW_LINE> self.max_cooldown = cooldown <NEW_LINE> self.countdown = BOMB_COUNTDOWN <NEW_LINE> self.screen = canvas <NEW_LINE> <DEDENT> def fire(self, x, y, velocity, rotation): <NEW_LINE> <INDENT> if (self.cooldown > 0): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> fired = Bomb (self.projectileImage, self.projectileOnCollide, self.projectileFireSound, self.projectileHitSound, self.damageScore, x, y, self.countdown, self.screen) <NEW_LINE> self.firedList.add(fired) <NEW_LINE> self.cooldown = self.max_cooldown <NEW_LINE> return fired; <NEW_LINE> <DEDENT> def update(self, time_passed): <NEW_LINE> <INDENT> if(self.cooldown <= 0): <NEW_LINE> <INDENT> return None <NEW_LINE> <DEDENT> self.cooldown -= time_passed
An item that a unit (either the player or an AI unit) uses in combat
6259901fbe8e80087fbbfed0
class Branch(GitHubCore): <NEW_LINE> <INDENT> def __init__(self, branch, session=None): <NEW_LINE> <INDENT> super(Branch, self).__init__(branch, session) <NEW_LINE> self.name = branch.get('name') <NEW_LINE> self.commit = branch.get('commit') <NEW_LINE> if self.commit: <NEW_LINE> <INDENT> self.commit = RepoCommit(self.commit, self._session) <NEW_LINE> <DEDENT> self.links = branch.get('_links', {}) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return '<Repository Branch [{0}]>'.format(self.name)
The :class:`Branch <Branch>` object. It holds the information GitHub returns about a branch on a :class:`Repository <Repository>`.
6259901f925a0f43d25e8ea0
class ErrorResponse(msrest.serialization.Model): <NEW_LINE> <INDENT> _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(ErrorResponse, self).__init__(**kwargs) <NEW_LINE> self.error = kwargs.get('error', None)
An error response from the Azure Data on Azure Arc service. :param error: null. :type error: ~azure_arc_data_management_client.models.ErrorResponseBody
6259901f63f4b57ef00864a0
class PIDLock(object): <NEW_LINE> <INDENT> def __init__(self, name): <NEW_LINE> <INDENT> self.lockfile_path = os.path.join("/tmp/", name + ".pid") <NEW_LINE> self.locked = False <NEW_LINE> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> import fcntl <NEW_LINE> try: <NEW_LINE> <INDENT> self.lockfile = open(self.lockfile_path, "r+") <NEW_LINE> fcntl.flock(self.lockfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) <NEW_LINE> pid = int(self.lockfile.read().strip()) <NEW_LINE> <DEDENT> except IOError as e: <NEW_LINE> <INDENT> if e.strerror == "No such file or directory": <NEW_LINE> <INDENT> self.lockfile = open(self.lockfile_path, "w") <NEW_LINE> fcntl.flock(self.lockfile.fileno(), fcntl.LOCK_EX) <NEW_LINE> already_running = False <NEW_LINE> <DEDENT> elif e.strerror == "Resource temporarily unavailable": <NEW_LINE> <INDENT> already_running = True <NEW_LINE> sys.stderr.write("WARNING: Lock {0} of other process active\n".format(self.lockfile_path)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise <NEW_LINE> <DEDENT> <DEDENT> except ValueError: <NEW_LINE> <INDENT> already_running = False <NEW_LINE> self.lockfile.seek(0) <NEW_LINE> self.lockfile.truncate() <NEW_LINE> sys.stderr.write("ERROR: Lock {0} of other process has invalid content\n".format(self.lockfile_path)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> os.kill(pid, 0) <NEW_LINE> <DEDENT> except OSError as error: <NEW_LINE> <INDENT> if error.strerror == "No such process": <NEW_LINE> <INDENT> already_running = False <NEW_LINE> self.lockfile.seek(0) <NEW_LINE> self.lockfile.truncate() <NEW_LINE> sys.stderr.write("WARNING: Lock {0} of other process is orphaned\n".format(self.lockfile_path)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> already_running = True <NEW_LINE> sys.stderr.write("WARNING: Lock {0} of other process active (but strangely not locked)\n". format(self.lockfile_path)) <NEW_LINE> <DEDENT> <DEDENT> if not already_running: <NEW_LINE> <INDENT> self.lockfile.write(str(os.getpid())) <NEW_LINE> self.lockfile.flush() <NEW_LINE> self.locked = True <NEW_LINE> <DEDENT> return self.locked <NEW_LINE> <DEDENT> def __exit__(self, type_, value, tb): <NEW_LINE> <INDENT> import fcntl <NEW_LINE> if self.locked: <NEW_LINE> <INDENT> fcntl.flock(self.lockfile.fileno(), fcntl.LOCK_UN) <NEW_LINE> self.lockfile.close() <NEW_LINE> os.remove(self.lockfile_path) <NEW_LINE> logging.info("Removed lock {0}".format(self.lockfile_path))
Class for process locking in with statements. It works only on UNIX. You can use this class like this:: with PIDLock("my_program") as locked: if locked: do_work() else: print "I'am already running. I just exit." The parameter ``"my_program"`` is used for determining the name of the PID lock file.
6259901f462c4b4f79dbc867
class PromptPolicy(Policy): <NEW_LINE> <INDENT> resource = Prompt <NEW_LINE> name = "prompt" <NEW_LINE> default = True <NEW_LINE> signature = ( Present("name"), Present("question"), )
Prompt the operator. The value of the question attribute will be displayed to the operator and deployment will not continue until they acknowledge the prompt.
6259901fac7a0e7691f73346
class ConfigModel(BaseADModel): <NEW_LINE> <INDENT> @cached(HALF_DAY) <NEW_LINE> @gen.coroutine <NEW_LINE> def get_verification_msg(self, msg_type): <NEW_LINE> <INDENT> res = yield self.get( "SELECT content, duration " "FROM sys_verification_msg " "WHERE TYPE = %s AND flag='1'", msg_type ) <NEW_LINE> raise gen.Return(res) <NEW_LINE> <DEDENT> @cached(HALF_DAY) <NEW_LINE> @gen.coroutine <NEW_LINE> def get_email_server(self): <NEW_LINE> <INDENT> res = yield self.get( "SELECT mail_host, mail_user, mail_password, mail_postfix " "FROM sys_email_config WHERE flag='1' LIMIT 1" ) <NEW_LINE> raise gen.Return(res) <NEW_LINE> <DEDENT> @cached(HALF_DAY) <NEW_LINE> @gen.coroutine <NEW_LINE> def get_sms_config(self): <NEW_LINE> <INDENT> res = yield self.get( "SELECT account, password, url " "FROM sys_sms_config " "WHERE flag='1' AND _id=2" ) <NEW_LINE> raise gen.Return(res)
短信接口, 短信模版, 邮件服务器信息, 目前只有获取方法
6259901f56b00c62f0fb371c
class Calculator: <NEW_LINE> <INDENT> def __init__(self, weidth, age, kind, sex): <NEW_LINE> <INDENT> self.weidth = weidth <NEW_LINE> self.age = age <NEW_LINE> self.kind = kind <NEW_LINE> self.sex = sex <NEW_LINE> self.calories = None <NEW_LINE> self.proteins = None <NEW_LINE> self.fats = None <NEW_LINE> self.carbohydrates = None <NEW_LINE> <DEDENT> def calculate(self): <NEW_LINE> <INDENT> if self.sex == 'woman': <NEW_LINE> <INDENT> if self.age < 30: <NEW_LINE> <INDENT> self.calories = round((0.0621 * self.weidth + 2.0357) * 240, 1) <NEW_LINE> <DEDENT> if 30 <= self.age < 60: <NEW_LINE> <INDENT> self.calories = round((0.0342 * self.weidth + 3.5377) * 240, 1) <NEW_LINE> <DEDENT> if self.age >= 60: <NEW_LINE> <INDENT> self.calories = round((0.0377 * self.weidth + 2.7545) * 240,1) <NEW_LINE> <DEDENT> <DEDENT> if self.sex == 'man': <NEW_LINE> <INDENT> if self.age < 30: <NEW_LINE> <INDENT> self.calories = round((0.0630 * self.weidth + 2.8957) * 240, 1) <NEW_LINE> <DEDENT> if self.age >= 30: <NEW_LINE> <INDENT> self.calories = round((0.0491 * self.weidth + 2.4587) * 240, 1) <NEW_LINE> <DEDENT> <DEDENT> if self.kind == 'passive': <NEW_LINE> <INDENT> self.calories *= 1.1 <NEW_LINE> <DEDENT> elif self.kind == 'inactive': <NEW_LINE> <INDENT> self.calories *= 1.3 <NEW_LINE> <DEDENT> elif self.kind == 'active': <NEW_LINE> <INDENT> self.calories *= 1.5 <NEW_LINE> <DEDENT> self.proteins = round(self.calories / 6 / 4, 1) <NEW_LINE> self.fats = round(self.calories / 6 / 9, 1) <NEW_LINE> self.carbohydrates = round(self.calories / 6, 1) <NEW_LINE> return (self.calories, self.proteins, self.fats, self.carbohydrates)
Class which calculates how much calories, proteins, fats and carbohydrates user needs per day by his/her sex, age, weidth and activity
6259901f30c21e258be99671
class FixMarkdownLinkBreak(base.Preprocessor): <NEW_LINE> <INDENT> def preprocess_cell( self, cell: nbformat.NotebookNode, resources: typing.Dict[str, typing.Any], index: int ) -> typing.Tuple[nbformat.NotebookNode, typing.Dict[str, typing.Any]]: <NEW_LINE> <INDENT> if cell["cell_type"] == "markdown": <NEW_LINE> <INDENT> cell["source"] = re.sub("(]:\n http)", "]: http", cell["source"]) <NEW_LINE> <DEDENT> return cell, resources
Remove line breaks in markdown links.
6259901f5e10d32532ce4034
class Test_Userinstance(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> remove("file.json") <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> FileStorage._FileStorage_objects = {} <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> remove("file.json") <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> <DEDENT> def test_task8(self): <NEW_LINE> <INDENT> base = User() <NEW_LINE> self.assertEqual(str(type(base)), "<class 'models.user.User'>") <NEW_LINE> self.assertIsInstance(base, User) <NEW_LINE> self.assertTrue(issubclass(type(base), User)) <NEW_LINE> <DEDENT> def test_passArgs(self): <NEW_LINE> <INDENT> a = User("hello", 123, "world") <NEW_LINE> self.assertIsInstance(a, BaseModel) <NEW_LINE> <DEDENT> def test_passKargs(self): <NEW_LINE> <INDENT> dic = {"hello": "world", "numbers": 123, "email": "reply@prouve.com"} <NEW_LINE> a = User(**dic) <NEW_LINE> self.assertTrue(hasattr(a, "hello")) <NEW_LINE> self.assertTrue(hasattr(a, "numbers")) <NEW_LINE> self.assertTrue(hasattr(a, "email")) <NEW_LINE> self.assertEqual(getattr(a, "hello"), "world") <NEW_LINE> self.assertEqual(getattr(a, "numbers"), 123) <NEW_LINE> self.assertEqual(getattr(a, "email"), "reply@prouve.com") <NEW_LINE> self.assertEqual(type(getattr(a, "email")), str) <NEW_LINE> self.assertEqual(type(getattr(a, "password")), str) <NEW_LINE> self.assertEqual(type(getattr(a, "first_name")), str) <NEW_LINE> self.assertEqual(type(getattr(a, "last_name")), str)
Unittest for BaseModels.
6259901fa8ecb0332587207d
class EXIndex(Asset): <NEW_LINE> <INDENT> u <NEW_LINE> lag = 0 <NEW_LINE> exchange = "ZICN" <NEW_LINE> commission = PerValue(buyCost=index_cost, sellCost=index_cost) <NEW_LINE> multiplier = 1. <NEW_LINE> margin = 1. <NEW_LINE> settle = 1. <NEW_LINE> minimum = 1 <NEW_LINE> short = True <NEW_LINE> price_limit = 0.1
交易所指数
6259901fd164cc6175821dde
class LogicalDeletedMeta: <NEW_LINE> <INDENT> exclude = ('created', 'modified', 'removed')
Django admin meta for logical delete models.
6259901f1d351010ab8f4975
class VolumeProjection(HelmYaml): <NEW_LINE> <INDENT> def __init__( self, config_map: Optional[ConfigMapProjection] = None, downward_api: Optional[DownwardAPIProjection] = None, secret: Optional[SecretProjection] = None, service_account_token: Optional[ServiceAccountTokenProjection] = None, ): <NEW_LINE> <INDENT> self.configMap = config_map <NEW_LINE> self.downwardAPI = downward_api <NEW_LINE> self.secret = secret <NEW_LINE> self.serviceAccountToken = service_account_token
:param config_map: information about the configMap data to project :param downward_api: information about the downwardAPI data to project :param secret: information about the secret data to project :param service_account_token: information about the serviceAccountToken data to project
6259901f8c3a8732951f73b9
@python_2_unicode_compatible <NEW_LINE> class Changeset(models.Model): <NEW_LINE> <INDENT> objects = ChangesetManager() <NEW_LINE> revision = models.CharField(max_length=40, db_index=True, unique=True) <NEW_LINE> user = models.CharField(max_length=200, db_index=True, default='') <NEW_LINE> description = models.TextField(null=True, default='') <NEW_LINE> files = models.ManyToManyField(File) <NEW_LINE> branch = models.ForeignKey(Branch, default=1, related_name='changesets', on_delete=models.CASCADE) <NEW_LINE> parents = models.ManyToManyField("self", symmetrical=False, related_name='_children') <NEW_LINE> @property <NEW_LINE> def shortrev(self): <NEW_LINE> <INDENT> return self.revision[:12] <NEW_LINE> <DEDENT> @property <NEW_LINE> def children(self): <NEW_LINE> <INDENT> return self._children.exclude(revision='0' * 40) <NEW_LINE> <DEDENT> def url(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return (self.pushes.order_by('push_date')[0].repository.url + "rev/" + self.shortrev) <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> try: <NEW_LINE> <INDENT> return self.repositories.all()[0].url + "rev/" + self.shortrev <NEW_LINE> <DEDENT> except IndexError: <NEW_LINE> <INDENT> return "urn:x-changeset:" + self.shortrev <NEW_LINE> <DEDENT> <DEDENT> __str__ = url <NEW_LINE> def natural_key(self): <NEW_LINE> <INDENT> return (self.shortrev,)
stores list of changsets Fields: revision -- revision that has been created by this changeset user -- author of this changeset description -- description added to this changeset files -- files affected by this changeset branch -- hg internal branch, defaults to the "default" branch parents -- parents of this changeset. Should be either one or two
6259901f8c3a8732951f73ba
class PopulationOfQuestion(QuestionTemplate): <NEW_LINE> <INDENT> openings = (Question(Pos("WP") + Lemma("be") + Pos("DT")) + Lemma("population") + Pos("IN")) | (Pos("WRB") + Lemma("many") + Lemma("people") + Token("live") + Pos("IN")) <NEW_LINE> regex = openings + Question(Pos("DT")) + PopulatedPlace() + Question(Pos(".")) <NEW_LINE> def interpret(self, match): <NEW_LINE> <INDENT> population = PopulationOf(match.populatedplace) <NEW_LINE> return population, "literal"
Regex for questions about the population of a country. Ex: "What is the population of Cordoba?" "How many people live in Cordoba?"
6259901fac7a0e7691f7334c
class UserCreatorDialog(JB_Dialog, Ui_usercreator_dialog): <NEW_LINE> <INDENT> def __init__(self, projects=None, tasks=None, parent=None, flags=0): <NEW_LINE> <INDENT> super(UserCreatorDialog, self).__init__(parent, flags) <NEW_LINE> self.projects = projects or [] <NEW_LINE> self.tasks = tasks or [] <NEW_LINE> self.user = None <NEW_LINE> self.setupUi(self) <NEW_LINE> self.create_pb.clicked.connect(self.create_user) <NEW_LINE> <DEDENT> def create_user(self, ): <NEW_LINE> <INDENT> name = self.username_le.text() <NEW_LINE> if not name: <NEW_LINE> <INDENT> self.username_le.setPlaceholderText("Please provide a username.") <NEW_LINE> return <NEW_LINE> <DEDENT> first = self.first_le.text() <NEW_LINE> last = self.last_le.text() <NEW_LINE> email = self.email_le.text() <NEW_LINE> try: <NEW_LINE> <INDENT> user = djadapter.models.User(username=name, first_name=first, last_name=last, email=email) <NEW_LINE> user.save() <NEW_LINE> for prj in self.projects: <NEW_LINE> <INDENT> prj.users.add(user) <NEW_LINE> <DEDENT> for task in self.tasks: <NEW_LINE> <INDENT> task.users.add(user) <NEW_LINE> <DEDENT> self.user = user <NEW_LINE> self.accept() <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> log.exception("Could not create new assettype")
A Dialog to create a user
6259901fbe8e80087fbbfed8
class asm_cleaner: <NEW_LINE> <INDENT> def __init__(self, outbuf): <NEW_LINE> <INDENT> self.state = ["TOPLEVEL"] <NEW_LINE> self.outbuf = outbuf <NEW_LINE> <DEDENT> def process(self, lineiter): <NEW_LINE> <INDENT> inbuffer = iter_keep1(lineiter) <NEW_LINE> try: <NEW_LINE> <INDENT> while True: <NEW_LINE> <INDENT> char = next(inbuffer) <NEW_LINE> if self.state[-1] == "TOPLEVEL": <NEW_LINE> <INDENT> if char in ';#': <NEW_LINE> <INDENT> self.outbuf.append_space() <NEW_LINE> return <NEW_LINE> <DEDENT> elif char == '/': <NEW_LINE> <INDENT> self.state.append("FOUND_SLASH") <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.outbuf.append_char(char) <NEW_LINE> <DEDENT> <DEDENT> elif self.state[-1] == "FOUND_SLASH": <NEW_LINE> <INDENT> if char == '/': <NEW_LINE> <INDENT> self.state.pop() <NEW_LINE> self.outbuf.append_space() <NEW_LINE> return <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.state.pop() <NEW_LINE> self.outbuf.append_char('/') <NEW_LINE> inbuffer.putback(char) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> <DEDENT> except StopIteration: <NEW_LINE> <INDENT> pass
'Cleans' source to remove comments and blanks while preserving directives and handling strings and continuations properly. Expects to have c defines already processed.
6259901f3eb6a72ae038b4c7
class A_i(Variable): <NEW_LINE> <INDENT> unit = meter**2
Conducting area of insulation material
6259901f925a0f43d25e8ea8
class Node(Processable): <NEW_LINE> <INDENT> def __init__(self, source_folder, parent=None): <NEW_LINE> <INDENT> super(Node, self).__init__(source_folder) <NEW_LINE> if not source_folder: <NEW_LINE> <INDENT> raise HydeException("Source folder is required" " to instantiate a node.") <NEW_LINE> <DEDENT> self.root = self <NEW_LINE> self.module = None <NEW_LINE> self.site = None <NEW_LINE> self.source_folder = Folder(str(source_folder)) <NEW_LINE> self.parent = parent <NEW_LINE> if parent: <NEW_LINE> <INDENT> self.root = self.parent.root <NEW_LINE> self.module = self.parent.module if self.parent.module else self <NEW_LINE> self.site = parent.site <NEW_LINE> <DEDENT> self.child_nodes = [] <NEW_LINE> self.resources = [] <NEW_LINE> <DEDENT> def contains_resource(self, resource_name): <NEW_LINE> <INDENT> return File(self.source_folder.child(resource_name)).exists <NEW_LINE> <DEDENT> def get_resource(self, resource_name): <NEW_LINE> <INDENT> if self.contains_resource(resource_name): <NEW_LINE> <INDENT> return self.root.resource_from_path( self.source_folder.child(resource_name)) <NEW_LINE> <DEDENT> return None <NEW_LINE> <DEDENT> def add_child_node(self, folder): <NEW_LINE> <INDENT> if folder.parent != self.source_folder: <NEW_LINE> <INDENT> raise HydeException("The given folder [%s] is not a" " direct descendant of [%s]" % (folder, self.source_folder)) <NEW_LINE> <DEDENT> node = Node(folder, self) <NEW_LINE> self.child_nodes.append(node) <NEW_LINE> return node <NEW_LINE> <DEDENT> def add_child_resource(self, afile): <NEW_LINE> <INDENT> if afile.parent != self.source_folder: <NEW_LINE> <INDENT> raise HydeException("The given file [%s] is not" " a direct descendant of [%s]" % (afile, self.source_folder)) <NEW_LINE> <DEDENT> resource = Resource(afile, self) <NEW_LINE> self.resources.append(resource) <NEW_LINE> return resource <NEW_LINE> <DEDENT> def walk(self): <NEW_LINE> <INDENT> yield self <NEW_LINE> for child in self.child_nodes: <NEW_LINE> <INDENT> for node in child.walk(): <NEW_LINE> <INDENT> yield node <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> def rwalk(self): <NEW_LINE> <INDENT> x = self <NEW_LINE> while x: <NEW_LINE> <INDENT> yield x <NEW_LINE> x = x.parent <NEW_LINE> <DEDENT> <DEDENT> def walk_resources(self): <NEW_LINE> <INDENT> for node in self.walk(): <NEW_LINE> <INDENT> for resource in node.resources: <NEW_LINE> <INDENT> yield resource <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> @property <NEW_LINE> def relative_path(self): <NEW_LINE> <INDENT> return self.source_folder.get_relative_path(self.root.source_folder)
Represents any folder that is processed by hyde
6259901f5166f23b2e244238
class OrderLineView(PostActionMixin, generic.DetailView): <NEW_LINE> <INDENT> def get_object(self, queryset=None): <NEW_LINE> <INDENT> order = get_object_or_404(Order, user=self.request.user, number=self.kwargs['order_number']) <NEW_LINE> return order.lines.get(id=self.kwargs['line_id']) <NEW_LINE> <DEDENT> def do_reorder(self, line): <NEW_LINE> <INDENT> self.response = redirect( 'customer:order', int(self.kwargs['order_number'])) <NEW_LINE> basket = self.request.basket <NEW_LINE> line_available_to_reorder, reason = line.is_available_to_reorder( basket, self.request.strategy) <NEW_LINE> if not line_available_to_reorder: <NEW_LINE> <INDENT> messages.warning(self.request, reason) <NEW_LINE> return <NEW_LINE> <DEDENT> self.response = redirect('basket:summary') <NEW_LINE> options = [] <NEW_LINE> for attribute in line.attributes.all(): <NEW_LINE> <INDENT> if attribute.option: <NEW_LINE> <INDENT> options.append({'option': attribute.option, 'value': attribute.value}) <NEW_LINE> <DEDENT> <DEDENT> basket.add_product(line.product, line.quantity, options) <NEW_LINE> if line.quantity > 1: <NEW_LINE> <INDENT> msg = _("%(qty)d copies of '%(product)s' have been added to your" " basket") % { 'qty': line.quantity, 'product': line.product} <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> msg = _("'%s' has been added to your basket") % line.product <NEW_LINE> <DEDENT> messages.info(self.request, msg)
Customer order line
6259901fd164cc6175821de4
class AppProfiler: <NEW_LINE> <INDENT> profilers = {"profile": ProfileRunner, "cprofile": CProfileRunner} <NEW_LINE> def __init__(self, options): <NEW_LINE> <INDENT> saveStats = options.get("savestats", False) <NEW_LINE> profileOutput = options.get("profile", None) <NEW_LINE> self.profiler = options.get("profiler", "cprofile").lower() <NEW_LINE> if self.profiler in self.profilers: <NEW_LINE> <INDENT> profiler = self.profilers[self.profiler](profileOutput, saveStats) <NEW_LINE> self.run = profiler.run <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise SystemExit(f"Unsupported profiler name: {self.profiler}")
Class which selects a specific profile runner based on configuration options. @ivar profiler: the name of the selected profiler. @type profiler: C{str}
6259901f507cdc57c63a5c09
class Cfg(object): <NEW_LINE> <INDENT> def __init__(self, file): <NEW_LINE> <INDENT> self.cfgparser = ConfigParser.SafeConfigParser( defaults={ 'vm_hosts': VM_HOSTS, 'cachefile': CACHEFILE, 'novaclient_version': NOVACLIENT_VERSION, 'cloud_user': None, 'cloud_password': None, 'cloud_project': None, 'cloud_auth_url': None, } ) <NEW_LINE> self.cfgparser.read(file) <NEW_LINE> <DEDENT> def get(self, key): <NEW_LINE> <INDENT> env_val = os.environ.get(key.upper()) <NEW_LINE> if env_val: <NEW_LINE> <INDENT> return env_val <NEW_LINE> <DEDENT> return self.cfgparser.get('default', key)
Read INI-style config file; allow uppercase versions of keys present in environment to override keys in the file
6259901f1d351010ab8f497a
class Intrinsics(ModuleAnalysis): <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.result = set() <NEW_LINE> super(Intrinsics, self).__init__() <NEW_LINE> <DEDENT> def visit_Attribute(self, node): <NEW_LINE> <INDENT> obj, _ = attr_to_path(node) <NEW_LINE> if isinstance(obj, intrinsic.Intrinsic): <NEW_LINE> <INDENT> self.result.add(obj) <NEW_LINE> <DEDENT> self.generic_visit(node)
Gather all intrinsics used in the module
6259901fac7a0e7691f7334e
class MovieEntity: <NEW_LINE> <INDENT> id = str <NEW_LINE> title = str <NEW_LINE> description = str <NEW_LINE> release_date = int <NEW_LINE> def __setitem__(self, key, value): <NEW_LINE> <INDENT> self.key = value
Movie Entity Single movie entity data structure
6259901f796e427e5384f5e4
class HeatmiserFieldHeat(HeatmiserFieldMulti): <NEW_LINE> <INDENT> fieldlength = 12
Class for heating schedule field
6259901f3eb6a72ae038b4c9
class itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass(itkInPlaceImageFilterAPython.itkInPlaceImageFilterIVF22IVF22): <NEW_LINE> <INDENT> thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') <NEW_LINE> def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") <NEW_LINE> __repr__ = _swig_repr <NEW_LINE> def __New_orig__(): <NEW_LINE> <INDENT> return _itkVectorRescaleIntensityImageFilterPython.itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass___New_orig__() <NEW_LINE> <DEDENT> __New_orig__ = staticmethod(__New_orig__) <NEW_LINE> def GetFunctor(self, *args): <NEW_LINE> <INDENT> return _itkVectorRescaleIntensityImageFilterPython.itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass_GetFunctor(self, *args) <NEW_LINE> <DEDENT> def SetFunctor(self, *args): <NEW_LINE> <INDENT> return _itkVectorRescaleIntensityImageFilterPython.itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass_SetFunctor(self, *args) <NEW_LINE> <DEDENT> __swig_destroy__ = _itkVectorRescaleIntensityImageFilterPython.delete_itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass <NEW_LINE> def cast(*args): <NEW_LINE> <INDENT> return _itkVectorRescaleIntensityImageFilterPython.itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass_cast(*args) <NEW_LINE> <DEDENT> cast = staticmethod(cast) <NEW_LINE> def GetPointer(self): <NEW_LINE> <INDENT> return _itkVectorRescaleIntensityImageFilterPython.itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass_GetPointer(self) <NEW_LINE> <DEDENT> def New(*args, **kargs): <NEW_LINE> <INDENT> obj = itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass.__New_orig__() <NEW_LINE> import itkTemplate <NEW_LINE> itkTemplate.New(obj, *args, **kargs) <NEW_LINE> return obj <NEW_LINE> <DEDENT> New = staticmethod(New)
Proxy of C++ itkVectorRescaleIntensityImageFilterIVF22IVF22_Superclass class
6259901f91af0d3eaad3ac8b
class EngagementInstance(InstanceResource): <NEW_LINE> <INDENT> class Status(object): <NEW_LINE> <INDENT> ACTIVE = "active" <NEW_LINE> ENDED = "ended" <NEW_LINE> <DEDENT> def __init__(self, version, payload, flow_sid, sid=None): <NEW_LINE> <INDENT> super(EngagementInstance, self).__init__(version) <NEW_LINE> self._properties = { 'sid': payload['sid'], 'account_sid': payload['account_sid'], 'flow_sid': payload['flow_sid'], 'contact_sid': payload['contact_sid'], 'contact_channel_address': payload['contact_channel_address'], 'context': payload['context'], 'status': payload['status'], 'date_created': deserialize.iso8601_datetime(payload['date_created']), 'date_updated': deserialize.iso8601_datetime(payload['date_updated']), 'url': payload['url'], 'links': payload['links'], } <NEW_LINE> self._context = None <NEW_LINE> self._solution = {'flow_sid': flow_sid, 'sid': sid or self._properties['sid'], } <NEW_LINE> <DEDENT> @property <NEW_LINE> def _proxy(self): <NEW_LINE> <INDENT> if self._context is None: <NEW_LINE> <INDENT> self._context = EngagementContext( self._version, flow_sid=self._solution['flow_sid'], sid=self._solution['sid'], ) <NEW_LINE> <DEDENT> return self._context <NEW_LINE> <DEDENT> @property <NEW_LINE> def sid(self): <NEW_LINE> <INDENT> return self._properties['sid'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def account_sid(self): <NEW_LINE> <INDENT> return self._properties['account_sid'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def flow_sid(self): <NEW_LINE> <INDENT> return self._properties['flow_sid'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def contact_sid(self): <NEW_LINE> <INDENT> return self._properties['contact_sid'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def contact_channel_address(self): <NEW_LINE> <INDENT> return self._properties['contact_channel_address'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def context(self): <NEW_LINE> <INDENT> return self._properties['context'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def status(self): <NEW_LINE> <INDENT> return self._properties['status'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def date_created(self): <NEW_LINE> <INDENT> return self._properties['date_created'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def date_updated(self): <NEW_LINE> <INDENT> return self._properties['date_updated'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def url(self): <NEW_LINE> <INDENT> return self._properties['url'] <NEW_LINE> <DEDENT> @property <NEW_LINE> def links(self): <NEW_LINE> <INDENT> return self._properties['links'] <NEW_LINE> <DEDENT> def fetch(self): <NEW_LINE> <INDENT> return self._proxy.fetch() <NEW_LINE> <DEDENT> def delete(self): <NEW_LINE> <INDENT> return self._proxy.delete() <NEW_LINE> <DEDENT> @property <NEW_LINE> def steps(self): <NEW_LINE> <INDENT> return self._proxy.steps <NEW_LINE> <DEDENT> @property <NEW_LINE> def engagement_context(self): <NEW_LINE> <INDENT> return self._proxy.engagement_context <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> context = ' '.join('{}={}'.format(k, v) for k, v in self._solution.items()) <NEW_LINE> return '<Twilio.Studio.V1.EngagementInstance {}>'.format(context)
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
6259901f925a0f43d25e8eaa
class AlphaBetaAgent(MultiAgentSearchAgent): <NEW_LINE> <INDENT> def getAction(self, gameState): <NEW_LINE> <INDENT> totalAgents = gameState.getNumAgents() <NEW_LINE> alpha = float("-inf") <NEW_LINE> beta = float("inf") <NEW_LINE> def AlphaBeta_Decision(state,alpha,beta): <NEW_LINE> <INDENT> index = 0 <NEW_LINE> depth = 0 <NEW_LINE> ab_action = None <NEW_LINE> temp_node_value = float('-inf') <NEW_LINE> legal_Moves = state.getLegalActions(index) <NEW_LINE> for move in legal_Moves: <NEW_LINE> <INDENT> successor = state.generateSuccessor(index,move) <NEW_LINE> succ_val = Min_Val(successor, index + 1, depth, alpha, beta)[0] <NEW_LINE> if succ_val > temp_node_value: <NEW_LINE> <INDENT> temp_node_value, ab_action = succ_val, move <NEW_LINE> <DEDENT> if temp_node_value > beta: <NEW_LINE> <INDENT> return ab_action <NEW_LINE> <DEDENT> alpha = max(alpha, temp_node_value) <NEW_LINE> <DEDENT> return ab_action <NEW_LINE> <DEDENT> def Max_Val(state, index, depth, alpha, beta): <NEW_LINE> <INDENT> if state.isWin() or state.isLose() or depth == self.depth: <NEW_LINE> <INDENT> return (self.evaluationFunction(state),None) <NEW_LINE> <DEDENT> index = 0 <NEW_LINE> v_node = float('-inf') <NEW_LINE> next_action = None <NEW_LINE> legal_Moves = state.getLegalActions(index) <NEW_LINE> for move in legal_Moves: <NEW_LINE> <INDENT> successor = state.generateSuccessor(index,move) <NEW_LINE> succ_val = Min_Val(successor, index + 1, depth, alpha, beta)[0] <NEW_LINE> if succ_val > v_node: <NEW_LINE> <INDENT> v_node, next_action = succ_val, move <NEW_LINE> <DEDENT> if v_node > beta: <NEW_LINE> <INDENT> return (v_node, next_action) <NEW_LINE> <DEDENT> alpha = max(alpha, v_node) <NEW_LINE> <DEDENT> return (v_node, next_action) <NEW_LINE> <DEDENT> def Min_Val(state, index, depth, alpha, beta): <NEW_LINE> <INDENT> if state.isWin() or state.isLose() or depth == self.depth: <NEW_LINE> <INDENT> return (self.evaluationFunction(state),None) <NEW_LINE> <DEDENT> v_node = float('inf') <NEW_LINE> next_action = None <NEW_LINE> legal_Moves = state.getLegalActions(index) <NEW_LINE> if index == totalAgents - 1: <NEW_LINE> <INDENT> for move in legal_Moves: <NEW_LINE> <INDENT> successor = state.generateSuccessor(index,move) <NEW_LINE> succ_val = Max_Val(successor, index, depth+1, alpha, beta )[0] <NEW_LINE> if succ_val < v_node: <NEW_LINE> <INDENT> v_node, next_action = succ_val, move <NEW_LINE> <DEDENT> if v_node < alpha: <NEW_LINE> <INDENT> return (v_node, next_action) <NEW_LINE> <DEDENT> beta = min(beta,v_node) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> for move in legal_Moves: <NEW_LINE> <INDENT> successor = state.generateSuccessor(index,move) <NEW_LINE> succ_val = Min_Val(successor, index + 1, depth, alpha, beta)[0] <NEW_LINE> if succ_val < v_node: <NEW_LINE> <INDENT> v_node, next_action = succ_val, move <NEW_LINE> <DEDENT> if v_node < alpha: <NEW_LINE> <INDENT> return (v_node, next_action) <NEW_LINE> <DEDENT> beta = min(beta,v_node) <NEW_LINE> <DEDENT> <DEDENT> return (v_node, next_action) <NEW_LINE> <DEDENT> return AlphaBeta_Decision(gameState,alpha,beta) <NEW_LINE> util.raiseNotDefined()
Your minimax agent with alpha-beta pruning (question 3)
6259901f8c3a8732951f73bf
class FolderPolicy(Policy): <NEW_LINE> <INDENT> def __init__(self, secure: bool=False, name: str='FolderPolicy'): <NEW_LINE> <INDENT> super(FolderPolicy, self).__init__(name) <NEW_LINE> self.desigCache = dict() <NEW_LINE> self.illegalCache = dict() <NEW_LINE> self.secure = secure <NEW_LINE> <DEDENT> def _computeFolder(self, f: File): <NEW_LINE> <INDENT> return f.getParentName() <NEW_LINE> <DEDENT> def _accFunPreCompute(self, f: File, acc: FileAccess): <NEW_LINE> <INDENT> return self._computeFolder(f) <NEW_LINE> <DEDENT> def _uaccFunCondPolicy(self, f: File, acc: FileAccess, composed: bool, data): <NEW_LINE> <INDENT> return self.dataInCache(self.desigCache, data, acc.actor) <NEW_LINE> <DEDENT> def _accFunSimilarAccessCond(self, f: File, acc: FileAccess, composed: bool, data): <NEW_LINE> <INDENT> return not self.dataInCache(self.illegalCache, data, acc.actor) and not f.hadPastSimilarAccess(acc, ILLEGAL_ACCESS, appWide=self.appWideRecords()) <NEW_LINE> <DEDENT> def updateDesignationState(self, f: File, acc: FileAccess, data=None): <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> data = self._accFunPreCompute(f, acc) <NEW_LINE> <DEDENT> self.addToCache(self.desigCache, data, acc.actor) <NEW_LINE> <DEDENT> def updateAllowedState(self, f: File, acc: FileAccess, data=None, strong=True): <NEW_LINE> <INDENT> if strong or not self.secure: <NEW_LINE> <INDENT> self.updateDesignationState(f, acc, data) <NEW_LINE> <DEDENT> <DEDENT> def updateIllegalState(self, f: File, acc: FileAccess, data=None): <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> data = self._accFunPreCompute(f, acc) <NEW_LINE> <DEDENT> self.addToCache(self.illegalCache, data, acc.actor) <NEW_LINE> <DEDENT> def addToCache(self, cache: dict, data: str, app: Application): <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> key = app.desktopid if self.appWideRecords() else app.uid() <NEW_LINE> s = cache.get(key) or set() <NEW_LINE> s.add(data) <NEW_LINE> cache[key] = s <NEW_LINE> <DEDENT> def dataInCache(self, cache: dict, data: str, app: Application): <NEW_LINE> <INDENT> if not data: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> s = cache.get(app.desktopid if self.appWideRecords() else app.uid()) <NEW_LINE> return data in s if s else False <NEW_LINE> <DEDENT> def _allowedByPolicy(self, f: File, app: Application): <NEW_LINE> <INDENT> folder = self._computeFolder(f) <NEW_LINE> if self.dataInCache(self.desigCache, folder, app): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return False
Policy where whole folders can be accessed after a designation event.
6259901f5166f23b2e244239
class roles: <NEW_LINE> <INDENT> valid_roles = [ 507374117964742670, 805266626898427915, 823732123931901972, ]
Config for roles.
6259901fa8ecb03325872085
class CGTransparencyLayer (object): <NEW_LINE> <INDENT> def __init__(self, context, info, rect = None): <NEW_LINE> <INDENT> self.context = context <NEW_LINE> self.info = info <NEW_LINE> self.rect = rect <NEW_LINE> <DEDENT> def __enter__(self): <NEW_LINE> <INDENT> if self.rect is None: <NEW_LINE> <INDENT> result = CG.CGContextBeginTransparencyLayer(self.context, self.info) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> result = CG.CGContextBeginTransparencyLayerWithRect(self.context, self.rect, self.info) <NEW_LINE> <DEDENT> return result <NEW_LINE> <DEDENT> def __exit__(self, exc_type, exc_value, exc_tp): <NEW_LINE> <INDENT> CG.CGContextEndTransparencyLayer(self.context) <NEW_LINE> return False
Context manager for working in a transparancylayer. Usage:: with CGTransparencyLayer(context, info [, rect]): statement This is equivalent to: CGContextBeginTransparencyLayer(context, info) try: statement finally: CGContextEndTransparencyLayer(context)
6259901fac7a0e7691f73350
class Classifier(nn.Module): <NEW_LINE> <INDENT> def __init__(self, cfg, n_labels): <NEW_LINE> <INDENT> super().__init__() <NEW_LINE> self.transformer = models.Transformer(cfg) <NEW_LINE> self.fc = nn.Linear(cfg.dim, cfg.dim) <NEW_LINE> self.activ = nn.Tanh() <NEW_LINE> self.drop = nn.Dropout(cfg.p_drop_hidden) <NEW_LINE> self.classifier = nn.Linear(cfg.dim, n_labels) <NEW_LINE> <DEDENT> def forward(self, input_ids, segment_ids, input_mask): <NEW_LINE> <INDENT> h = self.transformer(input_ids, segment_ids, input_mask) <NEW_LINE> pooled_h = self.activ(self.fc(h[:, 0])) <NEW_LINE> logits = self.classifier(self.drop(pooled_h)) <NEW_LINE> return logits
Classifier with Transformer
6259901fd18da76e235b7880
class TestDialog(BaseTestDialog): <NEW_LINE> <INDENT> dl_class = AddClinicianDialog <NEW_LINE> reject = True <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> localsettings.initiateUsers() <NEW_LINE> localsettings.initiate() <NEW_LINE> super().setUp() <NEW_LINE> <DEDENT> def test_exec(self): <NEW_LINE> <INDENT> self.exec_()
BaseTestDialog inherits from unittest.TestCase
6259901f6fece00bbaccc81f
class PrettyLoremProvider(BaseProvider): <NEW_LINE> <INDENT> def pretty_words(self, nb=3, ext_word_list=None): <NEW_LINE> <INDENT> words = fake.words(nb=3, ext_word_list=ext_word_list) <NEW_LINE> return [w.title() for w in words] <NEW_LINE> <DEDENT> def pretty_sentence(self, nb_words=6, ext_word_list=None): <NEW_LINE> <INDENT> words = fake.words(nb=nb_words, ext_word_list=ext_word_list) <NEW_LINE> return " ".join(map(lambda x: x.title(), words))
Provides fakes for text to include "pretty" features, like removing trailing periods, or capitalizing things
6259901f8c3a8732951f73c0
class MissingModuleError(Exception): <NEW_LINE> <INDENT> def __init__(self, message, import_traceback): <NEW_LINE> <INDENT> super(MissingModuleError, self).__init__(message) <NEW_LINE> self.import_traceback = import_traceback
Failed to import 3rd party module required by the caller
6259901fa8ecb03325872087
class SimpleUploadedFile(InMemoryUploadedFile): <NEW_LINE> <INDENT> def __init__(self, name, content, contentType='text/plain'): <NEW_LINE> <INDENT> content = content or b'' <NEW_LINE> super(SimpleUploadedFile, self).__init__(BytesIO(content), None, name, contentType, len(content), None, None) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def fromDict(cls, fileDict): <NEW_LINE> <INDENT> return cls(fileDict['filename'], fileDict['content'], fileDict.get('content-type', 'text/plain'))
A simple representation of a file, which just has content, size, and a name.
6259901f1d351010ab8f497d
class renew_delegation_token_args(object): <NEW_LINE> <INDENT> thrift_spec = ( None, (1, TType.STRING, 'token_str_form', None, None, ), ) <NEW_LINE> def __init__(self, token_str_form=None,): <NEW_LINE> <INDENT> self.token_str_form = token_str_form <NEW_LINE> <DEDENT> def read(self, iprot): <NEW_LINE> <INDENT> if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) <NEW_LINE> return <NEW_LINE> <DEDENT> iprot.readStructBegin() <NEW_LINE> while True: <NEW_LINE> <INDENT> (fname, ftype, fid) = iprot.readFieldBegin() <NEW_LINE> if ftype == TType.STOP: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if fid == 1: <NEW_LINE> <INDENT> if ftype == TType.STRING: <NEW_LINE> <INDENT> self.token_str_form = iprot.readString() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> iprot.readFieldEnd() <NEW_LINE> <DEDENT> iprot.readStructEnd() <NEW_LINE> <DEDENT> def write(self, oprot): <NEW_LINE> <INDENT> if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) <NEW_LINE> return <NEW_LINE> <DEDENT> oprot.writeStructBegin('renew_delegation_token_args') <NEW_LINE> if self.token_str_form is not None: <NEW_LINE> <INDENT> oprot.writeFieldBegin('token_str_form', TType.STRING, 1) <NEW_LINE> oprot.writeString(self.token_str_form) <NEW_LINE> oprot.writeFieldEnd() <NEW_LINE> <DEDENT> oprot.writeFieldStop() <NEW_LINE> oprot.writeStructEnd() <NEW_LINE> <DEDENT> def validate(self): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> def __hash__(self): <NEW_LINE> <INDENT> value = 17 <NEW_LINE> value = (value * 31) ^ hash(self.token_str_form) <NEW_LINE> return value <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> L = ['%s=%r' % (key, value) for key, value in self.__dict__.iteritems()] <NEW_LINE> return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other)
Attributes: - token_str_form
6259901fbf627c535bcb231c
class Element(): <NEW_LINE> <INDENT> def __init__(self, vdw, cov, m, n, s): <NEW_LINE> <INDENT> self.vdw = vdw <NEW_LINE> self.covalent = cov <NEW_LINE> self.mass = m <NEW_LINE> self.name = n <NEW_LINE> self.symbol = s <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return self.symbol
Element of the Periodic Table
6259901f3eb6a72ae038b4cd
class Unmarshaller(object): <NEW_LINE> <INDENT> @staticmethod <NEW_LINE> def unmarshal(pkg_reader, package, part_factory): <NEW_LINE> <INDENT> parts = Unmarshaller._unmarshal_parts( pkg_reader, package, part_factory ) <NEW_LINE> Unmarshaller._unmarshal_relationships(pkg_reader, package, parts) <NEW_LINE> for part in parts.values(): <NEW_LINE> <INDENT> part.after_unmarshal() <NEW_LINE> <DEDENT> package.after_unmarshal() <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def _unmarshal_parts(pkg_reader, package, part_factory): <NEW_LINE> <INDENT> parts = {} <NEW_LINE> for partname, content_type, blob in pkg_reader.iter_sparts(): <NEW_LINE> <INDENT> parts[partname] = part_factory( partname, content_type, blob, package ) <NEW_LINE> <DEDENT> return parts <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def _unmarshal_relationships(pkg_reader, package, parts): <NEW_LINE> <INDENT> for source_uri, srel in pkg_reader.iter_srels(): <NEW_LINE> <INDENT> source = package if source_uri == '/' else parts[source_uri] <NEW_LINE> target = (srel.target_ref if srel.is_external else parts[srel.target_partname]) <NEW_LINE> source.load_rel(srel.reltype, target, srel.rId, srel.is_external)
Hosts static methods for unmarshalling a package from a |PackageReader| instance.
6259901f8c3a8732951f73c2
class Parameters(): <NEW_LINE> <INDENT> labels = DatasetParameter('watershed labels', type='input') <NEW_LINE> resolved = DatasetParameter('filled-resolved elevation raster', type='output') <NEW_LINE> flat_labels = DatasetParameter('flat labels', type='output') <NEW_LINE> flat_graph = DatasetParameter('flat adjacency graph', type='output') <NEW_LINE> flat_spillover = DatasetParameter('flat spillover resolution', type='output') <NEW_LINE> output = DatasetParameter('flat-resolved elevation raster', type='output') <NEW_LINE> def __init__(self): <NEW_LINE> <INDENT> self.labels = 'dem-watershed-labels' <NEW_LINE> self.resolved = 'dem-filled-resolved' <NEW_LINE> self.flat_labels = 'dem-flat-labels' <NEW_LINE> self.flat_graph = 'dem-flat-graph' <NEW_LINE> self.flat_spillover = 'dem-flat-spillover' <NEW_LINE> self.output = 'dem-drainage-resolved'
Resolve flats parameters
6259901f63f4b57ef00864a7
class PlaceViewSet(ModelViewSet): <NEW_LINE> <INDENT> queryset = Place.objects.all() <NEW_LINE> serializer_class = PlaceSerializer
List of api views for ``Place`` model.
6259901f56b00c62f0fb372a
class Material(Model): <NEW_LINE> <INDENT> pass
原始物料信息
6259901fa8ecb0332587208b
class EmbeddedSequence(EmbeddedFactorSequence): <NEW_LINE> <INDENT> def __init__(self, name: str, vocabulary: Vocabulary, data_id: str, embedding_size: int, max_length: int = None, add_start_symbol: bool = False, add_end_symbol: bool = False, scale_embeddings_by_depth: bool = False, trainable: bool = True, embeddings_source: "EmbeddedSequence" = None, reuse: ModelPart = None, save_checkpoint: str = None, load_checkpoint: str = None, initializers: InitializerSpecs = None) -> None: <NEW_LINE> <INDENT> EmbeddedFactorSequence.__init__( self, name=name, vocabularies=[vocabulary], data_ids=[data_id], embedding_sizes=[embedding_size], max_length=max_length, add_start_symbol=add_start_symbol, add_end_symbol=add_end_symbol, scale_embeddings_by_depth=scale_embeddings_by_depth, trainable=trainable, embeddings_source=embeddings_source, reuse=reuse, save_checkpoint=save_checkpoint, load_checkpoint=load_checkpoint, initializers=initializers) <NEW_LINE> <DEDENT> @property <NEW_LINE> def inputs(self) -> tf.Tensor: <NEW_LINE> <INDENT> return self.input_factor_indices[0] <NEW_LINE> <DEDENT> @property <NEW_LINE> def embedding_matrix(self) -> tf.Tensor: <NEW_LINE> <INDENT> return self.embedding_matrices[0] <NEW_LINE> <DEDENT> @property <NEW_LINE> def vocabulary(self) -> Vocabulary: <NEW_LINE> <INDENT> return self.vocabularies[0] <NEW_LINE> <DEDENT> @property <NEW_LINE> def data_id(self) -> str: <NEW_LINE> <INDENT> return self.data_ids[0]
A sequence of embedded inputs (for a single factor).
6259901f796e427e5384f5ec
class BatchQuery(ClientQuery): <NEW_LINE> <INDENT> def __init__(self, context, queries=None): <NEW_LINE> <INDENT> super(BatchQuery, self).__init__(context) <NEW_LINE> self._current_boundary = create_boundary("batch_") <NEW_LINE> if queries is None: <NEW_LINE> <INDENT> queries = [] <NEW_LINE> <DEDENT> self._queries = queries <NEW_LINE> <DEDENT> def add(self, query): <NEW_LINE> <INDENT> self._queries.append(query) <NEW_LINE> <DEDENT> @property <NEW_LINE> def ordered_queries(self): <NEW_LINE> <INDENT> return self.change_sets + self.get_queries <NEW_LINE> <DEDENT> @property <NEW_LINE> def current_boundary(self): <NEW_LINE> <INDENT> return self._current_boundary <NEW_LINE> <DEDENT> @property <NEW_LINE> def change_sets(self): <NEW_LINE> <INDENT> return [qry for qry in self._queries if not isinstance(qry, ReadEntityQuery)] <NEW_LINE> <DEDENT> @property <NEW_LINE> def queries(self): <NEW_LINE> <INDENT> return self._queries <NEW_LINE> <DEDENT> @property <NEW_LINE> def get_queries(self): <NEW_LINE> <INDENT> return [qry for qry in self._queries if isinstance(qry, ReadEntityQuery)] <NEW_LINE> <DEDENT> @property <NEW_LINE> def has_change_sets(self): <NEW_LINE> <INDENT> return len(self.change_sets) > 0
Client query collection
6259901fa8ecb0332587208d
class Bee(Insect): <NEW_LINE> <INDENT> name = 'Bee' <NEW_LINE> watersafe = True <NEW_LINE> def sting(self, ant): <NEW_LINE> <INDENT> ant.reduce_armor(1) <NEW_LINE> <DEDENT> def move_to(self, place): <NEW_LINE> <INDENT> self.place.remove_insect(self) <NEW_LINE> place.add_insect(self) <NEW_LINE> <DEDENT> def blocked(self): <NEW_LINE> <INDENT> if not self.place.ant or not self.place.ant.blocks_path: <NEW_LINE> <INDENT> return False <NEW_LINE> <DEDENT> return True <NEW_LINE> <DEDENT> def action(self, colony): <NEW_LINE> <INDENT> if self.blocked(): <NEW_LINE> <INDENT> self.sting(self.place.ant) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> if self.place.name != 'Hive' and self.armor > 0: <NEW_LINE> <INDENT> self.move_to(self.place.exit)
A Bee moves from place to place, following exits and stinging ants.
6259901f21a7993f00c66ded
class TestMochadSwitchSetup(unittest.TestCase): <NEW_LINE> <INDENT> PLATFORM = mochad <NEW_LINE> COMPONENT = switch <NEW_LINE> THING = 'switch' <NEW_LINE> def setUp(self): <NEW_LINE> <INDENT> self.hass = get_test_home_assistant() <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> self.hass.stop() <NEW_LINE> <DEDENT> @mock.patch('homeassistant.components.switch.mochad.MochadSwitch') <NEW_LINE> def test_setup_adds_proper_devices(self, mock_switch): <NEW_LINE> <INDENT> good_config = { 'mochad': {}, 'switch': { 'platform': 'mochad', 'devices': [ { 'name': 'Switch1', 'address': 'a1', }, ], } } <NEW_LINE> self.assertTrue(setup_component(self.hass, switch.DOMAIN, good_config))
Test the mochad switch.
6259901fac7a0e7691f7335a
class PythonFileReporter(FileReporter): <NEW_LINE> <INDENT> def __init__(self, morf, coverage=None): <NEW_LINE> <INDENT> self.coverage = coverage <NEW_LINE> filename = source_for_morf(morf) <NEW_LINE> super().__init__(canonical_filename(filename)) <NEW_LINE> if hasattr(morf, '__name__'): <NEW_LINE> <INDENT> name = morf.__name__.replace(".", os.sep) <NEW_LINE> if os.path.basename(filename).startswith('__init__.'): <NEW_LINE> <INDENT> name += os.sep + "__init__" <NEW_LINE> <DEDENT> name += ".py" <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> name = relative_filename(filename) <NEW_LINE> <DEDENT> self.relname = name <NEW_LINE> self._source = None <NEW_LINE> self._parser = None <NEW_LINE> self._excluded = None <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return f"<PythonFileReporter {self.filename!r}>" <NEW_LINE> <DEDENT> @contract(returns='unicode') <NEW_LINE> def relative_filename(self): <NEW_LINE> <INDENT> return self.relname <NEW_LINE> <DEDENT> @property <NEW_LINE> def parser(self): <NEW_LINE> <INDENT> if self._parser is None: <NEW_LINE> <INDENT> self._parser = PythonParser( filename=self.filename, exclude=self.coverage._exclude_regex('exclude'), ) <NEW_LINE> self._parser.parse_source() <NEW_LINE> <DEDENT> return self._parser <NEW_LINE> <DEDENT> def lines(self): <NEW_LINE> <INDENT> return self.parser.statements <NEW_LINE> <DEDENT> def excluded_lines(self): <NEW_LINE> <INDENT> return self.parser.excluded <NEW_LINE> <DEDENT> def translate_lines(self, lines): <NEW_LINE> <INDENT> return self.parser.translate_lines(lines) <NEW_LINE> <DEDENT> def translate_arcs(self, arcs): <NEW_LINE> <INDENT> return self.parser.translate_arcs(arcs) <NEW_LINE> <DEDENT> @expensive <NEW_LINE> def no_branch_lines(self): <NEW_LINE> <INDENT> no_branch = self.parser.lines_matching( join_regex(self.coverage.config.partial_list), join_regex(self.coverage.config.partial_always_list) ) <NEW_LINE> return no_branch <NEW_LINE> <DEDENT> @expensive <NEW_LINE> def arcs(self): <NEW_LINE> <INDENT> return self.parser.arcs() <NEW_LINE> <DEDENT> @expensive <NEW_LINE> def exit_counts(self): <NEW_LINE> <INDENT> return self.parser.exit_counts() <NEW_LINE> <DEDENT> def missing_arc_description(self, start, end, executed_arcs=None): <NEW_LINE> <INDENT> return self.parser.missing_arc_description(start, end, executed_arcs) <NEW_LINE> <DEDENT> @contract(returns='unicode') <NEW_LINE> def source(self): <NEW_LINE> <INDENT> if self._source is None: <NEW_LINE> <INDENT> self._source = get_python_source(self.filename) <NEW_LINE> <DEDENT> return self._source <NEW_LINE> <DEDENT> def should_be_python(self): <NEW_LINE> <INDENT> _, ext = os.path.splitext(self.filename) <NEW_LINE> if ext.startswith('.py'): <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> if not ext: <NEW_LINE> <INDENT> return True <NEW_LINE> <DEDENT> return False <NEW_LINE> <DEDENT> def source_token_lines(self): <NEW_LINE> <INDENT> return source_token_lines(self.source())
Report support for a Python file.
6259901fbe8e80087fbbfee6
class Regexp(object): <NEW_LINE> <INDENT> def __init__(self, regex, flags=0, message=None): <NEW_LINE> <INDENT> if isinstance(regex, string_types): <NEW_LINE> <INDENT> regex = re.compile(regex, flags) <NEW_LINE> <DEDENT> self.regex = regex <NEW_LINE> self.message = message <NEW_LINE> <DEDENT> def __call__(self, form, field, message=None): <NEW_LINE> <INDENT> if not self.regex.match(field.data or ''): <NEW_LINE> <INDENT> if message is None: <NEW_LINE> <INDENT> if self.message is None: <NEW_LINE> <INDENT> message = field.gettext('Invalid input.') <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> message = self.message <NEW_LINE> <DEDENT> <DEDENT> raise ValidationError(message)
Validates the field against a user provided regexp. :param regex: The regular expression string to use. Can also be a compiled regular expression pattern. :param flags: The regexp flags to use, for example re.IGNORECASE. Ignored if `regex` is not a string. :param message: Error message to raise in case of a validation error.
6259901f925a0f43d25e8eb6
class IResourceRemoved(IResourceEvent): <NEW_LINE> <INDENT> pass
A resource was removed.
6259901f507cdc57c63a5c16
class AircraftFilter(object): <NEW_LINE> <INDENT> def __init__(self, *aircraft): <NEW_LINE> <INDENT> self.aircraft = aircraft <NEW_LINE> <DEDENT> def __call__(self, event): <NEW_LINE> <INDENT> return event.aircraft in self.aircraft
Match (Flight) events with one of given aircraft
6259901f5166f23b2e244245
class GoogleGeocoder(Geocoders): <NEW_LINE> <INDENT> def __init__(self, address): <NEW_LINE> <INDENT> return super(GoogleGeocoder, self).__init__(address) <NEW_LINE> <DEDENT> def geocode(self): <NEW_LINE> <INDENT> time.sleep(0.25) <NEW_LINE> Geocoders.count_dict['total'] += 1 <NEW_LINE> Geocoders.count_dict['google'] += 1 <NEW_LINE> return geocoder.google(self.address)
Google geocoder
6259901f63f4b57ef00864ab
class Node(object): <NEW_LINE> <INDENT> __slots__ = ('position', 'data', 'level', 'parent') <NEW_LINE> def __init__(self, position=None, data=None, parent=None, level=cns.NODE_FORUM_LEVEL): <NEW_LINE> <INDENT> self.position = position <NEW_LINE> self.data = data <NEW_LINE> self.level = level <NEW_LINE> self.parent = parent <NEW_LINE> <DEDENT> def __str__(self): <NEW_LINE> <INDENT> return '<{}.level={}>'.format(self.__class__.__name__, self.level) <NEW_LINE> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> return '<{}.level={}>'.format(self.__class__.__name__, self.level)
Сущность узла дерева необходима только лишь для простого доступа к данным родительских узлов(в редисе) в распределённой системе при сохранении их в БД обобщенным документом. Т.е. документ будет содержать данные из узлов дерева от листа до корня.
6259901f21a7993f00c66df1
class MipsRelocType(ElfRelocType): <NEW_LINE> <INDENT> _show = {}
ElfRelocType for MIPS processors.
6259901f5166f23b2e244247
class FFSocket(ForceField): <NEW_LINE> <INDENT> def __init__( self, latency=1.0, name="", pars=None, dopbc=True, active=np.array([-1]), threaded=True, interface=None, ): <NEW_LINE> <INDENT> super(FFSocket, self).__init__(latency, name, pars, dopbc, active, threaded) <NEW_LINE> if interface is None: <NEW_LINE> <INDENT> self.socket = InterfaceSocket() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> self.socket = interface <NEW_LINE> <DEDENT> self.socket.requests = self.requests <NEW_LINE> <DEDENT> def poll(self): <NEW_LINE> <INDENT> self.socket.poll() <NEW_LINE> <DEDENT> def start(self): <NEW_LINE> <INDENT> self.socket.open() <NEW_LINE> super(FFSocket, self).start() <NEW_LINE> <DEDENT> def stop(self): <NEW_LINE> <INDENT> super(FFSocket, self).stop() <NEW_LINE> if self._thread is not None: <NEW_LINE> <INDENT> self._thread.join() <NEW_LINE> <DEDENT> self.socket.close()
Interface between the PIMD code and a socket for a single replica. Deals with an individual replica of the system, obtaining the potential force and virial appropriate to this system. Deals with the distribution of jobs to the interface. Attributes: socket: The interface object which contains the socket through which communication between the forcefield and the driver is done.
6259901f9b70327d1c57fbf5
class MatchCondition(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'match_variables': {'required': True}, 'operator': {'required': True}, 'match_values': {'required': True}, } <NEW_LINE> _attribute_map = { 'match_variables': {'key': 'matchVariables', 'type': '[MatchVariable]'}, 'operator': {'key': 'operator', 'type': 'str'}, 'negation_conditon': {'key': 'negationConditon', 'type': 'bool'}, 'match_values': {'key': 'matchValues', 'type': '[str]'}, 'transforms': {'key': 'transforms', 'type': '[str]'}, } <NEW_LINE> def __init__( self, *, match_variables: List["MatchVariable"], operator: Union[str, "WebApplicationFirewallOperator"], match_values: List[str], negation_conditon: Optional[bool] = None, transforms: Optional[List[Union[str, "WebApplicationFirewallTransform"]]] = None, **kwargs ): <NEW_LINE> <INDENT> super(MatchCondition, self).__init__(**kwargs) <NEW_LINE> self.match_variables = match_variables <NEW_LINE> self.operator = operator <NEW_LINE> self.negation_conditon = negation_conditon <NEW_LINE> self.match_values = match_values <NEW_LINE> self.transforms = transforms
Define match conditions. All required parameters must be populated in order to send to Azure. :param match_variables: Required. List of match variables. :type match_variables: list[~azure.mgmt.network.v2019_12_01.models.MatchVariable] :param operator: Required. The operator to be matched. Possible values include: "IPMatch", "Equal", "Contains", "LessThan", "GreaterThan", "LessThanOrEqual", "GreaterThanOrEqual", "BeginsWith", "EndsWith", "Regex", "GeoMatch". :type operator: str or ~azure.mgmt.network.v2019_12_01.models.WebApplicationFirewallOperator :param negation_conditon: Whether this is negate condition or not. :type negation_conditon: bool :param match_values: Required. Match value. :type match_values: list[str] :param transforms: List of transforms. :type transforms: list[str or ~azure.mgmt.network.v2019_12_01.models.WebApplicationFirewallTransform]
6259901fa8ecb03325872093
class TestImioRevisionHistoryAdapter(IntegrationTestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> super(TestImioRevisionHistoryAdapter, self).setUp() <NEW_LINE> doc = api.content.create(type='Document', id='doc', container=self.portal) <NEW_LINE> self.doc = doc <NEW_LINE> <DEDENT> def test_getHistory(self): <NEW_LINE> <INDENT> adapter = getAdapter(self.doc, IImioHistory, 'revision') <NEW_LINE> history = adapter.getHistory() <NEW_LINE> self.assertEqual(len(history), 1) <NEW_LINE> self.assertEqual(history[0]['type'], 'versioning') <NEW_LINE> self.assertEqual(history[0]['actor'], TEST_USER_NAME) <NEW_LINE> self.assertEqual(history[0]['action'], 'Edited') <NEW_LINE> <DEDENT> def test_MayViewVersionComment(self, ): <NEW_LINE> <INDENT> view = getMultiAdapter((self.doc, self.portal.REQUEST), name='contenthistory') <NEW_LINE> history = view.getHistory() <NEW_LINE> pr = self.portal.portal_repository <NEW_LINE> self.assertTrue(self.doc.meta_type in pr.getVersionableContentTypes()) <NEW_LINE> lastEvent = history[0] <NEW_LINE> self.assertEqual(lastEvent['action'], u'Edited') <NEW_LINE> self.assertEqual(lastEvent['comments'], u'Initial revision') <NEW_LINE> self.assertTrue(view.versionIsViewable(lastEvent)) <NEW_LINE> zcml.load_config('testing-adapter.zcml', imio_history) <NEW_LINE> self.request.set('hide_revisions_comment', True) <NEW_LINE> history = view.getHistory() <NEW_LINE> lastEvent = history[0] <NEW_LINE> self.assertEqual(lastEvent['action'], u'Edited') <NEW_LINE> self.assertEqual(lastEvent['comments'], HISTORY_REVISION_NOT_VIEWABLE) <NEW_LINE> self.assertFalse(view.versionIsViewable(lastEvent)) <NEW_LINE> history = view.getHistory(checkMayViewComment=False) <NEW_LINE> lastEvent = history[0] <NEW_LINE> self.assertEqual(lastEvent['action'], u'Edited') <NEW_LINE> self.assertEqual(lastEvent['comments'], u'Initial revision') <NEW_LINE> zcml.cleanUp()
Test ImioRevisionHistoryAdapter.
6259901fbf627c535bcb2328
class EnhancedEthernetStatisticsTest(unittest.TestCase): <NEW_LINE> <INDENT> def test_enhanced_ethernet_statistics(self): <NEW_LINE> <INDENT> enhanced_ethernet_statistics_obj = EnhancedEthernetStatistics() <NEW_LINE> self.assertNotEqual(enhanced_ethernet_statistics_obj, None)
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
6259901fac7a0e7691f7335e
class Cache(object): <NEW_LINE> <INDENT> def __init__(self, graph): <NEW_LINE> <INDENT> self.enum = dict() <NEW_LINE> self.inv_enum = [] <NEW_LINE> self.in_neighbors = [] <NEW_LINE> self.terminals = [] <NEW_LINE> vertices = graph.vertices() <NEW_LINE> for (index, vertex) in enumerate(vertices): <NEW_LINE> <INDENT> self.enum[vertex] = index <NEW_LINE> self.inv_enum.append(vertex) <NEW_LINE> <DEDENT> for vertex in vertices: <NEW_LINE> <INDENT> in_dict = graph.in_dict(vertex) <NEW_LINE> self.in_neighbors.append([(self.enum[k], v) for k, v in in_dict.items()])
Caches common calculations for a given graph associated to a Markov process for efficiency when computing the stationary distribution with the approximate algorithm. Parameters ---------- graph: a Graph object The graph underlying the Markov process.
6259901fd18da76e235b7887
class DeleteGradesMixin(object): <NEW_LINE> <INDENT> @classmethod <NEW_LINE> def query_grades(cls, course_ids=None, modified_start=None, modified_end=None): <NEW_LINE> <INDENT> kwargs = {} <NEW_LINE> if course_ids: <NEW_LINE> <INDENT> kwargs['course_id__in'] = [course_id for course_id in course_ids] <NEW_LINE> <DEDENT> if modified_start: <NEW_LINE> <INDENT> if modified_end: <NEW_LINE> <INDENT> kwargs['modified__range'] = (modified_start, modified_end) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> kwargs['modified__gt'] = modified_start <NEW_LINE> <DEDENT> <DEDENT> return cls.objects.filter(**kwargs) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def delete_grades(cls, *args, **kwargs): <NEW_LINE> <INDENT> query = cls.query_grades(*args, **kwargs) <NEW_LINE> query.delete()
A Mixin class that provides functionality to delete grades.
6259901f287bf620b6272a61
class ChooseSameAddressTestCase(ComplianceTestCase): <NEW_LINE> <INDENT> def run(self): <NEW_LINE> <INDENT> if len(self.target(1).global_ip(offset='*')) < 2: <NEW_LINE> <INDENT> fail("Cannot Test. The UUT requires two global IP addresses for this test case to be valid.") <NEW_LINE> <DEDENT> self.ui.tell("Please send an ICMPv6 Echo Request from the UUT to %s." % self.target(1).global_ip(offset=0)) <NEW_LINE> self.ui.ask("Have you sent the Echo Request?") <NEW_LINE> self.logger.info("Attempting to find the Echo Request.") <NEW_LINE> r1 = self.node(1).received(dst=self.target(1).global_ip(offset=0), type=ICMPv6EchoRequest) <NEW_LINE> assertEqual(1, len(r1), "expected to see the ICMPv6 Echo Request sent by the UUT") <NEW_LINE> self.logger.info("Verifying the source of ICMPv6 Echo Request.") <NEW_LINE> assertEqual(self.target(1).global_ip(offset=0), r1[0].getlayer(IPv6).src) <NEW_LINE> self.ui.tell("Please send an ICMPv6 Echo Request from the UUT to %s." % self.target(1).global_ip(offset=1)) <NEW_LINE> self.ui.ask("Have you sent the Echo Request?") <NEW_LINE> self.logger.info("Attempting to find the second Echo Request.") <NEW_LINE> r1 = self.node(1).received(dst=self.target(1).global_ip(offset=1), type=ICMPv6EchoRequest) <NEW_LINE> assertEqual(1, len(r1), "expected to see the ICMPv6 Echo Request sent by the UUT") <NEW_LINE> self.logger.info("Verifying the source of ICMPv6 Echo Request.") <NEW_LINE> assertEqual(self.target(1).global_ip(offset=1), r1[0].getlayer(IPv6).src)
IPv6 Default Address Selection - Choose Same Address Verify that a node selects a source address that is the same as the destination address if the packet is being sent to the same interface. @private Source: RFC 3484 Section 5, Rule 1
6259901f5166f23b2e244249
class ConnectomistConcatenate(unittest.TestCase): <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> self.popen_patcher = patch("pyconnectomist.wrappers.subprocess.Popen") <NEW_LINE> self.mock_popen = self.popen_patcher.start() <NEW_LINE> mock_process = mock.Mock() <NEW_LINE> attrs = { "communicate.return_value": ("mock_OK", "mock_NONE"), "returncode": 0 } <NEW_LINE> mock_process.configure_mock(**attrs) <NEW_LINE> self.mock_popen.return_value = mock_process <NEW_LINE> <DEDENT> def tearDown(self): <NEW_LINE> <INDENT> self.popen_patcher.stop() <NEW_LINE> <DEDENT> def test_badfileerror_raise(self): <NEW_LINE> <INDENT> self.assertRaises(ConnectomistBadFileError, ptk_concatenate_volumes, ["input1", "input2"], "output", axis="t") <NEW_LINE> <DEDENT> @mock.patch("os.path") <NEW_LINE> def test_normal_execution(self, mock_path): <NEW_LINE> <INDENT> mock_path.isfile.side_effect = [True, True, False] <NEW_LINE> output_path = ptk_concatenate_volumes(["input1", "input2"], "output", axis="t") <NEW_LINE> self.assertEqual(output_path, "output.ima") <NEW_LINE> self.assertEqual([mock.call("input1"), mock.call("input2")], mock_path.isfile.call_args_list) <NEW_LINE> self.assertTrue(len(self.mock_popen.call_args_list) == 2)
Test the Connectomist function that concatenates volumes: 'pyconnectomist.utils.filetools.ptk_concatenate_volumes'
6259901fa8ecb03325872095
class NetworkInterface(object): <NEW_LINE> <INDENT> def __init__(self, name=None): <NEW_LINE> <INDENT> self.name = None <NEW_LINE> self.addr0 = None <NEW_LINE> self.addr1 = None <NEW_LINE> self.addr2 = None <NEW_LINE> self.addr3 = None <NEW_LINE> self.addr4 = None <NEW_LINE> self.addr5 = None <NEW_LINE> self.addr6 = None <NEW_LINE> self.addr7 = None
This class provides a place to store broken-out address fields into discrete attributes that can successfully have model references built on top of them. All attributes are meant to be public.
6259901fac7a0e7691f73360
class Pile: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> self.pile = None <NEW_LINE> self.nbr = 0 <NEW_LINE> <DEDENT> def empiler(self, elm): <NEW_LINE> <INDENT> element = Noeud(elm, self.pile) <NEW_LINE> self.pile = element <NEW_LINE> self.nbr += 1 <NEW_LINE> <DEDENT> def depiler(self): <NEW_LINE> <INDENT> assert self.nbr > 0, 'Pile vide' <NEW_LINE> element = self.pile.valeur <NEW_LINE> self.pile = self.pile.precedent <NEW_LINE> self.nbr -= 1 <NEW_LINE> return element <NEW_LINE> <DEDENT> def taille(self): <NEW_LINE> <INDENT> return self.nbr <NEW_LINE> <DEDENT> def est_vide(self): <NEW_LINE> <INDENT> return self.nbr == 0
File doublement chaîné +=========+ +=========+ +=========+ | NOEUDN-1|/_____ | NOEUDN |/____ | NOEUDN+1| |=========|\ \ |=========|\ \ |=========| None <--|precedent| \____|precedent| \____|precedent| |¨¨¨¨¨¨¨¨¨| |¨¨¨¨¨¨¨¨¨| |¨¨¨¨¨¨¨¨¨| |valeur | |valeur | |valeur | +=========+ +=========+ +=========+ (sommet/pile)
6259902021a7993f00c66df5
class LinearModel(Model): <NEW_LINE> <INDENT> def __init__(self, param, data): <NEW_LINE> <INDENT> super().__init__(param, data) <NEW_LINE> iname = 'imp_vol' if 'imp_vol' in data.dtype.names else 'imp_vol_data' <NEW_LINE> formula = 'np.log(' + iname + ') ~ moneyness_norm*maturity+moneyness2' <NEW_LINE> self.model = sm.OLS.from_formula(formula, data=pd.DataFrame(self.data)) <NEW_LINE> <DEDENT> def get_name(self): <NEW_LINE> <INDENT> return 'LM' <NEW_LINE> <DEDENT> def get_pnames(self): <NEW_LINE> <INDENT> return ['c', 'mon', 'mat', 'mm', 'm2'] <NEW_LINE> <DEDENT> def calibrate(self, param_start): <NEW_LINE> <INDENT> return self.get_pnames(), self.model.fit().params.values <NEW_LINE> <DEDENT> def impvol(self): <NEW_LINE> <INDENT> try: <NEW_LINE> <INDENT> return np.exp((self.model.exog * self.param).sum(1)) <NEW_LINE> <DEDENT> except ValueError: <NEW_LINE> <INDENT> return np.exp((self.model.exog * np.atleast_2d(self.param).T).sum(1)) <NEW_LINE> <DEDENT> <DEDENT> def premium(self): <NEW_LINE> <INDENT> return blackscholes_norm(self.data['moneyness'], self.data['maturity'], self.impvol(), self.data['call'])
Linear Regression model.
625990205e10d32532ce4041
class FetchListRequestHandler(HermesHTTPRequestHandler): <NEW_LINE> <INDENT> def get(self): <NEW_LINE> <INDENT> def _set_output(): <NEW_LINE> <INDENT> self.output = { 'groups': dao.fetch_list() } <NEW_LINE> <DEDENT> def _set_headers(): <NEW_LINE> <INDENT> self.set_header("Access-Control-Allow-Origin", "*") <NEW_LINE> <DEDENT> self.invoke(rv.validate_fetch_list, [ _set_output, _set_headers ])
Simulation list metric request handler.
625990201d351010ab8f498d
class HostsOrigin(main.Origin): <NEW_LINE> <INDENT> cobbler = None <NEW_LINE> expression = None <NEW_LINE> whitelist = [] <NEW_LINE> def __init__(self, server_url, user, pw, ssh_uri, expression="igor-", whitelist=[]): <NEW_LINE> <INDENT> self.cobbler = Cobbler(server_url, (user, pw), ssh_uri) <NEW_LINE> self.expression = expression <NEW_LINE> self.whitelist = whitelist <NEW_LINE> <DEDENT> def name(self): <NEW_LINE> <INDENT> return "CobblerHostsOrigin(%s)" % self.cobbler.server_url <NEW_LINE> <DEDENT> def items(self): <NEW_LINE> <INDENT> items = {} <NEW_LINE> with self.cobbler as remote: <NEW_LINE> <INDENT> for sysname in remote.systems(): <NEW_LINE> <INDENT> match = False <NEW_LINE> if self.expression in sysname: <NEW_LINE> <INDENT> logger.debug("cobbler host '%s' matched expression" % sysname) <NEW_LINE> match = True <NEW_LINE> <DEDENT> if sysname in self.__get_whitelist(): <NEW_LINE> <INDENT> logger.debug("cobbler host '%s' is in whitelist" % sysname) <NEW_LINE> match = True <NEW_LINE> <DEDENT> if not match: <NEW_LINE> <INDENT> continue <NEW_LINE> <DEDENT> host = Host() <NEW_LINE> host.remote = remote <NEW_LINE> host.name = sysname <NEW_LINE> host.origin = self <NEW_LINE> try: <NEW_LINE> <INDENT> host.mac = remote.system(sysname)["mac_address_eth0"] <NEW_LINE> <DEDENT> except: <NEW_LINE> <INDENT> host.mac = "" <NEW_LINE> <DEDENT> items[sysname] = host <NEW_LINE> <DEDENT> <DEDENT> return items <NEW_LINE> <DEDENT> def __get_whitelist(self): <NEW_LINE> <INDENT> w = self.whitelist <NEW_LINE> if type(w) is str: <NEW_LINE> <INDENT> w = self.__read_whitelist(self.whitelist) <NEW_LINE> <DEDENT> return w <NEW_LINE> <DEDENT> def __read_whitelist(self, filename): <NEW_LINE> <INDENT> whitelist = [] <NEW_LINE> with open(filename) as f: <NEW_LINE> <INDENT> for line in f: <NEW_LINE> <INDENT> line = line.strip() <NEW_LINE> if line.startswith("#"): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> whitelist.append(line) <NEW_LINE> <DEDENT> <DEDENT> <DEDENT> return whitelist
This is the source where igor retrieves cobbler systems as hosts
62599020462c4b4f79dbc882
class Bucketlist(models.Model): <NEW_LINE> <INDENT> deseo = models.CharField(max_length=255, blank=False, unique=True) <NEW_LINE> dueño = models.ForeignKey( 'auth.User', related_name='bucketlists', on_delete=models.CASCADE) <NEW_LINE> fecha_creacion = models.DateTimeField(auto_now_add=True) <NEW_LINE> fecha_modificacion = models.DateTimeField(auto_now=True) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return "{}".format(self.name)
This class represents the bucketlist model.
62599020ac7a0e7691f73362
class CpcNotInDpmError(ConflictError): <NEW_LINE> <INDENT> def __init__(self, method, uri, cpc): <NEW_LINE> <INDENT> super(CpcNotInDpmError, self).__init__( method, uri, reason=5, message="CPC is not in DPM mode: %s" % cpc.uri)
Indicates that the operation requires DPM mode but the CPC is not in DPM mode. Out of the set of operations that only work in DPM mode, this error is used only for the following subset: - Create Partition - Create Hipersocket - Start CPC - Stop CPC - Set Auto-Start List
62599020bf627c535bcb232c
class PropertyTests: <NEW_LINE> <INDENT> def setUp(self): <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> def test_no_default_value(self): <NEW_LINE> <INDENT> p = self.prop_class() <NEW_LINE> self.assertIs(p.default, none_object) <NEW_LINE> self.assertFalse(p.has_default) <NEW_LINE> self.assertTrue(p.required) <NEW_LINE> <DEDENT> def test_default_value(self): <NEW_LINE> <INDENT> default_value = object() <NEW_LINE> p = self.prop_class(default=default_value) <NEW_LINE> self.assertIs(p.default, default_value) <NEW_LINE> self.assertTrue(p.has_default) <NEW_LINE> self.assertFalse(p.required) <NEW_LINE> <DEDENT> def test_fill_brok(self): <NEW_LINE> <INDENT> p = self.prop_class() <NEW_LINE> self.assertNotIn('full_status', p.fill_brok) <NEW_LINE> p = self.prop_class(default='0', fill_brok=['full_status']) <NEW_LINE> self.assertIn('full_status', p.fill_brok) <NEW_LINE> <DEDENT> def test_unused(self): <NEW_LINE> <INDENT> p = self.prop_class() <NEW_LINE> self.assertFalse(p.unused)
Common tests for all property classes
62599020be8e80087fbbfeef
class SchNetInteraction(nn.Module): <NEW_LINE> <INDENT> def __init__(self, n_atom_basis, n_spatial_basis, n_filters, cutoff, cutoff_network=HardCutoff, normalize_filter=False): <NEW_LINE> <INDENT> super(SchNetInteraction, self).__init__() <NEW_LINE> self.filter_network = nn.Sequential( schnetpack.nn.base.Dense(n_spatial_basis, n_filters, activation=schnetpack.nn.activations.shifted_softplus), schnetpack.nn.base.Dense(n_filters, n_filters) ) <NEW_LINE> self.cutoff_network = cutoff_network(cutoff) <NEW_LINE> self.cfconv = schnetpack.nn.cfconv.CFConv(n_atom_basis, n_filters, n_atom_basis, self.filter_network, cutoff_network=self.cutoff_network, activation=schnetpack.nn.activations.shifted_softplus, normalize_filter=normalize_filter) <NEW_LINE> self.dense = schnetpack.nn.base.Dense(n_atom_basis, n_atom_basis) <NEW_LINE> <DEDENT> def forward(self, x, r_ij, neighbors, neighbor_mask, f_ij=None): <NEW_LINE> <INDENT> v = self.cfconv(x, r_ij, neighbors, neighbor_mask, f_ij) <NEW_LINE> v = self.dense(v) <NEW_LINE> return v
SchNet interaction block for modeling quantum interactions of atomistic systems with cosine cutoff. Args: n_atom_basis (int): number of features used to describe atomic environments n_spatial_basis (int): number of input features of filter-generating networks n_filters (int): number of filters used in continuous-filter convolution normalize_filter (bool): if true, divide filter by number of neighbors over which convolution is applied
625990203eb6a72ae038b4dd
class Base_2D_Grid_2_Lines(unittest.TestCase): <NEW_LINE> <INDENT> params = ["p1", "p2"] <NEW_LINE> param_range_dict = OD( [("p1", (-5, 3)), ("p2", (1.2e6, 15e6))] ) <NEW_LINE> n_gridpts_list = (11, 9) <NEW_LINE> interpd_shape = (50, 45) <NEW_LINE> lines = ["L1", "L2"] <NEW_LINE> line_peaks = [8, 5] <NEW_LINE> @classmethod <NEW_LINE> def setUpClass(cls): <NEW_LINE> <INDENT> line_peaks_dict = OD([(l,cls.line_peaks) for l in cls.lines]) <NEW_LINE> cls.DF = build_grid(cls.param_range_dict, line_peaks_dict, cls.n_gridpts_list) <NEW_LINE> cls.val_arrs = OD([(p,np.unique(cls.DF[p].values)) for p in cls.params]) <NEW_LINE> cls.DF.loc[:,"L1"] = 1. <NEW_LINE> cls.grid_file = os.path.join(TEST_DIR, cls.__name__ + "_grid.csv") <NEW_LINE> cls.DF.to_csv(cls.grid_file, index=False) <NEW_LINE> cls.NB_Model_1 = NB_Model(cls.grid_file, cls.params, cls.lines, interpd_grid_shape=cls.interpd_shape) <NEW_LINE> <DEDENT> @classmethod <NEW_LINE> def tearDownClass(cls): <NEW_LINE> <INDENT> if clean_up: <NEW_LINE> <INDENT> os.remove(cls.grid_file) <NEW_LINE> if hasattr(cls, "posterior_plot"): <NEW_LINE> <INDENT> os.remove(cls.posterior_plot)
Base class holding setup and cleanup methods to make a 2D grid with only 2 emission lines, and using a 2D Gaussian to make the grid. There are only two lines, but one has fluxes set to all 1 and is just for normalisation.
625990208c3a8732951f73d2
class Conditional: <NEW_LINE> <INDENT> def __init__(self, condition, if_true, if_false=None): <NEW_LINE> <INDENT> self.condition = condition <NEW_LINE> self.if_true = if_true <NEW_LINE> self.if_false = if_false <NEW_LINE> <DEDENT> def evaluate(self, scope): <NEW_LINE> <INDENT> if self.condition.evaluate(scope).value: <NEW_LINE> <INDENT> return ExprList(self.if_true).evaluate(scope) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> return ExprList(self.if_false).evaluate(scope)
Conditional - представляет ветвление в программе, т. е. if.
625990205166f23b2e24424d
class FuncBlock(Block): <NEW_LINE> <INDENT> def __init__(self, func, preset_kwargs, **block_kwargs): <NEW_LINE> <INDENT> if not hasattr(this_module, func.__name__): <NEW_LINE> <INDENT> func_copy = FunctionType(func.__code__, globals(), func.__name__) <NEW_LINE> setattr(this_module, func_copy.__name__, func_copy) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> raise ValueError("illegal blockified function name: {}".format(func.__name__)) <NEW_LINE> <DEDENT> self.func = func_copy <NEW_LINE> self.preset_kwargs = preset_kwargs <NEW_LINE> spec = inspect.getfullargspec(func) <NEW_LINE> if (spec.varargs or spec.varkw): <NEW_LINE> <INDENT> raise TypeError("function cannot accept a variable number of args") <NEW_LINE> <DEDENT> self._arg_spec = spec <NEW_LINE> super().__init__(self.func.__name__,**block_kwargs) <NEW_LINE> <DEDENT> def process(self, *args): <NEW_LINE> <INDENT> return self.func(*args, **self.preset_kwargs) <NEW_LINE> <DEDENT> def __call__(self, *args, **kwargs): <NEW_LINE> <INDENT> return self.func(*args,**kwargs) <NEW_LINE> <DEDENT> @property <NEW_LINE> def args(self): <NEW_LINE> <INDENT> if not self._arg_spec: <NEW_LINE> <INDENT> self._arg_spec = inspect.getfullargspec(self.func) <NEW_LINE> <DEDENT> pos_args = ([] if (self._arg_spec.args is None) else self._arg_spec.args).copy() <NEW_LINE> for idx,preset in enumerate(self.preset_kwargs.keys()): <NEW_LINE> <INDENT> pos_args.remove(preset) <NEW_LINE> <DEDENT> return pos_args
Block that will run anmy fucntion you give it, either unfettered through the __call__ function, or with optional hardcoded parameters for use in a pipeline. Typically the FuncBlock is only used in the `blockify` decorator method. Attributes: func(function): the function to call internally preset_kwargs(dict): preset keyword arguments, typically used for arguments that are not data to process
62599020462c4b4f79dbc884
class TestKnitSomeLines(CommunicationTest): <NEW_LINE> <INDENT> lines = ["B" * 200] * 301 <NEW_LINE> lines[100] = "BBBBBBBDDBBBBBBBDDDDBBBBDBDBDBDB" + "B" * 168 <NEW_LINE> line_100 = b'\x80\x01\x0fU' + b'\00' * 21 + b'\x00' + b'\xd0' <NEW_LINE> input = (b'\xc3\x04\x03\xcc\r\n' + b'\x84\x00BbCcde\r\n' + b'\x84\x01BbCcde\r\n' + b'\xc1\x01\r\n' + b'\x82\x64\r\n' + b'\x82\xc8\r\n' + b'\x82\x2c\r\n' + b'\x82\x90\r\n' + b'') <NEW_LINE> output = (b'\x03\r\n' + b'\x01\x00\xc7\r\n' + b'\x42\x64' + line_100 + b'\r\n' b'\x42\xc8' + b'\x00' * 26 + b'\x07\r\n' b'\x42\x2c' + b'\x00' * 25 + b'\x01\xdd\r\n' + b'\x42\x90' + b'\x00' * 25 + b'\x01\xb3\r\n' + b'') <NEW_LINE> states = ["is_initial_handshake", "is_initializing_machine", "is_initializing_machine", "is_starting_to_knit", "is_knitting_started", 100, 200, 300, 400]
Test that we knit some lines.
6259902066673b3332c31267
class Job(models.Model): <NEW_LINE> <INDENT> title = models.CharField(verbose_name='job title', max_length=50) <NEW_LINE> image = models.ImageField(verbose_name='thumbnail', upload_to='img/jobs') <NEW_LINE> summary = models.CharField(verbose_name='description', max_length=140) <NEW_LINE> copy = models.TextField(verbose_name='copy', null=True) <NEW_LINE> date = models.DateTimeField(verbose_name='date of job', null=True) <NEW_LINE> link = models.URLField(verbose_name='link to project', blank=True) <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return self.title
Describes individual past Jobs to display in CV
62599020d164cc6175821df1
class SpaException(Exception): <NEW_LINE> <INDENT> pass
A exception within the SPA subsystem.
6259902063f4b57ef00864b0
class Configuration(msrest.serialization.Model): <NEW_LINE> <INDENT> _validation = { 'display_name': {'readonly': True}, 'description': {'readonly': True}, 'image_information': {'readonly': True}, 'cost_information': {'readonly': True}, 'availability_information': {'readonly': True}, 'hierarchy_information': {'readonly': True}, 'filterable_properties': {'readonly': True}, 'specifications': {'readonly': True}, 'dimensions': {'readonly': True}, } <NEW_LINE> _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'Description'}, 'image_information': {'key': 'properties.imageInformation', 'type': '[ImageInformation]'}, 'cost_information': {'key': 'properties.costInformation', 'type': 'CostInformation'}, 'availability_information': {'key': 'properties.availabilityInformation', 'type': 'AvailabilityInformation'}, 'hierarchy_information': {'key': 'properties.hierarchyInformation', 'type': 'HierarchyInformation'}, 'filterable_properties': {'key': 'properties.filterableProperties', 'type': '[FilterableProperty]'}, 'specifications': {'key': 'properties.specifications', 'type': '[Specification]'}, 'dimensions': {'key': 'properties.dimensions', 'type': 'Dimensions'}, } <NEW_LINE> def __init__( self, **kwargs ): <NEW_LINE> <INDENT> super(Configuration, self).__init__(**kwargs) <NEW_LINE> self.display_name = None <NEW_LINE> self.description = None <NEW_LINE> self.image_information = None <NEW_LINE> self.cost_information = None <NEW_LINE> self.availability_information = None <NEW_LINE> self.hierarchy_information = None <NEW_LINE> self.filterable_properties = None <NEW_LINE> self.specifications = None <NEW_LINE> self.dimensions = None
Configuration object. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: Display Name for the product system. :vartype display_name: str :ivar description: Description related to the product system. :vartype description: ~azure.mgmt.edgeorder.v2021_12_01.models.Description :ivar image_information: Image information for the product system. :vartype image_information: list[~azure.mgmt.edgeorder.v2021_12_01.models.ImageInformation] :ivar cost_information: Cost information for the product system. :vartype cost_information: ~azure.mgmt.edgeorder.v2021_12_01.models.CostInformation :ivar availability_information: Availability information of the product system. :vartype availability_information: ~azure.mgmt.edgeorder.v2021_12_01.models.AvailabilityInformation :ivar hierarchy_information: Hierarchy information of a product. :vartype hierarchy_information: ~azure.mgmt.edgeorder.v2021_12_01.models.HierarchyInformation :ivar filterable_properties: list of filters supported for a product. :vartype filterable_properties: list[~azure.mgmt.edgeorder.v2021_12_01.models.FilterableProperty] :ivar specifications: Specifications of the configuration. :vartype specifications: list[~azure.mgmt.edgeorder.v2021_12_01.models.Specification] :ivar dimensions: Dimensions of the configuration. :vartype dimensions: ~azure.mgmt.edgeorder.v2021_12_01.models.Dimensions
6259902056b00c62f0fb373c
class AutoWidthListCtrl(wx12.ListCtrl, listmix.ListCtrlAutoWidthMixin): <NEW_LINE> <INDENT> def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, *args, **kwargs): <NEW_LINE> <INDENT> wx12.ListCtrl.__init__(self, parent, ID, pos, size, style, *args, **kwargs) <NEW_LINE> listmix.ListCtrlAutoWidthMixin.__init__(self) <NEW_LINE> <DEDENT> def clearSelections(self): <NEW_LINE> <INDENT> for item in range( self.GetItemCount() ): <NEW_LINE> <INDENT> self.Select(item, on=0) <NEW_LINE> <DEDENT> return <NEW_LINE> <DEDENT> def setSelection(self, itemtext = None): <NEW_LINE> <INDENT> self.clearSelections() <NEW_LINE> item = 0 <NEW_LINE> if itemtext: <NEW_LINE> <INDENT> item = self.FindItem(-1, itemtext) <NEW_LINE> self.Select(item) <NEW_LINE> self.Focus(item) <NEW_LINE> <DEDENT> return item
wxListCtrl subclass that automatically adjusts its column width.
6259902063f4b57ef00864b1
class Conflict(LeonardoException): <NEW_LINE> <INDENT> status_code = 409
Generic error to replace all "Conflict"-type API errors.
62599020462c4b4f79dbc888
class GLgetGames_result: <NEW_LINE> <INDENT> thrift_spec = ( (0, TType.LIST, 'success', (TType.STRUCT,(GLGame, GLGame.thrift_spec)), None, ), ) <NEW_LINE> def __init__(self, success=None,): <NEW_LINE> <INDENT> self.success = success <NEW_LINE> <DEDENT> def read(self, iprot): <NEW_LINE> <INDENT> if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec)) <NEW_LINE> return <NEW_LINE> <DEDENT> iprot.readStructBegin() <NEW_LINE> while True: <NEW_LINE> <INDENT> (fname, ftype, fid) = iprot.readFieldBegin() <NEW_LINE> if ftype == TType.STOP: <NEW_LINE> <INDENT> break <NEW_LINE> <DEDENT> if fid == 0: <NEW_LINE> <INDENT> if ftype == TType.LIST: <NEW_LINE> <INDENT> self.success = [] <NEW_LINE> (_etype24, _size21) = iprot.readListBegin() <NEW_LINE> for _i25 in xrange(_size21): <NEW_LINE> <INDENT> _elem26 = GLGame() <NEW_LINE> _elem26.read(iprot) <NEW_LINE> self.success.append(_elem26) <NEW_LINE> <DEDENT> iprot.readListEnd() <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> <DEDENT> else: <NEW_LINE> <INDENT> iprot.skip(ftype) <NEW_LINE> <DEDENT> iprot.readFieldEnd() <NEW_LINE> <DEDENT> iprot.readStructEnd() <NEW_LINE> <DEDENT> def write(self, oprot): <NEW_LINE> <INDENT> if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None: <NEW_LINE> <INDENT> oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) <NEW_LINE> return <NEW_LINE> <DEDENT> oprot.writeStructBegin('GLgetGames_result') <NEW_LINE> if self.success != None: <NEW_LINE> <INDENT> oprot.writeFieldBegin('success', TType.LIST, 0) <NEW_LINE> oprot.writeListBegin(TType.STRUCT, len(self.success)) <NEW_LINE> for iter27 in self.success: <NEW_LINE> <INDENT> iter27.write(oprot) <NEW_LINE> <DEDENT> oprot.writeListEnd() <NEW_LINE> oprot.writeFieldEnd() <NEW_LINE> <DEDENT> oprot.writeFieldStop() <NEW_LINE> oprot.writeStructEnd() <NEW_LINE> def validate(self): <NEW_LINE> <INDENT> return <NEW_LINE> <DEDENT> <DEDENT> def __repr__(self): <NEW_LINE> <INDENT> L = ['%s=%r' % (key, value) for key, value in self.__dict__.iteritems()] <NEW_LINE> return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) <NEW_LINE> <DEDENT> def __eq__(self, other): <NEW_LINE> <INDENT> return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ <NEW_LINE> <DEDENT> def __ne__(self, other): <NEW_LINE> <INDENT> return not (self == other)
Attributes: - success
62599020ac7a0e7691f73368
class BindReceiverResp(PDU): <NEW_LINE> <INDENT> command_id = Integer(command_ids.bind_receiver_resp, 4) <NEW_LINE> system_id = CString("") <NEW_LINE> sc_interface_version = Integer(IV.SMPP_VERSION_5, 1)
SMPP bind_receiver_resp PDU type
62599020be8e80087fbbfef5
class LabelParc(Parcellation): <NEW_LINE> <INDENT> DICT_ATTRS = ('kind', 'labels') <NEW_LINE> kind = 'label_parc' <NEW_LINE> make = True <NEW_LINE> def __init__( self, labels: Sequence[str], views: Union[str, Sequence[str]] = None, ): <NEW_LINE> <INDENT> Parcellation.__init__(self, views) <NEW_LINE> self.labels = tuple_arg(labels) <NEW_LINE> <DEDENT> def _make(self, e, parc): <NEW_LINE> <INDENT> labels = [] <NEW_LINE> hemis = ('lh.', 'rh.') <NEW_LINE> path = os.path.join(e.get('mri-dir'), 'label', '%s.label') <NEW_LINE> for label in self.labels: <NEW_LINE> <INDENT> if label.startswith(hemis): <NEW_LINE> <INDENT> labels.append(mne.read_label(path % label)) <NEW_LINE> <DEDENT> else: <NEW_LINE> <INDENT> labels.extend(mne.read_label(path % (hemi + label)) for hemi in hemis) <NEW_LINE> <DEDENT> <DEDENT> return labels
Assemble parcellation from FreeSurfer labels Combine one or several ``*.label`` files into a parcellation.
6259902063f4b57ef00864b2
class stdmodel(object): <NEW_LINE> <INDENT> _str = "" <NEW_LINE> def __str__(self): <NEW_LINE> <INDENT> return self._str <NEW_LINE> <DEDENT> def reset(self): <NEW_LINE> <INDENT> self._str = "" <NEW_LINE> <DEDENT> def get(self): <NEW_LINE> <INDENT> return self._str <NEW_LINE> <DEDENT> def write(self, line): <NEW_LINE> <INDENT> self._str += line <NEW_LINE> <DEDENT> def open(self, *args): <NEW_LINE> <INDENT> self._str = "" <NEW_LINE> <DEDENT> def close(self): <NEW_LINE> <INDENT> self._str = "" <NEW_LINE> <DEDENT> def read(self): <NEW_LINE> <INDENT> return self._str
a class to model stdout for pdfminer file parameter Can get context use get() method
62599020796e427e5384f600
class CommandBadArguments(CommandFailure): <NEW_LINE> <INDENT> pass
Command cannot be executed because the Arguments are wrong.
6259902091af0d3eaad3aca7
class TripRequest(models.Model): <NEW_LINE> <INDENT> initiator = models.ForeignKey(Traveller, on_delete=models.CASCADE) <NEW_LINE> trip = models.ForeignKey(Trip, on_delete=models.CASCADE) <NEW_LINE> status = models.CharField(max_length=20) <NEW_LINE> pass
In order to decline the trip from trip owner perspective: Make a post request and delete the TripRequest from DB. Optionally notify the initiator by using his id and email via emailing backend. Accept button will lock the trip to be proceeding (started). id initiator - relationships trip_owner - relationships trip_id - relationships
625990208c3a8732951f73db
class InputNotifyUsers(TLObject): <NEW_LINE> <INDENT> __slots__: List[str] = [] <NEW_LINE> ID = 0x193b4417 <NEW_LINE> QUALNAME = "types.InputNotifyUsers" <NEW_LINE> def __init__(self) -> None: <NEW_LINE> <INDENT> pass <NEW_LINE> <DEDENT> @staticmethod <NEW_LINE> def read(data: BytesIO, *args: Any) -> "InputNotifyUsers": <NEW_LINE> <INDENT> return InputNotifyUsers() <NEW_LINE> <DEDENT> def write(self) -> bytes: <NEW_LINE> <INDENT> data = BytesIO() <NEW_LINE> data.write(Int(self.ID, False)) <NEW_LINE> return data.getvalue()
This object is a constructor of the base type :obj:`~pyrogram.raw.base.InputNotifyPeer`. Details: - Layer: ``122`` - ID: ``0x193b4417`` **No parameters required.**
62599020bf627c535bcb2336
class LanguageIdentification: <NEW_LINE> <INDENT> def __init__(self): <NEW_LINE> <INDENT> pretrained_lang_model = "lid.176.bin" <NEW_LINE> self.model = fasttext.load_model(pretrained_lang_model) <NEW_LINE> <DEDENT> def predict_lang(self, text): <NEW_LINE> <INDENT> predictions = self.model.predict(text, k=1) <NEW_LINE> return predictions
Class object for Language Identification
6259902066673b3332c3126f