Use yaml2ical as CLI, clean up useless const.py

Declare a yaml2ical entry point to replace convert.py.

Clean up the useless const.py and move the only remaining constant to
meeting.py.

Change-Id: I6204aa2c9d96640e50167a9df78686a1cd25e9ec
This commit is contained in:
Thierry Carrez 2015-01-16 17:36:55 +01:00
parent d5ee614d95
commit 923218b121
6 changed files with 17 additions and 43 deletions

View File

@ -37,8 +37,9 @@ section below.
::
$ python convert.py -h
usage: convert.py [-h] -y YAML_DIR -i ICAL_DIR [-f]
$ pip install yaml2ical
$ yaml2ical
usage: yaml2ical [-h] -y YAML_DIR -i ICAL_DIR [-f]
A tool that automates the process for testing, integrating, and
publishing changes to OpenStack meetings using the existing OpenStack
@ -53,11 +54,6 @@ section below.
-f, --force forcefully remove old .ics files from iCal
directory
::
$ git clone https://github.com/openstack-infra/yaml2ical.git
$ cd yaml2ical/yaml2ical
The following are a few scenarios:
@ -65,8 +61,7 @@ Generate .ics files locally from existing yaml meeting files:
::
$ python convert.py -y ../meetings/ \
-i ../icals/
$ yaml2ical -y meetings/ -i icals/
The generated .ics files are not tracked in this git repository,
but they are available locally to import into your calendar. Note,
@ -74,7 +69,7 @@ to remove stale .ics files, use the ``--force`` argument:
::
yaml2ical/icals$ ls
$ ls icals/
Barbican Meeting-b58d78a4.ics
Ceilometer Team Meeting-9ed7b5b4.ics
Chef Cookbook Meeting-2418b331.ics
@ -83,7 +78,7 @@ With each .ics file looking something similar to:
::
yaml2ical/icals$ cat Barbican\ Meeting-b58d78a4.ics
$ cat icals/Barbican\ Meeting-b58d78a4.ics
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//yaml2ical agendas//EN

View File

@ -21,3 +21,7 @@ setup-hooks =
[files]
packages = yaml2ical
[entry_points]
console_scripts =
yaml2ical = yaml2ical.cli:main

View File

@ -15,8 +15,7 @@ commands = flake8
commands = {posargs}
[testenv:mkical]
commands = mkdir -p ical
python yaml2ical/convert.py -i ./ical -c
commands = yaml2ical -y meetings/ -i icals/ -f
[flake8]
show-source = True

View File

@ -1,27 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
project_dir = os.path.dirname(os.getcwd())
YAML_FILE_EXT = '.yaml'
WEEKDAYS = {'Monday': 0, 'Tuesday': 1, 'Wednesday': 2, 'Thursday': 3,
'Friday': 4, 'Saturday': 5, 'Sunday': 6}
SRC_DIR = project_dir
# NOTE(jotan): The following publish URL is for testing purposes only.
# It should be later changed to the official OpenStack Meetings Wiki.
PUBLISH_URL = 'https://wiki.openstack.org/wiki/Meetings_Autogenerated'

View File

@ -18,10 +18,13 @@ import icalendar
import pytz
import yaml
from yaml2ical import const
from yaml2ical import schedule
WEEKDAYS = {'Monday': 0, 'Tuesday': 1, 'Wednesday': 2, 'Thursday': 3,
'Friday': 4, 'Saturday': 5, 'Sunday': 6}
class Yaml2IcalCalendar(icalendar.Calendar):
"""A calendar in ics format."""
@ -71,11 +74,11 @@ class Meeting:
if sch.freq.startswith('biweekly'):
meet_on_even = sch.freq.endswith('even')
next_meeting = next_biweekly_meeting(start_date,
const.WEEKDAYS[sch.day],
WEEKDAYS[sch.day],
meet_on_even=meet_on_even)
else:
next_meeting = next_weekday(start_date,
const.WEEKDAYS[sch.day])
WEEKDAYS[sch.day])
next_meeting_date = datetime.datetime(next_meeting.year,
next_meeting.month,