Skip to content

Commit

Permalink
Collection size report: add --quasi-xml option
Browse files Browse the repository at this point in the history
For use on environments that have collections or data objects
that are not supported by the default parser.
  • Loading branch information
stsnel committed Feb 19, 2024
1 parent 06aa165 commit 855b5fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ optional arguments:
Shows a report of the size of all data objects in a (set of) collections.
```
usage: yreport_collectionsize [-y {1.7,1.8,1.9}] [--help] [-h] [-r] [-R]
usage: yreport_collectionsize [-y {1.7,1.8,1.9}] [--help] [-q] [-h] [-r] [-R]
[-g GROUP_BY]
(-c COLLECTION | -H | -C COMMUNITY)

Expand All @@ -263,6 +263,8 @@ optional arguments:
-y {1.7,1.8,1.9}, --yoda-version {1.7,1.8,1.9}
Override Yoda version on the server
--help show help information
-q, --quasi-xml Enable Quasi-XML parser in order to be able to parse
characters not supported by regular XML parser
-h, --human-readable Show sizes in human readable format, e.g. 1.0MB
instead of 1000000
-r, --count-all-replicas
Expand Down Expand Up @@ -290,7 +292,6 @@ optional arguments:
Show total size of data objects in each research and
vault collection in a Yoda community. Note: you will
only see the collections you have access to.

```
### yreport\_dataobjectspercollection
Expand Down
14 changes: 10 additions & 4 deletions yclienttools/reportsize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import humanize
import csv
import sys
from irods.message import (XML_Parser_Type, ET)
from irods.models import Collection, User, UserMeta
from yclienttools import session, common_args, exceptions
from yclienttools import session as s, common_args, common_config, exceptions
from yclienttools.common_queries import collection_exists, get_collection_size
from yclienttools.options import GroupByOption

Expand All @@ -14,9 +15,12 @@ def entry():
'''Entry point'''
try:
args = _get_args()
s = session.setup_session(args.yoda_version)
report_size(args, s)
s.cleanup()
yoda_version = args.yoda_version if args.yoda_version is not None else common_config.get_default_yoda_version()
session = s.setup_session(yoda_version)
if args.quasi_xml:
ET(XML_Parser_Type.QUASI_XML, session.server_version)
report_size(args, session)
session.cleanup()
except KeyboardInterrupt:
print("Script interrupted by user.\n", file=sys.stderr)

Expand All @@ -35,6 +39,8 @@ def _get_args():
parser = argparse.ArgumentParser(description=__doc__, add_help=False)
common_args.add_default_args(parser)
parser.add_argument('--help', action='help', help='show help information')
parser.add_argument("-q", "--quasi-xml", default=False, action='store_true',
help='Enable Quasi-XML parser in order to be able to parse characters not supported by regular XML parser')
parser.add_argument('-h', '--human-readable', action='store_true', default=False,
help="Show sizes in human readable format, e.g. 1.0MB instead of 1000000")
parser.add_argument("-r", '--count-all-replicas', action='store_true', default=False,
Expand Down

0 comments on commit 855b5fa

Please sign in to comment.