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


Python user.User方法代码示例

本文整理汇总了Python中user.User方法的典型用法代码示例。如果您正苦于以下问题:Python user.User方法的具体用法?Python user.User怎么用?Python user.User使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user的用法示例。


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

示例1: run_round

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def run_round(state, warmup=False):
    # 1) Agent takes action given state tracker's representation of dialogue (state)
    agent_action_index, agent_action = dqn_agent.get_action(state, use_rule=warmup)
    # 2) Update state tracker with the agent's action
    state_tracker.update_state_agent(agent_action)
    # 3) User takes action given agent action
    user_action, reward, done, success = user.step(agent_action)
    if not done:
        # 4) Infuse error into semantic frame level of user action
        emc.infuse_error(user_action)
    # 5) Update state tracker with user action
    state_tracker.update_state_user(user_action)
    # 6) Get next state and add experience
    next_state = state_tracker.get_state(done)
    dqn_agent.add_experience(state, agent_action_index, reward, next_state, done)

    return next_state, reward, done, success 
开发者ID:maxbren,项目名称:GO-Bot-DRL,代码行数:19,代码来源:train.py

示例2: getUser

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def getUser(self,username):
        '''
        Gets the user object based on the username. 
        Returns 'None' if not found
        '''
        user = None
        
        t = text("select valuntil from pg_user where usename = :uname")
        conn = self._engine.connect()
        result = conn.execute(t,uname = username).fetchone()
        
        if result is not None:
            user = User(username)
            
            #Get the date component only - first ten characters
            valDate = result["valuntil"]
            if valDate is not None:                
                valDate = valDate[:10]  
                          
            user.Validity = valDate
        
        return user 
开发者ID:gltn,项目名称:stdm,代码行数:24,代码来源:membership.py

示例3: __init__

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def __init__(self, username=None, password=None, user_agent="iMAL-iOS"):
    """Creates a new instance of Session.

    :type username: str
    :param username: A MAL username. May be omitted.

    :type password: str
    :param username: A MAL password. May be omitted.

    :type user_agent: str
    :param user_agent: A user-agent to send to MAL in requests. If you have a user-agent assigned to you by Incapsula, pass it in here.

    :rtype: :class:`.Session`
    :return: The desired session.

    """
    self.username = username
    self.password = password
    self.session = requests.Session()
    self.session.headers.update({
      'User-Agent': user_agent
    })

    """Suppresses any Malformed*PageError exceptions raised during parsing.

    Attributes which raise these exceptions will be set to None.
    """
    self.suppress_parse_exceptions = False 
开发者ID:shaldengeki,项目名称:python-mal,代码行数:30,代码来源:session.py

示例4: user

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def user(self, username):
    """Creates an instance of myanimelist.User with the given username

    :type username: str
    :param username: The desired user's username.

    :rtype: :class:`myanimelist.user.User`
    :return: A new User instance with the given username.

    """
    return user.User(self, username) 
开发者ID:shaldengeki,项目名称:python-mal,代码行数:13,代码来源:session.py

示例5: test_run

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def test_run():
    """
    Runs the loop that tests the agent.

    Tests the agent on the goal-oriented chatbot task. Only for evaluating a trained agent. Terminates when the episode
    reaches NUM_EP_TEST.

    """

    print('Testing Started...')
    episode = 0
    while episode < NUM_EP_TEST:
        episode_reset()
        episode += 1
        ep_reward = 0
        done = False
        # Get initial state from state tracker
        state = state_tracker.get_state()
        while not done:
            # Agent takes action given state tracker's representation of dialogue
            agent_action_index, agent_action = dqn_agent.get_action(state)
            # Update state tracker with the agent's action
            state_tracker.update_state_agent(agent_action)
            # User takes action given agent action
            user_action, reward, done, success = user.step(agent_action)
            ep_reward += reward
            if not done:
                # Infuse error into semantic frame level of user action
                emc.infuse_error(user_action)
            # Update state tracker with user action
            state_tracker.update_state_user(user_action)
            # Grab "next state" as state
            state = state_tracker.get_state(done)
        print('Episode: {} Success: {} Reward: {}'.format(episode, success, ep_reward))
    print('...Testing Ended') 
开发者ID:maxbren,项目名称:GO-Bot-DRL,代码行数:37,代码来源:test.py

示例6: main

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def main():
    """Mainroutine to run the prog-o-meter program.

    Opens a window, which lets the user choose if they are a new or returning user.
    Opens a new window, which lets the user type their name.
    Opens a new window, which shows the user's progress, and how many days remains of the challenge.
    """
    start_screen = StartGUI()
    user_state = start_screen.get_state()
    name_screen = UsernameGUI(user_state)
    username = name_screen.get_name()
    user = User(username, user_state == 2)
    logname = "".join((username.lower(), "_log.txt"))
    ProgressGUI(user, logname) 
开发者ID:prog-o-meter,项目名称:prog-o-meter,代码行数:16,代码来源:prog-o-meter.py

示例7: set_sender

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def set_sender(self, sender_username):
        self.sender = User(sender_username) 
开发者ID:just-an-dev,项目名称:sodogetip,代码行数:4,代码来源:tip.py

示例8: set_receiver

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def set_receiver(self, receiver_username):
        # update only if previous is blank (other case it will be set in parse_message)
        if self.receiver is None:
            self.receiver = User(receiver_username) 
