EntityScript

Draft 1.2:
Index


core_transmitter





"""
Copyright (C) 2020 New Entity Operations Inc.

ALL RIGHTS RESERVED

core_transmitter takes I/O tasks and turns them into phase based threads

This is the example simulation

"""
from collections import defaultdict
from tempfile import TemporaryFile

from core_middlelayer import (
    CURRENT_FULLES,
    DIRDATA,
    TEMP_FULLES
)

class PhaseTransmitter:
    """
    Usage: Run a conversation simulation or build deeper into the 
    prototype
    >>> from core_transmitter import PhaseTransmitter
    >>> PhaseTransmitter()
    """
    def __init__(self):
     # clock section
     clock_now = 0
     clock_then = 0

     # action default instance link
     action = str(
      '--- ADDED: SIMULATED PHASE MEMBER ---'
     )

     # usermask simulated values
     usermask_1 = 'NLLBELHNSLPNEA'
     usermask_2 = 'NXK3LPNHSDLPSB'
     usermask_3 = 'KMHEPNSLPNSHEL'
     usermask_4 = 'POLENSLIHANLPE'
     usermask_5 = 'AWYHLPNHSLNELP'
     usermask_6 = 'EEWOHNSLLHJESL'

     # phase_que
     text_now = 'Hey there PhaseQue'
     text_in_que = 'Again, Hey there PhaseQue'

     # define what happens when a function
     def register():
      """
      `register`: define what happens when a `phaseMember`
      class initiates
      """
      global r
      r = 'SLUG_ID: ABCDEFG'

     def defaultaction():
      global da
      da = print(action)

     # Build a class to establish the basic phase
     class phaseMember:
      """
      phaseMember is a class that allows you to
      add and delete instance participants
      """
      def __init__(self):
       """
       phaseMember __init__ of the dynamic usermask
       allocation and selected instance name
       """
       self.data = defaultdict(set)
       register()

      def add(self, usermask, instancename):
       """
       phaseMember: add ->
       set the 'usermask' and 'instancename' based off of the
       dynamic allocation from 'usermask_[1-n]
       '"""
       self.data[usermask].add(instancename)
       defaultaction()

      def remove(self, usermask):
       """
       phaseMember: remove ->
       unset usermask_[1-n] from the phase based off of the
      dynamic attribute provided
      """
       del self.data[usermask]

     allowed_member = phaseMember()

     # set the base instance for a resurrection
     a = 0

     def backup():
      global a
      a = allowed_member.data.copy()

     def clear():
      backup()
      allowed_member.data.clear()

     def resurrect():
      allowed_member.data = a

     # Build a class for stateful interactions
     class populatePhase:
      def __init__(self):
       self.data = defaultdict(set)

      def inspect(self, instancename):
       pass

      def post(self, usermask, vectorContent):
       pass

      def interact(self, vectorId):
       pass

     allowed_population = populatePhase()

     # Build a simple redundant-making class
     # This is on a timer, and every X seconds the phase is backed up to disk from memory
     class backupInterval:
      intervalPath = DIRDATA+CURRENT_FULLES
      tempPath = DIRDATA+TEMP_FULLES

      def __init__(self):
       self.data = defaultdict(set)
      def write():
       pass

     set_interval = backupInterval()

     class phase:
      __text__ = text_now

     message_que = phase.__text__
     manifest = []

     def clearmanifest():
      manifest.clear()

     def wrotetophase():
      with TemporaryFile('w+t') as f:
       f.write(message_que)
       f.seek(0)
       global tempdata
       tempdata = f.read()
       print(tempdata)
       f.truncate(0)
      f.close

      manifest.append(message_que)

     print('--- REGISTERING SIMULATION PHASE ---')
     print('---')
     print('--- Simulation Established with slug: ' + r)
     print('---')
     print(
      '--- STARTING: SIMULATION MEMBER PHASE' \
      'AFTER `phaseMember.add` ---'
     )
     print('---')
     allowed_member.add(usermask_1, 'pablo')
     allowed_member.add(usermask_2, 'bandit')
     print('---')
     print('--- SUMMARY: SIMULATION DATA ---')
     print('---')
     print(allowed_member.data)

     allowed_member.remove(usermask_1)
     print(
      '--- SUMMARY: SIMULATION DATA AFTER' \
      '`phaseMember.remove`---'
     )
     print('---')
     print(allowed_member.data)

     allowed_member.add(usermask_1, 'pablo')
     print('---')
     print(
      '--- STARTING: SIMULATION MEMBER PHASE' \
      'AFTER RESTORING USERMASK WITH `phaseMember.add` ---'
     )
     print(allowed_member.data)

     allowed_member.add(usermask_3, 'gemeni')
     allowed_member.add(usermask_4, 'grifter')
     allowed_member.add(usermask_5, 'anon')
     allowed_member.add(usermask_6, 'anon')

     print('---')
     print('--- SUMMARY: SIMULATION DATA ---')
     print('---')
     allowed_member.data

     # dir(allowed_member.data)

     print('---')
     print('--- SUMMARY: DOCSTRING DATA ---')
     print('---')
     print(allowed_member.__doc__)
     print(allowed_member.__init__.__doc__)
     print(allowed_member.add.__doc__)
     print(allowed_member.remove.__doc__)

     print('---')
     print('--- SUMMARY: SIMULATION DATA ---')
     print('---')
     print(allowed_member.data)

     backup()
     clear()
     print(allowed_member.data)

     a

     print(allowed_member.data)

     resurrect()

     print(allowed_member.data)

     # This is now a completed instance
     print(message_que)

     manifest

     wrotetophase()

     manifest

     wrotetophase()

     clearmanifest()

     manifest

     wrotetophase()
     wrotetophase()
     wrotetophase()

     manifest

     clearmanifest()

     manifest

class PhaseReceiverBasic:
    def __init__(self):

     class phaseone:
      __text__ = """Hey, this is a tester message."""

     phaseone
     phaseone.__text__
     message_now_a = phaseone.__text__
     message_now_a
     # Add a manifest of messages
     manifest = []
     manifest
     manifest.append(message_now_a)
     manifest
     # rewrite phase loop to auto increment 1
     # it would auto increment here

class PhaseReceiverBasicNew:
    def __init__(self):
     class phasetwo:
      __text__ = """Hey, this is a tester message."""

     phasetwo
     phasetwo.__text__
     message_now_a = phasetwo.__text__
     message_now_a
     # Setup a manifest
     manifest_two = []
     manifest_two
     manifest_two.append(message_now_a)
     manifest_two
     # rewrite phase loop to auto increment 1
     # it would auto increment here

     class phasetwo_receiver:
      manifest_two[0]

     phasetwo_receiver

     from tempfile import TemporaryFile
     with TemporaryFile('w+t') as f:
      f.write('Hello World\n')
      f.write('Testing\n')
      f.seek(0)
      data = f.read()
     f.close()



Return HOME