Skip to content

Commit 94b9103

Browse files
committed
oslcquery can now save raw results
1 parent 2cc8849 commit 94b9103

File tree

4 files changed

+102
-55
lines changed

4 files changed

+102
-55
lines changed

elmclient/examples/REQIF_IO.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ Installation
2626

2727
The `reqif_io` command is installed in your Python scripts folder when installing `elmclient`
2828

29+
TLDR;
30+
=====
31+
32+
Here's a sequence which lists definitions, creates a new definition for a specific module, exports it to reqifz, reimports the reqifz, and then deletes the definition
33+
34+
NOTE this is so brief because it's using the defaults for server URL and context roots, username and password - see below these sections for how to set these up for your environment.
35+
NOTE this works when project `rm_optout_p1` was created using the `Systems Requirement Sample`, which has a module `AMR Stakeholder Specification`.
36+
37+
38+
```
39+
reqif_io rm_optout_p1 list
40+
reqif_io rm_optout_p1 create stk -m "AMR Stakeholder Requirements Specification"
41+
reqif_io rm_optout_p1 list
42+
reqif_io rm_optout_p1 export stk
43+
reqif_io rm_optout_p1 import stk.reqifz
44+
reqif_io rm_optout_p1 delete stk
45+
```
46+
2947

3048
Usage
3149
=====

elmclient/examples/oslcquery.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def do_oslc_query(inputargs=None):
105105
parser.add_argument('--pagesize', default=200, type=int, help="Page size for OSLC query (default 200)")
106106
parser.add_argument('--typesystemreport', default=None, help="Load the specified project/configuration and then produce a simple HTML type system report of resource shapes/properties/enumerations to this file" )
107107
parser.add_argument('--cachedays', default=1,type=int, help="The number of days for caching received data, default 1. To disable caching use -WW. To keep using a non-default cache period you must specify this value every time" )
108+
parser.add_argument('--saverawresults', default=None, help="Save the raw results as XML to this path/file prefix - pages are numbered starting from 0000" )
109+
parser.add_argument('--saveprocessedresults', default=None, help="Save the processed results as JSON to this path/file" )
108110

109111
# saved credentials
110112
parser.add_argument('-0', '--savecreds', default=None, help="Save obfuscated credentials file for use with readcreds, then exit - this stores jazzurl, jts, appstring, username and password")
@@ -456,6 +458,7 @@ def do_oslc_query(inputargs=None):
456458
,pagesize=args.pagesize
457459
,resolvenames = args.resolvenames
458460
,totalize=args.totalize
461+
,saverawresults=args.saverawresults
459462
)
460463

461464
if args.debugprint:
@@ -509,6 +512,9 @@ def safeint(s,nonereturns=0):
509512

510513
resultsentries = "entries" if len(results.keys())!=1 else "entry"
511514

515+
if args.saveprocessedresults:
516+
open(args.saveprocessedresults+"_before.json","wt").write(json.dumps(results))
517+
512518
print( f"Query result has {len(results.keys())} {resultsentries}" )
513519

514520
# COMPARE IS UNTESTED!
@@ -557,6 +563,9 @@ def safeint(s,nonereturns=0):
557563
writer.writeheader()
558564
for k, v in results.items():
559565
writer.writerow(v)
566+
567+
if args.saveprocessedresults:
568+
open(args.saveprocessedresults+"_after.json","wt").write(json.dumps(results))
560569

561570
if args.compareresults:
562571
# a simple test by comparing the received results with a saved CSV from a previous run
@@ -619,7 +628,7 @@ def safeint(s,nonereturns=0):
619628
print( f"{len(results.keys())} results and {args.nresults} expected - Passed :-)" )
620629

621630
if args.xmloutputfile is not None:
622-
631+
# retrieve all resources in the results to XML
623632
# ensure output folder exists
624633
args.xmloutputfile = os.path.abspath(args.xmloutputfile)
625634
outputpath = os.path.split(args.xmloutputfile)[0]

elmclient/examples/reqif_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def reqif_main():
108108
parser_create.add_argument('-s', '--description', default="-", help="Description for the definition")
109109
parser_create.add_argument('-t', '--tags', action="store_false", help="Don't include tags in the reqif (defaults to including) - if you need this off, specify it on the last update or on the create")
110110
parser_create.add_argument('-u', '--update', action="store_true", help="Update the named definition by adding things - it must already exist!")
111-
# NIY parser_create.add_argument('-p', '--publicviews', nargs='*', default=[], help='* or CSL of public view names')
112-
# NIY parser_create.add_argument('-v', '--moduleviews', nargs='*', default=[], help='* or CSL of module view names')
111+
# TODO: NIY parser_create.add_argument('-p', '--publicviews', nargs='*', default=[], help='* or CSL of public view names')
112+
# TODO: NIY parser_create.add_argument('-v', '--moduleviews', nargs='*', default=[], help='* or CSL of module view names')
113113

114114
parser_delete.add_argument('definitionnames',nargs='*',default=[],help='One or more names of export definitions to delete - this can be a regex where . matches any character, etc. If you want the regex to match a complete name put ^ at the start and $ at the end')
115115
parser_delete.add_argument('-n', '--noconfirm', action='store_true', help="Don't prompt to confirm each delete (DANGEROUS!)")

0 commit comments

Comments
 (0)