LSST Applications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-10-gbfb87ad6+3307648ee3,21.0.0-15-gedb9d5423+47cba9fc36,21.0.0-2-g103fe59+fdf0863a2a,21.0.0-2-g1367e85+d38a93257c,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g5242d73+d38a93257c,21.0.0-2-g7f82c8f+e682ffb718,21.0.0-2-g8dde007+d179fbfa6a,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+e682ffb718,21.0.0-2-ga63a54e+08647d4b1b,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0445ed2f95,21.0.0-2-gfc62afb+d38a93257c,21.0.0-27-gbbd0d29+ae871e0f33,21.0.0-28-g5fc5e037+feb0e9397b,21.0.0-3-g21c7a62+f4b9c0ff5c,21.0.0-3-g357aad2+57b0bddf0b,21.0.0-3-g4be5c26+d38a93257c,21.0.0-3-g65f322c+3f454acf5d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+9e4ef6332c,21.0.0-3-ge02ed75+4b120a55c4,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-g591bb35+4b120a55c4,21.0.0-4-gc004bbf+4911b9cd27,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-ge8fba5a+2b3a696ff9,21.0.0-5-gb155db7+2c5429117a,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g00874e7+c9fd7f7160,21.0.0-6-g4e60332+4b120a55c4,21.0.0-7-gc8ca178+40eb9cf840,21.0.0-8-gfbe0b4b+9e4ef6332c,21.0.0-9-g2fd488a+d83b7cd606,w.2021.05
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree Class Reference
Inheritance diagram for lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree:
lsst.obs.base.gen2to3.repoWalker.builders.BuilderNode

Public Member Functions

def __init__ (self)
 
def insert (self, int level, BuilderInput leaf)
 
def fill (self, DirectoryScanner scanner, Dict[str, type] allKeys, Dict[str, type] previousKeys, *Optional[re.Pattern] fileIgnoreRegEx, Optional[re.Pattern] dirIgnoreRegEx)
 
Tuple[BuilderNode, List[str], bool] prune (self)
 
PathElementHandler build (self, PathElementParser parser, Dict[str, type] allKeys, Dict[str, type] cumulativeKeys, *Optional[re.Pattern] fileIgnoreRegEx, Optional[re.Pattern] dirIgnoreRegEx)
 

Detailed Description

A `BuilderNode` that represents a directory.

This is the only `BuilderNode` class that is not a leaf node.  If all
of its children can be pruned, it is replaced by a `BuilderPrunedTree`
(which can then be pruned itself).  It builds `SubdirectoryHandler`
instances when not pruned.

Definition at line 323 of file builders.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree.__init__ (   self)

Definition at line 331 of file builders.py.

331  def __init__(self):
332  self._children = {} # Maps template path element to BuilderNode
333 

Member Function Documentation

◆ build()

PathElementHandler lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree.build (   self,
PathElementParser  parser,
Dict[str, type allKeys,
Dict[str, type cumulativeKeys,
*Optional[re.Pattern]  fileIgnoreRegEx,
Optional[re.Pattern]   dirIgnoreRegEx 
)
Transform this node in the build tree into a corresponding
`PathElementHandler`, recursing to any children.

Must be called after `prune`.

Parameters
----------
parser : `PathElementParser`
    An object that matches the path element the new handler is
    responsible for and extracts a (partial) Gen2 data ID from it.
allKeys : `dict` [`str`, `type`]
    A mapping from Gen2 data ID key to the type of its value.  Will
    contain all keys that may be extracted by the given parser, and
    possibly others.
cumulativeKeys : `dict` [`str`, `type`], optional
    A dictionary containing key strings and types for Gen2 data ID keys
    that have been extracted from previous path elements for this
    template, including those extracted by ``parser``.

Returns
-------
handler : `PathElementHandler`
    A new handler object.

Reimplemented from lsst.obs.base.gen2to3.repoWalker.builders.BuilderNode.

Definition at line 413 of file builders.py.

415  ) -> PathElementHandler:
416  # Docstring inherited from BuilderNode.
417  built = SubdirectoryHandler(parser)
418  self.fill(built.scanner, allKeys, cumulativeKeys, fileIgnoreRegEx=fileIgnoreRegEx,
419  dirIgnoreRegEx=dirIgnoreRegEx)
420  return built

◆ fill()

def lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree.fill (   self,
DirectoryScanner  scanner,
Dict[str, type allKeys,
Dict[str, type previousKeys,
*Optional[re.Pattern]  fileIgnoreRegEx,
Optional[re.Pattern]  dirIgnoreRegEx 
)
Fill a `DirectoryScanner` instance by recursively building all
child nodes.

Parameters
----------
scanner : `DirectoryScanner`
    Object to populate.
allKeys : `dict` [`str`, `type`]
    Mapping from Gen2 data ID key to its value type, covering all keys
    that could be used in any child template.
previousKeys : `dict` [`str`, `type`], optional
    A dictionary containing key strings and types for Gen2 data ID keys
    that have been extracted from previous path elements of the same
    template.
fileIgnoreRegEx : `re.Pattern`, optional
    A regular expression pattern that identifies non-dataset files that
    can be ignored, to be applied at all levels of the directory tree.
dirIgnoreRegEx : `re.Pattern`, optional
    A regular expression pattern that identifies non-dataset
    subdirectories that can be ignored, to be applied at all levels of
    the directory tree.

Definition at line 360 of file builders.py.

361  fileIgnoreRegEx: Optional[re.Pattern], dirIgnoreRegEx: Optional[re.Pattern]):
362  """Fill a `DirectoryScanner` instance by recursively building all
363  child nodes.
364 
365  Parameters
366  ----------
367  scanner : `DirectoryScanner`
368  Object to populate.
369  allKeys : `dict` [`str`, `type`]
370  Mapping from Gen2 data ID key to its value type, covering all keys
371  that could be used in any child template.
372  previousKeys : `dict` [`str`, `type`], optional
373  A dictionary containing key strings and types for Gen2 data ID keys
374  that have been extracted from previous path elements of the same
375  template.
376  fileIgnoreRegEx : `re.Pattern`, optional
377  A regular expression pattern that identifies non-dataset files that
378  can be ignored, to be applied at all levels of the directory tree.
379  dirIgnoreRegEx : `re.Pattern`, optional
380  A regular expression pattern that identifies non-dataset
381  subdirectories that can be ignored, to be applied at all levels of
382  the directory tree.
383  """
384  if fileIgnoreRegEx is not None:
385  scanner.add(IgnoreHandler(fileIgnoreRegEx, isForFiles=True))
386  if dirIgnoreRegEx is not None:
387  scanner.add(IgnoreHandler(dirIgnoreRegEx, isForFiles=False))
388  for template, child in self._children.items():
389  parser = PathElementParser(template, allKeys, previousKeys=previousKeys)
390  cumulativeKeys = previousKeys.copy()
391  cumulativeKeys.update(parser.keys)
392  scanner.add(child.build(parser, allKeys, cumulativeKeys, fileIgnoreRegEx=fileIgnoreRegEx,
393  dirIgnoreRegEx=dirIgnoreRegEx))
394 
std::vector< SchemaItem< Flag > > * items

◆ insert()

def lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree.insert (   self,
int  level,
BuilderInput  leaf 
)
Insert an input leaf node into the tree, recursively constructing
intermediate parents in order to put it at the right level.

Parameters
----------
level : `int`
    The level ``self``is at in the larger tree, with zero the
    repository root.  The right level for the leaf is given by the
    length of ``leaf.elements``.
leaf : `BuilderInput`
    The leaf node to insert.

Definition at line 334 of file builders.py.

334  def insert(self, level: int, leaf: BuilderInput):
335  """Insert an input leaf node into the tree, recursively constructing
336  intermediate parents in order to put it at the right level.
337 
338  Parameters
339  ----------
340  level : `int`
341  The level ``self``is at in the larger tree, with zero the
342  repository root. The right level for the leaf is given by the
343  length of ``leaf.elements``.
344  leaf : `BuilderInput`
345  The leaf node to insert.
346  """
347  nextLevel = level + 1
348  element = leaf.elements[level]
349  if nextLevel == len(leaf.elements):
350  conflict = self._children.get(element)
351  if conflict is not None:
352  # Sadly, the Gen2 butler has some actual dataset types that
353  # use the exact same template.
354  leaf = BuilderDuplicateInputs(conflict, leaf)
355  self._children[element] = leaf
356  else:
357  child = self._children.setdefault(element, BuilderTree())
358  child.insert(nextLevel, leaf)
359 

◆ prune()

Tuple[BuilderNode, List[str], bool] lsst.obs.base.gen2to3.repoWalker.builders.BuilderTree.prune (   self)
Attempt to prune this node and its children from the tree.

Returns
-------
replacement : `BuilderNode`
    The result of recursively pruning child nodes; often just ``self``.
messages : `list` [`str`]
    Warning messages that should be logged by a parent node when a
    matching path element is encountered, if this node is pruned.
prune : `bool`
    If `True`, this node may be pruned from the tree (but will not
    necessarily be - it may correspond to a path element that should
    be skipped with siblings that should not be).

Reimplemented from lsst.obs.base.gen2to3.repoWalker.builders.BuilderNode.

Definition at line 395 of file builders.py.

395  def prune(self) -> Tuple[BuilderNode, List[str], bool]:
396  # Docstring inherited from BuilderNode.
397  toPruneThis = True
398  newChildren = {}
399  messages = []
400  # Recursively prune children.
401  for template, child in list(self._children.items()):
402  newChild, childMessages, toPruneChild = child.prune()
403  newChildren[template] = newChild
404  messages.extend(childMessages)
405  if not toPruneChild:
406  toPruneThis = False
407  self._children = newChildren
408  if toPruneThis:
409  return BuilderPrunedTree(messages), messages, True
410  else:
411  return self, [], False
412 
daf::base::PropertyList * list
Definition: fits.cc:913

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