LoginSignup
0
1

More than 3 years have passed since last update.

Redmine User一覧をDataFrameで取得

Posted at

クラスの一部分ですが切り出して記載。
コメント、、、ちゃんと書く(TODO)

Resourceからの情報取り出しがちょっと特殊な感じなので
ここに書いておく。

もっといい方法がありましたら教えてください。


    ########################################################    
    # ユーザID一覧作成
    ########################################################
    def getAllRedmineUsers(self):
        '''


        Args:

        Returns:
           df: DataFrame  Redmine登録全ユーザを格納したDataFrame

        Raises:
            TypeError: 引数型の不備
            Exception: ID登録時の例外

        Examples:
            >>> df = self.getAllRedmineUsers() 

        Note:
            あまりこまごまとした入力チェックをやっていませんので
            利用の際には慎重に w

        '''


        # 登録処理
        print(f'ユーザID一覧を取得します')
        try:
            # ユーザ取得:API
            users = self.redmine.user.all()
        except Exception as e:
            print(f'ユーザ一覧取得に失敗しました')
            print(f'エラー詳細:{e}')
            print()
        else:
            # Resourceから情報取り出し
            _list = []
            for _ in users:
                _list.append(list(_))

            # 取り出した情報を加工
            ## ログインID、名前(first,last)、ID作成日、最終ログイン時間を抽出
            ## TODO 抽出時間(GMT)をJSTに変換する(ライブラリは会社に置いてある、それつかう)
            __list = []
            for i in range(len(_list)):
                __list.append([f'{_list[i][5][1]}',
                               f'{_list[i][7][1]} {_list[i][8][1]}',
                               f'{_list[i][10][1]}',
                               f'{_list[i][11][1]}'])

            # DataFrame化    
            df = pd.DataFrame(__list)
            df.columns = ['LoginID','Name', 'Created','LastLogin']
            return df
                                                                                            ```
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1