MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / __init__

Method __init__

src/ext/makerbot_driver/profile.py:19–41  ·  view source on GitHub ↗

Constructor for the profile object. @param string name: Name of the profile, NOT the path.

(self, name, profiledir=None)

Source from the content-addressed store, hash-verified

17
18class Profile(object):
19 def __init__(self, name, profiledir=None):
20 """Constructor for the profile object.
21 @param string name: Name of the profile, NOT the path.
22 """
23 self._log = logging.getLogger(self.__class__.__name__)
24 self.path = _getprofiledir(profiledir)
25 self.name = os.path.splitext(name)[0] # name without any extension
26 extension = '.json'
27 if not name.endswith(extension):
28 name += extension
29 path = os.path.join(self.path, name)
30 self._log.debug('{"event":"open_profile", "path":%s}', path)
31 if os.path.isfile(path):
32 with open(path) as fh:
33 try:
34 self.values = json.load(fh)
35 except Exception, e:
36 self._log.debug('profile load fail for %s on err %s',
37 os.path.abspath(path), str(e))
38 raise e
39 else:
40 self._log.debug("no such profile file %s for %s", path, name)
41 raise IOError("no such profile file %s for %s", path, name)
42
43
44def list_profiles(profiledir=None):

Callers

nothing calls this directly

Calls 3

_getprofiledirFunction · 0.85
joinMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected