[pim/akonadi-calendar-tools] /: work/winterz/pre commit
Allen Winter
null at kde.org
Wed May 27 15:49:02 BST 2026
Git commit 0e3446dd875af05e5e8db1e94a1d27fdaa1c1c8f by Allen Winter.
Committed on 27/05/2026 at 14:49.
Pushed by winterz into branch 'master'.
work/winterz/pre commit
Add pre-commit support:
- whitespace cleaning
- .clang-format-pre-commit - add for pre-commit clang-formatting
- codespell fixes
- Use gersemi to format CMake files
- .markdownlint.json - add for pre-commit markdown linting
- shfmt and shellcheck bash files
- perltidy perl files
- Add pre-commit support
A +95 -0 .clang-format-pre-commit
M +1 -2 .codespellrc
A +3 -0 .editorconfig
A +4 -0 .gersemirc
M +1 -1 .gitlab-ci.yml
A +16 -0 .markdownlint.json
A +8 -0 .perltidyrc
A +57 -0 .pre-commit-config.yaml
A +2 -0 .shellcheckrc
M +82 -16 CMakeLists.txt
M +1 -1 LICENSES/GPL-2.0-or-later.txt
M +29 -16 calendarjanitor/CMakeLists.txt
M +1 -1 calendarjanitor/collectionloader.h
M +1 -1 doc/konsolekalendar/index.docbook
M +36 -27 konsolekalendar/CMakeLists.txt
M +0 -1 konsolekalendar/ROADMAP
M +0 -1 konsolekalendar/TODO
M +1 -1 konsolekalendar/examples/README
M +136 -122 konsolekalendar/examples/tcm2kcal.pl
M +5 -8 konsolekalendar/examples/testkalendar.sh
M +0 -1 konsolekalendar/pics/CMakeLists.txt
https://invent.kde.org/pim/akonadi-calendar-tools/-/commit/0e3446dd875af05e5e8db1e94a1d27fdaa1c1c8f
diff --git a/.clang-format-pre-commit b/.clang-format-pre-commit
new file mode 100644
index 0000000..9b5ae0a
--- /dev/null
+++ b/.clang-format-pre-commit
@@ -0,0 +1,95 @@
+---
+# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann at kde.org>
+# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard at absint.com>
+#
+# SPDX-License-Identifier: MIT
+
+# This file got automatically created by ECM, do not edit
+# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options
+# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting
+# for clang-format tips & tricks
+---
+Language: JavaScript
+DisableFormat: true
+---
+Language: Json
+DisableFormat: false
+IndentWidth: 4
+---
+
+# Style for C++
+Language: Cpp
+
+# base is WebKit coding style: https://webkit.org/code-style-guidelines/
+# below are only things set that diverge from this style!
+BasedOnStyle: WebKit
+
+# enforce C++11 (e.g. for std::vector<std::vector<lala>>
+Standard: Cpp11
+
+# 4 spaces indent
+TabWidth: 4
+
+# 2 * 80 wide lines
+ColumnLimit: 160
+
+# sort includes inside line separated groups
+SortIncludes: true
+
+# break before braces on function, namespace and class definitions.
+BreakBeforeBraces: Linux
+
+# CrlInstruction *a;
+PointerAlignment: Right
+
+# horizontally aligns arguments after an open bracket.
+AlignAfterOpenBracket: Align
+
+# don't move all parameters to new line
+AllowAllParametersOfDeclarationOnNextLine: false
+
+# no single line functions
+AllowShortFunctionsOnASingleLine: None
+
+# no single line enums
+AllowShortEnumsOnASingleLine: false
+
+# always break before you encounter multi line strings
+AlwaysBreakBeforeMultilineStrings: true
+
+# don't move arguments to own lines if they are not all on the same
+BinPackArguments: false
+
+# don't move parameters to own lines if they are not all on the same
+BinPackParameters: false
+
+# In case we have an if statement with multiple lines the operator should be at the beginning of the line
+# but we do not want to break assignments
+BreakBeforeBinaryOperators: NonAssignment
+
+# format C++11 braced lists like function calls
+Cpp11BracedListStyle: true
+
+# do not put a space before C++11 braced lists
+SpaceBeforeCpp11BracedList: false
+
+# remove empty lines
+KeepEmptyLinesAtTheStartOfBlocks: false
+
+# no namespace indentation to keep indent level low
+NamespaceIndentation: None
+
+# we use template< without space.
+SpaceAfterTemplateKeyword: false
+
+# Always break after template declaration
+AlwaysBreakTemplateDeclarations: true
+
+# macros for which the opening brace stays attached.
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
+
+# keep lambda formatting multi-line if not empty
+AllowShortLambdasOnASingleLine: Empty
+
+# We do not want clang-format to put all arguments on a new line
+AllowAllArgumentsOnNextLine: false
diff --git a/.codespellrc b/.codespellrc
index 0be43c4..9fb2fc3 100644
--- a/.codespellrc
+++ b/.codespellrc
@@ -1,4 +1,3 @@
[codespell]
-skip = ./build*,.git,*.notifyrc,*.desktop,*.json,*.xml
+skip = ./build*,.git,*.notifyrc,*.desktop,*.json,*.xml,*.po
interactive = 3
-ignore-words-list = accessort
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..b9a948f
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,3 @@
+[*.sh]
+indent_style = space
+indent_size = 2
diff --git a/.gersemirc b/.gersemirc
new file mode 100644
index 0000000..d4ce45f
--- /dev/null
+++ b/.gersemirc
@@ -0,0 +1,4 @@
+indent: 4
+line_length: 120
+list_expansion: favour-expansion
+warn_about_unknown_commands: false
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1313695..5d784f4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,6 @@ include:
file:
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/linux-qt6-next.yml
- - /gitlab-templates/json-validation.yml
- /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/cppcheck.yml
+ - /gitlab-templates/pre-commit.yml
diff --git a/.markdownlint.json b/.markdownlint.json
new file mode 100644
index 0000000..e2f811c
--- /dev/null
+++ b/.markdownlint.json
@@ -0,0 +1,16 @@
+{
+ "default": true,
+ "MD007": {
+ "indent": 2,
+ "start_indented": false
+ },
+ "MD013": {
+ "line_length": 100,
+ "tables": false,
+ "code_blocks": false
+ },
+ "MD029": {
+ "style": "ordered"
+ },
+ "MD033": false
+}
diff --git a/.perltidyrc b/.perltidyrc
new file mode 100644
index 0000000..b69e069
--- /dev/null
+++ b/.perltidyrc
@@ -0,0 +1,8 @@
+--indent-columns=2
+--maximum-line-length=100
+--paren-tightness=2
+--square-bracket-tightness=2
+--brace-tightness=2
+--block-brace-tightness=2
+--cuddled-else
+--opening-sub-brace-on-new-line
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..eb553bc
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,57 @@
+# SPDX-FileCopyrightText: none
+# SPDX-License-Identifier: CC0-1.0
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+
+exclude: (^po/|.desktop|Messages.sh)
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v6.0.0
+ hooks:
+ - id: trailing-whitespace
+ - id: end-of-file-fixer
+ exclude: ^(autotests/gnupg_home/)
+ - id: check-added-large-files
+ - id: check-case-conflict
+ - id: check-xml
+ - id: check-yaml
+ args: [--allow-multiple-documents]
+ exclude: ^(.clang-tidy)
+ - id: check-json
+ - id: check-symlinks
+ - id: destroyed-symlinks
+ - id: check-executables-have-shebangs
+ - id: check-toml
+ - repo: https://github.com/pre-commit/mirrors-clang-format
+ rev: v22.1.5
+ hooks:
+ - id: clang-format
+ # force using this project's configuration rather
+ # than the one provided by CI
+ args: ["--style=file:.clang-format-pre-commit"]
+ - repo: https://github.com/codespell-project/codespell
+ rev: v2.4.2
+ hooks:
+ - id: codespell
+ - repo: https://github.com/BlankSpruce/gersemi
+ rev: 0.26.1
+ hooks:
+ - id: gersemi
+ - repo: https://github.com/DavidAnson/markdownlint-cli2
+ rev: v0.22.1
+ hooks:
+ - id: markdownlint-cli2
+ files: \.(md|mdown|markdown)$
+ - repo: https://github.com/scop/pre-commit-shfmt
+ rev: v3.13.1-1
+ hooks:
+ - id: shfmt
+ args: ["--indent", "2"]
+ - repo: https://github.com/shellcheck-py/shellcheck-py
+ rev: v0.11.0.1
+ hooks:
+ - id: shellcheck
+# - repo: https://github.com/perltidy/perltidy
+# rev: "20260204.03"
+# hooks:
+# - id: perltidy
diff --git a/.shellcheckrc b/.shellcheckrc
new file mode 100644
index 0000000..916f336
--- /dev/null
+++ b/.shellcheckrc
@@ -0,0 +1,2 @@
+#disable=SC2006
+disable=SC2233
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc1bab8..e997462 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,6 @@ find_package(ECM ${KF_MIN_VERSION} CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(ECMInstallIcons)
-
include(ECMSetupVersion)
include(ECMAddTests)
@@ -17,9 +16,69 @@ include(ECMGenerateHeaders)
include(KDEGitCommitHooks)
include(KDEClangFormat)
-file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
-kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
-include(CheckFunctionExists)
+file(
+ GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES
+ *.cpp
+ *.h
+ *.c
+)
+if(EXISTS "${PROJECT_SOURCE_DIR}/.git/")
+ set(GIT_SOURCE_TARBALL TRUE)
+endif()
+
+if(GIT_SOURCE_TARBALL)
+ set(PRE_COMMIT_INSTALLED FALSE)
+ include(KDEGitCommitHooks)
+ include(KDEClangFormat)
+ kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
+ if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
+ if(EXISTS "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit")
+ file(READ "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit" FILE_CONTENTS)
+ string(
+ FIND "${FILE_CONTENTS}"
+ "File generated by pre-commit"
+ INDEX
+ )
+ if(${INDEX} GREATER_EQUAL 0)
+ set(PRE_COMMIT_INSTALLED TRUE)
+ endif()
+ endif()
+ endif()
+ if(NOT ${PRE_COMMIT_INSTALLED})
+ function(install_hook executable hook_name)
+ message(
+ STATUS
+ "This module has ${hook_name} support. ${hook_name} binary was found. Installing ${hook_name} hook"
+ )
+ execute_process(
+ COMMAND
+ "${executable}" install -f
+ ERROR_QUIET
+ RESULT_VARIABLE _precommitresult
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
+ )
+ if(_precommitresult EQUAL 0)
+ message(STATUS "${hook_name} installed.")
+ else()
+ message(
+ WARNING
+ "Error during installing ${hook_name} hook: ${executable} project source dir ${PROJECT_SOURCE_DIR}"
+ )
+ endif()
+ endfunction()
+ find_program(PREK_EXECUTABLE prek)
+ if(PREK_EXECUTABLE)
+ install_hook(${PREK_EXECUTABLE} "Prek")
+ else()
+ find_program(PRE_COMMIT_EXECUTABLE pre-commit)
+ if(PRE_COMMIT_EXECUTABLE)
+ install_hook(${PRE_COMMIT_EXECUTABLE} "pre-commit")
+ else()
+ message(WARNING "This module has pre-commit support. pre-commit binary was not found.")
+ endif()
+ endif()
+ endif()
+endif()
include(KDEInstallDirs)
include(KDECMakeSettings)
@@ -39,7 +98,6 @@ endif()
set(KDEPIM_VERSION "${PIM_VERSION}${KDEPIM_DEV_VERSION}")
-
set(AKONADICALENDAR_LIB_VERSION "6.7.40")
set(AKONADI_VERSION "6.7.40")
set(CALENDARSUPPORT_LIB_VERSION "6.7.40")
@@ -48,26 +106,31 @@ set(KDEPIM_LIB_SOVERSION "6")
find_package(Qt6 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets)
-
# Find KF6 package
find_package(KF6I18n ${KF_MIN_VERSION} REQUIRED)
find_package(KF6DocTools ${KF_MIN_VERSION})
-set_package_properties(KF6DocTools PROPERTIES DESCRIPTION
- "Tools to generate documentation"
- TYPE OPTIONAL
+set_package_properties(
+ KF6DocTools
+ PROPERTIES
+ DESCRIPTION
+ "Tools to generate documentation"
+ TYPE
+ OPTIONAL
)
# Find KdepimLibs Package
find_package(KPim6Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
-find_package(KF6CalendarCore ${KF_MIN_VERSION} CONFIG REQUIRED)
+find_package(KF6CalendarCore ${KF_MIN_VERSION} CONFIG REQUIRED)
find_package(KPim6AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED)
find_package(KPim6CalendarSupport ${CALENDARSUPPORT_LIB_VERSION} CONFIG REQUIRED)
-include_directories(${akonadi-calendar-tools_SOURCE_DIR} ${akonadi-calendar-tools_BINARY_DIR})
+include_directories(
+ ${akonadi-calendar-tools_SOURCE_DIR}
+ ${akonadi-calendar-tools_BINARY_DIR}
+)
configure_file(console-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/console-version.h @ONLY)
-
add_definitions(-DQT_NO_CONTEXTLESS_CONNECT)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Not setting for GNU due to too many warnings related to private members of base classes or around lambdas
@@ -80,7 +143,7 @@ add_definitions(-DQT_NO_EMIT)
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
-if (USE_UNITY_CMAKE_SUPPORT)
+if(USE_UNITY_CMAKE_SUPPORT)
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
add_definitions(-DCOMPILE_WITH_UNITY_CMAKE_SUPPORT)
endif()
@@ -92,9 +155,13 @@ ecm_qt_install_logging_categories(
EXPORT AKONADICALENDARTOOLS
FILE console.categories
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
- )
+)
-kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
+if(GIT_SOURCE_TARBALL)
+ if(DEFINED kde_configure_git_pre_commit_hook)
+ kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
+ endif()
+endif()
ki18n_install(po)
if(KF6DocTools_FOUND)
@@ -102,5 +169,4 @@ if(KF6DocTools_FOUND)
add_subdirectory(doc)
endif()
-
ecm_feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt
index 1d80ac3..96e2bf1 100644
--- a/LICENSES/GPL-2.0-or-later.txt
+++ b/LICENSES/GPL-2.0-or-later.txt
@@ -2,7 +2,7 @@ GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
-Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
diff --git a/calendarjanitor/CMakeLists.txt b/calendarjanitor/CMakeLists.txt
index 657226d..f0588b6 100644
--- a/calendarjanitor/CMakeLists.txt
+++ b/calendarjanitor/CMakeLists.txt
@@ -1,22 +1,35 @@
add_executable(calendarjanitor)
-if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
- set_target_properties(calendarjanitor PROPERTIES UNITY_BUILD ON)
+if(COMPILE_WITH_UNITY_CMAKE_SUPPORT)
+ set_target_properties(
+ calendarjanitor
+ PROPERTIES
+ UNITY_BUILD
+ ON
+ )
endif()
-target_sources(calendarjanitor PRIVATE
- main.cpp
- backuper.cpp
- calendarjanitor.cpp
- collectionloader.cpp
- options.cpp
- backuper.h
- calendarjanitor.h
- collectionloader.h
- options.h
- )
+target_sources(
+ calendarjanitor
+ PRIVATE
+ main.cpp
+ backuper.cpp
+ calendarjanitor.cpp
+ collectionloader.cpp
+ options.cpp
+ backuper.h
+ calendarjanitor.h
+ collectionloader.h
+ options.h
+)
-target_link_libraries(calendarjanitor
+target_link_libraries(
+ calendarjanitor
KF6::CalendarCore
- KPim6::AkonadiCalendar)
+ KPim6::AkonadiCalendar
+)
-install(TARGETS calendarjanitor ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+install(
+ TARGETS
+ calendarjanitor
+ ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
+)
diff --git a/calendarjanitor/collectionloader.h b/calendarjanitor/collectionloader.h
index 7c3781e..c92705e 100644
--- a/calendarjanitor/collectionloader.h
+++ b/calendarjanitor/collectionloader.h
@@ -21,7 +21,7 @@ public:
Akonadi::Collection::List collections() const;
Q_SIGNALS:
- void loaded(bool succcess);
+ void loaded(bool success);
private Q_SLOTS:
void onCollectionsLoaded(KJob *);
diff --git a/doc/konsolekalendar/index.docbook b/doc/konsolekalendar/index.docbook
index d583d77..0b6da7b 100644
--- a/doc/konsolekalendar/index.docbook
+++ b/doc/konsolekalendar/index.docbook
@@ -265,7 +265,7 @@ using the <parameter>--view</parameter>, <parameter>--next</parameter>
or <parameter>--show-next</parameter> options.</para>
<para>
-Changing behaves in the same way as inserting: you can change an event's start date
+Changing behaves in the same way as inserting: you can change an event's start date
and time, end date and time, summary, location, and description. Events
successfully changed will be immediately shown modified within &kde; calendar
applications (&korganizer;).</para>
diff --git a/konsolekalendar/CMakeLists.txt b/konsolekalendar/CMakeLists.txt
index c0b0eab..88d2518 100644
--- a/konsolekalendar/CMakeLists.txt
+++ b/konsolekalendar/CMakeLists.txt
@@ -1,28 +1,34 @@
-
-add_subdirectory(pics)
+add_subdirectory(pics)
add_executable(konsolekalendar)
-if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
- set_target_properties(konsolekalendar PROPERTIES UNITY_BUILD ON)
+if(COMPILE_WITH_UNITY_CMAKE_SUPPORT)
+ set_target_properties(
+ konsolekalendar
+ PROPERTIES
+ UNITY_BUILD
+ ON
+ )
endif()
-target_sources(konsolekalendar PRIVATE
- konsolekalendarepoch.cpp
- konsolekalendardelete.cpp
- konsolekalendarchange.cpp
- konsolekalendarvariables.cpp
- konsolekalendaradd.cpp
- konsolekalendarexports.cpp
- konsolekalendar.cpp
- konsolekalendarepoch.h
- konsolekalendardelete.h
- konsolekalendarchange.h
- konsolekalendarvariables.h
- konsolekalendaradd.h
- konsolekalendarexports.h
- konsolekalendar.h
-
- main.cpp )
+target_sources(
+ konsolekalendar
+ PRIVATE
+ konsolekalendarepoch.cpp
+ konsolekalendardelete.cpp
+ konsolekalendarchange.cpp
+ konsolekalendarvariables.cpp
+ konsolekalendaradd.cpp
+ konsolekalendarexports.cpp
+ konsolekalendar.cpp
+ konsolekalendarepoch.h
+ konsolekalendardelete.h
+ konsolekalendarchange.h
+ konsolekalendarvariables.h
+ konsolekalendaradd.h
+ konsolekalendarexports.h
+ konsolekalendar.h
+ main.cpp
+)
ecm_qt_declare_logging_category(konsolekalendar
HEADER konsolekalendar_debug.h
@@ -31,9 +37,10 @@ ecm_qt_declare_logging_category(konsolekalendar
DESCRIPTION "console (konsolekalendar)"
OLD_CATEGORY_NAMES log_konsolekalendar
EXPORT AKONADICALENDARTOOLS
- )
+)
-target_link_libraries(konsolekalendar
+target_link_libraries(
+ konsolekalendar
Qt::DBus
KF6::CalendarCore
KF6::ConfigGui
@@ -42,10 +49,12 @@ target_link_libraries(konsolekalendar
KF6::I18n
)
-install(TARGETS konsolekalendar ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
-
+install(
+ TARGETS
+ konsolekalendar
+ ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
+)
########### install files ###############
-install( PROGRAMS konsolekalendar.desktop DESTINATION ${KDE_INSTALL_APPDIR})
-
+install(PROGRAMS konsolekalendar.desktop DESTINATION ${KDE_INSTALL_APPDIR})
diff --git a/konsolekalendar/ROADMAP b/konsolekalendar/ROADMAP
index 333366e..edc6a4b 100644
--- a/konsolekalendar/ROADMAP
+++ b/konsolekalendar/ROADMAP
@@ -17,4 +17,3 @@ Inner Version| | From KDE version
| Want to have they kind of output |
Remember these are the highlights! There going to be plenty of other stuff.
-
diff --git a/konsolekalendar/TODO b/konsolekalendar/TODO
index ba4cdb6..b13a022 100644
--- a/konsolekalendar/TODO
+++ b/konsolekalendar/TODO
@@ -1,3 +1,2 @@
Todo:
Make new plans
-
diff --git a/konsolekalendar/examples/README b/konsolekalendar/examples/README
index d770ef2..db956c5 100644
--- a/konsolekalendar/examples/README
+++ b/konsolekalendar/examples/README
@@ -5,4 +5,4 @@ Here are some nice example scripts how to use konsolekalendar.
You need lynx and the Date::Calc to use this script
(you can install Date::Calc using 'perl -MCPAN -e 'install Date::Calc')
- * testkalendar.sh is crappy test script..
+ * testkalendar.sh is crappy test script..
diff --git a/konsolekalendar/examples/tcm2kcal.pl b/konsolekalendar/examples/tcm2kcal.pl
old mode 100755
new mode 100644
index e1d7584..31be047
--- a/konsolekalendar/examples/tcm2kcal.pl
+++ b/konsolekalendar/examples/tcm2kcal.pl
@@ -30,79 +30,81 @@ use strict;
use Env qw(HOME);
use Getopt::Std;
use Date::Calc qw(Today Month_to_Text
- Add_Delta_DHMS Add_Delta_Days
- Day_of_Week Day_of_Week_to_Text
- Month_to_Text);
+ Add_Delta_DHMS Add_Delta_Days
+ Day_of_Week Day_of_Week_to_Text
+ Month_to_Text);
#location of konsolekalendar program
-my($konkal)="/usr/bin/konsolekalendar";
+my ($konkal) = "/usr/bin/konsolekalendar";
#location of new TCM KDE calendar
-my($cal)="$HOME/.kde/share/apps/korganizer/tcm.ics";
+my ($cal) = "$HOME/.kde/share/apps/korganizer/tcm.ics";
#default program execution mode
-my($mode)="--add";
+my ($mode) = "--add";
#current date information
-my($year,$month,$d) = Today();
+my ($year, $month, $d) = Today();
#parse command line
&parse();
-my($mmonth)=Month_to_Text($month);
+my ($mmonth) = Month_to_Text($month);
#location of TCM monthly calendar web page
-my($TCM)="http://www.turnerclassicmovies.com/Schedule/Print/0,,$month-$year|0|,00.html";
+my ($TCM) = "http://www.turnerclassicmovies.com/Schedule/Print/0,,$month-$year|0|,00.html";
print "Processing $TCM ...\n";
-if( open(GET, "lynx -dump -nolist -connect_timeout=3 '$TCM'|") ) {
+if (open(GET, "lynx -dump -nolist -connect_timeout=3 '$TCM'|")) {
} else {
die "Failed to get the TCM calendar page.\n";
}
-if( $mode eq "--add" ) {
- if( ! -r $cal ) {
- if( system("$konkal --create --file $cal") ) {
- print "Failure Condition Encountered. Unable to Create KDE Calendar.\n"; exit 1;
+if ($mode eq "--add") {
+ if (!-r $cal) {
+ if (system("$konkal --create --file $cal")) {
+ print "Failure Condition Encountered. Unable to Create KDE Calendar.\n";
+ exit 1;
}
}
}
-my($tday,$mday);
-my($day)=1;
-my($lastampm)="AM";
-my($line)="";
-my($event)="";
-my($num)=0;
-while($line=<GET>) {
+my ($tday, $mday);
+my ($day) = 1;
+my ($lastampm) = "AM";
+my ($line) = "";
+my ($event) = "";
+my ($num) = 0;
+while ($line = <GET>) {
#prepare line
chomp($line);
- $line=&rmleadwhite($line);
+ $line = &rmleadwhite($line);
#skip junk lines
- next if( ! $line );
- next if( $line =~ m/^\[/ );
- next if( $line =~ m/^All Times Eastern/ );
- next if( $line =~ m/^$mmonth[[:space:]]*$year/ );
+ next if (!$line);
+ next if ($line =~ m/^\[/);
+ next if ($line =~ m/^All Times Eastern/);
+ next if ($line =~ m/^$mmonth[[:space:]]*$year/);
#start new day if line begins with a DD Sunday|Monday|...|Friday|Saturday
- ($tday,$mday) = split(" ",$line);
- if( $tday =~ m/^[0-9]*$/ ) {
- if( $tday >= 1 && $tday <= 31 ) {
- if( $mday =~ m/day$/ ) {
- &process() if( $event );
-# print "New day starting: $tday $mday\n";
- $day = $tday;
- $event = "";
- next;
+ ($tday, $mday) = split(" ", $line);
+ if ($tday =~ m/^[0-9]*$/) {
+ if ($tday >= 1 && $tday <= 31) {
+ if ($mday =~ m/day$/) {
+ &process() if ($event);
+
+ # print "New day starting: $tday $mday\n";
+ $day = $tday;
+ $event = "";
+ next;
}
}
}
#start a new event if line begins with a HH:MM[[space]]AM|PM
- if( $line =~ m/^[0-9]*:[0-9][0-9][[:space:]]*[A,P]M/ ) {
- &process() if( $event );
+ if ($line =~ m/^[0-9]*:[0-9][0-9][[:space:]]*[A,P]M/) {
+ &process() if ($event);
$event = "$line";
} else {
$event = $event . " " . $line;
@@ -110,175 +112,187 @@ while($line=<GET>) {
}
#process remaining event, if there is one.
-&process() if( $event );
+&process() if ($event);
close(GET);
print "$num movies processed\n";
##### END MAIN #####
-sub rmleadwhite() {
+sub rmleadwhite()
+{
#remove leading white space
- my($x)=@_;
- ($x)=~s+^[[:space:]]*++;
- return($x);
+ my ($x) = @_;
+ ($x) =~ s+^[[:space:]]*++;
+ return ($x);
}
-sub parse() {
+sub parse()
+{
#parse command line
- our($opt_h, $opt_d, $opt_c, $opt_m, $opt_y, $opt_f, $opt_w);
+ our ($opt_h, $opt_d, $opt_c, $opt_m, $opt_y, $opt_f, $opt_w);
getopts('hdcm:y:f:w:');
- $mode="--delete" if( $opt_d );
- $mode="--change" if( $opt_c );
- $month=$opt_m if( $opt_m );
- $year=$opt_y if( $opt_y );
- $cal=$opt_f if( $opt_f );
- $konkal=$opt_w if( $opt_w );
+ $mode = "--delete" if ($opt_d);
+ $mode = "--change" if ($opt_c);
+ $month = $opt_m if ($opt_m);
+ $year = $opt_y if ($opt_y);
+ $cal = $opt_f if ($opt_f);
+ $konkal = $opt_w if ($opt_w);
-# if( $opt_h ) {
-# print "help here!\r\n";
-# } // if
+ # if( $opt_h ) {
+ # print "help here!\r\n";
+ # } // if
}
-sub process() {
+sub process()
+{
#remove any evil double quotes from the event string
$event =~ s/\"//g;
### Compute starting date
- my($date) = sprintf("%4d-%02d-%02d",$year,$month,$day);
+ my ($date) = sprintf("%4d-%02d-%02d", $year, $month, $day);
### Compute starting time
- my($ttime,$ampm) = split(" ",$event);
- my($hour,$min) = split(":",$ttime);
+ my ($ttime, $ampm) = split(" ", $event);
+ my ($hour, $min) = split(":", $ttime);
# adjust the hour by am or pm
- $hour += 12 if( $ampm =~ m/[Pp][Mm]/ && $hour < 12 );
- $hour -= 12 if( $ampm =~ m/[Aa][Mm]/ && $hour == 12 );
+ $hour += 12 if ($ampm =~ m/[Pp][Mm]/ && $hour < 12);
+ $hour -= 12 if ($ampm =~ m/[Aa][Mm]/ && $hour == 12);
- my($time) = sprintf("%02d:%02d",$hour,$min);
+ my ($time) = sprintf("%02d:%02d", $hour, $min);
# advance day (for the enddate) if we have moved from pm to am
- if($lastampm =~ m/[Pp][Mm]/ && $ampm =~ m/[Aa][Mm]/ ) {
- ($year, $month, $day) = Add_Delta_Days($year,$month, $day, 1);
+ if ($lastampm =~ m/[Pp][Mm]/ && $ampm =~ m/[Aa][Mm]/) {
+ ($year, $month, $day) = Add_Delta_Days($year, $month, $day, 1);
}
# format start date and time for "greping" later
- my($gdate) = sprintf("\"%s %02d %s %4d\"",
- Day_of_Week_to_Text(Day_of_Week($year,$month,$day)),
- $day,
- Month_to_Text($month),
- $year);
- my($ghour) = $hour;
- if( $ghour == 12 ) {
+ my ($gdate) = sprintf(
+ "\"%s %02d %s %4d\"",
+ Day_of_Week_to_Text(Day_of_Week($year, $month, $day)),
+ $day, Month_to_Text($month), $year
+ );
+ my ($ghour) = $hour;
+ if ($ghour == 12) {
$ampm = "pm";
}
- if( $ghour > 12 ) {
+ if ($ghour > 12) {
$ghour -= 12;
- $ampm = "pm"
+ $ampm = "pm";
}
- if( $ghour == 0 ) {
+ if ($ghour == 0) {
$ghour = 12;
- $ampm = "am";
+ $ampm = "am";
}
- my($gtime) = sprintf("\"%02d:%02d %s\"",$ghour,$min,lc($ampm));
+ my ($gtime) = sprintf("\"%02d:%02d %s\"", $ghour, $min, lc($ampm));
### Compute Movie End Datetime by adding Movie Duration to Start Datetime
# derive duration
- my($duration) = $event;
+ my ($duration) = $event;
$duration =~ s/CC//g;
$duration =~ s/LBX//g;
$duration =~ s/DVS//g;
- my(@d) = reverse(split(" ",$duration));
- $duration=$d[0];
+ my (@d) = reverse(split(" ", $duration));
+ $duration = $d[0];
$duration =~ s/m\.$//g;
+
#print "DURATION COMPUTATION ERROR\n" if( $duration < 1 || $duration > 300);
- my($endyear,$endmonth,$endday,$endhh, $endmm, $endss) = Add_Delta_DHMS(
- $year,$month,$day,$hour,$min,0,
- 0, 0, $duration, 0);
+ my ($endyear, $endmonth, $endday, $endhh, $endmm, $endss) =
+ Add_Delta_DHMS($year, $month, $day, $hour, $min, 0, 0, 0, $duration, 0);
+
# format end datetime
- my($enddate) = sprintf("%4d-%02d-%02d",$endyear,$endmonth,$endday);
- my($endtime) = sprintf("%02d:%02d",$endhh,$endmm);
- my($genddate) = sprintf("\"%s %02d %s %4d\"",
- Day_of_Week_to_Text(Day_of_Week($endyear,$endmonth,$endday)),
- $endday,
- Month_to_Text($endmonth),
- $endyear);
+ my ($enddate) = sprintf("%4d-%02d-%02d", $endyear, $endmonth, $endday);
+ my ($endtime) = sprintf("%02d:%02d", $endhh, $endmm);
+ my ($genddate) = sprintf(
+ "\"%s %02d %s %4d\"",
+ Day_of_Week_to_Text(Day_of_Week($endyear, $endmonth, $endday)),
+ $endday, Month_to_Text($endmonth), $endyear
+ );
$ampm = "am";
- if( $endhh == 12 ) {
+ if ($endhh == 12) {
$ampm = "pm";
}
- if( $endhh > 12 ) {
+ if ($endhh > 12) {
$endhh -= 12;
$ampm = "pm";
}
- if( $endhh == 0 ) {
+ if ($endhh == 0) {
$endhh = 12;
- $ampm = "am";
+ $ampm = "am";
}
- my($gendtime) = sprintf("\"%02d:%02d %s\"",$endhh,$endmm,lc($ampm));
+ my ($gendtime) = sprintf("\"%02d:%02d %s\"", $endhh, $endmm, lc($ampm));
# Derive Movie Title
- my($tmp) = split("[)]",$event);
- my($tmp2,$title) = split("^[0-9]*:[0-9][0-9][[:space:]]*[A,P]M",$tmp);
- $title=&rmleadwhite($title);
- $title=$title . ")";
- if( $title =~ m/\([[:space:]]\)/ ) {
+ my ($tmp) = split("[)]", $event);
+ my ($tmp2, $title) = split("^[0-9]*:[0-9][0-9][[:space:]]*[A,P]M", $tmp);
+ $title = &rmleadwhite($title);
+ $title = $title . ")";
+ if ($title =~ m/\([[:space:]]\)/) {
print "SKIPPING MOVIE WITHOUT A TITLE\n";
return;
}
- my($gtitle) = "\"" . $title . "\"";
+ my ($gtitle) = "\"" . $title . "\"";
# "Grep line".
# Due to events across multiple days, search for ending date/time only.
-# my($UID)=&find_uid("$gdate,$gtime,$genddate,$gendtime,$gtitle");
- my($UID)=&find_uid(",$genddate,$gendtime,$gtitle");
+ # my($UID)=&find_uid("$gdate,$gtime,$genddate,$gendtime,$gtitle");
+ my ($UID) = &find_uid(",$genddate,$gendtime,$gtitle");
# New Title for Change Mode
- $title=uc($title) if( $mode eq "--change" );
+ $title = uc($title) if ($mode eq "--change");
# print "EVENT start datetime=$date, $time, title=$title, end datetime=$enddate, $endtime, duration=$duration\n";
- $lastampm=$ampm;
+ $lastampm = $ampm;
# Run konsolekalendar to insert/change/delete the event
- if( system("$konkal $mode $UID --file $cal --date $date --time $time --end-date $enddate --end-time $endtime --summary \"$title\" --description \"$event\"") ) {
+ if (
+ system(
+"$konkal $mode $UID --file $cal --date $date --time $time --end-date $enddate --end-time $endtime --summary \"$title\" --description \"$event\""
+ )
+ )
+ {
$mode =~ s/--//;
- print "Failure Condition Encountered. Unable to $mode Event.\n"; exit 1;
+ print "Failure Condition Encountered. Unable to $mode Event.\n";
+ exit 1;
}
$num++;
}
-sub find_uid() {
-
- my($line);
- my($grepline) = shift;
- my($UID)="";
-
- if( $mode ne "--add" ) {
- if( open(VIEW, "$konkal --view --all --export-type csv --file $cal |") ) {
- while($line=<VIEW>) {
- if( index($line,$grepline) >= 0) {
- my(@u) = reverse(split(",",$line));
- chomp($u[0]);
- $UID="--uid=$u[0]";
- last;
- }
+sub find_uid()
+{
+
+ my ($line);
+ my ($grepline) = shift;
+ my ($UID) = "";
+
+ if ($mode ne "--add") {
+ if (open(VIEW, "$konkal --view --all --export-type csv --file $cal |")) {
+ while ($line = <VIEW>) {
+ if (index($line, $grepline) >= 0) {
+ my (@u) = reverse(split(",", $line));
+ chomp($u[0]);
+ $UID = "--uid=$u[0]";
+ last;
+ }
}
- if( $UID eq "" ) {
- print "Failure Condition Encoutered. Unable to locate Event $grepline in calendar.\n"; exit 1;
+ if ($UID eq "") {
+ print "Failure Condition Encountered. Unable to locate Event $grepline in calendar.\n";
+ exit 1;
}
} else {
die "Failed to view cal $cal.\n";
}
close(VIEW);
}
- return($UID);
+ return ($UID);
}
__END__
diff --git a/konsolekalendar/examples/testkalendar.sh b/konsolekalendar/examples/testkalendar.sh
index 869653d..b7792ab 100644
--- a/konsolekalendar/examples/testkalendar.sh
+++ b/konsolekalendar/examples/testkalendar.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
##########################################################################################
#
# ***************************************************************************
@@ -30,7 +30,7 @@ while [ $DATE -lt 29 ]; do
COMMAND="$KONSOLEKALENDAR $1 --time $HOUR:$MINUTE --description $3 --summary $3 --date $YEAR-$MONTH-$DATE --create --file=$2"
-echo using command $COMMAND
+echo using command "$COMMAND"
$COMMAND
echo "################################ TEXT ##################################"
@@ -45,8 +45,8 @@ echo "################################ ORG ##################################"
COMMAND="$KONSOLEKALENDAR --view --time $HOUR:$MINUTE --date $YEAR-$MONTH-$DATE --export-type Text-organizer --file=$2"
$COMMAND
-let DATE=$DATE+1
-let MINUTE=$MINUTE+1
+DATE=$((DATE + 1))
+MINUTE=$((MINUTE + 1))
done
}
@@ -56,14 +56,11 @@ KONSOLEKALENDAR=../konsolekalendar
ADDING="--add"
REMOVE="--delete"
CHANGE="--change"
-VIEW="--view"
-COMMAND="";
+COMMAND=""
FILE="./testcaledar.ics"
do_test $ADDING $FILE "ADD"
do_test $CHANGE $FILE "CHANGE"
do_test $REMOVE $FILE "REMOVE"
-
-
diff --git a/konsolekalendar/pics/CMakeLists.txt b/konsolekalendar/pics/CMakeLists.txt
index 5360961..278a11d 100644
--- a/konsolekalendar/pics/CMakeLists.txt
+++ b/konsolekalendar/pics/CMakeLists.txt
@@ -1,4 +1,3 @@
-
########### install files ###############
ecm_install_icons(ICONS 128-apps-konsolekalendar.png 16-apps-konsolekalendar.png 22-apps-konsolekalendar.png 32-apps-konsolekalendar.png 48-apps-konsolekalendar.png DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor)
More information about the kde-doc-english
mailing list