当前位置: 首页>>代码示例>>Python>>正文


Python Lib类代码示例

本文整理汇总了Python中Lib的典型用法代码示例。如果您正苦于以下问题:Python Lib类的具体用法?Python Lib怎么用?Python Lib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Lib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: applyFilter

 def applyFilter(self, aImage):
     oldtime = time.time()
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     print height, width
     n = 0
     p = 1
     for x in range(width):
         for y in range(height):
             
             r = int(pixels[y][x][0]*self.amount)
             g = int(pixels[y][x][1]*self.amount)
             b = int(pixels[y][x][2]*self.amount)
             
             if Lib.isprime(n):
                 r=g=b=0
                 p+=1
             
             new_pixel = (r,g,b)
             new_image_list.append(new_pixel)
             n+=1
             
     new_image.putdata(new_image_list)
     timetaken = time.time()-oldtime
     print "primes:", n-p, ", out of", n , "pixels", ", it took", timetaken, "seconds"
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:35,代码来源:CFilterTest.py

示例2: applyFilter

 def applyFilter(self, aImage):
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     hardness = 1
     
     for x in range(width):
         for y in range(height):
             
             dist = Lib.distanceFromPoint(x, y, width/2, height/2) / math.sqrt((width/2)**2 + (height/2)**2)
             
             r = int(pixels[y][x][0]*(self.amount-dist))
             g = int(pixels[y][x][1]*(self.amount-dist))
             b = int(pixels[y][x][2]*(self.amount-dist))
             
             #r = int(r**hardness)
             #g = int(g**hardness)
             #b = int(b**hardness)
             
             new_image_list.append((r,g,b))
             
     new_image.putdata(new_image_list)
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:31,代码来源:CFilterVignette.py

示例3: expand_pic_in_html

def expand_pic_in_html(region, data):
    """取得图片地址"""
    pic_path = []
    reg_background = re.compile(
        r"background(?:\s*\:|-image\s*\:).*?url\([\'|\"]?([\w+:\/\/^]?[^? \}]*\.\w+)\?*.*?[\'|\"]?\)", re.I
    )
    reg_filter = re.compile(r"Microsoft\.AlphaImageLoader\(.*?src=[\'|\"]?([\w:\/\/\.]*\.\w+)\?*.*?[\'|\"]?.*?\)", re.I)
    reg_img = re.compile(r"<img[^>]+src\s*=\s*[\'\"]([^\'\"]+)[\'\"][^>]*>", re.I)
    _b1_ = reg_background.finditer(data)
    _b2_ = reg_background.findall(data)
    _f1_ = reg_filter.finditer(data)
    _f2_ = reg_filter.findall(data)
    _i1_ = reg_img.finditer(data)
    _i2_ = reg_img.findall(data)
    if ST2:
        _b_ = Lib.region_and_str(region, _b1_, _b2_)
        _f_ = Lib.region_and_str(region, _f1_, _f2_)
        _i_ = Lib.region_and_str(region, _i1_, _i2_)
    else:
        _b_ = modeCSS.Lib.region_and_str(region, _b1_, _b2_)
        _f_ = modeCSS.Lib.region_and_str(region, _f1_, _f2_)
        _i_ = modeCSS.Lib.region_and_str(region, _i1_, _i2_)
    if _b_:
        pic_path.append(_b_)
    if _f_:
        pic_path.append(_f_)
    if _i_:
        pic_path.append(_i_)
    return pic_path
开发者ID:ghostzhang,项目名称:modeCSS,代码行数:29,代码来源:EncodePic.py

示例4: main

def main():
    fileName = "./../test/test1.ir"
    if len(sys.argv) == 2:
        fileName = sys.argv[1]
    ir = IR(fileName)
    code = CodeGen(ir)
    print "\t.text"
    print "\t.globl main\n"
    print "main:\n"
    codeBlocks = code._codeBlocks
    # add the library functions
    # Now add the generated block by code generator
    i = 1
    for node in codeBlocks:   
        print "B"+str(i)+":"
        print "\t"+"\n\t".join(node)
        i += 1

    print "\tj "+LibFns["exit"]

    lib = Lib()
    instrs = lib.genFns()
    for ins in instrs.keys():
       print str(ins)+":"
       print "\t"+"\n\t".join(instrs[ins])



    print "\n\t.data"
    for var in code._globalVars:
        print "g_"+str(var) + ":\t.word\t0"
开发者ID:ssolanki,项目名称:php-python-mips-1,代码行数:31,代码来源:__main__.py

示例5: merge_css

def merge_css(self, edit, setlists):
    '''压缩样式内容'''
    view = self.view
    sel = view.sel()

    syntax = view.settings().get('syntax')
    _fsyntax_ = re.search(r'\/([\w ]+)\.',syntax)
    # 取得文件类型
    fsyntax = _fsyntax_.group(1)
    # 未选中时默认处理方式
    notSel = setlists['notSel']

    if fsyntax == 'CSS' or fsyntax == 'HTML':
        for region in sel:
            if region.empty():# 如果没有选中
                if fsyntax == 'CSS' and notSel == 'all':
                    # 全选
                    region = sublime.Region(0, view.size())
                    # 整理文本
                    text = merge_line(view.substr(region), setlists)
                    view.replace(edit, region, text)
                # 处理HTML文件中的STYLE标签
                elif fsyntax == 'HTML' and notSel == 'all':
                    if ST2:
                        rules = Lib.expand_to_style(view, region)
                    else:
                        rules = modeCSS.Lib.expand_to_style(view, region)
                    # 倒序替换
                    for i in range(len(rules)-1, -1,-1):
                        # 整理文本
                        text = merge_line(view.substr(rules[i]), setlists)
                        view.replace(edit, rules[i], text)
                else:
                    if ST2:
                        region = Lib.expand_to_css_rule(view, region)
                    else:
                        region = modeCSS.Lib.expand_to_css_rule(view, region)
                    # 整理文本
                    text = merge_line(view.substr(region), setlists)
                    view.replace(edit, region, text)
            else:
                if notSel == 'all':
                    # 全选
                    region = sublime.Region(0, view.size())
                if ST2:
                    region = Lib.get_cur_point(view,region)
                else:
                    region = modeCSS.Lib.get_cur_point(view,region)
                # 整理文本
                text = merge_line(view.substr(region), setlists)
                view.replace(edit, region, text)
开发者ID:chenermeng,项目名称:modeCSS,代码行数:51,代码来源:MergeCss.py

示例6: cubeCtl

def cubeCtl( name, functArgs ):
        J=[]
        ctl = Lib.getFirst(cmds.polyCube( n = (name + "_CTL"), w= functArgs["size"], h= functArgs["size"], d= 1, sx= 1, sy= 1, sz= 1, ax= [0, 1, 0], cuv= 4, ch= 1))
        grp = cmds.group( ctl, n = (name + "Ctl_GRP"))
        J.append(ctl)
        J.append(grp)
        return J
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:7,代码来源:Control.py

示例7: applyFilter

 def applyFilter(self, aImage):
     # intialize a new filtered image
     new_image = Image.new('RGB', aImage.size)
     new_image_list = []
     #get the pixels list from the original image
     #pixels = aImage.getdata()
     
     pixels = Lib.to2d(aImage)
     
     height = len(pixels)
     width = len(pixels[0])
     
     for x in range(width):
         for y in range(height):
                 
             if x > self.size and x < (width - self.size) and \
             y > self.size and y < (height - self.size):
                 r = int(pixels[y][x][0])
                 g = int(pixels[y][x][1])
                 b = int(pixels[y][x][2])
             else:
                 r = int(self.color[0]*255)
                 g = int(self.color[1]*255)
                 b = int(self.color[2]*255)
             
             new_pixel = (r,g,b)
             new_image_list.append(new_pixel)
             
     new_image.putdata(new_image_list)
     return new_image
开发者ID:Cheesier,项目名称:Instapy,代码行数:30,代码来源:CFilterPlainBorder.py

示例8: sendTCPRequest

 def sendTCPRequest(self, server):
     " do the work of sending a TCP request "
     first_socket_error = None
     self.response=None
     for self.ns in server:
         #print "trying tcp",self.ns
         try:
             if self.ns.count(':'):
                 if hasattr(socket,'has_ipv6') and socket.has_ipv6:
                     self.socketInit(socket.AF_INET6, socket.SOCK_STREAM)
                 else: continue
             else:
                 self.socketInit(socket.AF_INET, socket.SOCK_STREAM)
             try:
                 # TODO. Handle timeouts &c correctly (RFC)
                 self.time_start=time.time()
                 self.conn()
                 buf = Lib.pack16bit(len(self.request))+self.request
                 # Keep server from making sendall hang
                 self.s.setblocking(0)
                 # FIXME: throws WOULDBLOCK if request too large to fit in
                 # system buffer
                 self.s.sendall(buf)
                 # SHUT_WR breaks blocking IO with google DNS (8.8.8.8)
                 #self.s.shutdown(socket.SHUT_WR)
                 r=self.processTCPReply()
                 if r.header['id'] == self.tid:
                     self.response = r
                     break
             finally:
                 self.s.close()
         except socket.error, e:
             first_socket_error = first_socket_error or e
             continue
开发者ID:01-,项目名称:mailin,代码行数:34,代码来源:Base.py

示例9: sphereCtl

def sphereCtl( name, functArgs ):
        J=[]
        ctl = Lib.getFirst(cmds.polySphere( n = (name + "_CTL"), r= functArgs["size"], sx= 1, sy= 1, ax= [0, 1, 0], ch= 1))
        grp = cmds.group( ctl, n = (name + "Ctl_GRP"))
        J.append(ctl)
        J.append(grp)
        return J
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:7,代码来源:Control.py

示例10: circleCtl

def circleCtl( name, radius ):
        'Creates arrow control'
        J=[]
        curve= Lib.getFirst(cmds.circle( n = (name+ "_CTL"), c= [0, 0, 0], nr= [0, 1, 0], sw= 360, r= radius, d= 3, ut= 0, tol= 0.01 ,s= 8, ch=1))
        grp = cmds.group( curve, n = (name + "Ctl_GRP"))
        J.append(curve)
        J.append(grp)
        return J
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:8,代码来源:Control.py

示例11: run

 def run(self, edit):
     view = self.view
     if ST2:
         setlists = Lib.get_default_set()
     else:
         setlists = modeCSS.Lib.get_default_set()
     setlists["notSel"] = "all"
     merge_css(self, edit, setlists)
开发者ID:TIDTeam,项目名称:modeCSS,代码行数:8,代码来源:MergeCss.py

示例12: locatorCtl

def locatorCtl( name, args ):
        'Creates locator ctl'
        J=[]
        ctl = Lib.getFirst(cmds.spaceLocator( n =(name + "_CTL") ) )
        grp = cmds.group( ctl, n = (name + "Ctl_GRP"))
        cmds.xform(grp, piv= [0,0,0] )
        J.append(ctl)
        J.append(grp)
        return J
开发者ID:jwnwilson,项目名称:nw_rig,代码行数:9,代码来源:Control.py

示例13: run

 def run(self, edit):
     view = self.view
     if ST2:
         setlists = Lib.get_default_set()
     else:
         setlists = modeCSS.Lib.get_default_set()
     setlists["notSel"] = "all"
     setlists["all_in_one"] = True
     setlists["delete_comments"] = True
     merge_css(self, edit, setlists)
开发者ID:chenermeng,项目名称:modeCSS,代码行数:10,代码来源:MergeCss.py

示例14: processTCPReply

 def processTCPReply(self):
     if self.timeout > 0:
         self.s.settimeout(self.timeout)
     else:
         self.s.settimeout(None)
     f = self.s.makefile('r')
     header = self._readall(f,2)
     count = Lib.unpack16bit(header)
     self.reply = self._readall(f,count)
     self.time_finish=time.time()
     self.args['server']=self.ns
     return self.processReply()
开发者ID:BeanYoung,项目名称:ToodledoGtalkRobot,代码行数:12,代码来源:Base.py

示例15: duplicateChain

def duplicateChain(name , chainJoints):
        'Duplicates a chain of joints'
        i = 1
        joints = []
        jointNo = len(chainJoints)
        
        for x in range( jointNo ):
            joints.append( Lib.getFirst(cmds.duplicate(chainJoints[x], po = True, n = (name + str(x + 1) + "_JNT"))) ) 
        
        for x in range( 1, jointNo ):
            cmds.parent(joints[jointNo - x], joints[jointNo - (x + 1)])
        
        return joints
开发者ID:jwnwilson,项目名称:nw_maya,代码行数:13,代码来源:joint.py


注:本文中的Lib类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。