Skip to content

Commit

Permalink
Trying to unify questions (issue #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfursin committed Dec 16, 2014
1 parent 33fefb1 commit 1324f75
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion repo/module/index/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def clean(i):

to_delete=True
if o=='con' and i.get('force','')!='yes':
r=ck.inp({'text':'Are you sure to clean the whole index (Y/yes or N/no/Enter): '})
r=ck.inp({'text':'Are you sure to clean the whole index (y/N): '})
c=r['string'].lower()
if c!='y' and c!='yes': to_delete=False

Expand Down
15 changes: 12 additions & 3 deletions repo/module/kernel/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ def setup(i):

if not installed or param=='install':
ck.out('')
r=ck.inp({'text':'Would you like to install CK as root library (yes or no/Enter): '})
d=r['string'].lower()
if d=='yes':
r=ck.inp({'text':'Would you like to install CK as root library (y/N): '})
d=''
x=r['string'].lower()
if x=='y' or x=='yes': d='yes'

if d=='yes':
p=ck.work['env_root']
ck.out('')
ck.out('* Changing directory to '+p+' ...')
Expand Down Expand Up @@ -189,26 +191,32 @@ def setup(i):
ck.out('')
r=ck.inp({'text': 'Forbid all writing operations (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['forbid_global_writing']=d

r=ck.inp({'text': 'Forbid all delete operations (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['forbid_global_delete']=d

r=ck.inp({'text': 'Forbid adding new modules (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['forbid_writing_modules']=d

r=ck.inp({'text': 'Forbid writing to default repo (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['forbid_writing_to_default_repo']=d

r=ck.inp({'text': 'Forbid writing to local repo (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['forbid_writing_to_local_repo']=d

r=ck.inp({'text': 'Allow writing only to allowed individual repos (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['allow_writing_only_to_allowed']=d

# Developer options
Expand All @@ -222,6 +230,7 @@ def setup(i):
ck.out('')
r=ck.inp({'text': 'Use indexing (yes or Enter to keep previous)?: '})
d=r['string'].lower()
if d=='y': d=='yes'
if d!='': cfg['use_indexing']=d

# Writing/updating configuration
Expand Down
15 changes: 9 additions & 6 deletions repo/module/module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,22 @@ def add(i):
if developer_webpage=='': developer_webpage=ck.cfg['default_developer_webpage']

if len(actions)==0:
ck.out('')
act='*'
while act!='':
r=ck.inp({'text':'Add action function (or Enter to stop): '})
if act!='*': ck.out('')

r=ck.inp({'text':'Add action function (or Enter to stop): '})
act=r['string']
if act!='':
actions[act]={}

r1=ck.inp({'text':'Support web (yes or Enter to skip): '})
fweb=r1['string']
if fweb!='': actions[act]['for_web']=fweb
r1=ck.inp({'text':'Support web (y/N): '})
x=r1['string'].lower()
if x=='yes' or x=='y':
fweb='yes'
actions[act]['for_web']=fweb

r1=ck.inp({'text':'Add action description (or Enter to stop): '})
r1=ck.inp({'text':'Add action description: '})
adesc=r1['string']
if adesc!='':
actions[act]['desc']=adesc
Expand Down
63 changes: 34 additions & 29 deletions repo/module/repo/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def add(i):
(sync) - if 'yes' and type=='git', sync repo after each write operation
(quiet) - if 'yes', do not ask questions unless really needed
(skip_reusing_remote_info) - if 'yes', do not reuse remote .cmr.json description of a repository
}
Output: {
Expand Down Expand Up @@ -126,45 +128,46 @@ def add(i):
# Asking for a user-friendly name
if df!='yes' and dn=='':
if quiet!='yes':
r=ck.inp({'text':'Enter a user-friendly name of this repository (or nothing to reuse alias): '})
r=ck.inp({'text':'Enter a user-friendly name of this repository (or Enter to reuse alias): '})
dn=r['string']
if dn=='': dn=d

# Asking if remote
if df!='yes' and remote=='':
if quiet!='yes':
r=ck.inp({'text':'Is this repository a remote CK web service ("yes" or "no"/Enter)? '})
r=ck.inp({'text':'Is this repository a remote CK web service (y/N)? '})
remote=r['string'].lower()
if remote!='yes': remote=''
if remote!='yes' and remote!='y': remote=''

# Asking for a user-friendly name
if df!='yes' and remote!='yes' and udp=='':
cur_path=os.getcwd()
if quiet!='yes':
r=ck.inp({'text':'Would you like to create repo in the current path ("yes" or "no"/Enter for CK_REPOS): '})
cur_path=r['string']
if cur_path!='yes': p=os.path.join(ck.work['dir_repos'], d)
r=ck.inp({'text':'Would you like to create repo in the directory from CK_REPOS variable (Y/n): '})
x=r['string'].lower()
if x=='' or x=='yes' or x=='y':
p=os.path.join(ck.work['dir_repos'], d)

# Asking for remote url
if df!='yes' and remote=='yes' and url=='':
if quiet!='yes':
r=ck.inp({'text':'Enter URL of remote CK repo (http://localhost:3344/ck?): '})
r=ck.inp({'text':'Enter URL of remote CK repo (example: http://localhost:3344/ck?): '})
url=r['string'].lower()
if url=='':
return {'return':1, 'error':'URL is empty'}

# Asking for remote repo UOA
if df!='yes' and remote=='yes' and rruoa=='':
if quiet!='yes':
r=ck.inp({'text':'Enter remote repo UOA or Enter for nothing: '})
r=ck.inp({'text':'Enter remote repo UOA or Enter to skip: '})
rruoa=r['string'].lower()

# Asking for shared
if remote=='' and shared=='':
if quiet!='yes':
r=ck.inp({'text':'Is this repository shared ("git" or "no"/Enter)? '})
shared=r['string'].lower()
if shared!='git': shared=''
r=ck.inp({'text':'Is this repository shared through GIT (y/N)? '})
x=r['string'].lower()
if x=='yes' or x=='y':
shared='git'

# Check additional parameters if git
if shared=='git' and url=='':
Expand All @@ -180,14 +183,18 @@ def add(i):
# Check additional parameters if git
if shared=='git' and sync=='':
if quiet!='yes':
r=ck.inp({'text': 'Would you like to sync repo each time after writing to it ("yes" or "no"/Enter)?: '})
sync=r['string'].lower()
r=ck.inp({'text': 'Would you like to sync repo each time after writing to it (y/N)?: '})
x=r['string'].lower()
if x=='yes' or x=='y':
sync='yes'

# Asking for a user-friendly name
if df!='yes' and remote!='yes' and eaw=='':
if quiet!='yes':
r=ck.inp({'text':'Would you like to explicitly allow writing to this repository ("yes" or "no"/Enter): '})
eaw=r['string'].lower()
r=ck.inp({'text':'Would you like to explicitly allow writing to this repository (y/N): '})
x=r['string'].lower()
if x=='yes' or x=='y':
eaw='yes'

# Check if already registered (if not remote)
if remote!='yes':
Expand Down Expand Up @@ -230,9 +237,7 @@ def add(i):
ck.out(' UOA = '+xd)
ck.out(' User friendly name = '+xdn)
ck.out('')
r=ck.inp({'text': 'Would you like to reuse them ("yes" or "no"/Enter)?: '})
reuse=r['string'].lower()
if reuse=='yes':
if i.get('skip_reusing_remote_info','')!='yes':
d=xd
di=xdi
dn=xdn
Expand Down Expand Up @@ -374,7 +379,7 @@ def update(i):
ck.out('Current user-friendly name of this repository: '+dn)
ck.out('')

r=ck.inp({'text':'Enter a user-friendly name of this repository (or nothing to keep old value): '})
r=ck.inp({'text':'Enter a user-friendly name of this repository (or Enter to keep old value): '})
x=r['string']
if x!='':
dn=x
Expand All @@ -388,7 +393,7 @@ def update(i):
ck.out('')
ck.out('Current URL: '+url)
ck.out('')
rx=ck.inp({'text':'Enter new URL (or nothing to leave old one): '})
rx=ck.inp({'text':'Enter new URL (or Enter to leave old one): '})
x=rx['string']
if x!='':
d['url']=x
Expand All @@ -404,10 +409,10 @@ def update(i):
ck.out('')
if sync!='':
ck.out('Current sync setting: '+sync)
r=ck.inp({'text': 'Would you like to sync repo each time after writing to it (yes/no or Enter to keep old value)?: '})
r=ck.inp({'text': 'Would you like to sync repo each time after writing to it (y/N)?: '})
x=r['string'].lower()
if x!='':
d['sync']=x
if x=='yes' or x=='y':
d['sync']='yes'
changed=True

# Asking for a user-friendly name
Expand All @@ -417,10 +422,10 @@ def update(i):
if eaw!='':
ck.out('Current "allow writing" setting: '+eaw)

r=ck.inp({'text':'Would you like to allow writing to this repository ("yes" or "no"/Enter): '})
r=ck.inp({'text':'Would you like to allow writing to this repository (y/N): '})
x=r['string'].lower()
if x=='yes':
d['allow_writing']=x
if x=='yes' or x=='y':
d['allow_writing']='yes'
changed=True

# Write if changed
Expand Down Expand Up @@ -824,9 +829,9 @@ def rm(i):

to_delete=True
if o=='con' and i.get('force','')!='yes':
r=ck.inp({'text':'Are you sure to delete information about repository '+duoa+' (Y/yes or N/no/Enter): '})
r=ck.inp({'text':'Are you sure to delete information about repository '+duoa+' (y/N): '})
c=r['string'].lower()
if c!='y' and c!='yes': to_delete=False
if c!='yes' and c!='y': to_delete=False

if to_delete:
if o=='con':
Expand Down

0 comments on commit 1324f75

Please sign in to comment.