GRAPHIC: New Entity Operations™ Alpha Logo

EntityScript



ingest_commands




# -*- coding: utf-8 -*-
"""
COPYRIGHT (C) 2020-2023 NEW ENTITY OPERATIONS INC. ALL RIGHTS RESERVED
INSTANCE: OPENPACKAGER-> internal-> ingest_commands
MODIFIED: 2023/05/31
OVERVIEW: ingest_commands translates 'DigitalTransactionObject' class code
 into an parse-ready object

"""
__version__ = "0.0.6"
__author__ = "New Entity Operations Inc."
__copyright__ = "Copyright (C) 2020-2023 New Entity Operations Inc."
__credits__ = ["New Entity Operations Inc.", "Ryan McKenna"]
__email__ = "Operator@NewEntityOperations.com"
__license__ = "New Entity License"
__maintainer__ = "Ryan McKenna"
__status__ = "Production"

## MODE-> facilities
from MODE.facilities import (Creader, oFo, PATH_INSTANCE, SDT)

## Imports: Custom
from core_middlelayer import (DIRDATA, SLUG_BLOB_OBJECT, OVD)

## Vectorize output data
class Vectorize:
 """
 Vectorize allows you to define a data* format and seek various raw values
 from a blob and convert them to a structured data-format, such ad DTO
 You can extend the seek-criteria, but the basic ones let you build a
 structured data-type by_key, and by defining a amount of 
 """
 ## retrieval by key
 def dataDTO(by_key, header_fields):
  """
  Vectorize a DTO data-object from a injested value
  """
  with open(PATH_INSTANCE+DIRDATA+OVD, oFo.write) as file:
   with open(PATH_INSTANCE+SLUG_BLOB_OBJECT, oFo.read) as slugs:
    CREADER = Creader(slugs)
    print("SLUGS-> instance: "+str(CREADER))
    ROW_NOW = 1
    COLUMN_OBJECT = []
    for i in CREADER:
     ## Pass all header values based on the provided header length
     if ROW_NOW < header_fields:
      pass
     else:
      if ROW_NOW == by_key+header_fields:
       COLUMN_OBJECT.append(i)
      else:
       ROW_NOW = ROW_NOW+1
    try:
     print("Z-> object: "+str(COLUMN_OBJECT[0]))
     ## Build the Z Fields
     ZFields_0=COLUMN_OBJECT[0][0]
     ZFields_1=COLUMN_OBJECT[0][1]
     ZFields_2=COLUMN_OBJECT[0][2]
     ZFields_3=COLUMN_OBJECT[0][3]
     ZFields_4=COLUMN_OBJECT[0][4]
     ZFields_5=COLUMN_OBJECT[0][5]
     ZFields_6=COLUMN_OBJECT[0][6]
     ## Assemble the DTO
     ZFields = DigitalTransactionObject(id=ZFields_0, code=ZFields_1,
      payment_origin=ZFields_2, description=ZFields_3, amount=ZFields_4,
      datetime_then=ZFields_5, to=ZFields_6)
     file.write(str(ZFields))
    except IndexError:
     print("No Z-object was located in your search.")
   slugs.close()
  file.close()

class DigitalTransactionObject:
 def __init__(self, id, code, payment_origin, description, amount,
  datetime_then, to):
  self.id = id
  self.code = code
  self.payment_origin = payment_origin
  self.description = description
  self.amount = amount
  self.datetime_then = datetime_then
  self.to = to

 def __str__(self):
  return(SDT).format(self=self,
   a=SDT[0],
   b=SDT[1],
   c=SDT[2],
   d=SDT[3],
   e=SDT[4],
   f=SDT[5],
   g=SDT[6])

 def __repr__(self):
  return(SDT).format(self=self,
   a=SDT[0],
   b=SDT[1],
   c=SDT[2],
   d=SDT[3],
   e=SDT[4],
   f=SDT[5],
   g=SDT[6])



Return HOME