Closed tanay1337 closed 7 years ago
On it
is there really a need to import profile in start? I dont see any reference in start.py
here is another alternative, but more complex from than deleting that print line
# on profile.py
# - move load_profile func to new file name e.g. profile_loader.py (see the change belowe)
# .... import package
from profile_loader import load_profile
data = {}
if len(data) == 0:
data = load_profile()
# on profile_loader.py
# .... import other package
from profile_populator import profile_populator
def load_profile(skip_message=False):
if not skip_message:
print("Loading profile data")
if not os.path.isfile('profile.json'):
profile_populator()
profile_json = open('profile.json')
data = json.load(profile_json, object_hook=jd.decode_dict)
profile_json.close()
return data
any from both file can import profile_loader
and run load_profile(skip_message=True)
, to skip the message
so instead of profile.data
, use data = load_profile(); data
.
advantage of this
profile.py
. afaik no module use load_profile
func directly from that profile
moduleprofile
module is only simple script, a single global variable. load_profile
func dont have to connect directly to global variable.edit: add load_profile
usage
edit2: not use function inside of function
Yes, @rachmadaniHaryono's implementation seems a better solution instead of deleting that print statement. Feel free to pick this issue up guys!
if anyone want to pick this, please check if there is any race condition of profile creation between start.py
and main.py
.
anyone working on this? @aniketk21 @vedmathai @tanay1337 @rosskyl
Go ahead @rachmadaniHaryono!
I would like to take up this issue @tanay1337 @rachmadaniHaryono
OK @lakshmanaram, you can take it.
When running
python main.py
, we get the messageLoading profile data
twice which needs to be resolved.