def __new__(self, raw, start_offset, tab_stops, is_toplevel=True): if raw.endswith('}'): unescape = escape_funcs()[1] num, default = raw[2:-1].partition(':')[0::2] # Look for tab stops defined in the default text uraw, child_stops = parse_template(unescape(default), start_offset=start_offset, is_toplevel=False, grouped=False) for c in child_stops: c.parent = self tab_stops.extend(child_stops) self = unicode_type.__new__(self, uraw) if num.endswith('*'): self.takes_selection = True num = num[:-1] else: self.takes_selection = False self.num = int(num) else: self = unicode_type.__new__(self, '') self.num = int(raw[1:]) self.takes_selection = False self.start = start_offset self.is_toplevel = is_toplevel self.is_mirror = False self.parent = None tab_stops.append(self) return self
def __new__(self, series, series_index): if series and series_index is not None: roman = _('{1} of <em>{0}</em>').format( escape(series), escape(fmt_sidx(series_index, use_roman=True))) combined = _('{1} of <em>{0}</em>').format( escape(series), escape(fmt_sidx(series_index, use_roman=False))) else: combined = roman = escape(series or u'') s = unicode_type.__new__(self, combined) s.roman = roman s.name = escape(series or u'') s.number = escape(fmt_sidx(series_index or 1.0, use_roman=False)) s.roman_number = escape(fmt_sidx(series_index or 1.0, use_roman=True)) return s
def __new__(self, series, series_index): if series and series_index is not None: roman = _('{1} of <em>{0}</em>').format( escape(series), escape(fmt_sidx(series_index, use_roman=True))) combined = _('{1} of <em>{0}</em>').format( escape(series), escape(fmt_sidx(series_index, use_roman=False))) else: combined = roman = escape(series or u'') s = unicode_type.__new__(self, combined) s.roman = roman s.name = escape(series or '') s.number = escape(fmt_sidx(series_index or 1.0, use_roman=False)) s.roman_number = escape(fmt_sidx(series_index or 1.0, use_roman=True)) return s
def __new__(self, name, mime_type, spine_names): ans = unicode_type.__new__(self, name) ans.mime_type = mime_type ans.in_spine = name in spine_names return ans
def __new__(self, tags, output_profile): tags = [escape(x) for x in tags or ()] t = unicode_type.__new__(self, ', '.join(tags)) t.alphabetical = ', '.join(sorted(tags, key=sort_key)) t.tags_list = tags return t
def __new__(cls, text): self = unicode_type.__new__(cls, text) self.as_you_type = True return self