Serialize all the Rule object as string.

    New string is used to compare the rules list.
338154
def _serialize_rules(rules):
    
    result = [(rule_name, str(rule)) for rule_name, rule in rules.items()]
    return sorted(result, key=lambda rule: rule[0])
721254
def _css_rules_to_string(self, rules):
        
        lines = []
        for item in rules:
            if isinstance(item, tuple):
                k, v = item
                lines.append("%s {%s}" % (k, make_important(v)))
            # media rule
            else:
                for rule in item.cssRules:
                    if isinstance(
                        rule,
                        (
                            cssutils.css.csscomment.CSSComment,
                            cssutils.css.cssunknownrule.CSSUnknownRule,
                        ),
                    ):
                        continue
                    for key in rule.style.keys():
                        rule.style[key] = (
                            rule.style.getPropertyValue(key, False),
                            "!important",
                        )
                lines.append(item.cssText)
        return "\n".join(lines)
641093
def to_string(self, value):
        
        self.enforce_type(value)
        if isinstance(value, dict) and None in value:
            value = value.copy()
            value['null'] = value[None]
            del value[None]
        return super(Dict, self).to_string(value)
641975
def as_string(self, forsigning=False):
		
		ret = OutBuffer()
		self.serialize(ret, forsigning)
		return ret.getvalue()
400797
def serialize(self):
        
        res = super(Check, self).serialize()
        if 'depend_on' in res:
            del res['depend_on']
        if 'depend_on_me' in res:
            del res['depend_on_me']
        return res
665492
public String serialize() {
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (String key : options.keySet()) {
      if (first) {
        first = false;
      } else {
        sb.append(';');
      }
      sb.append(key).append('=').append(options.get(key));
    }
    return sb.toString();
  }
167740
def to_xml_string(str='')
      return if empty?
      str << ('<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">')
      each { |brk| brk.to_xml_string(str) }
      str << '</rowBreaks>'
    end
751791
public static String printRules() {

    theRules.get(0).getSAXRules();
    expandRules();

    Vector<SAXRule> rules = new Vector<SAXRule>(numRules.intValue());
    SAXRule currentRule;
    SAXRule referedTo;
    SAXSymbol sym;
    int index;
    int processedRules = 0;
    StringBuilder text = new StringBuilder();

    text.append("Number\tName\tLevel\tOccurr.\tUsage\tYield\tRule str\tExpaneded\tIndexes\n");
    rules.addElement(theRules.get(0));

    // add-on - keeping the rule string, will be used in order to expand rules
    StringBuilder currentRuleString = new StringBuilder();

    while (processedRules < rules.size()) {

      currentRule = rules.elementAt(processedRules);

      // seninp: adding to original output rule occurrence indexes
      //
      text.append(SPACE);
      text.append(arrRuleRecords.get(processedRules).getRuleNumber()).append(TAB);
      text.append(arrRuleRecords.get(processedRules).getRuleName()).append(TAB);
      text.append(arrRuleRecords.get(processedRules).getRuleLevel()).append(TAB);
      text.append(arrRuleRecords.get(processedRules).getOccurrences().size()).append(TAB);
      text.append(arrRuleRecords.get(processedRules).getRuleUseFrequency()).append(TAB);
      text.append(arrRuleRecords.get(processedRules).getRuleYield()).append(TAB);

      for (sym = currentRule.first(); (!sym.isGuard()); sym = sym.n) {
        if (sym.isNonTerminal()) {
          referedTo = ((SAXNonTerminal) sym).r;
          if ((rules.size() > referedTo.index) && (rules.elementAt(referedTo.index) == referedTo)) {
            index = referedTo.index;
          }
          else {
            index = rules.size();
            referedTo.index = index;
            rules.addElement(referedTo);
          }
          text.append('R');
          text.append(index);

          currentRuleString.append('R');
          currentRuleString.append(index);
        }
        else {
          if (sym.value.equals(" ")) {
            text.append('_');
            currentRuleString.append('_');
          }
          else {
            if (sym.value.equals("\n")) {
              text.append("\\n");
              currentRuleString.append("\\n");
            }
            else {
              text.append(sym.value);
              currentRuleString.append(sym.value);
            }
          }
        }
        text.append(' ');
        currentRuleString.append(' ');
      }
      text.append(TAB).append(arrRuleRecords.get(processedRules).getExpandedRuleString())
          .append(TAB);
      text.append(Arrays.toString(currentRule.getIndexes())).append(CR);

      processedRules++;

      currentRuleString = new StringBuilder();
    }
    return text.toString();
  }
1302236
public GrammarRules toGrammarRulesData() {

    GrammarRules res = new GrammarRules();

    GrammarRuleRecord r0 = new GrammarRuleRecord();
    r0.setRuleNumber(0);
    r0.setRuleString(this.r0String);
    r0.setExpandedRuleString(this.r0ExpandedString);
    r0.setOccurrences(new int[] { 0 });
    r0.setMeanLength(-1);
    r0.setMinMaxLength(new int[] { -1 });
    res.addRule(r0);

    for (RePairRule rule : theRules.values()) {
      // System.out.println("processing the rule " + rule.ruleNumber);
      GrammarRuleRecord rec = new GrammarRuleRecord();

      rec.setRuleNumber(rule.ruleNumber);
      rec.setRuleString(rule.toRuleString());
      rec.setExpandedRuleString(rule.expandedRuleString);
      rec.setRuleYield(countSpaces(rule.expandedRuleString));
      rec.setOccurrences(rule.getOccurrences());
      rec.setRuleIntervals(rule.getRuleIntervals());
      rec.setRuleLevel(rule.getLevel());
      rec.setMinMaxLength(rule.getLengths());
      rec.setMeanLength(mean(rule.getRuleIntervals()));

      res.addRule(rec);
    }

    // count the rule use
    for (GrammarRuleRecord r : res) {
      String str = r.getRuleString();
      String[] tokens = str.split("\\s+");
      for (String t : tokens) {
        if (t.startsWith("R")) {
          Integer ruleId = Integer.valueOf(t.substring(1));
          GrammarRuleRecord rr = res.get(ruleId);
          // System.out.print(rr.getRuleUseFrequency() + " ");
          int newFreq = rr.getRuleUseFrequency() + 1;
          rr.setRuleUseFrequency(newFreq);
          // System.out.println(rr.getRuleUseFrequency());
        }
      }
    }

    return res;
  }
860922
def serialize(self):
        
        data = {}

        for field_name in self.get_statement_field_names():
            format_method = getattr(self, 'get_{}'.format(
                field_name
            ), None)

            if format_method:
                data[field_name] = format_method()
            else:
                data[field_name] = getattr(self, field_name)

        return data
105250
def serialize(d):
    
    ret = {}
    for k,v in d.items():
        if not k.startswith('_'):
            ret[k] = str(d[k])
    #ret['__class__'] = obj.__class__.__name__
    return ret
726706
def tostr(object, encoding=None):
    
    if isinstance(object, basestring):
        if encoding is None:
            return object
        else:
            return object.encode(encoding)
    if isinstance(object, tuple):
        s = ['(']
        for item in object:
            if isinstance(item, basestring):
                s.append(item)
            else:
                s.append(tostr(item))
            s.append(', ')
        s.append(')')
        return ''.join(s)
    if isinstance(object, list):
        s = ['[']
        for item in object:
            if isinstance(item, basestring):
                s.append(item)
            else:
                s.append(tostr(item))
            s.append(', ')
        s.append(']')
        return ''.join(s)
    if isinstance(object, dict):
        s = ['{']
        for item in object.items():
            if isinstance(item[0], basestring):
                s.append(item[0])
            else:
                s.append(tostr(item[0]))
            s.append(' = ')
            if isinstance(item[1], basestring):
                s.append(item[1])
            else:
                s.append(tostr(item[1]))
            s.append(', ')
        s.append('}')
        return ''.join(s)
    try:
        return unicode(object)
    except:
        return str(object)
20394
static String stripRules(String rules) {
        StringBuilder strippedRules = new StringBuilder();
        int rulesLength = rules.length();
        for (int idx = 0; idx < rulesLength;) {
            char ch = rules.charAt(idx++);
            if (ch == '#') {
                while (idx < rulesLength
                        && ch != '\r' && ch != '\n' && ch != chNEL) {
                    ch = rules.charAt(idx++);
                }
            }
            if (!UCharacter.isISOControl(ch)) {
                strippedRules.append(ch);
            }
        }
        return strippedRules.toString();
    }
686736
def serialize(self):
        '''
        
        '''
        serialized = {'type': self.__type__}
        for argname in self._attributes:
            if argname == 'required':
                # This is handled elsewhere
                continue
            argvalue = self._get_argname_value(argname)
            if argvalue is not None:
                if argvalue is Null:
                    argvalue = None
                # None values are not meant to be included in the
                # serialization, since this is not None...
                if self.__serialize_attr_aliases__ and argname in self.__serialize_attr_aliases__:
                    argname = self.__serialize_attr_aliases__[argname]
                serialized[argname] = argvalue
        return serialized
974047
def to_xml_string(str = '')
      str << ('<patternFill patternType="' << patternType.to_s << '">')
      if fgColor.is_a?(Color)
        fgColor.to_xml_string str, "fgColor"
      end

      if bgColor.is_a?(Color)
        bgColor.to_xml_string str, "bgColor"
      end
      str << '</patternFill>'
    end
1021601
function (ruleStr) {
		var name;
		var params = '';

		ruleStr.replace(this._RULE_STRING_FORMAT, function ($0, _name, _params) {
			name = _name;
			params = _params.trim();
		});

		params = params.length ? this._parseParamsString(params) : null;

		return Rule.create(name, params);
	}
1212936
def to_string(self, obj):
        
        try:
            converted = [str(element) for element in obj]
            string = ','.join(converted)
        except TypeError:
            # for now this is ok for booleans
            string = str(obj)
        return string