Skip to content

Commit 3ee5867

Browse files
committed
Filter by bundle
1 parent a0257b8 commit 3ee5867

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

getBitstreams.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def main():
3838
parser.add_argument('-f', '--formats', nargs='*',
3939
help='optional list of bitstream formats. will return all formats if not provided')
4040

41+
parser.add_argument('-b', '--bundles', nargs='*',
42+
help='optional list of bundles (e.g. ORIGINAL or LICENSE). will return all bundles if not provided')
43+
4144
parser.add_argument('-dl', '--download', action='store_true',
4245
help='download bitstreams (rather than just retreive metadata about them). default: false')
4346

@@ -74,10 +77,10 @@ def main():
7477
else:
7578
print('Accessing Stage')
7679

77-
if args.rtimeout:
80+
if not args.rtimeout:
7881
args.rtimeout = default_response_timeout
7982

80-
if args.limit:
83+
if not args.limit:
8184
args.limit = default_limit
8285

8386
if not args.baseURL:
@@ -111,6 +114,11 @@ def main():
111114
else:
112115
print('returning bitstreams of any format')
113116

117+
if args.bundles:
118+
print('filtering results to the following bundles: {}').format(args.bundles)
119+
else:
120+
print('returning bitstreams from any bundle')
121+
114122
if args.download:
115123
print('downloading bitstreams')
116124

@@ -190,7 +198,8 @@ def processItem(dsObject, args):
190198
bitstreams.raise_for_status() # ensure we notice bad responses
191199
bitstreams = bitstreams.json()
192200
for bitstream in bitstreams:
193-
if args.formats and bitstream['format'] in args.formats or not args.formats:
201+
if (args.formats and bitstream['format'] in args.formats or not args.formats
202+
and args.bundles and bitstream['bundleName'] in args.bundles or not args.bundles):
194203
if args.verbose: print(bitstream)
195204
sequenceId = str(bitstream['sequenceId'])
196205
fileName = bitstream['name']

0 commit comments

Comments
 (0)