Skip to content

Commit a0a0a96

Browse files
Merge pull request #416 from ugoano/feature/enhanced-sheets-formatting
feat(sheets): add text wrapping, alignment, and font formatting to format_sheet_range
2 parents 8fee8ea + 2df308c commit a0a0a96

8 files changed

Lines changed: 1742 additions & 1111 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,7 @@ attachments=[{
936936
| `create_spreadsheet` | **Core** | Create new spreadsheets |
937937
| `list_spreadsheets` | Extended | List accessible spreadsheets |
938938
| `get_spreadsheet_info` | Extended | Get spreadsheet metadata |
939+
| `format_sheet_range` | Extended | Apply colors, number formats, text wrapping, alignment, bold/italic, font size |
939940
| `create_sheet` | Complete | Add sheets to existing files |
940941
| `*_sheet_comment` | Complete | Read/create/reply/resolve comments |
941942

README_NEW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export OAUTHLIB_INSECURE_TRANSPORT=1 # Development only
121121
| `create_spreadsheet` | Core | Create new spreadsheets with multiple sheets |
122122
| `list_spreadsheets` | Extended | List accessible spreadsheets |
123123
| `get_spreadsheet_info` | Extended | Get metadata, sheets, conditional formats |
124+
| `format_sheet_range` | Extended | Apply colors, number formats, text wrapping, alignment, bold/italic, font size |
124125
| `create_sheet` | Complete | Add sheets to existing spreadsheets |
125-
| `format_sheet_range` | Complete | Apply colors and number formats |
126126
| `add_conditional_formatting` | Complete | Add boolean or gradient rules |
127127
| `update_conditional_formatting` | Complete | Modify existing rules |
128128
| `delete_conditional_formatting` | Complete | Remove formatting rules |

core/tool_tiers.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ sheets:
8585
extended:
8686
- list_spreadsheets
8787
- get_spreadsheet_info
88+
- format_sheet_range
8889
complete:
8990
- create_sheet
9091
- read_spreadsheet_comments

gcalendar/calendar_tools.py

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ async def get_events(
376376
if event_id:
377377
logger.info(f"[get_events] Retrieving single event with ID: {event_id}")
378378
event = await asyncio.to_thread(
379-
lambda: service.events()
380-
.get(calendarId=calendar_id, eventId=event_id)
381-
.execute()
379+
lambda: (
380+
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
381+
)
382382
)
383383
items = [event]
384384
else:
@@ -701,13 +701,15 @@ async def create_event(
701701
if drive_service:
702702
try:
703703
file_metadata = await asyncio.to_thread(
704-
lambda: drive_service.files()
705-
.get(
706-
fileId=file_id,
707-
fields="mimeType,name",
708-
supportsAllDrives=True,
704+
lambda: (
705+
drive_service.files()
706+
.get(
707+
fileId=file_id,
708+
fields="mimeType,name",
709+
supportsAllDrives=True,
710+
)
711+
.execute()
709712
)
710-
.execute()
711713
)
712714
mime_type = file_metadata.get("mimeType", mime_type)
713715
filename = file_metadata.get("name")
@@ -735,24 +737,28 @@ async def create_event(
735737
if drive_service:
736738
drive_service.close()
737739
created_event = await asyncio.to_thread(
738-
lambda: service.events()
739-
.insert(
740-
calendarId=calendar_id,
741-
body=event_body,
742-
supportsAttachments=True,
743-
conferenceDataVersion=1 if add_google_meet else 0,
740+
lambda: (
741+
service.events()
742+
.insert(
743+
calendarId=calendar_id,
744+
body=event_body,
745+
supportsAttachments=True,
746+
conferenceDataVersion=1 if add_google_meet else 0,
747+
)
748+
.execute()
744749
)
745-
.execute()
746750
)
747751
else:
748752
created_event = await asyncio.to_thread(
749-
lambda: service.events()
750-
.insert(
751-
calendarId=calendar_id,
752-
body=event_body,
753-
conferenceDataVersion=1 if add_google_meet else 0,
753+
lambda: (
754+
service.events()
755+
.insert(
756+
calendarId=calendar_id,
757+
body=event_body,
758+
conferenceDataVersion=1 if add_google_meet else 0,
759+
)
760+
.execute()
754761
)
755-
.execute()
756762
)
757763
link = created_event.get("htmlLink", "No link available")
758764
confirmation_message = f"Successfully created event '{created_event.get('summary', summary)}' for {user_google_email}. Link: {link}"
@@ -976,9 +982,9 @@ async def modify_event(
976982
# Get the existing event to preserve fields that aren't being updated
977983
try:
978984
existing_event = await asyncio.to_thread(
979-
lambda: service.events()
980-
.get(calendarId=calendar_id, eventId=event_id)
981-
.execute()
985+
lambda: (
986+
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
987+
)
982988
)
983989
logger.info(
984990
"[modify_event] Successfully retrieved existing event before update"
@@ -1035,14 +1041,16 @@ async def modify_event(
10351041

10361042
# Proceed with the update
10371043
updated_event = await asyncio.to_thread(
1038-
lambda: service.events()
1039-
.update(
1040-
calendarId=calendar_id,
1041-
eventId=event_id,
1042-
body=event_body,
1043-
conferenceDataVersion=1,
1044+
lambda: (
1045+
service.events()
1046+
.update(
1047+
calendarId=calendar_id,
1048+
eventId=event_id,
1049+
body=event_body,
1050+
conferenceDataVersion=1,
1051+
)
1052+
.execute()
10441053
)
1045-
.execute()
10461054
)
10471055

10481056
link = updated_event.get("htmlLink", "No link available")
@@ -1096,9 +1104,9 @@ async def delete_event(
10961104
# Try to get the event first to verify it exists
10971105
try:
10981106
await asyncio.to_thread(
1099-
lambda: service.events()
1100-
.get(calendarId=calendar_id, eventId=event_id)
1101-
.execute()
1107+
lambda: (
1108+
service.events().get(calendarId=calendar_id, eventId=event_id).execute()
1109+
)
11021110
)
11031111
logger.info("[delete_event] Successfully verified event exists before deletion")
11041112
except HttpError as get_error:
@@ -1115,9 +1123,9 @@ async def delete_event(
11151123

11161124
# Proceed with the deletion
11171125
await asyncio.to_thread(
1118-
lambda: service.events()
1119-
.delete(calendarId=calendar_id, eventId=event_id)
1120-
.execute()
1126+
lambda: (
1127+
service.events().delete(calendarId=calendar_id, eventId=event_id).execute()
1128+
)
11211129
)
11221130

11231131
confirmation_message = f"Successfully deleted event (ID: {event_id}) from calendar '{calendar_id}' for {user_google_email}."

0 commit comments

Comments
 (0)