예제 #1
0
def color():
    c = Random.selector(5)
    if c == 0:
        return Random.choice(["currentColor", "transparent"])
    elif c == 1:
        return Random.choice(["red", "blue", "green", "black", "white"])
    elif c == 2:
        return "#{}".format(Random.hex_digits(Random.choice([6, 8])))
    elif c == 3:
        return "rgb({})".format(seq([Random.hex_byte() for _ in range(3)]))
    else:
        return "rgba({})".format(seq([Random.hex_byte() for _ in range(4)]))
예제 #2
0
def animation_easing():
    value = Random.choice([
        "linear", "ease", "ease-in", "ease-out", "ease-in-out", "cubic-bezier"
    ])
    if value == "cubic-bezier":
        value += "({})".format(seq([Random.number() for _ in range(4)]))
    return value
예제 #3
0
파일: protocol.py 프로젝트: nivertech/mrim
    def __init__(self,
                 typ=0,
                 seq=0,
                 fromip='0.0.0.0',
                 fromport='0',
                 dict={},
                 packet=''):
        self.header = ''
        self.body = ''
        self.typ = typ

        if packet:
            raw_header = packet[:44]
            try:
                magic = struct.unpack('I', raw_header[:4])[0]
            except:
                magic = 0
            if magic == CS_MAGIC:
                self.header = MMPHeader(header=raw_header)
                if self.header:
                    self.typ = self.header['msg']
                    dlen = self.header['dlen']
                    self.body = MMPBody(typ=self.typ,
                                        body=packet[44:44 + dlen])

        else:
            self.body = MMPBody(self.typ, dict)
            dlen = len(self.body.__str__())
            self.header = MMPHeader(self.typ, dlen, seq, fromip, fromport)
            self.setHeaderAttr('seq', utils.seq())
예제 #4
0
def polygon():
    values = []
    if Random.bool():
        values.append(fill_rule())
    num = Random.range(2, 5)
    for _ in range(num):
        values.append("{} {}".format(length_percentage(), length_percentage()))
    return "polygon({})".format(seq(values))
예제 #5
0
def coords():
    c = Random.selector(3)
    if c == 0:
        n = 4
    elif c == 1:
        n = 3
    else:
        n = Random.range(3, 5) * 2
    return seq([Random.integer() for _ in range(n)])
예제 #6
0
	def __init__(self,to='',body=' ',flags=[],payload=None):
		if not payload:
			d = {}
			flags_sum = 0
			for f in flags:
				flags_sum += f
			d['flags'] = flags_sum & MESSAGE_USERFLAGS_MASK
			d['to'] = to
			d['message'] = body
			if MESSAGE_FLAG_RTF in flags:
				d['rtf-message'] = utils.pack_rtf(body)
			else:
				d['rtf-message'] = ' '
			MMPPacket.__init__(self,typ=MRIM_CS_MESSAGE,dict=d)
			self.setHeaderAttr('seq', utils.seq())
		else:
			MMPPacket.__init__(self,typ=payload.getType(),dict=payload.getBody())
예제 #7
0
def font_feature_settings():
    def single():
        values = [
            "'{}'".format(
                Random.choice([
                    "smcp", "c2sc", "zero", "hist", "liga", "tnum", "frac",
                    "swsh", "ss07", "dlig", "vert", "hwid", "twid", "qwid",
                    "kern", "onum"
                ]))
        ]
        if Random.bool():
            if Random.bool():
                values.append(Random.choice(["on", "off"]))
            else:
                values.append(Random.integer())
        return cat(values)

    num = Random.range(1, 2)
    return seq([single() for _ in range(num)])
예제 #8
0
파일: protocol.py 프로젝트: nivertech/mrim
 def __init__(self, to='', body=' ', flags=[], payload=None):
     if not payload:
         d = {}
         flags_sum = 0
         for f in flags:
             flags_sum += f
         d['flags'] = flags_sum & MESSAGE_USERFLAGS_MASK
         d['to'] = to
         d['message'] = body
         if MESSAGE_FLAG_RTF in flags:
             d['rtf-message'] = utils.pack_rtf(body)
         else:
             d['rtf-message'] = ' '
         MMPPacket.__init__(self, typ=MRIM_CS_MESSAGE, dict=d)
         self.setHeaderAttr('seq', utils.seq())
     else:
         MMPPacket.__init__(self,
                            typ=payload.getType(),
                            dict=payload.getBody())
예제 #9
0
	def __init__(self,typ=0,seq=0,fromip='0.0.0.0',fromport='0',dict={},packet=''):
		self.header = ''
		self.body = ''
		self.typ = typ

		if packet:
			raw_header = packet[:44]
			try:
				magic = struct.unpack('I', raw_header[:4])[0]
			except:
				magic = 0
			if magic == CS_MAGIC:
				self.header = MMPHeader(header=raw_header)
				if self.header:
					self.typ = self.header['msg']
					dlen = self.header['dlen']
					self.body = MMPBody(typ=self.typ,body=packet[44:44+dlen])

		else:
			self.body = MMPBody(self.typ,dict)
			dlen = len(self.body.__str__())
			self.header = MMPHeader(self.typ,dlen,seq,fromip,fromport)
			self.setHeaderAttr('seq', utils.seq())
예제 #10
0
def scale3d():
    value = seq([Random.number() for _ in range(3)])
    return "scale3d({})".format(value)
예제 #11
0
파일: svg.py 프로젝트: sslab-gatech/freedom
 def generate(self, _):
     num = dv.list_size()
     if num > 0:
         self.value = seq([dv.length_percentage() for _ in range(num)])
     else:
         self.value = "0"
예제 #12
0
    def do_GET(self):
        """This method is called whenever the client invokes the GET method
        in the HTTP protocol request"""

        # Print the request line
        termcolor.cprint(self.requestline, 'green')
        termcolor.cprint(self.path, "blue")

        o = urlparse(self.path)
        path_name = o.path
        arguments = parse_qs(o.query)
        print("Resource requested:", path_name)
        print("Parameters:", arguments)

        json_check = "json" in arguments and arguments["json"][0] == "1"
        context = {}
        print("path", path_name)
        if path_name == "/":
            context["list_genes"] = DICT_GENES.keys()
            context["dict_operations"] = {"1) Gene Sequence": "geneSeq", "2) Gene Information": "geneInfo", "3) Gene Calculations": "geneCalc"}
            context["op_names"] = ["1) Gene Sequence", "2) Gene Information", "3) Gene Calculations"]
            contents = us.read_template_html_file("./html/index.html").render(context=context)
            context.clear()
        elif path_name == "/listSpecies":
            limit = arguments["limit"][0]
            context = us.list_sp(limit)
            if json_check:
                contents = str(context)
                print(contents)
            else:
                if "error" in context:
                    contents = us.read_template_html_file("./html/error.html").render(context=context)
                else:
                    contents = us.read_template_html_file("./html/list_species.html").render(context=context)

        elif path_name == "/karyotype":
            context = us.karyotype(arguments["specie"][0])
            if json_check:
                contents = str(context)
            else:
                if "error" in context:
                    contents = us.read_template_html_file("./html/error.html").render(context=context)
                else:
                    contents = us.read_template_html_file("./html/karyotype.html").render(context=context)

        elif path_name == "/chromosomeLength":
            context = us.chromo_len(arguments["specie"][0], arguments["chromo"][0])
            if json_check:
                contents = str(context)
            else:
                if "error" in context:
                    contents = us.read_template_html_file("./html/error.html").render(context=context)
                else:
                    contents = us.read_template_html_file("./html/chromo_length.html").render(context=context)
        elif path_name == "/geneSeq":
            gene_name = arguments["gene"][0]
            seq = us.seq(gene_name).strbases
            context = {"gene_contents": seq, "gene_name": gene_name}
            if json_check:
                contents = str(context)
            else:
                contents = us.read_template_html_file("./html/geneSeq.html").render(context=context)
        elif path_name == "/geneInfo":
            gene_name = arguments["gene"][0]
            context = us.info(gene_name)
            if json_check:
                contents = str(context)
            else:
                contents = us.read_template_html_file("./html/geneInfo.html").render(context=context)
        elif path_name == "/geneCalc":
            gene_name = arguments["gene"][0]
            context = us.calc(gene_name)
            if json_check:
                contents = str(context)
            else:
                contents = us.read_template_html_file("./html/geneCalc.html").render(context=context)
        else:
            context["error"] = "Not a valid path"
            contents = us.read_template_html_file("./html/error.html").render(context=context)


        # Message to send back to the client

        # Generating the response message
        self.send_response(200)  # -- Status line: OK!

        # Define the content-type header:
        self.send_header('Content-Type', 'text/html')
        self.send_header('Content-Length', len(contents.encode()))

        # The header is finished
        self.end_headers()

        # Send the response message
        self.wfile.write(contents.encode())

        return
예제 #13
0
파일: svg.py 프로젝트: sslab-gatech/freedom
def coordinate():
    return seq([Random.integer(), Random.integer()])
예제 #14
0
파일: svg.py 프로젝트: sslab-gatech/freedom
 def generate(self, _):
     self.value = seq([Random.integer() for _ in range(4)])
예제 #15
0
 def __str__(self):
     return seq(list(map(str, self.selectors)))
예제 #16
0
 def __str__(self):
     return "var {} = {{ {} }}".format(
         str(self.ret),
         seq(["{}: {}".format(prop, str(value)) for prop, value in self.shape.items()])
     )
예제 #17
0
def translate():
    num = Random.range(1, 2)
    value = seq([length_percentage() for _ in range(num)])
    return "translate({})".format(value)
예제 #18
0
def number_optional_number(signed):
    if signed:
        return seq([Random.signed_number(), Random.signed_number()])
    else:
        return seq([Random.number(), Random.number()])
예제 #19
0
def scale():
    num = Random.range(1, 2)
    value = seq([Random.number() for _ in range(num)])
    return "scale({})".format(value)
예제 #20
0
def rotate3d():
    values = [Random.number() for _ in range(3)]
    values.append(angle())
    return "rotate3d({})".format(seq(values))
예제 #21
0
def skew():
    num = Random.range(1, 2)
    value = seq([angle() for _ in range(num)])
    return "skew({})".format(value)
예제 #22
0
def translate3d():
    value = seq([length_percentage(), length_percentage(), length()])
    return "translate3d({})".format(value)
예제 #23
0
def matrix3d():
    value = seq([Random.number() for _ in range(16)])
    return "matrix3d({})".format(value)