core_modify
"""
Copyright (C) 2020 New Entity Operations Inc.
ALL RIGHTS RESERVED
core_modify allows you to perform basic read/write operations in C.ORE
"""
## Imports: Custom
from core_middlelayer import (
COREES, DIRDATA
)
class Scope:
"""
Modify an entry 'Scope' based off of variousu defined routines
There are two types of values:
1. global
2. local
'global' interacts with the 'CONSTRUCTED_core.es'
'CONSTRUCTED_core.es' is the compiled combination of all 'core.es'
'local' interacts with the 'core.es'
'core.es' doesn't leave your machine
Right now, only exact full-line matching is supported
The feature is meant to be built upon by the operator
"""
# Two part replacement logic
Replace_Core_Value = input("What core entry would you like to modify?: ")
Replace_Core_W_This = input("What would you like to replace this entry with?: ")
# global logic
def modify_global():
"""
Modify a CONSTRUCTED_core.es entry
"""
GLOBAL_file_to_modify = DIRDATA+CONSRUCTEDCOREES
with open(GLOBAL_file_to_modify, 'rt') as f:
data = f.read()
data = data.replace(Replace_Core_Value, Replace_Core_W_This)
f.close()
with open(GLOBAL_file_to_modify, 'wt') as f:
f.write(data)
f.close()
# local logic
def modify_local():
"""
Modify a core.es entry
"""
LOCAL_file_to_modify = DIRDATA+COREES
with open(LOCAL_file_to_modify, 'rt') as f:
data = f.read()
data = data.replace(Replace_Core_Value, Replace_Core_W_This)
f.close()
with open(LOCAL_file_to_modify, 'wt') as f:
f.write(data)
f.close()
Return HOME