commotion_client.utils.validate.ClientConfig Class Reference
Inheritance diagram for commotion_client.utils.validate.ClientConfig:

Public Member Functions

def __init__
 
def config
 
def config
 
def extension_path
 
def extension_path
 
def validate_all
 
def gui
 
def name
 
def menu_item
 
def parent
 
def menu_level
 
def tests
 
def check_menu_text
 
def check_exists
 
def check_path
 
def check_path_chars
 
def check_path_length
 

Public Attributes

 config_values
 
 log
 
 translate
 
 config
 
 extension_path
 
 errors
 

Constructor & Destructor Documentation

def commotion_client.utils.validate.ClientConfig.__init__ (   self,
  config,
  directory = None 
)
Args:
  config (dictionary): The config for the extension.
  directory (string): Absolute Path to the directory containing the extension zipfile. If not specified the validator will ONLY check the validity of the config passed to it.

References commotion_client.utils.validate.ClientConfig.config, commotion_client.utils.validate.ClientConfig.config_values, commotion_client.utils.validate.ClientConfig.errors, commotion_client.utils.validate.ClientConfig.extension_path, commotion_client.GUI.system_tray.TrayIcon.log, commotion_client.utils.thread.GenericThread.log, commotion_client.utils.single_application.SingleApplication.log, commotion_client.GUI.welcome_page.ViewPort.log, commotion_client.GUI.menu_bar.MenuBar.log, commotion_client.GUI.crash_report.CrashReport.log, commotion_client.extensions.config_editor.main.ViewPort.log, commotion_client.GUI.main_window.MainWindow.log, commotion_client.GUI.toolbar_builder.ToolBar.log, commotion_client.utils.validate.ClientConfig.log, commotion_client.GUI.extension_toolbar.ExtensionToolBar.log, commotion_client.GUI.toolbar.ToolBar.log, commotion_client.utils.extension_manager.ExtensionManager.log, commotion_client.commotion_client.HoldStateDuringRestart.log, commotion_client.GUI.extension_toolbar.MenuItem.log, commotion_client.GUI.crash_report.ReportGatherer.log, commotion_client.commotion_client.CommotionClientApplication.log, commotion_client.utils.extension_manager.ConfigManager.log, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

30 
31  def __init__(self, config, directory=None):
32  """
33  Args:
34  config (dictionary): The config for the extension.
35  directory (string): Absolute Path to the directory containing the extension zipfile. If not specified the validator will ONLY check the validity of the config passed to it.
36  """
37  self.config_values = ["name",
38  "main",
39  "menu_item",
40  "menu_level",
41  "parent",
42  "settings",
43  "toolbar",
44  "tests",
45  "initialized",]
46  self.log = logging.getLogger("commotion_client."+__name__)
47  self.translate = QtCore.QCoreApplication.translate
48  self.config = config
49  if directory:
50  #set extension directory to point at config zipfile in that directory
51  self.extension_path = directory
52  self.errors = None
extension_path
Definition: validate.py:50
def __init__
Definition: validate.py:30
config_values
Definition: validate.py:36

Member Function Documentation

def commotion_client.utils.validate.ClientConfig.check_exists (   self,
  file_name 
)
Checks if a specified file exists within an extension.

@param file_name string The file name from a config file

References commotion_client.utils.validate.ClientConfig.extension_path, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.gui(), and commotion_client.utils.validate.ClientConfig.tests().

236  def check_exists(self, file_name):
237  """Checks if a specified file exists within an extension.
238 
239  @param file_name string The file name from a config file
240  """
241  if not self.extension_path:
242  self.log.debug(self.translate("logs", "No extension directory was specified so file checking was skipped."))
243  return True
244  ext_zip = zipfile.ZipFile(self.extension_path, 'r')
245  files = ext_zip.namelist()
246  if not str(file_name) in files:
247  self.log.warning(self.translate("logs", "The specified file '{0}' does not exist.".format(file_name)))
248  return False
249  else:
250  return True
extension_path
Definition: validate.py:50
def check_exists
Definition: validate.py:235
def commotion_client.utils.validate.ClientConfig.check_menu_text (   self,
  menu_text 
)
Checks that menu text fits within the accepted string length bounds.

@param menu_text string The text that will appear in the menu.

References commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.menu_item(), and commotion_client.utils.validate.ClientConfig.parent().

224  def check_menu_text(self, menu_text):
225  """
226  Checks that menu text fits within the accepted string length bounds.
227 
228  @param menu_text string The text that will appear in the menu.
229  """
230  if not 3 < len(str(menu_text)) < 40:
231  self.log.warning(self.translate("logs", "Menu items must be between 3 and 40 chars long. Becuase it looks prettier that way."))
232  return False
233  else:
234  return True
def check_menu_text
Definition: validate.py:223
def commotion_client.utils.validate.ClientConfig.check_path (   self,
  file_name 
)
Runs all path checking functions on a string.

