Files
dev/script/__Lib/diffcalc-2.1/diffcalc/hkl/willmott/commands.py
2019-03-20 13:52:00 +01:00

59 lines
1.9 KiB
Python
Executable File

###
# Copyright 2008-2011 Diamond Light Source Ltd.
# This file is part of Diffcalc.
#
# Diffcalc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Diffcalc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Diffcalc. If not, see <http://www.gnu.org/licenses/>.
###
from diffcalc.hkl.common import getNameFromScannableOrString
from diffcalc.util import command
class WillmottHklCommands(object):
def __init__(self, hklcalc):
self._hklcalc = hklcalc
self.commands = [self.con,
self.uncon,
self.cons]
def __str__(self):
return self._hklcalc.__str__()
@command
def con(self, scn_or_string):
"""con <constraint> -- constrains constraint
"""
name = getNameFromScannableOrString(scn_or_string)
self._hklcalc.constraints.constrain(name)
print self._report_constraints()
@command
def uncon(self, scn_or_string):
"""uncon <constraint> -- unconstrains constraint
"""
name = getNameFromScannableOrString(scn_or_string)
self._hklcalc.constraints.unconstrain(name)
print self._report_constraints()
@command
def cons(self):
"""cons -- list available constraints and values
"""
print self._report_constraints()
def _report_constraints(self):
return (self._hklcalc.constraints.build_display_table_lines() + '\n\n' +
self._hklcalc.constraints._report_constraints())