Skip to content

Commit

Permalink
ReadmeClass: Add interactive option
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed May 5, 2021
1 parent 21ec56e commit d78d44e
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions ldcoolp/curation/inspection/readme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ class ReadmeClass:
"""

def __init__(self, dn, config_dict=config_default_dict, update=False,
q: Qualtrics = None, log=None):
q: Qualtrics = None, interactive=True, log=None):
self.config_dict = config_dict
self.interactive = interactive

self.dn = dn
self.folderName = self.dn.folderName
Expand Down Expand Up @@ -180,8 +181,12 @@ def check_for_readme(self):
self.log.info("Only one README file found!")

self.log.info("PROMPT: Type 'Yes'/'yes' if you wish to use as template.")
src_input = input("PROMPT: Anything else will use 'default' : ")
self.log.info(f"RESPONSE: {src_input}")
if self.interactive:
src_input = input("PROMPT: Anything else will use 'default' : ")
self.log.info(f"RESPONSE: {src_input}")
else:
self.log.info("Interactive mode disabled. Using default")
src_input = ''

if src_input.lower() == 'yes':
template_source = 'user'
Expand Down Expand Up @@ -411,17 +416,22 @@ def main(self):
self.log.info("")
self.log.info("** STARTING README.txt CONSTRUCTION **")

if self.template_source != 'unknown':
self.log.info("PROMPT: Do you wish to create a README file?")
user_response = input("PROMPT: Type 'Yes'/'yes'. Anything else will exit : ")
self.log.info(f"RESPONSE: {user_response}")
if user_response.lower() == "yes":
self.construct()
if self.interactive:
if self.template_source != 'unknown':
self.log.info("PROMPT: Do you wish to create a README file?")
user_response = input("PROMPT: Type 'Yes'/'yes'. Anything else will exit : ")
self.log.info(f"RESPONSE: {user_response}")
else:
self.log.warn("Exiting script")
return
self.log.warn(f"Multiple README files. Unable to save {self.readme_template} and README.txt")
else:
self.log.info("Interactive mode disabled. Always creating README.txt")
user_response = 'yes'

if user_response.lower() == "yes":
self.construct()
else:
self.log.warn(f"Multiple README files. Unable to save {self.readme_template} and README.txt")
self.log.warn("Exiting script")
return


def walkthrough(data_path, ignore='', log=None):
Expand Down

0 comments on commit d78d44e

Please sign in to comment.