Ejemplo n.º 1
0
def create_new_palette(config):
	model = XMLObject('palette')
	model.attrs['name'] = '' + config.default_name
	model.attrs['guid'] = generate_guid()
	colors = XMLObject('colors')
	model.childs.append(colors)
	page = XMLObject('page')
	colors.childs.append(page)
	return model
Ejemplo n.º 2
0
	def start_element(self, name, attrs):
		obj = XMLObject()
		obj.tag = name
		if not self.stack: self.model = obj

		for item in attrs._attrs.keys():
			obj.attrs[item] = attrs._attrs[item].strip().encode('utf-8')

		if self.stack: self.stack[-1].childs.append(obj)
		self.stack.append(obj)
Ejemplo n.º 3
0
    def start_element(self, name, attrs):
        obj = XMLObject()
        obj.tag = name
        if not self.stack: self.model = obj

        for item in attrs._attrs.keys():
            obj.attrs[item] = attrs._attrs[item].strip().encode('utf-8')

        if self.stack: self.stack[-1].childs.append(obj)
        self.stack.append(obj)
Ejemplo n.º 4
0
 def add_color(self, color):
     if color[0] == COLOR_SPOT:
         self.add_spot_color(color)
         return
     if not color[0] in [COLOR_RGB, COLOR_CMYK, COLOR_GRAY]:
         color = self.cms.get_rgb_color(color)
     page = self.get_page_obj()
     clr = XMLObject('color')
     clr.attrs['cs'] = CS_MATCH[color[0]]
     name = self.get_color_name(color)
     clr.attrs['name'] = name
     clr.attrs['tints'] = self.get_tints(color[1])
     page.childs.append(clr)
Ejemplo n.º 5
0
	def add_color(self, color):
		if color[0] == COLOR_SPOT:
			self.add_spot_color(color)
			return
		if not color[0] in [COLOR_RGB, COLOR_CMYK, COLOR_GRAY]:
			color = self.cms.get_rgb_color(color)
		page = self.get_page_obj()
		clr = XMLObject('color')
		clr.attrs['cs'] = CS_MATCH[color[0]].encode(self.config.encoding)
		name = self.get_color_name(color)
		clr.attrs['name'] = name.encode(self.config.encoding)
		clr.attrs['tints'] = self.get_tints(color[1])
		page.childs.append(clr)
Ejemplo n.º 6
0
    def start_element(self, name, attrs):
        obj = XMLObject()
        obj.tag = name
        if not self.stack:
            self.model = obj
            self.model.id_map = {}

        for item in attrs._attrs.keys():
            obj.attrs[item] = attrs._attrs[item].strip()

        if 'id' in obj.attrs:
            self.model.id_map[obj.attrs['id']] = obj

        if self.stack: self.stack[-1].childs.append(obj)
        self.stack.append(obj)
Ejemplo n.º 7
0
 def get_localization(self):
     localization = None
     for child in self.model.childs:
         if child.tag == 'localization':
             localization = child
     if not localization:
         localization = XMLObject('localization')
         self.model.childs += [localization, ]
     return localization
Ejemplo n.º 8
0
 def get_colorspaces(self):
     colorspaces = None
     for child in self.model.childs:
         if child.tag == 'colorspaces':
             colorspaces = child
     if not colorspaces:
         colorspaces = XMLObject('colorspaces')
         self.model.childs = [colorspaces, ] + self.model.childs
     return colorspaces
Ejemplo n.º 9
0
def create_new_palette(config):
    model = XMLObject('palette')
    model.attrs['name'] = config.default_name
    model.attrs['guid'] = generate_guid()
    colors = XMLObject('colors')
    model.childs.append(colors)
    page = XMLObject('page')
    colors.childs.append(page)
    return model
Ejemplo n.º 10
0
 def new(self):
     self.model = XMLObject('root')
Ejemplo n.º 11
0
    def add_spot_color(self, color):
        page = self.get_page_obj()
        clr = XMLObject('color')
        name = color[3].decode('utf-8').encode(self.config.encoding)
        clr.attrs['cs'] = name
        clr.attrs['name'] = name
        clr.attrs['tints'] = '1'
        page.childs.append(clr)

        colorspaces = self.get_colorspaces()
        fixed_id = len(colorspaces.childs) + 1
        cs = XMLObject('color')
        cs.attrs['fixedID'] = str(fixed_id)
        cs.attrs['version'] = '1500'
        cs.attrs['name'] = name
        colorspaces.childs.append(cs)

        if color[1][1]:
            clr = XMLObject('color')
            clr.attrs['cs'] = 'CMYK'.encode(self.config.encoding)
            clr.attrs['tints'] = self.get_tints(color[1][1])
            cs.childs.append(clr)

        if color[1][0]:
            clr = XMLObject('color')
            clr.attrs['cs'] = 'RGB'.encode(self.config.encoding)
            clr.attrs['tints'] = self.get_tints(color[1][0])
            cs.childs.append(clr)
Ejemplo n.º 12
0
def create_xmlobj(tag, attrs={}):
    obj = XMLObject(tag)
    if attrs: obj.attrs = attrs
    return obj
Ejemplo n.º 13
0
	def add_spot_color(self, color):
		page = self.get_page_obj()
		clr = XMLObject('color')
		name = color[3].encode(self.config.encoding)
		clr.attrs['cs'] = '' + name
		clr.attrs['name'] = '' + name
		clr.attrs['tints'] = '1'
		page.childs.append(clr)

		colorspaces = self.get_colorspaces()
		fixed_id = len(colorspaces.childs) + 1
		cs = XMLObject('color')
		cs.attrs['fixedID'] = str(fixed_id)
		cs.attrs['version'] = '1500'
		cs.attrs['name'] = '' + name
		colorspaces.childs.append(cs)

		if color[1][1]:
			clr = XMLObject('color')
			clr.attrs['cs'] = 'CMYK'.encode(self.config.encoding)
			clr.attrs['tints'] = self.get_tints(color[1][1])
			cs.childs.append(clr)

		if color[1][0]:
			clr = XMLObject('color')
			clr.attrs['cs'] = 'RGB'.encode(self.config.encoding)
			clr.attrs['tints'] = self.get_tints(color[1][0])
			cs.childs.append(clr)