コード例 #1
0
def test_path(vertices: int, colors: int):
    """Test path graph colorings."""
    graph = create_path(vertices)
    colorings = graph.colorings(colors)
    num_colorings = len_iter(colorings)
    assert num_colorings == colors * (colors - 1) ** (vertices - 1)
    assert check_surjective(graph, colors, num_colorings)
コード例 #2
0
def click_script_item( target, operation, src, images_dct ):
        info = images_dct[ src ][0]
        fpath = os.path.join( info['path'], info['filename'] )
	fpath = common.path_replace(fpath)
	fpath = common.create_path( fpath )
        script = "document.getElementById('%s').src='%s';document.getElementById('%s').style.visibility='visible';" % (target,fpath,target)
        return script
コード例 #3
0
def cpo_expand_caption_item( accum_ids, parent, asset_def, cp_dct, cpo_dct, images_dct, init_item, action_scripts ):

        print "CPO EXPAND CAPTION->", asset_def, cpo_dct.keys()

        typ = asset_def["type"]
        x = int(asset_def['x'])
        y = int(asset_def['y'])
        z = int(asset_def['z'])
        name = asset_def['asset_name']
        hid = common.get_id( name, accum_ids )

        # get the individual images and create ids...
        img_init_asset = images_dct[init_item][0]
        path = img_init_asset['path']
        fname = img_init_asset['filename']
        src = os.path.join(path,fname)
        src = common.path_replace( src )
        src = common.create_path( src )
	print "init src->", src

        # style...
        style = ""
        style += common.emit_line("#%s {" % hid )
        style += common.emit_line(" position: absolute;")
        style += common.emit_line(" top: %dpx;" % y )
        style += common.emit_line(" left: %dpx;" % x )
        style += common.emit_line(" z-index: %d;" % (z+1) )
        style += common.emit_line(" border:none;" )
        style += common.emit_line(" visibility: hidden;" )
        style += common.emit_line("}")

        # content...
        content = "<img id=\"%s\" src=\"%s\" alt=\"TheStudio\"  />\n"  % (hid, src)

        # scriptlet dct...
        scriptlet_dct = {}
        scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % hid
        scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % hid
        scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % hid

        return [ style, content, scriptlet_dct ]
コード例 #4
0
ファイル: gen_click_panels.py プロジェクト: gosha1128/c2d
def cpo_expand_preview_item(accum_ids, parent, asset_def, cp_dct, cpo_dct, images_dct, init_item, action_scripts):

    print "CPO EXPAND PREVIEW->", asset_def, cpo_dct.keys()

    typ = asset_def["type"]
    x = int(asset_def["x"])
    y = int(asset_def["y"])
    z = int(asset_def["z"])
    name = asset_def["asset_name"]
    hid = common.get_id(name, accum_ids)

    # get the individual images and create ids...
    img_init_asset = images_dct[init_item][0]
    path = img_init_asset["path"]
    fname = img_init_asset["filename"]
    src = os.path.join(path, fname)
    src = common.path_replace(src)
    src = common.create_path(src)

    # style...
    style = ""
    style += common.emit_line("#%s {" % hid)
    style += common.emit_line(" position: absolute;")
    style += common.emit_line(" top: %dpx;" % y)
    style += common.emit_line(" left: %dpx;" % x)
    style += common.emit_line(" z-index: %d;" % (z + 1))
    style += common.emit_line(" border:none;")
    style += common.emit_line(" visibility: hidden;")
    style += common.emit_line("}")

    # content...
    content = '<img id="%s" src="%s" alt="TheStudio"  />\n' % (hid, src)

    # scriptlet dct...
    scriptlet_dct = {}
    scriptlet_dct["on"] = "document.getElementById('%s').style.visibility='visible';" % hid
    scriptlet_dct["off"] = "document.getElementById('%s').style.visibility='hidden';" % hid
    scriptlet_dct["init"] = "document.getElementById('%s').style.visibility='visible';" % hid

    return [style, content, scriptlet_dct]
コード例 #5
0
ファイル: gen_movies.py プロジェクト: gosha1128/Studio2
def expand_item( accum_ids, asset_def, images_dct, movies_dct ):

	print "mov->", movies_dct.keys()

	# get the movie asset name...
	asset_name = asset_def["asset_name"]

	# get the base def of the item...
	item_def = movies_dct[asset_name][0]

	# get type...
	typ = "file"
	if item_def.has_key("type"):
		typ = item_def["type"]

	# if video type, branch here...
	if typ == "vimeo":
		return expand_vimeo_item( accum_ids, asset_def, images_dct, movies_dct )
	elif typ == "brightcove":
		return expand_brightcove_item( accum_ids, asset_def, images_dct, movies_dct )

	# get the alt movie asset name, if any...
	alt_name = ""
	if asset_def.has_key("alt"): alt_name = asset_def["alt"]

	# get an html id for video element...	
	htmlid = common.get_id( asset_name, accum_ids )
	accum_ids.append(htmlid)

	# get the poster path, if any...
	poster_path = ""
	if item_def["poster"].strip()!="":
		poster = item_def["poster"].strip()
		poster_path = gen_images.get_item_path( poster, images_dct )
		poster_path = common.create_path( poster_path )

	# get the alternate movie path src, if any...
	alt_path = ""
	if alt_name != "":
		alt_path = get_item_path( alt_name, movies_dct )
		alt_path = common.create_path( alt_path )

	# finally, get the primary movie path src...
	movie_path = get_item_path( asset_name, movies_dct )
	movie_path = common.create_path( movie_path )

	# get coords for def...
	x = asset_def['x']
	y = asset_def['y']
	z = asset_def['z']

	# create the style...
	style  = ""
	style += common.emit_line( "#%s {" % htmlid )
	style += common.emit_line( "position: absolute;")
	style += common.emit_line( "left: %dpx;" % int(x) )
	style += common.emit_line( "top: %dpx;" % int(y) )
	style += common.emit_line( "z-index: %d;" % int(z) )
	style += common.emit_line( "visibility: hidden;" )
	style += common.emit_line( "}" )

	if poster_path == "":	
		content = common.emit_line( "<video controls id=%s ><source src=\"%s\" />CANNOT LOAD</video>" % (htmlid, movie_path) )
	else:
		if alt_path != "":
			content = common.emit_line( "<video controls id=%s poster=\"%s\" >" % ( htmlid, poster_path ) )
			content += common.emit_line( "<source src=\"%s\" />" % movie_path )
			content += common.emit_line( "<source src=\"%s\" />" % alt_path )
			content += common.emit_line( "</video>" )
		else:	
			content = common.emit_line( "<video controls id=%s poster=\"%s\" ><source src=\"%s\" /></video>" % (htmlid, poster_path, movie_path) )

	scriptlet_dct = {}
	scriptlet_dct['on'] = "document.getElementById('%s').style.visibility='visible';" % htmlid
	scriptlet_dct['off'] = "document.getElementById('%s').style.visibility='hidden';" % htmlid
	scriptlet_dct['init'] = "document.getElementById('%s').style.visibility='visible';" % htmlid
	
	return [ style, content, scriptlet_dct ]