开发者ID:just-an-dev,项目名称:sodogetip,代码行数:6,代码来源:tip.py

示例9: create_from_array

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def create_from_array(self, arr_tip):
        # import user
        self.receiver = User(arr_tip['receiver'])
        self.sender = User(arr_tip['sender'])
        del arr_tip['receiver']
        del arr_tip['sender']

        for key in arr_tip.keys():
            setattr(self, key, arr_tip[key])

        return self 
开发者ID:just-an-dev,项目名称:sodogetip,代码行数:13,代码来源:tip.py

示例10: startElement

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def startElement(self, name, attrs, connection):
        if name == 'Initiator':
            self.initiator = user.User(self)
            return self.initiator
        elif name == 'Owner':
            self.owner = user.User(self)
            return self.owner
        elif name == 'Part':
            part = Part(self.bucket)
            self._parts.append(part)
            return part
        return None 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:14,代码来源:multipart.py

示例11: local_users

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def local_users(self):
        """Returns an array of user ids for users on the filesystem"""
        # Any users on the machine will have an entry inside of the userdata
        # folder. As such, the easiest way to find a list of all users on the
        # machine is to just list the folders inside userdata
        userdirs = filter(self._is_user_directory, os.listdir(self.userdata_location()))
        # Exploits the fact that the directory is named the same as the user id
        return map(lambda userdir: user.User(self, int(userdir)), userdirs) 
开发者ID:scottrice,项目名称:pysteam,代码行数:10,代码来源:steam.py

示例12: set_rating

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def set_rating(self, user_or_ip, rating):
        '''Record a user's rating of this package.

        The caller function is responsible for doing the commit.

        If a rating is outside the range MAX_RATING - MIN_RATING then a
        RatingValueException is raised.

        @param user_or_ip - user object or an IP address string
        '''
        user = None
        from user import User
        from rating import Rating, MAX_RATING, MIN_RATING
        if isinstance(user_or_ip, User):
            user = user_or_ip
            rating_query = meta.Session.query(Rating)\
                               .filter_by(package=self, user=user)
        else:
            ip = user_or_ip
            rating_query = meta.Session.query(Rating)\
                               .filter_by(package=self, user_ip_address=ip)

        try:
            rating = float(rating)
        except TypeError:
            raise RatingValueException
        except ValueError:
            raise RatingValueException
        if rating > MAX_RATING or rating < MIN_RATING:
            raise RatingValueException

        if rating_query.count():
            rating_obj = rating_query.first()
            rating_obj.rating = rating
        elif user:
            rating = Rating(package=self,
                            user=user,
                            rating=rating)
            meta.Session.add(rating)
        else:
            rating = Rating(package=self,
                            user_ip_address=ip,
                            rating=rating)
            meta.Session.add(rating) 
开发者ID:italia,项目名称:daf-recipes,代码行数:46,代码来源:package.py

示例13: Loves

# 需要导入模块: import user [as 别名]
# 或者: from user import User [as 别名]
def Loves(self,user=None,objects=False):
            if user:
                userobj = _user.User()
                userobj.setUsername(user)
                playerlist = []
                teamlist = []
                leaguelist = []
                eventlist = []
                url = '%s/%s/searchloves.php?u=%s' % (API_BASE_URL,API_KEY,str(user))
                data = json.load(urllib2.urlopen(url))
                edits = data["players"]
                if edits:
                    for edit in edits:
                        if edit["idTeam"]: teamlist.append(edit["idTeam"])
                        if edit["idPlayer"]: playerlist.append(edit["idPlayer"]) 
                        if edit["idLeague"]: leaguelist.append(edit["idLeague"])
                        if edit["idEvent"]: eventlist.append(edit["idEvent"])
                    if objects:
                        _teamlist = []
                        _playerlist = []
                        _eventlist = []
                        _leaguelist = []
                        if teamlist:
                            for tmid in teamlist:
                                try:
                                    _teamlist.append(Api(API_KEY).Lookups().Team(teamid=tmid)[0])
                                except: pass
                        teamlist = _teamlist
                        del _teamlist
                        if playerlist:
                            for plid in playerlist:
                                try:
                                    _playerlist.append(Api(API_KEY).Lookups().Player(playerid=plid)[0])
                                except: pass
                        playerlist = _playerlist
                        del _playerlist
                        if leaguelist:
                            for lgid in leaguelist:
                                try:
                                    _leaguelist.append(Api(API_KEY).Lookups().League(leagueid=lgid)[0])
                                except: pass
                        leaguelist = _leaguelist
                        del _leaguelist
                        if eventlist:
                            for evid in eventlist:
                                try:
                                    _eventlist.append(Api(API_KEY).Lookups().Event(eventid=lgid)[0])
                                except: pass
                        eventlist = _eventlist
                        del _eventlist
                userobj.setTeams(teamlist)
                userobj.setPlayers(playerlist)
                userobj.setLeagues(leaguelist)
                userobj.setEvents(eventlist)
                return userobj
            else:
                xbmc.log(msg="[TheSportsDB] A user must be provided", level=xbmc.LOGERROR) 
开发者ID:enen92,项目名称:script.module.thesportsdb,代码行数:59,代码来源:thesportsdb.py


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