LSSTApplications  19.0.0-10-g4a5fae6+3,19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+16,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+6,19.0.0-20-g5a5a17ab+14,19.0.0-21-g2644856+17,19.0.0-24-g0913cb1,19.0.0-24-g878c510+4,19.0.0-25-g6c8df7140+1,19.0.0-25-gb330496+4,19.0.0-3-g2b32d65+6,19.0.0-3-g8227491+15,19.0.0-3-g9c54d0d+15,19.0.0-3-gca68e65+11,19.0.0-3-gcfc5f51+6,19.0.0-3-ge110943+14,19.0.0-3-ge74d124,19.0.0-30-g9c3fd16+5,19.0.0-4-g06f5963+6,19.0.0-4-g10df615,19.0.0-4-g3d16501+17,19.0.0-4-g4a9c019+6,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+16,19.0.0-4-ge404a01+15,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gb9eeb60,19.0.0-5-gfb03ce7+16,19.0.0-6-gbaebbfb+15,19.0.0-61-gec4c6e08+5,19.0.0-7-g039c0b5+15,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+16,19.0.0-72-g37abf38+2,19.0.0-9-g463f923+15,v20.0.0.rc1
LSSTDataManagementBasePackage
testMapper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # LSST Data Management System
4 # Copyright 2017 LSST Corporation.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <http://www.lsstcorp.org/LegalNotices/>.
22 #
23 
24 import os
25 
26 from .. import ButlerLocation
27 from .. import Mapper
28 from .. import Storage
29 from . import TestObject
30 
31 
32 class EmptyTestMapper(Mapper):
33  """Class that can be used as a stub for a mapper."""
34 
35  def __init__(self, root=None, parentRegistry=None, repositoryCfg=None, **kwargs):
36  self.root = root
37  self.kwargs = kwargs
38  pass
39 
40 
41 class MapperForTestWriting(Mapper):
42 
43  def __init__(self, root, **kwargs):
44  self.root = root
45  self.storage = Storage.makeFromURI(self.root)
46 
47  def map_foo(self, dataId, write):
48  python = TestObject
49  persistable = None
50  storage = 'PickleStorage'
51  fileName = 'filename'
52  for key, value in sorted(dataId.items()):
53  fileName += '_' + key + str(value)
54  fileName += '.txt'
55  path = os.path.join(self.root, fileName)
56  if not write and not os.path.exists(path):
57  return None
58  return ButlerLocation(python, persistable, storage, path, dataId, self, self.storage)
lsst::daf::persistence.test.testMapper.MapperForTestWriting.root
root
Definition: testMapper.py:44
lsst::daf::persistence.test.testMapper.EmptyTestMapper.root
root
Definition: testMapper.py:36
lsst::daf::persistence.test.testMapper.EmptyTestMapper
Definition: testMapper.py:32
lsst::daf::persistence.test.testMapper.MapperForTestWriting.__init__
def __init__(self, root, **kwargs)
Definition: testMapper.py:43
lsst::daf::persistence.test.testMapper.MapperForTestWriting.map_foo
def map_foo(self, dataId, write)
Definition: testMapper.py:47
lsst::daf::persistence.test.testMapper.EmptyTestMapper.__init__
def __init__(self, root=None, parentRegistry=None, repositoryCfg=None, **kwargs)
Definition: testMapper.py:35
lsst::daf::persistence.test.testMapper.MapperForTestWriting
Definition: testMapper.py:41
lsst::daf::persistence.test.testMapper.MapperForTestWriting.storage
storage
Definition: testMapper.py:45
lsst::daf::persistence.test.testMapper.EmptyTestMapper.kwargs
kwargs
Definition: testMapper.py:37