Data Model version 2.0.6

Method: refreshTopObjects


    Check on disk to make sure all topObjects in package packageName are present.

guid: www.ccpn.ac.uk_Fogh_2007-04-24-16:25:58_00001__www.ccpn.ac.uk_Fogh_2006-08-16-14:22:53_00047
OpType: other
OpSubType: None
isQuery: False
isAbstract: False
Scope: instance_level
Code: # NB must be done by direct access
if packageName == 'memops.Implementation':
    raise ApiError("refreshTopObjects not allowed for memops.Implementation")

import os, os.path
from memops.format.xml import XmlIO
from memops.format.xml import Util as xmlUtil

topObjects = self.__dict__['topObjects']
ff = self.findFirstPackageLocator

activeRepositories = {}

repositories = (ff(targetName=packageName) or ff(targetName='any')).repositories
for repository in repositories:

  fileLocation = repository.getFileLocation(packageName)
  if not os.path.exists(fileLocation):
    continue
  if not os.path.isdir(fileLocation):
    raise ApiError("%s is not a directory" % fileLocation)
  
  fileSuffix = xmlUtil.fileSuffix
  lenSuffix = xmlUtil.lenFileSuffix
  sep = xmlUtil.keySep
  for filename in os.listdir(fileLocation):

    if filename.startswith('.'):
      # skip hidden files (on *nix/Mac)
      continue

    elif filename.endswith(fileSuffix):
      guid = filename.split(sep)[-1][:-lenSuffix]
      
      topObject = topObjects.get(guid)
      if topObject is None:
        filePath = os.path.join(fileLocation, filename)
        topObject = XmlIO.loadFromFile(self, filePath, partialLoad=True)
      
      ll = activeRepositories.setdefault(topObject, [])
      ll.append(repository)

# set activeRepositories
for topObject, ll in activeRepositories.iteritems():
  topObject.__dict__['activeRepositories'] = ll
  
  Data Model Version 2.0.6
Go to Top  
  Autogenerated by  PyApiDocGen  revision 1.3   on  Wed Aug 7 15:06:17 2013    from data model package  memops.api.Implementation.MemopsRoot   revision 1.69  
  Work done by the CCPN team.
www.ccpn.ac.uk