core_creator
"""
Copyright (C) 2020 New Entity Operations Inc.
ALL RIGHTS RESERVED
core_creator allows you to create a .entity/.ds relationship in text-mode and system routines
for modules running within C.ORE that rely on add/edit/delete methodology
"""
## Imports: Standard
from pathlib import (
Path,
)
from shutil import (
rmtree,
)
## Imports: Custom
from core_middlelayer import (
ENTITYSLUG,
DATASHEETFOLDER, EXTDS, EXTENTITY, LINEBLANK,
DATASHEETNAME, DATASHEETKEY,
ENTITYTITLE, ENTITYINDEX, ENTITYIDENTIFIER,
PTYPE, VIRTUALPACKAGEID,
DATASCRIPTMODULE, INCLUDEDMODULE,
chosen_entity_path,
ACCESSPATH, MASTERLISTPATH, MEMBERPATH,
INSTALLED, CONTEXTENGINE, CONTROLS, VIRTUALPACKAGE,
SLUG_LL_FULL, SLUG_LL, LLES, KEY_LL_PLAIN, KEY_LLB_PLAIN,
SLUG_LLB_FULL, SLUG_LLB_COMPACT, SLUG_LLB, LLBES,
DASH_UTIL,
RING_KEY_LOCATION
)
#class CREATOR_ENTITY_OPTIONS:
# """
# This can be used to go through an exact input format. Utility behind inputs
# will continue over time.
# """
# global chosen_entity_path
#
# def entity_form():
# def summarize():
# print("-------------------------------------------------")
# print("ENTITY: "+ENTITYTITLE)
# print(DATASHEETNAME)
# print(DATASHEETKEY)
# print(ENTITYTITLE)
# print(PTYPE)
# print(VIRTUALPACKAGEID)
# print(ENTITYINDEX)
# print(ENTITYIDENTIFIER)
# print(DATASCRIPTMODULE)
# print(INCLUDEDMODULE)
# print("-------------------------------------------------")
#
# def run_creator():
# global datasheet_name
# global datasheet_key
# global title
# global ptype
# global package_id
# global index
# global identifier_type
# global datascript_module
# global included_module
# # Define your input questions for the exact format.
# datasheet_name = input(DATASHEETNAME)
# datasheet_key = input(DATASHEETKEY)
# title = input(ENTITYTITLE)
# ptype = input(PTYPE)
# package_id = input(VIRTUALPACKAGEID)
# index = input(ENTITYINDEX)
# identifier_type = input(ENTITYIDENTIFIER)
# datascript_module = input(DATASCRIPTMODULE)
# included_module = input(INCLUDEDMODULE)
# global generated_template
# generated_template = LINEBLANK+datasheet_name+EXTDS+\
# " - KEY::: ""'"+datasheet_key+"'"+\
# "\n \n# Entity Snapshot\ndatascript_id = ['"+datasheet_key+\
# "']\ntitle = ['"+title+"']\n \n# Package Snapshot\npackage_type = ['"+ptype+\
# "']\npackage_id = ['"+package_id+\
# "']\n \n# Directory List-file\nDLIST = ['"+datasheet_name+\
# ".ds']\n \n# Index-List\nINDEX = ["+index+\
# "]\n \n# Identifier Overview\nidentifier_type = [\n"+identifier_type+\
# "\n]\n \n# Datascript Module Context\ndatascript_module = [\n"+datascript_module+\
# "\n]\n \n# INCLUDE - Additional modules that were included \ninclude_module = [\n"+\
# included_module+"\n]\n"
# # Append to - won't skip a line
# with open(ENTITYSLUG+chosen_entity_path+
# ext_path+datasheet_name+EXTENTITY, 'x+') as f:
# f.write(str(generated_template))
# f.close()
# with open(ENTITYSLUG+chosen_entity_path+ext_path+
# DATASHEETFOLDER+datasheet_name+EXTDS, 'x+') as f:
# f.write(str(index))
# f.close()
#
# summarize()
#
# global chosen_entity_path
#
# # If you don't want to modify/create something, 0 will pass to the loops end.
# ENTITY_Add = int(input(
# "Would you like to add a New Entity? (1) for Yes - (0) for No"
# ))
# if ENTITY_Add == 0:
# pass
# # If you want to create something, 1 will bring you into the creator.
# elif ENTITY_Add == 1:
# # Setup your global to export the chosen_entity_path at the end of the loop.
# # All standard options can be configured automatically at the end of this
# # block will take you to the manual setting. Exact adherence to the structure is
# # required for operations until regex is used to clean the inputs
# # If you want to fall back to your automation routine, select 1
# # Else, if you want to adhere to the format, select 0 and proceed.
# auto_add = int(input(
# "Would you like to automate this process? : (1) for Yes - (0) for No"
# ))
# if auto_add == 0:
# MEMBERPATH = ACCESSPATH+MASTERLISTPATH
# # Establish the base folders here
# ext_path_context = INSTALLED+CONTEXTENGINE
# ext_path_controls = INSTALLED+CONTROLS
# ext_path_virtual_package = INSTALLED+VIRTUALPACKAGE
# # Ask the questoin that states the creator
# entity_type_selector = input(
# "Would you like to generate this process for... :" \
# "(a) for Alias OR " \
# "{for ENTITY: (b) Context - (c) Figments - (d) Human -" \
# "(e) Alias}?"
# )
# # This doesn't run_program()
# if entity_type_selector == 'a':
# alias_type_selector = input("What are you doing?" \
# " : (a) for Add MEMBER- (b) for Modify your VCN Alias List (VCN)"
# )
# # Outline relevant access lists
# chosen_member_path = MEMBERPATH
# member_file = MEMBERFILE
# ext_path = chosen_member_path+member_file
# # Start your game-logic
# if alias_type_selector == 'a':
# # make sure Alias writes to the correct folder
# print('Add Memberto: '+ext_path)
# # The rest of the routine logic goes here to write the member in, but will
# # require you to enter admin password on your machine to make the file
# # writeable, which requires it to be unmuted.
# elif alias_type_selector == 'b':
# print('Modify VCN Alias List (VCN) at location: '+
# ext_path
# )
# # The rest of the modify logic loop would go here. Which follows a similar pattern
# # from above.
# else:
# print('Please, only (a) or (b)')
#
# elif entity_type_selector == 'b':
# alias_type_selector = input("What type of entity are you creating?" \
# " : (a) Context Engine - (b) Controller - (c) Virtual Package"
# )
#
# chosen_entity_selector = 'INSTALLED/'
# if alias_type_selector == 'a':
# ext_path = 'CONTEXT_ENGINE'
# print('Creating a Context Engine at path: '+chosen_entity_path+ext_path_context)
# self.run_creator()
# elif alias_type_selector == 'b':
# ext_path = 'CONTROLS/'
# print('Creating Controls at path: '+chosen_entity_path+ext_path_controller)
# self.run_creator()
# elif alias_type_selector == 'c':
# ext_path = 'VIRTUAL_PACKAGE/'
# print('Creating a Virtual Package at path: '+
# chosen_entity_path+ext_path_virtual_package
# )
# self.run_creator()
# else:
# print('Please, only (a), (b), or (c)')
#
# elif entity_type_selector == 'c':
# alias_type_selector = input("What are you doing?" \
# ": a for Quick Format - b for Staging"
# )
# chosen_entity_path = 'FIGMENTS/'
# if alias_type_selector == 'a':
# ext_path = 'QUICK_FORMAT/'
# # print('Add a Quick format datasript sheet.')
# self.run_creator()
# elif alias_type_selector == 'b':
# ext_path = 'STAGING/'
# # print('Add a datascript sheet to staging.')
# self.run_creator()
# else:
# print('Please, only (a) or (b)')
#
# elif entity_type_selector == 'd':
# alias_type_selector = input("What type of Human are you adding?" \
# "a for Contact - b for Ficticious - c for a Person"
# )
# chosen_entity_path = 'HUMAN/'
# if alias_type_selector == 'a':
# ext_path = 'CONTACT/'
# # print('Add contact sheet')
# run_creator()
# elif alias_type_selector == 'b':
# ext_path = 'FICTICIOUS/'
# # print('Add a ficticious character sheet')
# run_creator()
# elif alias_type_selector == 'c':
# ext_path = 'PERSON/'
# # print('Add a personal contact sheet')
# run_creator()
# else:
# print('Please, only (a), (b), or (c)')
#
# # This doesn't run_program()
# elif entity_type_selector == 'e':
# alias_type_selector = input("Are you creating an aliased file type?" \
# "(a) Masked (b) VCN_KEY"
# )
# chosen_entity_path = 'ALIAS/'
# if alias_type_selector == 'a':
# ext_path = 'MASKED_MASTER/'
# print("Selected Masked creation")
# elif alias_type_selector == 'b':
# ext_path = "VCN_DIRECTORY/"
# print("Selected VCN Creation")
# else:
# print('Please, only (a) or (b)')
#
# # fallback block
# # Automation Block: Blank for the time being
# elif auto_add ==1:
# pass
# else:
# # If you put in anything else you'll fall into the else block and
# # restart
# print("Please, only 0 or 1")
class LockerLink:
def create_LockerLink(a, b, c, d, e, f, g, h, i, j, k):
no_spaces_a = a.replace(" ", "-")
no_caps_a = no_spaces_a.lower()
no_spaces_a = no_caps_a.replace("'", "")
no_quotes_a = no_spaces_a.replace("\"", "")
try:
Path(SLUG_LL_FULL+no_quotes_a).mkdir(exist_ok=False,
parents=True
)
with open(SLUG_LL_FULL+no_quotes_a+DASH_UTIL+\
LLES, 'w'
) as LL_s:
LL_s.write(
'TITLE: '+a+'\n'+\
'LL1: '+b+'\n'+\
'LL2: '+c+'\n'+\
'LL3: '+d+'\n'+\
'LL4: '+e+'\n'+\
'LL5: '+f+'\n'+\
'LL6: '+g+'\n'+\
'LL7: '+h+'\n'+\
'LL8: '+i+'\n'+\
'LL9: '+j+'\n'+\
'LL10: '+k+'\n'+\
'features: https-only'+'\n'+\
'DIRECTORY: '+'LL'+no_quotes_a
)
LL_s.close()
except:
print("Directory Exists")
def edit_LockerLink(a, b, c, d, e, f, g, h, i, j, k, SLUG_current_LockerLink):
no_spaces_a = a.replace(" ", "-")
no_caps_a = no_spaces_a.lower()
no_spaces_a = no_caps_a.replace("'", "")
no_quotes_a = no_spaces_a.replace("\"", "")
try:
Path(SLUG_LL_FULL+no_quotes_a).mkdir(exist_ok=False,
parents=True
)
with open(SLUG_LL_FULL+no_quotes_a+DASH_UTIL+LLES, 'w') as LL_s:
LL_s.write(
'TITLE: '+a+'\n'+\
'LL1: '+b+'\n'+\
'LL2: '+c+'\n'+\
'LL3: '+d+'\n'+\
'LL4: '+e+'\n'+\
'LL5: '+f+'\n'+\
'LL6: '+g+'\n'+\
'LL7: '+h+'\n'+\
'LL8: '+i+'\n'+\
'LL9: '+j+'\n'+\
'LL10: '+k+'\n'+\
'features: https-only'+'\n'+\
'DIRECTORY: '+'LL'+no_quotes_a
)
rmtree(SLUG_LLB_COMPACT+SLUG_current_LockerLink)
LL_s.close()
except:
print("Directory Exists")
class LockerLink_BrowseMeh:
def create_LockerLink_BrowseMeh(NEW_LLB_TITLE, SLUG_LLB_BrowseMeh):
no_spaces_title = NEW_LLB_TITLE.replace(" ", "-")
no_caps_title = no_spaces_title.lower()
no_quote_strings_title = no_caps_title.replace("'", "")
no_quotes_title = no_quote_strings_title.replace("\"", "")
try:
Path(SLUG_LLB_FULL+no_quotes_title).mkdir(exist_ok=False,
parents=True
)
with open(SLUG_LLB_FULL+\
no_quotes_title+DASH_UTIL+LLBES, 'w') as LLB_s:
LLB_s.write(
'TITLE: '+NEW_LLB_TITLE+'\n'+\
'features: local-only'+'\n'+\
'DIRECTORY: '+'LLB'+no_quotes_title+'\n'+\
'QUALITY: none'+'\n'+\
'TOKEN_ID: 0'+'\n'+\
'CATEGORY_SET_RANK: (0,0)'+'\n'+\
'CATEGORY_SET_CHARACTER: (0,0)'+'\n'+\
SLUG_LLB_BrowseMeh+'\n'
)
LLB_s.close()
except:
print("Directory Exists")
return("Directory Exists")
def LLB_destroy(DESTROY_THIS_LLB):
try:
rmtree(SLUG_LLB_COMPACT+DESTROY_THIS_LLB)
print("LLB DESTROY: "+DESTROY_THIS_LLB)
except:
print("Nothing was found...")
return("Nothing was found...")
def LLB_treeswap(DESTROY_THIS_LLB_TREE, NEW_LLB_TITLE, SLUG_LLB_BrowseMeh):
SWAP_ME = DESTROY_THIS_LLB_TREE
try:
rmtree(SLUG_LLB_COMPACT+DESTROY_THIS_LLB_TREE)
print(KEY_LLB_PLAIN+" SWAP STARTED: "+DESTROY_THIS_LLB_TREE)
try:
Path(SLUG_LLB_COMPACT+SWAP_ME).mkdir(exist_ok=False,
parents=True
)
with open(SLUG_LLB_COMPACT+SWAP_ME+DASH_UTIL+\
LLBES, 'w') as LLB_s:
LLB_s.write(
'TITLE: '+NEW_LLB_TITLE+'\n'+\
'features: local-only'+'\n'+\
'DIRECTORY: '+'LLB'+no_quotes_title+'\n'+\
'QUALITY: none'+'\n'+\
'TOKEN_ID: 0'+'\n'+\
'CATEGORY_SET_RANK: (0,0)'+'\n'+\
'CATEGORY_SET_CHARACTER: (0,0)'+'\n'+\
SLUG_LLB_BrowseMeh+'\n'
)
LLB_s.close()
except:
print("LLB_treeswap: State Error")
except:
print("Nothing was found to SWAP/overwrite...")
return("Nothing was found to SWAP/overwrite...")
Return HOME