Skip to content

Commit 7e4209a

Browse files
committed
added alternative blackduck client and alternative core methods based on new BearerAuth class
1 parent 4881877 commit 7e4209a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

blackduck/Utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
logger = logging.getLogger(__name__)
1414

1515

16-
def iso8061_to_date(iso_string, with_zone=False):
16+
def iso8601_to_date(iso_string, with_zone=False):
1717
"""Utility function to convert iso_8061 formatted string to datetime object, optionally accounting for timezone
1818
1919
Args:
@@ -31,6 +31,12 @@ def iso8061_to_date(iso_string, with_zone=False):
3131
date = date + datetime.timedelta(minutes=minutes)
3232
return date
3333

34+
def iso8601_timespan(days_ago, from_date=datetime.utcnow(), delta=timedelta(weeks=1)):
35+
curr_date = from_date - timedelta(days=days_ago)
36+
while curr_date < from_date:
37+
yield curr_date.isoformat('T', 'seconds')
38+
curr_date += delta
39+
3440
def min_iso8061():
3541
"""Utility wrapper for iso8061_to_date which provides minimum date (for comparison purposes).
3642
@@ -50,7 +56,7 @@ def find_field(data_to_filter, field_name, field_value):
5056
Returns:
5157
object: object if found or None.
5258
"""
53-
return next(filter(lambda d: d.get(field) == field_value, data_to_filter), None)
59+
return next(filter(lambda d: d.get(field_name) == field_value, data_to_filter), None)
5460

5561
def safe_get(obj, *keys):
5662
"""Utility function to safely perform multiple get's on a dict.

0 commit comments

Comments
 (0)