OSDN Git Service

revise view
[amulettoolsmh4/main.git] / model / sufficientsholder.py
1 # -*- coding: utf-8 -*-
2
3 # sufficient valueを保持するクラス
4 # 2013/12/04 written by kei9 
5
6 import db_supports
7
8 class SufficientsHolder(object):
9     u""" ランダムのSeed値を保持するクラス """
10     def __init__(self, sufficient_list):
11         u""" sufficient_list: list of sufficient
12         """
13         self.sufficient_set = set(sufficient_list)
14
15     def get_where_sql(self, remove_where=False):
16         u""" SQLのWhere文に変換する(IN句) """
17         if len(self.sufficient_set) >= 1:
18             uni_list = [u"{0}".format(x) for x in self.sufficient_set]
19             sql = u" {col} IN({in_phrase})".format(
20                     col=db_supports.SUFFICIENT_COL_SUFFICIENT_VALUE,
21                     in_phrase=u",".join(uni_list))
22
23             if remove_where:
24                 return sql
25             else:
26                 return u" where" + sql
27         else:
28             return ""
29
30