當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。