• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python match.match函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: seek_time_ok

def seek_time_ok(FILENAME,ERRORS):

  # create a video reader using the tiny videofile VIDEOS+FILENAME
  video=cvCreateFileCapture(VIDEOS+FILENAME)

  if video is None:
    # couldn't open video (FAIL)
    return 1

  if show_frames:
    cvNamedWindow("test", CV_WINDOW_AUTOSIZE)

  # skip 2 frames and read 3rd frame each until EOF and check if the read image is ok
  for k in [0,3,6,9,12,15,18,21,24,27]:

    cvSetCaptureProperty(video, CV_CAP_PROP_POS_MSEC, k*40)

    # try to query frame
    image=cvQueryFrame(video)

    if image is None:
    # returned image is NULL (FAIL)
      return 1

    compresult = match.match(image,k,ERRORS[k])
    if not compresult:
      return 1

    if show_frames:
      cvShowImage("test",image)
      cvWaitKey(200)

  # same as above, just backwards...
  for k in [27,24,21,18,15,12,9,6,3,0]:

    cvSetCaptureProperty(video, CV_CAP_PROP_POS_MSEC, k*40)

    # try to query frame
    image=cvQueryFrame(video)

    if image is None:
    # returned image is NULL (FAIL)
      return 1

    compresult = match.match(image,k,ERRORS[k])
    if not compresult:
      return 1

    if show_frames:
      cvShowImage("test",image)
      cvWaitKey(200)

  # ATTENTION: We do not release the video reader, window or any image.
  # This is bad manners, but Python and OpenCV don't care,
  # the whole memory segment will be freed on finish anyway...

  del video
  # everything is fine (PASS)
  return 0
开发者ID:Ikem,项目名称:opencv-1.1.0,代码行数:59,代码来源:seek_test.py


示例2: test_no_match

    def test_no_match(self):
        vals = []
        vals.append(match("a"))
        vals.append(match("AB"))
        vals.append(match("A B"))

        for val in vals:
            self.assertIsNone(val, msg="Invalid pattern matched!")
开发者ID:astonshane,项目名称:DavisPutnamNoCNF,代码行数:8,代码来源:test_match.py


示例3: test_find_match

 def test_find_match(self):
     body1 = Mock()
     body2 = Mock()
     match_cases = {
         MatchKey('tests', [], []) : 'body1()',
         MatchKey('test', [], []) : 'body2()'}
     match('test', match_cases)
     self.assertFalse(body1.called)
     self.assertTrue(body2.called)
开发者ID:mnussbaum,项目名称:python-match,代码行数:9,代码来源:match_tests.py


示例4: test_harder_match

 def test_harder_match(self):
     body1 = Mock()
     body2 = Mock()
     match_cases = {
         MatchKey('test %s %M %M', ['this'], ['var1', 'var2']) : \
           'body1()',
         MatchKey('test %s %M', ['this'], ['var1']) : 'body2(var1)'}
     match('test this case', match_cases)
     self.assertFalse(body1.called)
     body2.assert_called_once_with('case')
开发者ID:mnussbaum,项目名称:python-match,代码行数:10,代码来源:match_tests.py


示例5: test_condition_match

 def test_condition_match(self):
     body1 = Mock()
     body2 = Mock()
     match_cases = {
         MatchKey('test %M', [], [(lambda x : False, 'var1')]) \
         : 'body1()',
         MatchKey('test %M', [], [(lambda x : x == 'a', 'var1')]) \
         : 'body2()'}
     match('test a', match_cases)
     self.assertFalse(body1.called)
     self.assertTrue(body2.called)
开发者ID:mnussbaum,项目名称:python-match,代码行数:11,代码来源:match_tests.py


示例6: checkstatus

