Commit 1f1b5806 authored by Ben Cooksley's avatar Ben Cooksley

Port to non-deprecated PyYAML functions.

This should also correct the breakage which is currently causing all Frameworks Linux builds to have an UNSTABLE (failing tests) status as the YAML depreciation warnings were causing the check-platforms logic to trip.

CCMAIL: kde-frameworks-devel@kde.org
parent 878b26e5
Pipeline #2285 skipped with stage
...@@ -26,7 +26,7 @@ resolver.loadProjectsIgnoreRules(os.path.join( CommonUtils.scriptsBaseDirectory( ...@@ -26,7 +26,7 @@ resolver.loadProjectsIgnoreRules(os.path.join( CommonUtils.scriptsBaseDirectory(
for metainfo in arguments.metainfo: for metainfo in arguments.metainfo:
metainfoFile = open(metainfo, 'r', encoding='utf-8') metainfoFile = open(metainfo, 'r', encoding='utf-8')
read = yaml.load(metainfoFile) read = yaml.safe_load(metainfoFile)
platforms = [p['name'] for p in read['platforms']] platforms = [p['name'] for p in read['platforms']]
if 'All' in platforms: if 'All' in platforms:
platforms = allPlatforms.values() platforms = allPlatforms.values()
......
...@@ -52,7 +52,7 @@ class Loader(object): ...@@ -52,7 +52,7 @@ class Loader(object):
# Load the file now # Load the file now
with open(configFileLocation, 'r') as configFile: with open(configFileLocation, 'r') as configFile:
# Parse the YAML file # Parse the YAML file
projectConfig = yaml.load(configFile) projectConfig = yaml.safe_load(configFile)
# Does it specify something for this branch group? # Does it specify something for this branch group?
if branchGroup in projectConfig: if branchGroup in projectConfig:
......
...@@ -107,7 +107,7 @@ class DependencyResolver(object): ...@@ -107,7 +107,7 @@ class DependencyResolver(object):
# Load the metadata.yaml file and create a project from it # Load the metadata.yaml file and create a project from it
projectMetadataFile = open(entry.path, 'r', encoding='utf-8') projectMetadataFile = open(entry.path, 'r', encoding='utf-8')
# Parse the YAML file # Parse the YAML file
projectMetadata = yaml.load(projectMetadataFile) projectMetadata = yaml.safe_load(projectMetadataFile)
# Is it a repository - ie. something we need to know about? # Is it a repository - ie. something we need to know about?
if not projectMetadata['hasrepo'] or not projectMetadata['repoactive']: if not projectMetadata['hasrepo'] or not projectMetadata['repoactive']:
continue continue
...@@ -135,7 +135,7 @@ class DependencyResolver(object): ...@@ -135,7 +135,7 @@ class DependencyResolver(object):
# Open the file # Open the file
ignoreRulesFile = open(ignoreRulesPath, 'r', encoding='utf-8') ignoreRulesFile = open(ignoreRulesPath, 'r', encoding='utf-8')
# Parse the YAML file # Parse the YAML file
ignoreRules = yaml.load(ignoreRulesFile) ignoreRules = yaml.safe_load(ignoreRulesFile)
# We'll go through each platform's section in turn # We'll go through each platform's section in turn
for platform in ignoreRules.keys(): for platform in ignoreRules.keys():
# Now go over each rule in turn (which is just the name of the project... # Now go over each rule in turn (which is just the name of the project...
...@@ -295,7 +295,7 @@ class ProductHandler(object): ...@@ -295,7 +295,7 @@ class ProductHandler(object):
# We expect a YAML format file # We expect a YAML format file
with open(filePath, 'r') as dataFile: with open(filePath, 'r') as dataFile:
# Parse the YAML file # Parse the YAML file
self.productsData = yaml.load( dataFile ) self.productsData = yaml.safe_load( dataFile )
# Let the user know what Products we know about # Let the user know what Products we know about
def knownProducts(self): def knownProducts(self):
......
...@@ -28,7 +28,7 @@ class Archive(object): ...@@ -28,7 +28,7 @@ class Archive(object):
configFileLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'archive-configs', name + '.yaml' ) configFileLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'archive-configs', name + '.yaml' )
with open(configFileLocation, 'r') as configFile: with open(configFileLocation, 'r') as configFile:
# Parse the YAML file # Parse the YAML file
self.config = yaml.load( configFile ) self.config = yaml.safe_load( configFile )
# Are we using a local cache? # Are we using a local cache?
# If not, then retrieval of packages won't be possible so nothing further needs to be done # If not, then retrieval of packages won't be possible so nothing further needs to be done
...@@ -43,7 +43,7 @@ class Archive(object): ...@@ -43,7 +43,7 @@ class Archive(object):
# Retrieve the archive manifest from the remote server # Retrieve the archive manifest from the remote server
# We'll use this to determine if we need to update a file from the remote server # We'll use this to determine if we need to update a file from the remote server
response = urllib.request.urlopen( self.downloadBaseUrl() + '/manifest.yaml' ) response = urllib.request.urlopen( self.downloadBaseUrl() + '/manifest.yaml' )
self.serverManifest = yaml.load( response.read() ) self.serverManifest = yaml.safe_load( response.read() )
# Make sure the Manifest is valid... # Make sure the Manifest is valid...
if self.serverManifest is None: if self.serverManifest is None:
...@@ -103,7 +103,7 @@ class Archive(object): ...@@ -103,7 +103,7 @@ class Archive(object):
if os.path.exists( localMetadataPath ): if os.path.exists( localMetadataPath ):
# Load the local metadata # Load the local metadata
with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile: with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile:
localMetadata = yaml.load( localMetadataFile ) localMetadata = yaml.safe_load( localMetadataFile )
# Look it up in the server manifest... # Look it up in the server manifest...
serverMetadata = self.serverManifest[ package ] serverMetadata = self.serverManifest[ package ]
# If the server timestamp is lower or the same, no need to fetch # If the server timestamp is lower or the same, no need to fetch
...@@ -216,7 +216,7 @@ class Archive(object): ...@@ -216,7 +216,7 @@ class Archive(object):
# And update our internal copy of the server side metadata # And update our internal copy of the server side metadata
with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile: with open(localMetadataPath, 'r', encoding='utf-8') as localMetadataFile:
self.serverManifest[ package ] = yaml.load( localMetadataFile ) self.serverManifest[ package ] = yaml.safe_load( localMetadataFile )
# Performs the package publishing process # Performs the package publishing process
# This function should only be called on the archive server and will not function correctly on clients. # This function should only be called on the archive server and will not function correctly on clients.
...@@ -228,7 +228,7 @@ class Archive(object): ...@@ -228,7 +228,7 @@ class Archive(object):
# Because we need to know the contentsSuffix of the file we're publishing, load the metadata for the file... # Because we need to know the contentsSuffix of the file we're publishing, load the metadata for the file...
with open(stagedMetadataPath, 'r', encoding='utf-8') as metadataFile: with open(stagedMetadataPath, 'r', encoding='utf-8') as metadataFile:
metadata = yaml.load( metadataFile ) metadata = yaml.safe_load( metadataFile )
contentsSuffix = metadata.get('contentsSuffix', self.contentsSuffix) contentsSuffix = metadata.get('contentsSuffix', self.contentsSuffix)
# Now that we know the contentsSuffix, we can go ahead and determine where our package's content can be found and where it needs to be moved to # Now that we know the contentsSuffix, we can go ahead and determine where our package's content can be found and where it needs to be moved to
...@@ -277,7 +277,7 @@ class Archive(object): ...@@ -277,7 +277,7 @@ class Archive(object):
metadataPath = os.path.join(archiveFolder, fileToCheck) metadataPath = os.path.join(archiveFolder, fileToCheck)
# Load the YAML file # Load the YAML file
with open(metadataPath, 'r', encoding='utf-8') as metadataFile: with open(metadataPath, 'r', encoding='utf-8') as metadataFile:
metadata = yaml.load( metadataFile ) metadata = yaml.safe_load( metadataFile )
# Add it to our Manifest # Add it to our Manifest
manifestContents[ packageName ] = metadata manifestContents[ packageName ] = metadata
......
...@@ -45,7 +45,7 @@ class Loader(object): ...@@ -45,7 +45,7 @@ class Loader(object):
# Load the file now # Load the file now
with open( configFileLocation, 'r' ) as configFile: with open( configFileLocation, 'r' ) as configFile:
# Parse the YAML file # Parse the YAML file
projectConfig = yaml.load( configFile ) projectConfig = yaml.safe_load( configFile )
entries = [] entries = []
for key in projectConfig: for key in projectConfig:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment