From 9fc9b74724b7549615a1d05b5ca6a3a84148eb5e Mon Sep 17 00:00:00 2001 From: John Mertic Date: Mon, 2 Dec 2024 17:36:24 -0500 Subject: [PATCH] Add Reddit, Pintrest, YouTube, Facebook, and LinkedIn extra fields (#80) Corresponds to the new fields added from https://github.com/cncf/landscape2/pull/759 --------- Signed-off-by: John Mertic --- lfx_landscape_tools/lfxprojects.py | 4 ++++ lfx_landscape_tools/member.py | 6 ++++++ test/test_lfxprojects.py | 10 ++++++++++ test/test_member.py | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/lfx_landscape_tools/lfxprojects.py b/lfx_landscape_tools/lfxprojects.py index fa61cb6..7138451 100644 --- a/lfx_landscape_tools/lfxprojects.py +++ b/lfx_landscape_tools/lfxprojects.py @@ -103,6 +103,10 @@ def loadData(self): member.crunchbase = record.get('CrunchBaseUrl',self.defaultCrunchbase) member.linkedin = record.get('LinkedIn') member.twitter = record.get('Twitter') + extra['facebook_url'] = record.get('Facebook') + extra['reddit_url'] = record.get('Reddit') + extra['pinterest_url'] = record.get('Pinterest') + extra['youtube_url'] = record.get('YouTube') if self.addPMOManagedStatus and record.get('HasProgramManager'): second_path.append('PMO Managed / All') if self.addIndustrySector and record.get('IndustrySector') != '': diff --git a/lfx_landscape_tools/member.py b/lfx_landscape_tools/member.py index 1e427f4..16e014c 100644 --- a/lfx_landscape_tools/member.py +++ b/lfx_landscape_tools/member.py @@ -285,6 +285,12 @@ def toLandscapeItemAttributes(self): if returnentry.get('crunchbase'): del returnentry['crunchbase'] + if self.linkedin: + logging.getLogger().info("Setting 'extra.linkedin_url' to '{}' for '{}'".format(self.linkedin,self.orgname)) + if not returnentry['extra']: + returnentry['extra'] = {} + returnentry['extra']['linkedin_url'] = self.linkedin + return returnentry def isValidLandscapeItem(self): diff --git a/test/test_lfxprojects.py b/test/test_lfxprojects.py index 1582d97..0f94abd 100755 --- a/test/test_lfxprojects.py +++ b/test/test_lfxprojects.py @@ -145,6 +145,11 @@ def testLoadData(self): "Motion Pictures" ], "IndustrySector": "Motion Pictures", + "Facebook": "https://www.facebook.com/TheLinuxFoundation", + "LinkedIn": "https://www.linkedin.com/company/208777", + "Reddit": "https://www.reddit.com/r/vfx/", + "Pinterest": "https://www.pinterest.com/linuxfoundation/", + "YouTube": "https://www.youtube.com/user/TheLinuxFoundation", "Name": "OpenCue", "ParentID": "a09410000182dD2AAI", "ParentSlug": "aswf", @@ -780,6 +785,11 @@ def testLoadData(self): members.loadData() self.assertEqual(members.members[0].orgname,"OpenCue") self.assertEqual(members.members[0].crunchbase,"https://www.crunchbase.com/organization/linux-foundation") + self.assertEqual(members.members[0].extra["facebook_url"],"https://www.facebook.com/TheLinuxFoundation") + self.assertEqual(members.members[0].linkedin,"https://www.linkedin.com/company/208777") + self.assertEqual(members.members[0].extra["reddit_url"],"https://www.reddit.com/r/vfx/") + self.assertEqual(members.members[0].extra["pinterest_url"],"https://www.pinterest.com/linuxfoundation/") + self.assertEqual(members.members[0].extra["youtube_url"],"https://www.youtube.com/user/TheLinuxFoundation") self.assertEqual(members.members[0].logo,"opencue.svg") self.assertEqual(members.members[0].membership,"All") self.assertEqual(members.members[0].website,"https://opencue.io/") diff --git a/test/test_member.py b/test/test_member.py index 967a1bd..6b70ab0 100755 --- a/test/test_member.py +++ b/test/test_member.py @@ -225,11 +225,13 @@ def testToLandscapeItemAttributesEmptyCrunchbase(self): member.orgname = 'test' member.website = 'https://foo.com' member.membership = 'Gold' + member.linkedin = 'https://www.linkedin.com/company/208777' dict = member.toLandscapeItemAttributes() self.assertEqual(dict.get('name'),member.orgname) self.assertEqual(dict.get('homepage_url'),member.website) self.assertEqual(dict.get('organization',{}).get('name'),member.orgname) + self.assertEqual(dict.get('organization',{}).get('linkedin'),member.linkedin) self.assertIsNone(dict.get('logo')) self.assertIsNone(dict.get('item')) self.assertNotIn('crunchbase',dict) @@ -241,11 +243,13 @@ def testToLandscapeItemAttributesWithSuffix(self): member.website = 'https://foo.com' member.membership = 'Gold' member.crunchbase = 'https://www.crunchbase.com/organization/visual-effects-society' + member.linkedin = 'https://www.linkedin.com/company/208777' dict = member.toLandscapeItemAttributes() self.assertEqual(dict.get('name'),member.orgname+" (testme)") self.assertEqual(dict.get('homepage_url'),member.website) self.assertEqual(dict.get('crunchbase'),member.crunchbase) + self.assertEqual(dict.get('extra',{}).get('linkedin_url'),member.linkedin) self.assertIsNone(dict.get('logo')) self.assertIsNone(dict.get('item')) self.assertNotIn('membership',dict)