def checkstatus(repo, subset, pat, field):
    m = None
    s = []
    fast = not matchmod.patkind(pat)
    for r in subset:
        c = repo[r]
        if fast:
            if pat not in c.files():
                continue
        else:
            if not m or matchmod.patkind(pat) == 'set':
                m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
            for f in c.files():
                if m(f):
                    break
            else:
                continue
        files = repo.status(c.p1().node(), c.node())[field]
        if fast:
            if pat in files:
                s.append(r)
        else:
            for f in files:
                if m(f):
                    s.append(r)
                    break
    return s
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:27,代码来源:revset.py


示例7: apply_promo_store

def apply_promo_store(userid, store_name):
    itemlist = find_shelf(userid, store_name)
    num_items = len(itemlist)
    print "Apply_promo: We have " + str(num_items) + " items in " + store_name + " shelf."
    total_combinations = 1 << (num_items)
    total_combinations -= 1
    print "Total combination: " + str(total_combinations)
    date_ = datetime.date.today()
    promo_date = Promoinfo.objects.filter(d=date_)
    if store_name == "Express":
        i = 0
    if store_name == "J.Crew":
        i = 1
    promo = promo_date.filter(store__id=i)

    # for all possible combinations
    # find the price by calling match.py
    # upper bound is total_combinations+1 because we are starting with index 1
    # and that is because we don't want to calculate discount for an empty wishlist
    # which will happen when j = 0

    for j in range(1, total_combinations + 1):
        wishlist = find_combination(itemlist, j)
        cached_result, digest = check_if_combination_exists(wishlist)
        if cached_result == None:
            print "No, didn't find result for list " + str(j) + " in cache, so storing it"
            orig_cost, total_cost, savings, shipping = match.match(store_name, date_, copy.deepcopy(wishlist), promo)
            # store this result
            new_result = StoreItemCombinationResults(
                combination_id=digest, price=orig_cost, saleprice=total_cost, free_shipping=shipping
            )
            new_result.save()

    print "Done with apply_promo_store"
开发者ID:rkishore,项目名称:shelf_on_rails,代码行数:34,代码来源:view_shelf.py


示例8: checkstatus

def checkstatus(repo, subset, pat, field):
    m = None
    s = []
    hasset = matchmod.patkind(pat) == 'set'
    fname = None
    for r in subset:
        c = repo[r]
        if not m or hasset:
            m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
            if not m.anypats() and len(m.files()) == 1:
                fname = m.files()[0]
        if fname is not None:
            if fname not in c.files():
                continue
        else:
            for f in c.files():
                if m(f):
                    break
            else:
                continue
        files = repo.status(c.p1().node(), c.node())[field]
        if fname is not None:
            if fname in files:
                s.append(r)
        else:
            for f in files:
                if m(f):
                    s.append(r)
                    break
    return s
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:30,代码来源:revset.py


示例9: do_match

def do_match(img1, img2, cang, crat, cdesc):
    M = None

    # Get features and distances between every pair of points from both images
    (kpts1, des1) = get_features(img1, M, 'target.jpg')
    (kpts2, des2) = get_features(img2, M, 'reference.jpg')

    Hgt = Hypergraph(kpts1, des1)
    Hgr = Hypergraph(kpts2, des2)

    # draw.triangulation(kpts1, Hgt.E, img1, 'Triangulation 1')
    # draw.triangulation(kpts2, Hgr.E, img2, 'Triangulation 2')

    print 'Hypergraph construction done'
    edge_matches, point_matches = match(
        Hgt.E, Hgr.E, kpts1, kpts2, des1, des2,
        cang, crat, cdesc,
        0.7, 0.75, True
    )
    print 'Hyperedges matching done'

    # draw.edges_match(edge_matches, kpts1, kpts2, Hgt.E, Hgr.E, img1, img2)

    point_matches = sorted(point_matches, key=lambda x: x.distance)
    draw.points_match(point_matches, kpts1, kpts2, img1, img2)

    cv2.waitKey()
    cv2.destroyAllWindows()
开发者ID:kala855,项目名称:hypergraphs-matching,代码行数:28,代码来源:main.py


