def purge(opts):
old = False<EOL>try:<EOL><INDENT>environment = Environment.load(opts['<STR_LIT>'], opts['<STR_LIT>'])<EOL><DEDENT>except DatacatsError:<EOL><INDENT>environment = Environment.load(opts['<STR_LIT>'], opts['<STR_LIT>'], data_only=True)<EOL>if get_format_version(environment.datadir) == <NUM_LIT:1>:<EOL><INDENT>old = True<EOL>environment = Environment.load(opts['<STR_LIT>'], opts['<STR_LIT>'], allow_old=True)<EOL><DEDENT><DEDENT>if not opts['<STR_LIT>'] and not old:<EOL><INDENT>environment.require_valid_site()<EOL><DEDENT>sites = [opts['<STR_LIT>']] if not opts['<STR_LIT>'] else environment.sites<EOL>if not opts['<STR_LIT>']:<EOL><INDENT>y_or_n_prompt('<STR_LIT>')<EOL><DEDENT>environment.stop_ckan()<EOL>environment.stop_supporting_containers()<EOL>environment.purge_data(sites)<EOL>if opts['<STR_LIT>']:<EOL><INDENT>if environment.target:<EOL><INDENT>rmtree(environment.target)<EOL><DEDENT>else:<EOL><INDENT>DatacatsError(("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"))<EOL><DEDENT><DEDENT>
Purge environment database and uploaded files

Usage:
  datacats purge [-s NAME | --delete-environment] [-y] [ENVIRONMENT]

Options:
  --delete-environment   Delete environment directory as well as its data, as
                         well as the data for **all** sites.
  -s --site=NAME         Specify a site to be purge [default: primary]
  -y --yes               Respond yes to all prompts (i.e. force)

ENVIRONMENT may be an environment name or a path to an environment directory.
Default: '.'