-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket_with_folder_count.py
49 lines (38 loc) · 1.28 KB
/
bucket_with_folder_count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from collections import Counter
from datetime import datetime, timedelta
import boto3
conn = boto3.Session("""credentials hidden"""
)
s3_resource = conn.resource("s3")
s3_client = conn.client("s3")
paginator = s3_client.get_paginator("list_objects")
BUCKET_NAME_TRAYPORT_REFERENCEDATA = "uat-mapl-s3-trayport-storage-reference-data"
REFERENCE_DATA = [
"BrokerFilter",
"Commodity",
"Company",
"ContractMap",
"CurrencyCode",
"DatePart",
"DeliveryArea",
"InstrumentTerm",
"InstSequence",
"SequenceFilter",
"SequenceItem",
"SettlementType",
"Tariff",
"TermFormat",
"TradeDeliveryType",
"VersionInfo",
]
for ref in REFERENCE_DATA:
for page in paginator.paginate(Bucket=BUCKET_NAME_TRAYPORT_REFERENCEDATA, Prefix="TrayportClient/dbo/" + ref + "/"):
for key in page["Contents"]:
item = key["Key"]
print(str(item))
today = datetime.today().strftime("%Y/%m/%d/")
yesterday = (datetime.today() - timedelta(1)).strftime("%Y/%m/%d/")
count = 1
for ref in REFERENCE_DATA:
print(str(count) + ". " + paginator_count(BUCKET_NAME_TRAYPORT_REFERENCEDATA, "TrayportClient/dbo/" + ref + "/") + "\n")
count += 1