Commit 9d0623db authored by Julien Muchembled's avatar Julien Muchembled


parent e724ca50
......@@ -537,27 +537,33 @@ class NetworkcacheException(Exception):
DirectoryNotFound = UploadError = NetworkcacheException # BBB
id_help = \
"identifier used for the shadir URL"
key_help = (
"The identifier under which the data is indexed."
" Defaults to 'file-urlmd5:md5(URL)'"
def _newArgumentParser(url_help, id_help, id_required):
def _newArgumentParser(url_help, key_help, key_required):
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=argparse.FileType('r'), required=True,
help='SlapOS configuration file.')
shadir_id = parser.add_mutually_exclusive_group(required=id_required)
shadir_id.add_argument('--id', help=id_help)
shadir_id.add_argument('--url', help=url_help)
_ = parser.add_mutually_exclusive_group(required=key_required).add_argument
_('--key', help=key_help)
_('--url', help=url_help)
return parser
def cmd_upload(*args):
parser = _newArgumentParser(
"Upload data pointed to by this argument, unless --file is specified."
" Non-local contents is first downloaded to a temporary file."
"The %s will be 'file-urlmd5:md5(URL)'. If not given, the uploaded data is not indexed." % id_help,
"%s - WARNING: The identifier must be chosen carefully. Ideally, it should be a URI. It should never contain more that 1000 entries. To avoid the latter case, developpers may include the year into the identifier and make sure the client falls back to the previous years when the resource is not found." % id_help,
" Non-local contents is first downloaded to a temporary file.",
key_help + " if --url is given, else the uploaded data are not indexed."
" This should be a unique value that refers to related entries,"
" and that starts with 'SCHEME:' where SCHEME"
" indicates how (or by what) the data is processed."
" For performance reasons, avoid having too"
" many entries by making your key more specific.",
help="Upload the contents of this file, overriding --url. The %s will depend on whether --url or --id is used." % id_help)
help="Upload the contents of this file, overriding --url.")
help="Take a file containing a json-serializable dictionary with shadir metadata.")
parser.add_argument('meta', nargs='*', metavar='KEY=VALUE',
......@@ -598,9 +604,7 @@ def cmd_upload(*args):
f is None or f.close()
def cmd_download(*args):
parser = _newArgumentParser("URL of data to download. The %s will be 'file-urlmd5:md5(URL)'." % id_help,
"The %s." % id_help,
parser = _newArgumentParser("URL of data to download.", key_help, True)
parser.add_argument('meta', nargs='*', metavar='KEY{>=,<=,==,<,>,:}VALUE',
help='Filter metadata. Each argument represents a filter with a comparison condition. The filters will be applied one by one with the arguments processed in the order of appearance.VALUE is expected to be a json dump of a comparable object in Python (strings included), except when the separator is ":" (in this case VALUE must be min or max).')
args = parser.parse_args(args or sys.argv[1:])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment