reverse nowrite option
This commit is contained in:
@@ -87,6 +87,10 @@ def list_folders(shares,config):
|
||||
|
||||
def add_share(shares, config, opts):
|
||||
|
||||
# Make name and path safe:
|
||||
opts.name = opts.name.decode('ascii','replace').replace(u'\uFFFD','_')
|
||||
opts.path = opts.path.decode('ascii','replace').replace(u'\uFFFD','_')
|
||||
|
||||
# check for share name exists already
|
||||
for share in shares:
|
||||
if share['name'] == opts.name:
|
||||
@@ -136,7 +140,7 @@ def add_share(shares, config, opts):
|
||||
print("Add share: %s"%( opts.name, ))
|
||||
check_login(share, config)
|
||||
else:
|
||||
print("Share not saved anywhere. Save with -w")
|
||||
print("Share not saved anywhere.")
|
||||
|
||||
|
||||
|
||||
@@ -165,6 +169,9 @@ def check_login(share, config):
|
||||
|
||||
def modify_share(shares, config, opts):
|
||||
|
||||
# Make name safe:
|
||||
opts.name = opts.name.decode('ascii','replace').replace(u'\uFFFD','_')
|
||||
|
||||
print("Modifying share: %s"%( opts.name, ))
|
||||
found = False
|
||||
for i,share in enumerate(shares):
|
||||
@@ -180,7 +187,7 @@ def modify_share(shares, config, opts):
|
||||
print('no such share')
|
||||
sys.exit(1)
|
||||
if opts.path != None:
|
||||
share['path'] = opts.path
|
||||
share['path'] = opts.path.decode('ascii','replace').replace(u'\uFFFD','_')
|
||||
for attr in ('public','upload','direct_links','overwrite'):
|
||||
if getattr(opts,attr) != None:
|
||||
share[attr] = getattr(opts,attr) == 'true'
|
||||
@@ -241,8 +248,7 @@ def modify_share(shares, config, opts):
|
||||
with open(shares_file,'wt') as fp:
|
||||
json.dump(shares, fp, indent = 2, sort_keys = True)
|
||||
print("Wrote file %s"%(shares_file,))
|
||||
else:
|
||||
print("Share not saved anywhere. Save with -w")
|
||||
|
||||
modified = []
|
||||
for key in share:
|
||||
if not key in orig_share:
|
||||
@@ -256,6 +262,8 @@ def modify_share(shares, config, opts):
|
||||
modified.append(key)
|
||||
print("Modified values: %s"%(", ".join(modified)))
|
||||
print(json.dumps(share, indent = 2, sort_keys = True))
|
||||
if not opts.write:
|
||||
print("Share not saved anywhere.")
|
||||
|
||||
|
||||
def remove_share(shares,config,opts):
|
||||
@@ -505,8 +513,8 @@ def parse_options():
|
||||
parser_add.add_argument('-r','--recipient', action="store", dest="recipient", default = "",
|
||||
help= "Recipient for notifications (if enabled)"
|
||||
)
|
||||
parser_add.add_argument('-w','--write', action="store_true", dest="write", default = False,
|
||||
help = "Write changes to the shares.json file"
|
||||
parser_add.add_argument('--dry', action="store_false", dest="write", default = True,
|
||||
help = "Do not write changes to the shares.json file"
|
||||
)
|
||||
## Modify
|
||||
parser_modify = subparsers.add_parser('modify', help = "Modify share")
|
||||
@@ -539,8 +547,8 @@ def parse_options():
|
||||
parser_modify.add_argument('--remove-token', action="append", dest="remove_tokens", default = [],
|
||||
help= "Remove REST tokens, may be issued multiple times"
|
||||
)
|
||||
parser_modify.add_argument('-w','--write', action="store_true", dest="write", default = False,
|
||||
help = "Write changes to the shares.json file"
|
||||
parser_modify.add_argument('--dry', action="store_false", dest="write", default = True,
|
||||
help = "Do not write changes to the shares.json file"
|
||||
)
|
||||
## REST
|
||||
parser_rest = subparsers.add_parser('rest', help = "Display REST API links")
|
||||
|
||||
Reference in New Issue
Block a user