From 4d2c90ccbec068364fbf7363f5cd49f9517d1c85 Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Fri, 10 Feb 2023 07:21:02 +0100 Subject: [PATCH 1/2] Fix some errors after updating dependencies --- src/Parser/ConfsTech/ConferenceParser.php | 12 ++++++++---- src/Writer/NullOutput.php | 15 +++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Parser/ConfsTech/ConferenceParser.php b/src/Parser/ConfsTech/ConferenceParser.php index 203a345..0117ad8 100644 --- a/src/Parser/ConfsTech/ConferenceParser.php +++ b/src/Parser/ConfsTech/ConferenceParser.php @@ -32,11 +32,15 @@ public function __construct( public function __invoke(array $conference) : Cfp { $cfp = new Cfp(); - $cfp->location = $conference['city']; + if (isset($conference['city'])) { + $cfp->location = $conference['city']; + } - $geolocation = $this->geolocation->getLocationForAddress( - $conference['country'] . ', ' . $cfp->location - ); + if (isset($conference['country'])) { + $geolocation = $this->geolocation->getLocationForAddress( + $conference['country'] . ', ' . $cfp->location + ); + } $cfp->latitude = $geolocation->getLatitude(); $cfp->longitude = $geolocation->getLongitude(); diff --git a/src/Writer/NullOutput.php b/src/Writer/NullOutput.php index abee643..ba9677d 100644 --- a/src/Writer/NullOutput.php +++ b/src/Writer/NullOutput.php @@ -38,7 +38,7 @@ class NullOutput implements OutputInterface * * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise */ - public function isDebug() + public function isDebug(): bool { return false; } @@ -60,7 +60,7 @@ public function setFormatter(OutputFormatterInterface $formatter) * * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise */ - public function isVerbose() + public function isVerbose(): bool { return false; } @@ -70,7 +70,7 @@ public function isVerbose() * * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise */ - public function isVeryVerbose() + public function isVeryVerbose(): bool { return false; } @@ -125,7 +125,7 @@ public function setVerbosity($level) * @return int The current level of verbosity (one of the VERBOSITY constants) * @api */ - public function getVerbosity() + public function getVerbosity(): int { return 0; } @@ -148,7 +148,7 @@ public function setDecorated($decorated) * @return bool true if the output will decorate messages, false otherwise * @api */ - public function isDecorated() + public function isDecorated(): bool { return 0; } @@ -156,10 +156,9 @@ public function isDecorated() /** * Returns current output formatter instance. * - * @return OutputFormatterInterface * @api */ - public function getFormatter() + public function getFormatter(): OutputFormatterInterface { // TODO: Implement getFormatter() method. } @@ -169,7 +168,7 @@ public function getFormatter() * * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise */ - public function isQuiet() + public function isQuiet(): bool { // TODO: Implement isQuiet() method. } From b42273b6052828d91082764cbdb963505a128609 Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Fri, 10 Feb 2023 08:13:00 +0100 Subject: [PATCH 2/2] Adapt Sessionize parser to the new layout --- src/Command/AbstractParseEvents.php | 4 +++- src/Parser/ConfsTech/ConferenceParser.php | 14 +++++++------- src/Subcommands/Sessionize/Parser/ClosingDate.php | 4 ++-- .../Sessionize/Parser/EventStartDate.php | 11 ++++++++++- src/Subcommands/Sessionize/Parser/Sessionize.php | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/Command/AbstractParseEvents.php b/src/Command/AbstractParseEvents.php index 8373ba1..e497d74 100644 --- a/src/Command/AbstractParseEvents.php +++ b/src/Command/AbstractParseEvents.php @@ -77,7 +77,7 @@ protected function configure() , $this->getServiceUrl())); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $header_style = new OutputFormatterStyle('white', 'green', array('bold')); $style = new SymfonyStyle($input, $output); @@ -161,6 +161,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $style->writeln('There where issues with these conferences:'); $style->listing($items); } + + return 0; } abstract protected function getParser(ServiceContainer $serviceContainer) : ParserInterface; diff --git a/src/Parser/ConfsTech/ConferenceParser.php b/src/Parser/ConfsTech/ConferenceParser.php index 0117ad8..43881d1 100644 --- a/src/Parser/ConfsTech/ConferenceParser.php +++ b/src/Parser/ConfsTech/ConferenceParser.php @@ -40,15 +40,15 @@ public function __invoke(array $conference) : Cfp $geolocation = $this->geolocation->getLocationForAddress( $conference['country'] . ', ' . $cfp->location ); - } - $cfp->latitude = $geolocation->getLatitude(); - $cfp->longitude = $geolocation->getLongitude(); + $cfp->latitude = $geolocation->getLatitude(); + $cfp->longitude = $geolocation->getLongitude(); - $cfp->timezone = $this->timezone->getTimezoneForLocation( - $cfp->latitude, - $cfp->longitude - ); + $cfp->timezone = $this->timezone->getTimezoneForLocation( + $cfp->latitude, + $cfp->longitude + ); + } $cfp->conferenceName = $conference['name']; $cfp->eventStartDate = new DateTimeImmutable( diff --git a/src/Subcommands/Sessionize/Parser/ClosingDate.php b/src/Subcommands/Sessionize/Parser/ClosingDate.php index e2b1c98..8b6cb99 100644 --- a/src/Subcommands/Sessionize/Parser/ClosingDate.php +++ b/src/Subcommands/Sessionize/Parser/ClosingDate.php @@ -28,14 +28,14 @@ public function __construct(DateTimeZone $timezone) public function parse(DOMDocument $dom, DOMXPath $xpath) : DateTimeImmutable { - $closingDateHolder = $xpath->query('//div[./div/span[contains(text(), "CfS closes at")]]'); + $closingDateHolder = $xpath->query('//div[./div/span[contains(text(), "Call closes at")]]'); if (! $closingDateHolder || $closingDateHolder->length == 0) { throw new InvalidArgumentException('The CfP does not seem to have a closing date'); } $closingDay = $closingDateHolder->item(0)->getElementsByTagName('h2')->item(0)->textContent; - $closingHour = $closingDateHolder->item(0)->getElementsByTagName('span')->item(0)->textContent; + $closingHour = str_replace('Call closes at ', '', $closingDateHolder->item(0)->getElementsByTagName('span')->item(0)->textContent); $closingHour = $this->clearClosingHour($closingHour); diff --git a/src/Subcommands/Sessionize/Parser/EventStartDate.php b/src/Subcommands/Sessionize/Parser/EventStartDate.php index f64e20a..b7c14d4 100644 --- a/src/Subcommands/Sessionize/Parser/EventStartDate.php +++ b/src/Subcommands/Sessionize/Parser/EventStartDate.php @@ -34,6 +34,11 @@ public function parse(DOMDocument $dom, DOMXPath $xpath) : DateTimeImmutable //$startDate = $xpath->query('//div[contains(text()[2], "event date")]/following-sibling::h2'); $startDate = $xpath->query('//div[contains(., "event date")]'); } + if (! $startDate || $startDate->length == 0) { + // This expression does not work. It looks like the reason is the array-notation... + //$startDate = $xpath->query('//div[contains(text()[2], "event date")]/following-sibling::h2'); + $startDate = $xpath->query('//div[contains(., "planned future dates")]'); + } if (! $startDate || $startDate->length == 0) { throw new \InvalidArgumentException('The Event does not seem to have a start date-identifier'); } @@ -46,6 +51,10 @@ public function parse(DOMDocument $dom, DOMXPath $xpath) : DateTimeImmutable $startDate = $startDate->item(0)->textContent; - return new DateTimeImmutable($startDate, $this->timezone); + // Make sure that with multiple start-dates separated by a comma + // only the first one is used + $startDate = implode(', ', $startDate); + + return new DateTimeImmutable($startDate[0], $this->timezone); } } diff --git a/src/Subcommands/Sessionize/Parser/Sessionize.php b/src/Subcommands/Sessionize/Parser/Sessionize.php index 80dc4c4..74df1d3 100644 --- a/src/Subcommands/Sessionize/Parser/Sessionize.php +++ b/src/Subcommands/Sessionize/Parser/Sessionize.php @@ -66,7 +66,7 @@ public function parse(WriterInterface $writer) $writer->write($cfp, 'Sessionize'); $cfpList->append($cfp); } catch (\Exception $e) { - //error_log($e->getMEssage()); + error_log($e->getMEssage() . ' ' . $loc->textContent); } }