diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..55c17b1 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,42 @@ +name: Python package + +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop + +jobs: + build: + + runs-on: ubuntu-18.04 + strategy: + max-parallel: 4 + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pip install pytest + pytest -v diff --git a/.travis.yml b/.travis.yml index 08379dd..f913379 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: python python: - - "2.7" + - "3.5" - "3.6" - - "3.7" + - "3.7" + - "3.8" script: - pytest -v diff --git a/README.md b/README.md index 23fb4a6..79d7c92 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,15 @@ # sync_ics2gcal [![Build Status](https://travis-ci.org/b4tman/sync_ics2gcal.svg?branch=master)](https://travis-ci.org/b4tman/sync_ics2gcal) -[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=b4tman/sync_ics2gcal)](https://dependabot.com) +[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=b4tman/sync_ics2gcal)](https://dependabot.com) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fb4tman%2Fsync_ics2gcal.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fb4tman%2Fsync_ics2gcal?ref=badge_shield) +![Python package status](https://github.com/b4tman/sync_ics2gcal/workflows/Python%20package/badge.svg) Python scripts for sync .ics file with Google calendar ## How it works ![How it works](how-it-works.png) + + +## License +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fb4tman%2Fsync_ics2gcal.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fb4tman%2Fsync_ics2gcal?ref=badge_large) \ No newline at end of file diff --git a/manage-calendars.py b/manage-calendars.py index e746c48..e528c76 100644 --- a/manage-calendars.py +++ b/manage-calendars.py @@ -30,6 +30,12 @@ def parse_args(): 'remove', help='remove calendar') parser_remove.add_argument( 'id', action='store', help='calendar id to remove') + parser_rename = command_subparsers.add_parser( + 'rename', help='rename calendar') + parser_rename.add_argument( + 'id', action='store', help='calendar id') + parser_rename.add_argument( + 'summary', action='store', help='new summary') args = parser.parse_args() if args.command is None: @@ -39,7 +45,7 @@ def parse_args(): def load_config(): with open('config.yml', 'r', encoding='utf-8') as f: - result = yaml.load(f) + result = yaml.safe_load(f) return result @@ -68,6 +74,10 @@ def remove_calendar(service, id): calendar.delete() print('removed: {}'.format(id)) +def rename_calendar(service, id, summary): + calendar = {'summary': summary} + service.calendars().patch(body=calendar, calendarId=id).execute() + print('{}: {}'.format(summary, id)) def main(): args = parse_args() @@ -87,6 +97,8 @@ def main(): add_owner(service, args.id, args.owner_email) elif 'remove' == args.command: remove_calendar(service, args.id) + elif 'rename' == args.command: + rename_calendar(service, args.id, args.summary) if __name__ == '__main__': main() diff --git a/requirements.txt b/requirements.txt index 208a63c..5369fe9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -google-auth==1.6.3 -google-api-python-client==1.7.9 -icalendar==4.0.3 -pytz==2019.1 -PyYAML==5.1 +google-auth==1.11.0 +google-api-python-client==1.7.11 +icalendar==4.0.4 +pytz==2019.3 +PyYAML==5.3 diff --git a/sync-calendar.py b/sync-calendar.py index 74c81bf..6df9a79 100644 --- a/sync-calendar.py +++ b/sync-calendar.py @@ -14,7 +14,7 @@ from gcal_sync import ( def load_config(): with open('config.yml', 'r', encoding='utf-8') as f: - result = yaml.load(f) + result = yaml.safe_load(f) return result