
import json
import os.path

class CoreConfig(object):
	"""
	MCServer Tools configuration
	"""

	SETTINGS_FILE = 'mcserver.settings'

	def __init__(self, path):
		"""
		Load configuration from the given file path
		"""

		self.settings_file = os.path.join(path, self.SETTINGS_FILE)
		self._settings     = {}

		self._load_settings()

	def _load_settings(self):
		"""
		Load the settings from disk
		"""

		with open(self.settings_file, 'r') as fh:
			self._settings = json.load(fh)

	def get(self, property, default = None):
		"""
		Try to get the property value. If the property was not found
		then return the given default.
		"""

		if property not in self._settings:
			return default

		return self._settings[property]

	def has(self, property):
		"""
		Check if the config has the given property.
		"""

		return property in self._settings



import json
import os.path

from mcserver import MCServerError

class CoreConfig(object):
	"""
	MCServer Tools configuration
	"""

	SETTINGS_FILE = 'mcserver.settings'

	def __init__(self, path):
		"""
		Load configuration from the given file path
		"""

		self.settings_file = os.path.join(path, self.SETTINGS_FILE)
		self._settings     = {}

		self._load_settings()

	def _load_settings(self):
		"""
		Load the settings from disk
		"""

		try:
			with open(self.settings_file, 'r') as fh:
				self._settings = json.load(fh)
		except:
			raise MCServerError('Could not open settings file: {}'.format(self.settings_file))

	def get(self, property, default = None):
		"""
		Try to get the property value. If the property was not found
		then return the given default.
		"""

		if property not in self._settings:
			return default

		return self._settings[property]

	def has(self, property):
		"""
		Check if the config has the given property.
		"""

		return property in self._settings


Check for the existance of the settings file and report if its not there
Check for the existance of the settings file and report if its not there

  
  import json
  import os.path
+ 
+ from mcserver import MCServerError
  
  class CoreConfig(object):
  	"""
  	MCServer Tools configuration
  	"""
  
  	SETTINGS_FILE = 'mcserver.settings'
  
  	def __init__(self, path):
  		"""
  		Load configuration from the given file path
  		"""
  
  		self.settings_file = os.path.join(path, self.SETTINGS_FILE)
  		self._settings     = {}
  
  		self._load_settings()
  
  	def _load_settings(self):
  		"""
  		Load the settings from disk
  		"""
  
+ 		try:
- 		with open(self.settings_file, 'r') as fh:
+ 			with open(self.settings_file, 'r') as fh:
- 			self._settings = json.load(fh)
+ 				self._settings = json.load(fh)
+ 		except:
+ 			raise MCServerError('Could not open settings file: {}'.format(self.settings_file))
  
  	def get(self, property, default = None):
  		"""
  		Try to get the property value. If the property was not found
  		then return the given default.
  		"""
  
  		if property not in self._settings:
  			return default
  
  		return self._settings[property]
  
  	def has(self, property):
  		"""
  		Check if the config has the given property.
  		"""
  
  		return property in self._settings
  
  
Check for the existance of the settings file and report if its not there
## Code Before:

import json
import os.path

class CoreConfig(object):
	"""
	MCServer Tools configuration
	"""

	SETTINGS_FILE = 'mcserver.settings'

	def __init__(self, path):
		"""
		Load configuration from the given file path
		"""

		self.settings_file = os.path.join(path, self.SETTINGS_FILE)
		self._settings     = {}

		self._load_settings()

	def _load_settings(self):
		"""
		Load the settings from disk
		"""

		with open(self.settings_file, 'r') as fh:
			self._settings = json.load(fh)

	def get(self, property, default = None):
		"""
		Try to get the property value. If the property was not found
		then return the given default.
		"""

		if property not in self._settings:
			return default

		return self._settings[property]

	def has(self, property):
		"""
		Check if the config has the given property.
		"""

		return property in self._settings


## Instruction:
Check for the existance of the settings file and report if its not there
## Code After:

import json
import os.path

from mcserver import MCServerError

class CoreConfig(object):
	"""
	MCServer Tools configuration
	"""

	SETTINGS_FILE = 'mcserver.settings'

	def __init__(self, path):
		"""
		Load configuration from the given file path
		"""

		self.settings_file = os.path.join(path, self.SETTINGS_FILE)
		self._settings     = {}

		self._load_settings()

	def _load_settings(self):
		"""
		Load the settings from disk
		"""

		try:
			with open(self.settings_file, 'r') as fh:
				self._settings = json.load(fh)
		except:
			raise MCServerError('Could not open settings file: {}'.format(self.settings_file))

	def get(self, property, default = None):
		"""
		Try to get the property value. If the property was not found
		then return the given default.
		"""

		if property not in self._settings:
			return default

		return self._settings[property]

	def has(self, property):
		"""
		Check if the config has the given property.
		"""

		return property in self._settings

