Esempio n. 1
0
def parse_strings(value):
    try:
        if (value != "") and (not "\"" in value) and (not "'" in value):
            value = "\"" + "\" \"".join(value.split()) + "\""
        words = list(tokenizer.word_iterator(value))
        string_list = strings_from_words(words)
    except ValueError, e:
        raise Sorry(str(e))
Esempio n. 2
0
def parse_strings (value) :
  try :
    if (value != "") and (not "\"" in value) and (not "'" in value) :
      value = "\"" + "\" \"".join(value.split()) + "\""
    words = list(tokenizer.word_iterator(value))
    string_list = strings_from_words(words)
  except ValueError, e :
    raise Sorry(str(e))
Esempio n. 3
0
    def make_changes(self, wrong_defs, backend="cctbx_xfel"):
        """Find paths that have changed and change them to new paths.

        :return: 'user phil' object with corrected paths
        """
        from libtbx.phil import strings_from_words

        fix_txt = ""
        fixed_defs = []

        # Change old paths to new paths
        for l in wrong_defs:
            path = l.path
            for fix in self.diffs:
                if fix[0] in path:
                    new_path = path.replace(fix[0], fix[1])
                    value = strings_from_words(l.object.words)
                    value = self.check_values(new_path, value)
                    if type(value) == list:
                        value = " ".join(value)
                    entry = "{} = {}\n".format(new_path, value)
                    fix_txt += entry
                    fixed_defs.append(l)

        # Change backend to the appropriate version
        remaining_defs = list(set(wrong_defs) - set(fixed_defs))
        if backend == "ha14":
            backend_defs = ["cctbx", "cctbx_ha14"]
        else:
            backend_defs = ["dials"]
        for r in remaining_defs:
            path = r.path
            for bd in backend_defs:
                if bd in path:
                    new_path = path.replace(bd, "cctbx_xfel")
                    value = strings_from_words(r.object.words)
                    value = self.check_values(new_path, value)
                    if type(value) == list:
                        value = " ".join(value)
                    entry = "{} = {}\n".format(new_path, value)
                    fix_txt += entry

        return ip.parse(fix_txt)
Esempio n. 4
0
  def make_changes(self, wrong_defs):
    """ Find paths that have changed and change them to new paths

    :return: 'user phil' object with corrected paths
    """
    from libtbx.phil import strings_from_words
    fix_txt = ''
    for l in wrong_defs:
      path = l.path
      object = l.object

      # Change paths to new paths
      for fix in self.diffs:
        if fix[0] in path:
          new_path = path.replace(fix[0], fix[1])
          value = strings_from_words(l.object.words)
          value = self.check_values(new_path, value)
          if type(value) == list:
            value = ' '.join(value)
          entry = '{} = {}\n'.format(new_path, value)
          fix_txt += entry

    return ip.parse(fix_txt)