Skip to content

Commit

Permalink
Add support for multiple spreadsheet configuration formats (#15)
Browse files Browse the repository at this point in the history
- Update config.sample.json to show alternative configuration with 'files' list
- Modify target_gsheet.py to handle both 'spreadsheet_id' and 'files' config formats
- Add .venv/ to .gitignore for virtual environment support
  • Loading branch information
Renan Butkeraites authored Feb 6, 2025
1 parent 0b1e2b6 commit 0606147
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
.venv/
build/
develop-eggs/
dist/
Expand Down
10 changes: 10 additions & 0 deletions config.sample.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"spreadsheet_id": "abcdefgh-hijklmn-opqrstuvwxyz123456789ABCDEF"
}

// or

{
"files": [
{
"id": "abcdefgh-hijklmn-opqrstuvwxyz123456789ABCDEF"
}
]
}
8 changes: 7 additions & 1 deletion target_gsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,13 @@ def main():
discoveryServiceUrl=discoveryUrl)

# Get spreadsheet_id
spreadsheet = get_spreadsheet(service, config['spreadsheet_id'])
try:
spreadsheet_id = config['spreadsheet_id'] if 'spreadsheet_id' in config else config['files'][0]['id']
except Exception as e:
logger.error(f"Error getting spreadsheet_id: {e}")
logger.error(f"Either 'spreadsheet_id' or a list called 'files' with at least one element that contains the 'id' of the spreadsheet must be provided in the config")
raise e
spreadsheet = get_spreadsheet(service, spreadsheet_id)

input = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')
state = None
Expand Down

0 comments on commit 0606147

Please sign in to comment.