HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
app.ContentCheck.ContentCheck Class Reference
Inheritance diagram for app.ContentCheck.ContentCheck:
Collaboration diagram for app.ContentCheck.ContentCheck:

Public Member Functions

def __init__ (self)
 
def checkUrlObj (self, urlObj, checkType=CHECK_TYPE_SIMPLE)
 
def checkUrlPutObj (self, urlPutObj, checkType=CHECK_TYPE_SIMPLE, metricProperty=None)
 

Static Public Member Functions

def lookMetricsinContent (urlPutObj)
 

Static Public Attributes

int CHECK_TYPE_SIMPLE = 0
 
int CHECK_TYPE_OR = 1
 
int CHECK_TYPE_AND = 2
 

Detailed Description

Definition at line 26 of file ContentCheck.py.

Constructor & Destructor Documentation

◆ __init__()

def app.ContentCheck.ContentCheck.__init__ (   self)

Definition at line 35 of file ContentCheck.py.

35  def __init__(self):
36  pass
37 
38 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ checkUrlObj()

def app.ContentCheck.ContentCheck.checkUrlObj (   self,
  urlObj,
  checkType = CHECK_TYPE_SIMPLE 
)

Definition at line 66 of file ContentCheck.py.

66  def checkUrlObj(self, urlObj, checkType=CHECK_TYPE_SIMPLE):
67  ret = True
68  if checkType == self.CHECK_TYPE_SIMPLE:
69  if urlObj.tagsCount <= 3:
70  ret = False
71  return ret
72 
73 

◆ checkUrlPutObj()

def app.ContentCheck.ContentCheck.checkUrlPutObj (   self,
  urlPutObj,
  checkType = CHECK_TYPE_SIMPLE,
  metricProperty = None 
)

Definition at line 80 of file ContentCheck.py.

80  def checkUrlPutObj(self, urlPutObj, checkType=CHECK_TYPE_SIMPLE, metricProperty=None):
81  ret = True
82  useMetricProperty = False
83  try:
84  dataBuf = base64.b64decode(urlPutObj.putDict["data"])
85  if dataBuf is not None:
86  dataElem = json.loads(dataBuf)
87  if dataElem is not None:
88  Metrics.fillMetricModulesList()
89  metricsBuf = dataElem[0]["metrics"]
90  metrics = json.loads(metricsBuf)
91  if metrics is not None and isinstance(metrics, dict):
92  localList = []
93  localList.append(TmpObj(metrics=metrics))
94  resObjs = []
95  if metricProperty is not None:
96  try:
97  localMetricProperty = json.loads(metricProperty)
98  for elem in localMetricProperty["contentMetrics"]:
99  localResObjs = Metrics.selectElementsByMetric(localList, elem["NAME"], elem["LIMIT_MAX"],
100  elem["LIMIT_MIN"])
101  if localMetricProperty["type"] == self.CHECK_TYPE_SIMPLE:
102  resObjs = localResObjs
103  break
104  elif localMetricProperty["type"] == self.CHECK_TYPE_OR:
105  resObjs += localResObjs
106  elif localMetricProperty["type"] == self.CHECK_TYPE_AND:
107  if len(localResObjs) == 0:
108  resObjs = localResObjs
109  break
110  useMetricProperty = True
111  except Exception as excp:
112  logger.debug(">>> Wrong metric property = " + str(excp))
113  if not useMetricProperty:
114  if checkType == self.CHECK_TYPE_SIMPLE:
115  resObjs = Metrics.selectElementsByMetric(localList, "TAGS_NUMBER", None, 3)
116  if len(resObjs) == 0:
117  ret = False
118  except Exception as excp:
119  logger.debug(">>> ContentCheck.checkUrlPutObj something wrong, err=" + str(excp))
120  return ret

◆ lookMetricsinContent()

def app.ContentCheck.ContentCheck.lookMetricsinContent (   urlPutObj)
static

Definition at line 45 of file ContentCheck.py.

45  def lookMetricsinContent(urlPutObj):
46  ret = False
47  try:
48  dataBuf = base64.b64decode(urlPutObj.putDict["data"])
49  if dataBuf is not None:
50  dataElem = json.loads(dataBuf)
51  if dataElem is not None and len(dataElem) > 0 and "metrics" in dataElem[0]:
52  metricsBuf = dataElem[0]["metrics"]
53  metrics = json.loads(metricsBuf)
54  if metrics is not None and isinstance(metrics, dict):
55  ret = True
56  except Exception as excp:
57  logger.debug(">>> Wrong content checking=" + str(excp))
58  return ret
59 
60 

Member Data Documentation

◆ CHECK_TYPE_AND

int app.ContentCheck.ContentCheck.CHECK_TYPE_AND = 2
static

Definition at line 30 of file ContentCheck.py.

◆ CHECK_TYPE_OR

int app.ContentCheck.ContentCheck.CHECK_TYPE_OR = 1
static

Definition at line 29 of file ContentCheck.py.

◆ CHECK_TYPE_SIMPLE

int app.ContentCheck.ContentCheck.CHECK_TYPE_SIMPLE = 0
static

Definition at line 28 of file ContentCheck.py.


The documentation for this class was generated from the following file: