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


Python rules.Rules类代码示例

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


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

示例1: test_reMach

    def test_reMach(self):
        msg = """
===        
RegExp:%s        
Text:%s
NOT MACH ===
                """
        lanRules = Rules()
        Format = lanRules.get('Format', 'pattern')
#         print(lanRules.get('Filter', 'pattern'))
        Filter = lanRules['Filter']['pattern']
        Blank = lanRules['Blank']['pattern']
        print(Blank)
        testSamples = [
                        # [resault,regExp,Text,re.report]
                        [True, r'hello', 'hello world!'],
                        [True, Format, 'E\tE/_1_=English\tS/_1_=简体中文'],
                        [False, Format, 'E\tE/_2_=English\tS/_1_=简体中文'],
                        [True, Format, 'F\tF/_16_=la touche # pour entrer espace\tS/_16_=#键输入空格\t35'],

                        [True, Filter, 'E\t#E/_1_=English\tS/_1_=简体中文'],
                        [True, Filter, 'E\tE/_1_=English\t#S/_1_=简体中文'],
                        [True, Filter, 'E\tE/_1_=English\tS/1_=简体中文'],  # 基准字段格式检测错误,也会排除
                        [True, Filter, 'G\tF/_16_=la touche # pour entrer espace\tS/_1k6_=#键输入空格    35'],
                        [True, Blank, 'E/_1_=Eng   lish'],
                     ]

        for mustRet, regExp, text in testSamples:
            resault = Rules().Test(regExp, text)
            emsg = msg % (regExp, text)
            self.assertEqual(resault, mustRet, emsg)
        pass
开发者ID:agz1990,项目名称:GitPython,代码行数:32,代码来源:cutter_Test.py

示例2: __init__

class GenerateXML:
    def __init__(self):
        """
        init method
        :return: None
        """
        self.r = Rules("domain")
        self.create_file()

    def create_file(self):
        """
        Creates the xml file
        :return: None
        """
        save = open("/Users/arashsaidi/Blindern/INF5820/oblig3/opendial/domains/my-test-domains/therapist.xml", "w")
        save2 = open("therapist.xml", "w")

        self.rules()

        save.write(self.r.create_xml())
        save2.write(self.r.create_xml())

    def rules(self):
        self.r = Rules("domain")

        self.r.if_("trigger", "u_u", "ta til venstre", "ok")
开发者ID:gpeegpee,项目名称:opendial-1,代码行数:26,代码来源:create_file.py

示例3: main

def main():
    rules    = Rules()
    rulefunc = getattr(rules, rule)
    lastfld  = None
    # t = Thing(fld, cell, Location(0,0))
    # t.program = list("ddrrrull")
    # things.generate()
    rooms = add_rooms()
    # for r in rooms:
        # for l in r.tpoints: fld.put('*', Location(l))
    # print [str(r) for r in rooms]
    corridors = Corridors(fld, rooms)
    corridors.create()
    fld.display()
    return

    for i in range(period):
        rules.n = i
        for thing in things: thing.movep()
        # if p: t.movep()
        for location in fld:
            val = fld.value(location)
            rulefunc(fld, location, val, len(fld.live_neighbours(location)))

        fld.display()
        print ' ' + "%d/%d add:%d" % (i+1, period, rules.add)
        sleep(interval)
        lastfld = fld.field
开发者ID:Voder,项目名称:PBE,代码行数:28,代码来源:main.py

示例4: findrule

def findrule(ruletype="", attribute="", value=""):
    """
    debugging: find rules that have a certain ruleType and some 
    attribute-value pair
    
    Example: findrule("Concession", "nucleus", "usermodel_match") finds 
    rules of type 'Concession' where rule.nucleus == 'usermodel_match'.
    """
    rules = Rules().rule_dict
    matching_rules = {}
    
    if ruletype == "":
        for index, (name, rule) in enumerate(rules.iteritems()):
            if getattr(rule, attribute) is value:
                print "rule {0} - {1}:\n{2}".format(index, name, rule)
                matching_rules[name] = rule
    elif attribute == "":
        for index, (name, rule) in enumerate(rules.iteritems()):
            if rule.ruleType is ruletype:
                print "rule {0} - {1}:\n{2}".format(index, name, rule)
                matching_rules[name] = rule
    else:
        for index, (name, rule) in enumerate(rules.iteritems()):
            if rule.ruleType is ruletype and getattr(rule, attribute) is value:
                print "rule {0} - {1}:\n{2}".format(index, name, rule)
                matching_rules[name] = rule
    return matching_rules
开发者ID:DrDub,项目名称:pypolibox,代码行数:27,代码来源:debug.py

示例5: __init__

 def __init__(self):
     Board.__init__(self)
     Actions.__init__(self)
     Rules.__init__(self)
     self.players = {}
     self.turn = 0
     self.game_over = True
开发者ID:ncdesouza,项目名称:GameServer,代码行数:7,代码来源:game.py

示例6: TestMedia

class TestMedia(unittest.TestCase):
    def setUp(self):
        self.css = '''@media screen {
@font-face {
  font-family: 'Cantarell';
  font-style: normal;
  font-weight: normal;
  src: local('Cantarell'), \
url('http://themes.googleusercontent.com/font?kit=tGao7ZPoloMxQHxq-2oxNA') \
format('truetype');
}
}'''
        self.parsed = Rules(code=self.css)
        parse(less=self.css, parent=self.parsed)

    def test_is_the_same(self):
        self.assertEqual(str(self.parsed), self.css)

    def test_media_selector(self):
        self.assertEqual(self.parsed.get_selectors(media=['screen']),
                         {'@font-face': {'src': '''local('Cantarell'), \
url('http://themes.googleusercontent.com/font?kit=tGao7ZPoloMxQHxq-2oxNA') \
format('truetype')''',
                                         'font-weight': 'normal',
                                         'font-style': 'normal',
                                         'font-family': "'Cantarell'"}})

    def test_media_selectors(self):
        self.assertEqual(self.parsed.get_media_selectors(),
                         (None, ['screen']))

    def test_none_selector(self):
        self.assertEqual(self.parsed.get_selectors(), {})
开发者ID:madzak,项目名称:lesscss-python,代码行数:33,代码来源:test_parse.py

示例7: __init__

 def __init__(self, page, main):
     """Inits the Container and the claim buffers. Gets the item of a page
      and check if it exists, and if it is already transffered to Wikidata.
     @param page Wikipedia Page object.
     @var self.claims Raw claims as extracted.
     @var self.merged_claims self.claims merged between the languages.
     @var self.validated_claims Merged claims after checks for some
         selected propertys.
     @var self.new_claims Claims, which where not on Wikidata before and
         have no conficts.
     @var self.proceed If the item should be extracted.
     """
     #create variables
     self.lang_claims = []
     self.merged_claims = []
     self.validated_claims = []
     self.new_claims = []
     self.proceed = True
     self.main = main
     #init parents
     pywikibot.ItemPage.__init__(self, page.site, page.title())
     output.Logger.__init__(self)
     Rules.__init__(self)
     self.main = main
     #get the page
     if not self.checkNoItem():
         self.proceed = False
     else:
         self.get()
         #check if the item is untransferred
         if self.checkTransferred():
             self.proceed = False
开发者ID:pyfisch,项目名称:wikibase-statement-bot,代码行数:32,代码来源:containerclass.py

示例8: _build_kill

    def _build_kill(self):
        for idx, cell in enumerate(self.state):
            if cell != 46:
                child_state = self.state.copy()
                child_state[idx] = 46
                Rules.calculate_next_state(child_state)

                child = Node(child_state, not self.my_turn, self, MoveType.KILL, idx)
                if cell == settings.PLAYER_ID:
                    self.best_kill_moves.append({'idx': idx, 'score': child.minimax_value})
                self.children.append(child)
开发者ID:PhilipCastiglione,项目名称:learning-machines,代码行数:11,代码来源:node.py

示例9: update_pieces_page