示例10: validate

 def validate(self, first, second):
     """
     Compares first to second to determine if they sufficiently agree.
     """
     matches = match(first, second,
                     lambda x, y: self.overlapcost(x, y))
     return sum(x[2] != 0 for x in matches) <= self.mistakes
开发者ID:ALexanderpu,项目名称:vatic,代码行数:7,代码来源:qa.py


示例11: checkstatus

def checkstatus(repo, subset, pat, field):
    m = matchmod.match(repo.root, repo.getcwd(), [pat])
    s = []
    fast = (m.files() == [pat])
    for r in subset:
        c = repo[r]
        if fast:
            if pat not in c.files():
                continue
        else:
            for f in c.files():
                if m(f):
                    break
            else:
                continue
        files = repo.status(c.p1().node(), c.node())[field]
        if fast:
            if pat in files:
                s.append(r)
                continue
        else:
            for f in files:
                if m(f):
                    s.append(r)
                    continue
    return s
开发者ID:MezzLabs,项目名称:mercurial,代码行数:26,代码来源:revset.py


示例12: _matchfiles

def _matchfiles(repo, subset, x):
    # _matchfiles takes a revset list of prefixed arguments:
    #
    #   [p:foo, i:bar, x:baz]
    #
    # builds a match object from them and filters subset. Allowed
    # prefixes are 'p:' for regular patterns, 'i:' for include
    # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass
    # a revision identifier, or the empty string to reference the
    # working directory, from which the match object is
    # initialized. Use 'd:' to set the default matching mode, default
    # to 'glob'. At most one 'r:' and 'd:' argument can be passed.

    # i18n: "_matchfiles" is a keyword
    l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
    pats, inc, exc = [], [], []
    hasset = False
    rev, default = None, None
    for arg in l:
        s = getstring(arg, _("_matchfiles requires string arguments"))
        prefix, value = s[:2], s[2:]
        if prefix == 'p:':
            pats.append(value)
        elif prefix == 'i:':
            inc.append(value)
        elif prefix == 'x:':
            exc.append(value)
        elif prefix == 'r:':
            if rev is not None:
                raise error.ParseError(_('_matchfiles expected at most one '
                                         'revision'))
            rev = value
        elif prefix == 'd:':
            if default is not None:
                raise error.ParseError(_('_matchfiles expected at most one '
                                         'default mode'))
            default = value
        else:
            raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
        if not hasset and matchmod.patkind(value) == 'set':
            hasset = True
    if not default:
        default = 'glob'
    m = None
    s = []
    for r in subset:
        c = repo[r]
        if not m or (hasset and rev is None):
            ctx = c
            if rev is not None:
                ctx = repo[rev or None]
            m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
                               exclude=exc, ctx=ctx, default=default)
        for f in c.files():
            if m(f):
                s.append(r)
                break
    return s
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:58,代码来源:revset.py


示例13: apply_promo

def apply_promo(request, d1, d2):
    if "u" in request.GET and request.GET["u"]:
        userid = urllib.unquote(request.GET["u"].decode("utf-8"))
        result_list = {}
        # for each store-shelf
        shelf_per_store = find_shelf_store_based_for_user(userid)
        for i in range(0, len(shelf_per_store)):
            # how many items in this shelf
            store_name = stores[i]
            num_items = len(shelf_per_store[store_name])
            print "Apply_promo: We have " + str(num_items) + " items in " + store_name + " shelf."
            total_combinations = 1 << (num_items)
            total_combinations -= 1
            print "Total combination: " + str(total_combinations)
            date_ = datetime.date.today()
            promo_date = Promoinfo.objects.filter(d=date_)
            promo = promo_date.filter(store__id=i)

            # for all possible combinations
            # find the price by calling match.py
            # upper bound is total_combinations+1 because we are starting with index 1
            # and that is because we don't want to calculate discount for an empty wishlist
            # which will happen when j = 0
            itemlist = []
            for j in range(1, total_combinations + 1):
                wishlist = find_combination(shelf_per_store[store_name], j)
                cached_result, digest = check_if_combination_exists(wishlist)
                if cached_result == None:
                    print "No, didn't find result for list " + str(j) + " in cache, so storing it"
                    orig_cost, total_cost, savings, shipping = match.match(
                        store_name, date_, copy.deepcopy(wishlist), promo
                    )
                    # store this result
                    new_result = StoreItemCombinationResults(
                        combination_id=digest, price=orig_cost, saleprice=total_cost, free_shipping=shipping
                    )
                    new_result.save()
                else:
                    print "Great, found the result! Using it here."
                    orig_cost = cached_result.price
                    total_cost = cached_result.saleprice
                    savings = cached_result.price - cached_result.saleprice
                    shipping = cached_result.free_shipping

                print "RESULT:: " + str(j) + " " + str(store_name) + " " + str(orig_cost) + " " + str(
                    total_cost
                ) + " " + str(savings)
                itemlist.append(
                    {"orig_cost": orig_cost, "total_cost": total_cost, "savings": savings, "shipping": shipping}
                )

            result_list[store_name] = itemlist
        return list_detail.object_list(
            request,
            queryset=WishlistI.objects.none(),
            template_name="apply_promo.html",
            extra_context={"uid": userid, "result_list": result_list},
        )
开发者ID:rkishore,项目名称:shelf_on_rails,代码行数:58,代码来源:view_shelf.py


示例14: match

def match(repo, pats=[], opts={}, globbed=False, default='relpath'):
    if not globbed and default == 'relpath':
        pats = expandpats(pats or [])
    m = _match.match(repo.root, repo.getcwd(), pats,
                    opts.get('include'), opts.get('exclude'), default)
    def badfn(f, msg):
        repo.ui.warn("%s: %s\n" % (m.rel(f), msg))
    m.bad = badfn
    return m
开发者ID:Frostman,项目名称:intellij-community,代码行数:9,代码来源:cmdutil.py


示例15: find_price_of_wishlist_for_store

def find_price_of_wishlist_for_store(wishlist, store_name, store_id, date_):
    '''
    Find the total price for the items in the wishlist from store_name and on date_
    '''
    promo_date = Promoinfo.objects.filter(d = date_)
    promo_store = promo_date.filter(store__id = store_id)
    promo = promo_store
    orig_cost, total_cost, savings, shipping = match.match(store_name, date_, copy.deepcopy(wishlist), promo)
    return (orig_cost, total_cost, savings, shipping)
开发者ID:rkishore,项目名称:shelf_on_rails,代码行数:9,代码来源:view_mock_wishlist.py


示例16: matchcapthca

def matchcapthca():
    """
    generate captcha.
    """
    captcha = ""
    for n in range(len(os.listdir(_CROPS))):
        char = match(_CROPS + "char" + str(n) + ".png")
        captcha += str(char)
    return captcha
开发者ID:fudong1127,项目名称:crszu,代码行数:9,代码来源:cr.py


示例17: attempt

def attempt(num,expected,e1,e2):
   rs = False
   try:
      num_tests[0]+=1
      rs = (expected == match.match(e1,e2))
   finally:
      if( rs != True):
         global_fail_flag = True
         fail_count[0]+= 1
         print("{:<10d} : {},{}".format(num,e1,e2) )
开发者ID:Stymphalian,项目名称:CSC421_Assignments,代码行数:10,代码来源:test_match.py


示例18: merge

