Skip to content

Commit

Permalink
Added workflow and argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
rsb-23 committed Jan 15, 2025
1 parent ef757b5 commit 27bec6b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pre-commit
name: Code Lint Check

on:
pull_request:
Expand All @@ -17,9 +17,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit
pip install pre-commit pylint
- name: Run pre-commit
env:
SKIP: pylint,mypy,no-commit-to-branch
SKIP: mypy,no-commit-to-branch
run: pre-commit run --all-files
17 changes: 15 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,23 @@ repos:
- id: check-toml
- id: end-of-file-fixer
- id: no-commit-to-branch
args: [-b, main, -b, master]
args: [ -b, main, -b, master ]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-pyproject]
additional_dependencies: [ flake8-pyproject ]

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [ python ]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
]
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[MASTER]
jobs=2
ignore-paths=(?!(vobject|tests))/*

[FORMAT]
max-line-length = 130
Expand All @@ -18,8 +19,8 @@ max-statements = 95
[MESSAGES CONTROL]
disable=
I,
import-error,
# W
deprecated-module,
fixme,
keyword-arg-before-vararg,
logging-format-interpolation,
Expand Down
12 changes: 7 additions & 5 deletions vobject/change_tz.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Translate an ics file's events to a different timezone."""

from argparse import ArgumentParser
from datetime import datetime
from optparse import OptionParser

import pytz
from dateutil import tz
Expand Down Expand Up @@ -70,13 +70,15 @@ def main():
def get_options():
# Configuration options
usage = """usage: %prog [options] ics_file [timezone]"""
parser = OptionParser(usage=usage, version=vobject.VERSION)
parser.set_description("change_tz will convert the timezones in an ics file. ")
parser = ArgumentParser(usage=usage, description="change_tz will convert the timezones in an ics file.")
parser.add_argument("--version", action="version", version=vobject.VERSION)

parser.add_option(
parser.add_argument(
"-u", "--only-utc", dest="utc", action="store_true", default=False, help="Only change UTC events."
)
parser.add_option("-l", "--list", dest="list", action="store_true", default=False, help="List available timezones")
parser.add_argument(
"-l", "--list", dest="list", action="store_true", default=False, help="List available timezones"
)

(cmdline_options, args) = parser.parse_args()
if not (args or cmdline_options.list):
Expand Down
9 changes: 4 additions & 5 deletions vobject/ics_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Compare VTODOs and VEVENTs in two iCalendar sources.
"""

from optparse import OptionParser
from argparse import ArgumentParser

import vobject

Expand Down Expand Up @@ -199,10 +199,9 @@ def getOptions():
# Configuration options #

usage = "usage: %prog [options] ics_file1 ics_file2"
parser = OptionParser(usage=usage, version=vobject.VERSION)
parser.set_description("ics_diff will print a comparison of two iCalendar files ")

parser.add_option(
parser = ArgumentParser(usage=usage, description="ics_diff will print a comparison of two iCalendar files")
parser.add_argument("--version", action="version", version=vobject.VERSION)
parser.add_argument(
"-i",
"--ignore-dtstamp",
dest="ignore",
Expand Down

0 comments on commit 27bec6b

Please sign in to comment.