@param file_name string  The string to check for validity.

References commotion_client.utils.validate.ClientConfig.check_path_chars(), commotion_client.utils.validate.ClientConfig.check_path_length(), commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.gui(), and commotion_client.utils.validate.ClientConfig.tests().

252  def check_path(self, file_name):
253  """Runs all path checking functions on a string.
254 
255  @param file_name string The string to check for validity.
256  """
257  if not self.check_path_length(file_name):
258  self.log.warning(self.translate("logs", "This value is too long for your system."))
259  return False
260  if not self.check_path_chars(file_name):
261  self.log.warning(self.translate("logs", "This value uses invalid characters for your system."))
262  return False
263  return True
def check_path
Definition: validate.py:251
def check_path_chars
Definition: validate.py:264
def check_path_length
Definition: validate.py:286
def commotion_client.utils.validate.ClientConfig.check_path_chars (   self,
  file_name 
)
Checks if a string is a valid file name on this system.

@param file_name string The string to check for validity

References commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.check_path(), and commotion_client.utils.validate.ClientConfig.gui().

265  def check_path_chars(self, file_name):
266  """Checks if a string is a valid file name on this system.
267 
268  @param file_name string The string to check for validity
269  """
270  # file length limit
271  platform = sys.platform
272  reserved = {"cygwin" : r"[|\?*<\":>+[]/]",
273  "win32" : r"[|\?*<\":>+[]/]",
274  "darwin" : "[:]",
275  "linux" : "[/\x00]"}
276  if platform and reserved[platform]:
277  if re.search(file_name, reserved[platform]):
278  self.log.warning(self.translate("logs", "The extension's config file contains an invalid main value."))
279  return False
280  else:
281  return True
282  else:
283  self.log.warning(self.translate("logs", "Your system, {0} is not recognized. This may cause instability if file uses chars that your system does not allow.").format(platform))
284  return True
285 
def check_path_chars
Definition: validate.py:264
def commotion_client.utils.validate.ClientConfig.check_path_length (   self,
  file_name = None 
)
Checks if a string will be of a valid length for a file name and full path on this system.

@param file_name string The string to check for validity.

References commotion_client.utils.validate.ClientConfig.extension_path, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.check_path(), and commotion_client.utils.validate.ClientConfig.gui().

287  def check_path_length(self, file_name=None):
288  """Checks if a string will be of a valid length for a file name and full path on this system.
289 
290  @param file_name string The string to check for validity.
291  """
292  if not self.extension_path:
293  self.log.debug(self.translate("logs", "No extension directory was specified so file checking was skipped."))
294  return True
295  # file length limit
296  platform = sys.platform
297  # OSX(name<=255), linux(name<=255)
298  name_limit = ['linux', 'darwin']
299  # Win(name+path<=260),
300  path_limit = ['win32', 'cygwin']
301  if platform in path_limit:
302  extension_path = os.path.join(QtCore.QDir.currentPath(), "extensions")
303  full_path = os.path.join(extension_path, file_name)
304  if len(str(full_path)) > 255:
305  self.log.warning(self.translate("logs", "The full extension path cannot be greater than 260 chars"))
306  return False
307  else:
308  return True
309  elif platform in name_limit:
310  if len(str(file_name)) >= 260:
311  self.log.warning(self.translate("logs", "File names can not be greater than 260 chars on your system"))
312  return False
313  else:
314  return True
315  else:
316  self.log.warning(self.translate("logs", "Your system, {0} is not recognized. This may cause instability if file or path names are longer than your system allows.").format(platform))
317  return True
extension_path
Definition: validate.py:50
def check_path_length
Definition: validate.py:286
def commotion_client.utils.validate.ClientConfig.config (   self)
Return the config value.

References commotion_client.utils.validate.ClientConfig._config.

54 
55  def config(self):
56  """Return the config value."""
57  return self._config
def commotion_client.utils.validate.ClientConfig.config (   self,
  value 
)
Check for valid values before allowing them to be set.

References commotion_client.utils.validate.ClientConfig._config, commotion_client.utils.validate.ClientConfig._extension_path, commotion_client.utils.validate.ClientConfig.config_values, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

59 
60  def config(self, value):
61  """Check for valid values before allowing them to be set."""
62  if 'name' not in value:
63  raise KeyError(self.translate("logs", "The config file must contain at least a name value."))
64  for val in value.keys():
65  if val not in self.config_values:
66  raise KeyError(self.translate("logs", "The config file specified has the value {0} within it which is not a valid value.".format(val)))
67  self._config = value
68 
config_values
Definition: validate.py:36
def commotion_client.utils.validate.ClientConfig.extension_path (   self,
  value 
)
Takes any directory passed to it and specifies the config file  

References commotion_client.utils.validate.ClientConfig._extension_path, commotion_client.utils.validate.ClientConfig.config, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

74 
75  def extension_path(self, value):
76  """Takes any directory passed to it and specifies the config file """
77  value_dir = QtCore.QDir(value)
78  #Check that the directory in fact exists.
79  if not value_dir.exists():
80  raise NotADirectoryError(self.translate("logs", "The directory should, by definition, actually be a directory. What was submitted was not a directory. Please specify the directory of an existing extension to continue."))
81  #Check that there are files in the directory provided
82  if not value_dir.exists(self.config['name']):
83  raise FileNotFoundError(self.translate("logs", "The extension is not in the extension directory provided. Is an extension directory without an extension an extension directory at all? We will ponder these mysteries while you check to see if the extension directory provided is correct." ))
84  #Check that we can read the directory and its files. Sadly, QDir.isReadable() is broken on a few platforms so we check that and use the file filter to check each file.
85  value_dir.setFilter(QtCore.QDir.Readable|QtCore.QDir.Files)
86  file_list = value_dir.entryInfoList()
87  if not file_list or not value_dir.isReadable():
88  raise PermissionError(self.translate("logs", "The application does not have permission to read any files within this directory. How is it supposed to validate the extension within then? You ask. It can't. Please modify the permissions on the directory and files within to allow the application to read the extension file."))
89  #Set the extension "directory" to point at the extension zipfile
90  path = os.path.join(value, self.config['name'])
91  self._extension_path = path
_extension_path
Definition: validate.py:90
def commotion_client.utils.validate.ClientConfig.gui (   self,
  gui_name 
)
Validate of one of the gui objects config values. (main, settings, or toolbar)

@param gui_name string "main", "settings", or "toolbar"

References commotion_client.utils.validate.ClientConfig.check_exists(), commotion_client.utils.validate.ClientConfig.check_path(), commotion_client.utils.validate.ClientConfig.check_path_chars(), commotion_client.utils.validate.ClientConfig.check_path_length(), commotion_client.utils.validate.ClientConfig.config, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.validate_all().

130  def gui(self, gui_name):
131  """Validate of one of the gui objects config values. (main, settings, or toolbar)
132 
133  @param gui_name string "main", "settings", or "toolbar"
134  """
135  try:
136  val = str(self.config[gui_name])
137  except KeyError:
138  if gui_name != "main":
139  try:
140  val = str(self.config["main"])
141  except KeyError:
142  val = str('main')
143  else:
144  val = str('main')
145  file_name = val + ".py"
146  if not self.check_path(file_name):
147  self.log.warning(self.translate("logs", "The extensions {0} file name is invalid for this system.".format(gui_name)))
148  return False
149  if not self.check_exists(file_name):
150  self.log.warning(self.translate("logs", "The extensions {0} file does not exist.".format(gui_name)))
151  return False
152  return True
def check_path
Definition: validate.py:251
def check_exists
Definition: validate.py:235
def gui
Definition: validate.py:129
def commotion_client.utils.validate.ClientConfig.menu_item (   self)
Validate a  menu item value.

References commotion_client.utils.validate.ClientConfig.check_menu_text(), commotion_client.utils.validate.ClientConfig.config, commotion_client.utils.validate.ClientConfig.name(), commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.validate_all().

168  def menu_item(self):
169  """Validate a menu item value."""
170  try:
171  val = str(self.config["menu_item"])
172  except KeyError:
173  if self.name():
174  val = str(self.config["name"])
175  else:
176  self.log.warning(self.translate("logs", "The name value is the default for a menu_item if none is specified. You don't have a menu_item specified and the name value in this config is invalid."))
177  return False
178  if not self.check_menu_text(val):
179  self.log.warning(self.translate("logs", "The menu_item value is invalid"))
180  return False
181  return True
def name
Definition: validate.py:153
def check_menu_text
Definition: validate.py:223
def menu_item
Definition: validate.py:167
def commotion_client.utils.validate.ClientConfig.menu_level (   self)
Validate a Menu Level Config item.

References commotion_client.utils.validate.ClientConfig.config, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.validate_all().

195  def menu_level(self):
196  """Validate a Menu Level Config item."""
197  try:
198  val = int(self.config["menu_level"])
199  except KeyError:
200  self.log.info(self.translate("logs", "There is no 'menu_level' value set in the config. As such the default value of 10 will be used."))
201  return True
202  except ValueError:
203  self.log.info(self.translate("logs", "The 'menu_level' value set in the config is not a number and is therefore invalid."))
204  return False
205  if not 0 < val > 100:
206  self.log.warning(self.translate("logs", "The menu_level is invalid. Choose a number between 1 and 100"))
207  return False
208  return True
def menu_level
Definition: validate.py:194
def commotion_client.utils.validate.ClientConfig.parent (   self)
Validate a  parent value.

References commotion_client.utils.validate.ClientConfig.check_menu_text(), commotion_client.utils.validate.ClientConfig.config, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.validate_all().

183  def parent(self):
184  """Validate a parent value."""
185  try:
186  val = str(self.config["parent"])
187  except KeyError:
188  self.log.info(self.translate("logs", "There is no 'parent' value set in the config. As such the default value of 'Extensions' will be used."))
189  return True
190  if not self.check_menu_text(val):
191  self.log.warning(self.translate("logs", "The parent value is invalid"))
192  return False
193  return True
def check_menu_text
Definition: validate.py:223
def parent
Definition: validate.py:182
def commotion_client.utils.validate.ClientConfig.tests (   self)
Validate a tests config menu item.

References commotion_client.utils.validate.ClientConfig.check_exists(), commotion_client.utils.validate.ClientConfig.check_path(), commotion_client.utils.validate.ClientConfig.config, commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

Referenced by commotion_client.utils.validate.ClientConfig.validate_all().

210  def tests(self):
211  """Validate a tests config menu item."""
212  try:
213  val = str(self.config["tests"])
214  except KeyError:
215  val = str('tests')
216  file_name = val + ".py"
217  if not self.check_path(file_name):
218  self.log.warning(self.translate("logs", "The extensions 'tests' file name is invalid for this system."))
219  return False
220  if not self.check_exists(file_name):
221  self.log.info(self.translate("logs", "The extensions 'tests' file does not exist. But tests are not required. Shame on you though, SHAME!."))
222  return True
def check_path
Definition: validate.py:251
def check_exists
Definition: validate.py:235
def tests
Definition: validate.py:209
def commotion_client.utils.validate.ClientConfig.validate_all (   self)
Run all validation functions on an uncompressed extension.

@brief Will set self.errors if any errors are found.
@return bool True if valid, False if invalid. 

References commotion_client.utils.validate.ClientConfig.config, commotion_client.utils.validate.ClientConfig.errors, commotion_client.utils.validate.ClientConfig.gui(), commotion_client.utils.validate.ClientConfig.menu_item(), commotion_client.utils.validate.ClientConfig.menu_level(), commotion_client.utils.validate.ClientConfig.name(), commotion_client.utils.validate.ClientConfig.parent(), commotion_client.utils.validate.ClientConfig.tests(), commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

92 
93  def validate_all(self):
94  """Run all validation functions on an uncompressed extension.
95 
96  @brief Will set self.errors if any errors are found.
97  @return bool True if valid, False if invalid.
98  """
99  self.errors = None
100  if not self.config:
101  raise NameError(self.translate("logs", "ClientConfig validator requires at least a config has been specified"))
102  errors = []
103  if not self.name():
104  errors.append("name")
105  self.log.info(self.translate("logs", "The name of extension {0} is invalid.".format(self.config['name'])))
106  if not self.tests():
107  errors.append("tests")
108  self.log.info(self.translate("logs", "The extension {0}'s tests is invalid.".format(self.config['name'])))
109  if not self.menu_level():
110  errors.append("menu_level")
111  self.log.info(self.translate("logs", "The extension {0}'s menu_level is invalid.".format(self.config['name'])))
112  if not self.menu_item():
113  errors.append("menu_item")
114  self.log.info(self.translate("logs", "The extension {0}'s menu_item is invalid.".format(self.config['name'])))
115  if not self.parent():
116  errors.append("parent")
117  self.log.info(self.translate("logs", "The extension {0}'s parent is invalid.".format(self.config['name'])))
118  else:
119  for gui_name in ['main', 'settings', 'toolbar']:
120  if not self.gui(gui_name):
121  self.log.info(self.translate("logs", "The extension {0}'s {1} is invalid.".format(self.config['name'], gui_name)))
122  errors.append(gui_name)
123  if errors:
124  self.errors = errors
125  return False
126  else:
127  return True
128 
def menu_level
Definition: validate.py:194
def name
Definition: validate.py:153
def gui
Definition: validate.py:129
def validate_all
Definition: validate.py:92
def tests
Definition: validate.py:209
def parent
Definition: validate.py:182
def menu_item
Definition: validate.py:167

The documentation for this class was generated from the following file: