python类atoi()的实例源码

caldav.py 文件源码 项目:health-mosconi 作者: GNUHealth-Mosconi 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def do_POST(self):
    dc = self.IFACE_CLASS

    uri = urlparse.urljoin(self.get_baseuri(dc), self.path)
    uri = urllib.unquote(uri)

    dbname, dburi = TrytonDAVInterface.get_dburi(uri)
    if dburi.startswith('Calendars'):
        # read the body
        body = None
        if 'Content-Length' in self.headers:
            l = self.headers['Content-Length']
            body = self.rfile.read(atoi(l))
        ct = None
        if 'Content-Type' in self.headers:
            ct = self.headers['Content-Type']

        try:
            DATA = '%s\n' % dc._get_caldav_post(uri, body, ct)
        except DAV_Error, exception:
            ec, _ = exception
            return self.send_status(ec)
        self.send_body(DATA, 200, 'OK', 'OK')
        return
    return _prev_do_POST(self)
version.py 文件源码 项目:kinect-2-libras 作者: inessadl 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
syscalls.py 文件源码 项目:darkc0de-old-stuff 作者: tuwid 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, mmemory, typeaccess=0) :
        if not isinstance(mmemory, Memory):
            raise TypeError("ERREUR")

        self.mmemory = mmemory
        self.mmemory.open("r", typeaccess)

        try :
            fichier = open("/usr/include/asm/unistd.h", "r")
        except IOError :
            print "No such file /usr/include/asm/unistd.h"
            sys.exit(-1)

        liste = fichier.readlines()
        fichier.close()
        count = 0
        for i in liste :
            if(re.match("#define __NR_", i)) :
                l = string.split(i)
                if(l[2][0].isdigit()) :
                    count = string.atoi(l[2], 10)
                    self.lists_syscalls.append([count, l[1][5:]])
                else :
                    count = count + 1
                    self.lists_syscalls.append([count, l[1][5:]])
version.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
SAM.py 文件源码 项目:RSeQC 作者: MonashBioinformaticsPlatform 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def getProperPair(self,outfile=None):
        '''Extract proper paried mapped reads.'''
        if outfile is None:
            outfile = self.fileName + ".PP.sam"
        FO=open(outfile,'w')
        PPcount=0
        print >>sys.stderr, "Writing proper paired reads to\"",outfile,"\"... ",
        for line in self.f:
            hits=[]
            if line[0] == '@':continue                      #skip head lines    
            if ParseSAM._reExpr2.match(line):continue       #skip blank lines
            field=line.rstrip('\n').split() 
            flagCode=string.atoi(field[1])
            if ((flagCode & 0x0001) != 0) and ((flagCode & 0x0002)!=0):
                PPcount +=1
                FO.write(line)
        FO.close()
        print >>sys.stderr, str(PPcount) + " reads were saved!\n",
        self.f.seek(0)
SAM.py 文件源码 项目:RSeQC 作者: MonashBioinformaticsPlatform 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def getUniqMapRead(self,outfile=None):
        '''Extract uniquely mapped reads.'''
        if outfile is None:
            outfile = self.fileName + ".uniq.sam"
        FO=open(outfile,'w')
        Uniqcount=0
        print >>sys.stderr, "Writing uniquely mapped reads to\"",outfile,"\"... ",
        for line in self.f:
            hits=[]
            if line[0] == '@':continue                      #skip head lines    
            if ParseSAM._reExpr2.match(line):continue       #skip blank lines
            field=line.rstrip('\n').split() 
            flagCode=string.atoi(field[1])
            if (flagCode & 0x0004) == 1: 
                continue            #skip unmapped reads
            #else:
                #print >>sys.stderr,line,
            if (ParseSAM._uniqueHit_pat.search(line)):
                print >>sys.stderr,line,
                Uniqcount +=1
                FO.write(line)
        FO.close()
        print >>sys.stderr, str(Uniqcount) + " reads were saved!\n",
        self.f.seek(0)
SAM.py 文件源码 项目:RSeQC 作者: MonashBioinformaticsPlatform 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def collapseSAM(self, outfile=None,collevel=10):
        '''At most collevel[default=10] identical reads will be retained in outputting SAM file
        The original SAM file must be sorted before hand. if not, using linux command like "sort -k3,3 -k4,4n myfile.sam >myfile.sorted.sam" '''
        if outfile is None:
            outfile = self.fileName + ".collapsed.sam"
        print >>sys.stderr, "Writing collapsed SAM file to\"",outfile,"\"... "
        FO=open(outfile,'w')        
        flag=""
        for line in self.f:
            if line[0] == '@':continue                      #skip head lines    
            if ParseSAM._reExpr2.match(line):continue       #skip blank lines   
            field=line.rstrip('\n').split() 
            if (string.atoi(field[1]) & 0x0004)!=0: continue    #skip unmapped line 
            id=field[2] + field[3] + field[5]
            if (id != flag):
                FO.write(line)
                flag=id
                skipTrigger=0
            else:
                skipTrigger+=1
                if skipTrigger < collevel:
                    FO.write(line)
                else:continue
        FO.close()
        self.f.seek(0)
netblock.py 文件源码 项目:pentestly 作者: praetorian-inc 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def strtoip(ipstr):
    """convert an IP address in string form to numeric."""
    res = 0L
    count = 0
    n = string.split(ipstr, '.')
    for i in n:
        res = res << 8L
        ot = string.atoi(i)
        if ot < 0 or ot > 255:
            raise ValueError, "invalid IP octet"
        res = res + ot
        count = count + 1
    # could be incomplete (short); make it complete.
    while count < 4:
        res = res << 8L
        count = count + 1
    return res
netblock.py 文件源码 项目:pentestly 作者: praetorian-inc 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def cidrstrerr(str):
    """Check an IP address or CIDR netblock for validity.

    Returns None if it is and otherwise an error string."""
    if not cvalid.match(str):
        return 'Not a syntatically valid IP address or netblock'
    rng = 32
    pos = string.find(str, '/')
    ips = str
    if not pos == -1:
        rng = string.atoi(ips[pos+1:])
        ips = str[:pos]
    if rng < 0 or rng > 32:
        return 'CIDR length out of range'
    n = string.split(ips, '.')
    for i in n:
        ip = string.atoi(i)
        if (ip < 0 or ip > 255):
            return 'an IP octet is out of range'
    # could check to see if it is 'proper', but.
    return None
version.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
remote.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def GET(self, id=None):
        if id == None:
            return('Here are all the functions available: %s' % self.functions)

        fn_name=id.split('(')[0]
        args=str(id.split('(')[1]).split(',')

        if len(args):args[-1]=args[-1][:-1]
        total_args=[]
        for t in args:
            print (t,len(t))
            if t[0]=="'" or t[0]=='"':total_args.append(t[1:-1])
            else:total_args.append(string.atoi(t))

        method = self.methods.get(fn_name)[0]
        if method == None :
            print ('no such command :',fn_name)
            return 'no such command : %s'%fn_name
        else:
            print (method,total_args)
            #while self.hw_lock and self.active: pass
            #self.hw_lock=True
            result=method(*total_args)      
            #self.hw_lock=False
            return json.dumps(result,cls=NumpyEncoder)
virtual.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def setThingSpeakCommand(self):
        try:
            message = str(self.cmdEditThingSpeak.text())
            fn_name=message.split('(')[0]
            args = message[message.find("(")+1:message.find(")")].strip().split(',')
            total_args=[]
            for t in args:
                if not len(t):continue
                if t[0]=="'" or t[0]=='"':total_args.append(t[1:-1])
                else:total_args.append(string.atoi(t))

            method = self.methods.get(fn_name)[0]
            if method == None :
                print ('no such command :',fn_name)
                return 'no such command : %s'%fn_name
            else:
                #while self.hw_lock and self.active: pass
                #self.hw_lock=True
                self.thingSpeakCommand=[method,total_args]
        except Exception,e:
            self.results_2.append('Set Error : %s'%( e.message))
            pass
C_stream.py 文件源码 项目:pslab-desktop-apps 作者: fossasia 项目源码 文件源码 阅读 142 收藏 0 点赞 0 评论 0
def parseFunc(self,fn):
        fn_name=fn.split('(')[0]
        args=str(fn.split('(')[1]).split(',')
        int_args=[]
        try:
            args[-1]=args[-1][:-1]
            int_args=[string.atoi(t) for t in args]
        except: 
            int_args=[] #in case the function has zero arguments, args[-1] will fail.
        method = getattr(self.I,fn_name)
        if method == None :
            print ('no such command :',fn_name)
            return None
        else:
            print (method,int_args)
            return method,int_args
version.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
get_words_for_CCIR.py 文件源码 项目:CCIR 作者: xiaogang00 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def process_id(train_file_dir,train_file_name):
    # ???????????????????????????????query??????list??????????list
    # train_file_dir?????????train_file_name????????
    unable = open(os.path.join(train_file_dir, 'cannot_segment_query_id.txt'), 'r')
    lines = unable.readlines()
    unable_id = []
    for line in lines:
        a = line.replace("\n", "").split("  ")
        unable_id.append(string.atoi(a[0]))
    f = open(os.path.join(train_file_dir, train_file_name),'r')
    qaid = []
    for line in f:
        file_dict_temp = json.loads(line)
        temp_id = file_dict_temp['query_id']
        if temp_id in unable_id:
            continue
        qaid.append(temp_id)
    return qaid
get_words_for_CCIR.py 文件源码 项目:CCIR 作者: xiaogang00 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def process_id(train_file_dir,train_file_name):
    # ???????????????????????????????query??????list??????????list
    # train_file_dir?????????train_file_name????????
    unable = open(os.path.join(train_file_dir, 'cannot_segment_query_id.txt'), 'r')
    lines = unable.readlines()
    unable_id = []
    for line in lines:
        a = line.replace("\n", "").split("  ")
        unable_id.append(string.atoi(a[0]))
    f = open(os.path.join(train_file_dir, train_file_name),'r')
    qaid = []
    for line in f:
        file_dict_temp = json.loads(line)
        temp_id = file_dict_temp['query_id']
        if temp_id in unable_id:
            continue
        qaid.append(temp_id)
    return qaid
class_central_spider.py 文件源码 项目:CourseWebCrawler 作者: BitTigerInst 项目源码 文件源码 阅读 50 收藏 0 点赞 0 评论 0
def parse_detail_page(self, response):
        """
        Get details for each course
        """
        item = response.meta['item']

        parse_review_num = response.xpath('//span[@itemprop="votes"]/text()').extract_first().strip()
        item['review_num'] = string.atoi(parse_review_num)

        parse_student_num = re.findall(r'"mycourses-listed-count", 0, (.*), 0', response.text)[0].strip() or '0'
        item['student_num'] = string.atoi(parse_student_num)

        parse_course_info = response.xpath('//div[@class="course-desc"]').extract()
        for i in range(len(parse_course_info) - 1):
            parse_course_info[0].extend(parse_course_info[i+1])
        item['keywords'] = self.get_keywords(parse_course_info[0]+item['name']) or []

        yield item
PmwColor.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def name2rgb(root, colorName, asInt = 0):
    if colorName[0] == '#':
        # Extract rgb information from the color name itself, assuming
        # it is either #rgb, #rrggbb, #rrrgggbbb, or #rrrrggggbbbb
        # This is useful, since tk may return incorrect rgb values if
        # the colormap is full - it will return the rbg values of the
        # closest color available.
        colorName = colorName[1:]
        digits = len(colorName) / 3
        factor = 16 ** (4 - digits)
        rgb = (
            string.atoi(colorName[0:digits], 16) * factor,
            string.atoi(colorName[digits:digits * 2], 16) * factor,
            string.atoi(colorName[digits * 2:digits * 3], 16) * factor,
        )
    else:
        # We have no choice but to ask Tk what the rgb values are.
        rgb = root.winfo_rgb(colorName)

    if not asInt:
        rgb = (rgb[0] / _MAX_RGB, rgb[1] / _MAX_RGB, rgb[2] / _MAX_RGB)
    return rgb
Pmw.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def timestringtoseconds(text, separator = ':'):
  inputList = string.split(string.strip(text), separator)
  if len(inputList) != 3:
    raise ValueError, 'invalid value: ' + text

  sign = 1
  if len(inputList[0]) > 0 and inputList[0][0] in ('+', '-'):
    if inputList[0][0] == '-':
      sign = -1
    inputList[0] = inputList[0][1:]

  if re.search('[^0-9]', string.join(inputList, '')) is not None:
    raise ValueError, 'invalid value: ' + text

  hour = string.atoi(inputList[0])
  minute = string.atoi(inputList[1])
  second = string.atoi(inputList[2])

  if minute >= 60 or second >= 60:
    raise ValueError, 'invalid value: ' + text
  return sign * (hour * 60 * 60 + minute * 60 + second)
Pmw.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def aligngrouptags(groups):
    # Adjust the y position of the tags in /groups/ so that they all
    # have the height of the highest tag.

    maxTagHeight = 0
    for group in groups:
        if group._tag is None:
            height = (string.atoi(str(group._ring.cget('borderwidth'))) +
                    string.atoi(str(group._ring.cget('highlightthickness'))))
        else:
            height = group._tag.winfo_reqheight()
        if maxTagHeight < height:
            maxTagHeight = height

    for group in groups:
        ringBorder = (string.atoi(str(group._ring.cget('borderwidth'))) +
                string.atoi(str(group._ring.cget('highlightthickness'))))
        topBorder = maxTagHeight / 2 - ringBorder / 2
        group._hull.grid_rowconfigure(0, minsize = topBorder)
        group._ring.grid_rowconfigure(0,
                minsize = maxTagHeight - topBorder - ringBorder)
        if group._tag is not None:
            group._tag.place(y = maxTagHeight / 2)
Pmw.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def _next(self, event):
        size = self.size()
        if size <= 1:
            return

        cursels = self.curselection()

        if len(cursels) == 0:
            index = 0
        else:
            index = string.atoi(cursels[0])
            if index == size - 1:
                index = 0
            else:
                index = index + 1

        self.selectitem(index)
Pmw.py 文件源码 项目:ecel 作者: ARL-UTEP-OC 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _previous(self, event):
        size = self.size()
        if size <= 1:
            return

        cursels = self.curselection()

        if len(cursels) == 0:
            index = size - 1
        else:
            index = string.atoi(cursels[0])
            if index == 0:
                index = size - 1
            else:
                index = index - 1

        self.selectitem(index)
version.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
pysvr.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "")
        if len(args) > 1:
            raise getopt.error, "Too many arguments."
    except getopt.error, msg:
        usage(msg)
    for o, a in opts:
        pass
    if args:
        try:
            port = string.atoi(args[0])
        except ValueError, msg:
            usage(msg)
    else:
        port = PORT
    main_thread(port)
find.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def main():
    nworkers = 4
    opts, args = getopt.getopt(sys.argv[1:], '-w:')
    for opt, arg in opts:
        if opt == '-w':
            nworkers = string.atoi(arg)
    if not args:
        args = [os.curdir]

    wq = WorkQ()
    for dir in args:
        wq.addwork(find, (dir, selector, wq))

    t1 = time.time()
    wq.run(nworkers)
    t2 = time.time()

    sys.stderr.write('Total time %r sec.\n' % (t2-t1))


# The predicate -- defines what files we look for.
# Feel free to change this to suit your purpose
rpython.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def main():
    if len(sys.argv) < 3:
        print "usage: rpython host command"
        sys.exit(2)
    host = sys.argv[1]
    port = PORT
    i = string.find(host, ':')
    if i >= 0:
        port = string.atoi(port[i+1:])
        host = host[:i]
    command = string.join(sys.argv[2:])
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((host, port))
    s.send(command)
    s.shutdown(1)
    reply = ''
    while 1:
        data = s.recv(BUFSIZE)
        if not data: break
        reply = reply + data
    print reply,
mbox.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def open_message(e=None):
    global viewer
    sel = scanbox.curselection()
    if len(sel) != 1:
        if len(sel) > 1:
            msg = "Please open one message at a time"
        else:
            msg = "Please select a message to open"
        dialog(root, "Can't Open Message", msg, "", 0, "OK")
        return
    cursor = scanbox['cursor']
    scanbox['cursor'] = 'watch'
    tk.call('update', 'idletasks')
    i = sel[0]
    line = scanbox.get(i)
    if scanparser.match(line) >= 0:
        num = string.atoi(scanparser.group(1))
        m = mhf.openmessage(num)
        if viewer: viewer.destroy()
        from MimeViewer import MimeViewer
        viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
        viewer.pack()
        viewer.show()
    scanbox['cursor'] = cursor
cvslib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 46 收藏 0 点赞 0 评论 0
def unctime(date):
    if date == "None": return None
    if not unctime_monthmap:
        months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        i = 0
        for m in months:
            i = i+1
            unctime_monthmap[m] = i
    words = string.split(date) # Day Mon DD HH:MM:SS YEAR
    year = string.atoi(words[4])
    month = unctime_monthmap[words[1]]
    day = string.atoi(words[2])
    [hh, mm, ss] = map(string.atoi, string.splitfields(words[3], ':'))
    ss = ss - time.timezone
    return time.mktime((year, month, day, hh, mm, ss, 0, 0, 0))
version.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None
version.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def parse (self, vstring):
        match = self.version_re.match(vstring)
        if not match:
            raise ValueError, "invalid version number '%s'" % vstring

        (major, minor, patch, prerelease, prerelease_num) = \
            match.group(1, 2, 4, 5, 6)

        if patch:
            self.version = tuple(map(string.atoi, [major, minor, patch]))
        else:
            self.version = tuple(map(string.atoi, [major, minor]) + [0])

        if prerelease:
            self.prerelease = (prerelease[0], string.atoi(prerelease_num))
        else:
            self.prerelease = None


问题


面经


文章

微信
公众号

扫码关注公众号