first
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
output_markdown_files/output_1.md
|
||||||
|
output_markdown_files/output_2.md
|
||||||
|
output_markdown_files/output_3.md
|
||||||
|
output_markdown_files/output_4.md
|
||||||
|
output_markdown_files/output_5.md
|
||||||
|
output_markdown_files/output_6.md
|
||||||
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python Debugger: Current File",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
45
edn_to_md.py
Normal file
45
edn_to_md.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import edn_format
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def parse_edn_file(file_path):
|
||||||
|
with open(file_path, 'r') as file:
|
||||||
|
data = edn_format.loads(file.read())
|
||||||
|
return data
|
||||||
|
|
||||||
|
def convert_to_markdown(data, output_dir):
|
||||||
|
if not os.path.exists(output_dir):
|
||||||
|
os.makedirs(output_dir)
|
||||||
|
|
||||||
|
for i, item in enumerate(data):
|
||||||
|
file_name = f"output_{i+1}.md"
|
||||||
|
file_path = os.path.join(output_dir, file_name)
|
||||||
|
|
||||||
|
with open(file_path, 'w') as file:
|
||||||
|
file.write("# Data Item\n\n")
|
||||||
|
if isinstance(item, dict):
|
||||||
|
for key, value in item.items():
|
||||||
|
file.write(f"## {key}\n\n")
|
||||||
|
file.write(f"{value}\n\n")
|
||||||
|
else:
|
||||||
|
file.write(f"{item}\n\n")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Usage: python edn_to_markdown.py <input_edn_file>")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
edn_file_path = sys.argv[1]
|
||||||
|
output_dir = "output_markdown_files"
|
||||||
|
|
||||||
|
data = parse_edn_file(edn_file_path)
|
||||||
|
|
||||||
|
# Debugging output to inspect the structure of the data
|
||||||
|
print("Parsed EDN data structure:")
|
||||||
|
print(data)
|
||||||
|
|
||||||
|
convert_to_markdown(data, output_dir)
|
||||||
|
print(f"Converted EDN data to Markdown files in '{output_dir}'")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
53
fetch_outlook_events.py
Normal file
53
fetch_outlook_events.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import os
|
||||||
|
import msal
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
from dateutil import parser
|
||||||
|
|
||||||
|
# Read Azure app credentials from environment variables
|
||||||
|
client_id = os.getenv('AZURE_CLIENT_ID')
|
||||||
|
tenant_id = os.getenv('AZURE_TENANT_ID')
|
||||||
|
|
||||||
|
if not client_id or not tenant_id:
|
||||||
|
raise ValueError("Please set the AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables.")
|
||||||
|
|
||||||
|
# Authentication
|
||||||
|
authority = f'https://login.microsoftonline.com/{tenant_id}'
|
||||||
|
scopes = ['https://graph.microsoft.com/Calendars.Read']
|
||||||
|
|
||||||
|
app = msal.PublicClientApplication(client_id, authority=authority)
|
||||||
|
flow = app.initiate_device_flow(scopes=scopes)
|
||||||
|
if 'user_code' not in flow:
|
||||||
|
raise Exception("Failed to create device flow")
|
||||||
|
print(flow['message'])
|
||||||
|
token_response = app.acquire_token_by_device_flow(flow)
|
||||||
|
|
||||||
|
if 'access_token' not in token_response:
|
||||||
|
raise Exception("Failed to acquire token")
|
||||||
|
|
||||||
|
access_token = token_response['access_token']
|
||||||
|
|
||||||
|
# Fetch events with pagination and expand recurring events
|
||||||
|
headers = {'Authorization': f'Bearer {access_token}'}
|
||||||
|
events_url = 'https://graph.microsoft.com/v1.0/me/events?$top=100&$expand=instances'
|
||||||
|
events = []
|
||||||
|
|
||||||
|
while events_url:
|
||||||
|
response = requests.get(events_url, headers=headers)
|
||||||
|
response_data = response.json()
|
||||||
|
events.extend(response_data.get('value', []))
|
||||||
|
events_url = response_data.get('@odata.nextLink')
|
||||||
|
|
||||||
|
# Save events to a file in iCalendar format
|
||||||
|
with open('outlook_events.ics', 'w') as f:
|
||||||
|
f.write("BEGIN:VCALENDAR\nVERSION:2.0\n")
|
||||||
|
for event in events:
|
||||||
|
if 'start' in event and 'end' in event:
|
||||||
|
start = parser.isoparse(event['start']['dateTime'])
|
||||||
|
end = parser.isoparse(event['end']['dateTime'])
|
||||||
|
f.write(f"BEGIN:VEVENT\nSUMMARY:{event['subject']}\n")
|
||||||
|
f.write(f"DTSTART:{start.strftime('%Y%m%dT%H%M%S')}\n")
|
||||||
|
f.write(f"DTEND:{end.strftime('%Y%m%dT%H%M%S')}\n")
|
||||||
|
f.write("END:VEVENT\n")
|
||||||
|
f.write("END:VCALENDAR\n")
|
||||||
Reference in New Issue
Block a user