def update_pieces_page(key = None):
    page = Rules(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_updatepieces(id = key)
    elif 'updatepieces' in request.form:
        piece_name = request.form['piece_name']
        piece_move = request.form['piece_move']
        special_move = request.form['special_move']
        return page.update_pieces(key, piece_name, piece_move, special_move)
    else:
        return redirect(url_for('home_page'))
开发者ID:itucsdb1513,项目名称:itucsdb1513,代码行数:11,代码来源:server.py

示例10: update_rules_page

def update_rules_page(key = None):
    page = Rules(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_updaterules(id = key)
    elif 'updaterules' in request.form:
        the_rule = request.form['the_rule']
        made_by = request.form['made_by']
        date = request.form['date']
        return page.update_rules(key, the_rule, made_by, date)
    else:
        return redirect(url_for('home_page'))
开发者ID:itucsdb1513,项目名称:itucsdb1513,代码行数:11,代码来源:server.py

示例11: update_captures_page

def update_captures_page(key = None):
    page = Rules(dsn = app.config['dsn'])
    if request.method == 'GET':
        return page.open_updatecaptures(id = key)
    elif 'updatecaptures' in request.form:
        name = request.form['name']
        capture_direction = request.form['capture_direction']
        starting_place = request.form['starting_place']
        can_start = request.form['can_start']
        return page.update_captures(key, name, capture_direction, starting_place, can_start)
    else:
        return redirect(url_for('home_page'))
开发者ID:itucsdb1513,项目名称:itucsdb1513,代码行数:12,代码来源:server.py

示例12: __init__

    def __init__(self, parent, code, name, params, contents):
        Rules.__init__(self, parent=parent, code=code, contents=contents)

        self.__name = name
        self.__params = list()

        for param in params:
            param = Param(code=param['code'],
                          name=param['name'],
                          value=param['value'],
                          parent=self)

            self.__params.append(param)
开发者ID:madzak,项目名称:lesscss-python,代码行数:13,代码来源:mixin.py

示例13: _build_birth

    def _build_birth(self):
        for idx, cell in enumerate(self.state):
            if cell == 46:
                for a, b in itertools.combinations(self.best_kill_moves, 2):
                    a_idx = a['idx']
                    b_idx = b['idx']

                    child_state = self.state.copy()
                    child_state[idx] = settings.PLAYER_ID
                    child_state[a_idx] = 46
                    child_state[b_idx] = 46
                    Rules.calculate_next_state(child_state)

                    child = Node(child_state, not self.my_turn, self, MoveType.BIRTH, idx, (a_idx, b_idx))
                    self.children.append(child)
开发者ID:PhilipCastiglione,项目名称:learning-machines,代码行数:15,代码来源:node.py

示例14: __init__

 def __init__(self,nodeNetwork=None, players={}, bonuses=[], mapString=None, coordinates=None, mapFile=None, settingsMap={}):
     self.mapFile = mapFile
     self.coordinates = coordinates
     self.rules = Rules(map=nodeNetwork, players=players)
     self.whosTurn = self.rules.players[0]
     self.turnStage = 'reinforce'
     self.reinforcementsToPlace = {}
     self.lastAttack = None
     self.fortifies = 1
     if 'fortifies' in settingsMap:
         self.fortifies = int(settingsMap['fortifies'])
     self.fortifiesLeft = self.fortifies
     self.bonuses=bonuses
     for player in self.rules.players:
         self.reinforcementsToPlace[player]=0
     self.reinforced = False
     if not mapString and not (coordinates and mapFile):
         print "this game has no pretty visualization available"
     self.mapString = mapString
     self.settingsMap = settingsMap
     self.fog = False
     if 'fog' in self.settingsMap:
         self.fog = self.settingsMap['fog']
     self.selectionList = []
     self.showAttackResult = False
     self.justMadeFreeMove = False
开发者ID:thomasballinger,项目名称:Utok,代码行数:26,代码来源:game.py

示例15: load_rules

    def load_rules(self, rulesfilename):
        """
        Load the list of rules.

        @param rulesfilename is a file with rules to syllabify.

         """
        self.rules = Rules(rulesfilename)
开发者ID:brigittebigi,项目名称:sppas,代码行数:8,代码来源:syllabification.py


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