Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
generic.models.Organizational.Folder Class Reference
Inheritance diagram for generic.models.Organizational.Folder:
object

Public Member Functions

def __init__ (self, name, plot_ids=[], subfolders=[])
 

Static Public Member Functions

def FromDict (config_dict)
 

Public Attributes

 name
 
 plot_entries
 
 subfolders
 
short int type
 
short int number
 
cat_entry star
 

Static Public Attributes

list ALLOWED_ATTRS
 

Detailed Description

Simple container for creating structure in plot collections. 

Definition at line 399 of file Organizational.py.

Constructor & Destructor Documentation

def generic.models.Organizational.Folder.__init__ (   self,
  name,
  plot_ids = [],
  subfolders = [] 
)

Definition at line 436 of file Organizational.py.

436  def __init__(self, name, plot_ids=[], subfolders=[]):
437  self.name = name
438 
439  assert hasattr(plot_ids, "__iter__"), "Invalid configuration supplied for Folder plot entries: '%s'" % plot_ids
440  self.plot_entries = [PlotID(p) if not isinstance(p, PlotID) else p for p in plot_ids]
441 
442  assert hasattr(subfolders, "__iter__"), "Invalid configuration supplied for Folder subfolders: '%s'" % subfolders
443  self.subfolders = []
444  for subfolder in subfolders:
445  if isinstance(subfolder, Folder):
446  self.subfolders.append(subfolder)
447  elif hasattr(subfolder, "__contains__"):
448  self.subfolders.append(Folder.FromDict(subfolder))
449 

Member Function Documentation

def generic.models.Organizational.Folder.FromDict (   config_dict)
static

Definition at line 409 of file Organizational.py.

409  def FromDict(config_dict):
410  # JSON/YAML format (and thus Python dictionary) for a folder looks like:
411  # {
412  # "name": "folder1",
413  # "plot_ids": ["key1", "key2"],
414  #
415  # "subfolders": [
416  # {
417  # "name": "subfolder1",
418  # "plot_ids": [ "key1.1", "key1.2" ]
419  # },
420  #
421  # {
422  # "name": "subfolder2",
423  # "plot_ids": [ "key2.1", "key2.2" ]
424  # }
425  # ]
426  # }
427  assert "name" in config_dict, "Folder configuration must specify 'name'"
428 
429  for attr in config_dict:
430  assert attr in Folder.ALLOWED_ATTRS, "Unrecognized attribute in folder configuration: '%s'" % attr
431 
432  args = {attr: config_dict[attr] for attr in Folder.ALLOWED_ATTRS if attr in config_dict}
433 
434  return Folder(**args)
435 

Member Data Documentation

list generic.models.Organizational.Folder.ALLOWED_ATTRS
static
Initial value:
1 = [
2  "name",
3  "plot_ids",
4  "subfolders",
5  ]

Definition at line 402 of file Organizational.py.

short int object::number
inherited

Definition at line 115 of file novas.h.

generic.models.Organizational.Folder.plot_entries

Definition at line 440 of file Organizational.py.

cat_entry object::star
inherited

Definition at line 117 of file novas.h.

generic.models.Organizational.Folder.subfolders

Definition at line 443 of file Organizational.py.

short int object::type
inherited

Definition at line 114 of file novas.h.


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