-
Notifications
You must be signed in to change notification settings - Fork 2
Add pipfile for pipenv, add count and json options #16
base: main
Are you sure you want to change the base?
Conversation
mxr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Had no idea this was opened, sorry I missed the notification...
| @@ -0,0 +1,21 @@ | |||
| [[source]] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the dependencies in #18 - let's undo the pipenv changes please
| if args.count < 1: | ||
| print("Count cannot be < 1. Your input: {}".format(args.count)) | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be validated with the type= arg instead
| object_ids = [gen_random_object_id() for _ in range(args.count)] | ||
|
|
||
| if args.long_form: | ||
| print('ObjectId("{}")'.format(object_id)) | ||
| object_ids = ['ObjectId("{}")'.format(object_id) for object_id in object_ids] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function was structured to avoid reassigning object_ids, so let's preserve that
| print(json.dumps(object_ids, indent=" ")) | ||
| else: | ||
| print(object_id) | ||
| [print(object_id) for object_id in object_ids] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using a list-comprehension solely to execute a side effect in a loop. Let's write an explicit loop instead
Couple of features I needed: create ObjectIDs in batch, and also output them in json format.