def merge(segments, method = None, threshold = 0.5, groundplane = False):
    """
    Takes a list of segments and attempts to find a correspondance between
    them by returning a list of merged paths.

    Uses 'method' to score two candidate paths. If the score returned by
    'method' is greater than the number of overlaping frames times the 
    threshold, then the correspondance is considered bunk and a new path
    is created instead.

    In general, if 'method' returns 0 for a perfect match and 1 for a
    horrible match, then 'threshold' = 0.5 is pretty good.
    """
    if method is None:
        method = getpercentoverlap(groundplane)

    logger.debug("Starting to merge!")
    paths = {}
    segments.sort(key = lambda x: x.start)
    for path in segments[0].paths:
        paths[path.id] = path.getboxes(groundplane=groundplane), [path]
    for x, y in zip(segments, segments[1:]):
        logger.debug("Merging segments {0} and {1}".format(x.id, y.id))
        if x.stop < y.start:
            logger.debug("Segments {0} and {1} do not overlap"
                         .format(x.id, y.id))
            for path in y.paths:
                paths[path.id] = path.getboxes(groundplane=groundplane), [path]
        else:
            for first, second, score in match(x.paths, y.paths, method):
                logger.debug("{0} associated to {1} with score {2}"
                            .format(first, second, score))
                if second is None:
                    continue

                isbirth = first is None
                if not isbirth:
                    scorerequirement = threshold * overlapsize(first, second, groundplane)
                    if score > scorerequirement:
                        logger.debug("Score {0} exceeds merge threshold of {1}"
                                    .format(score, scorerequirement))
                        isbirth = True
                    else:
                        logger.debug("Score {0} satisfies merge threshold of "
                                     "{1}" .format(score, scorerequirement))

                if isbirth:
                    paths[second.id] = second.getboxes(groundplane=groundplane), [second]
                else:
                    path = mergepath(paths[first.id][0], second.getboxes(groundplane=groundplane))
                    paths[first.id][1].append(second)
                    paths[second.id] = (path, paths[first.id][1])
                    del paths[first.id]
    logger.debug("Done merging!")
    return paths.values()
开发者ID:Jamesjue,项目名称:vatic,代码行数:55,代码来源:merge.py


示例19: GET

  def GET(self, name):

    user_data = web.input(input_song='../songs/loseyourself.mp3')
    print 'start'

    target_wav = '../songs/' + user_data.input_song[:-4] + '.wav'
    mp3towav.mp3towav('../songs/' + user_data.input_song, target_wav);
    print 'done conversion'

    print 'isolating', target_wav
    isolate.isolate(target_wav)
    print 'done isolation'


    bpm = None
    if user_data.input_song == 'animals.wav':
        bpm = 95
    elif user_data.input_song == 'payphone.wav':
        bpm = 110
    elif user_data.input_song == 'sugar.wav':
        bpm = 121
    elif user_data.input_song == 'loseyourself.wav':
        bpm = 116
    elif user_data.input_song == 'baby.wav':
        bpm = 128

    print 'speeding up', target_wav[:-4] + "_high.wav"
    speedup.ver3(target_wav[:-4] + "_high.wav")
    print 'done speedup'

    hi_wav = target_wav[:-4] + '_high-128.wav'
    audseg = match.match('bg/bg128_pop.wav', hi_wav);
    audseg.export('../www/public/uploads/edm_' + target_wav[9:-4] + "_finalpop.wav", format="wav")

    audseg = match.match('bg/bg128_calvinharris.wav', hi_wav);
    audseg.export('../www/public/uploads/edm_' + target_wav[9:-4] + "_finalcalvin.wav", format="wav")

    audseg = match.match('bg/bg128_oncelydian.wav', hi_wav);
    audseg.export('../www/public/uploads/edm_' + target_wav[9:-4] + "_finaloncelydian.wav", format="wav")
    print 'done export'

    return target_wav[:-4] + "_final.wav"
开发者ID:jhedwardyang,项目名称:edmdis.co,代码行数:42,代码来源:server.py


示例20: casual_match_view

def casual_match_view(request, match_id):
    mid = int(match_id)
    stats = match.match(mid)
    if stats is not None:
        t = loader.get_template('match.html')
        c = Context({'match_id': mid, 'stats': stats})
        return HttpResponse(t.render(c))
    else:
        t = loader.get_template('error.html')
        c = Context({'id': match_id})
        return HttpResponse(t.render(c))
开发者ID:ColBW,项目名称:honbot-django,代码行数:11,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python match.Match类代码示例发布时间:2022-05-27
下一篇:
Python logging.make_logger函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap