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
FetcherType.py
Go to the documentation of this file.
1 # coding: utf-8
2 
3 """
4 HCE project, Python bindings, Distributed Tasks Manager application.
5 DateTimeType Class content main functional extract of datetime.
6 
7 @package: dc_crawler
8 @file FetcherType.py
9 @author Aleksandr Skuridin <skuridin.alexander+hce@gmail.com>
10 @link: http://hierarchical-cluster-engine.com/
11 @copyright: Copyright &copy; 2013-2015 IOIX Ukraine
12 @license: http://hierarchical-cluster-engine.com/license/
13 @since: 0.1
14 """
15 
16 
17 import re
18 import json
19 from dc_crawler.Fetcher import BaseFetcher
20 
21 class FetcherType(object):
22 
23 
31  @staticmethod
32  def getFromProperty(propertyValue, siteUrl, logger=None):
33  #isExtendLog = False
34  if logger is not None:
35  logger.debug(siteUrl + ', FETCHER_TYPE: ' + propertyValue)
36 
37  fetchType = None
38  try:
39  fetcherProperties = json.loads(propertyValue)
40  for pattern in fetcherProperties:
41  match = re.search(pattern, siteUrl)
42  if match:
43  fetchType = fetcherProperties[pattern]
44  # if fetchType in BaseFetcher.fetchers:
45  if fetchType == BaseFetcher.TYP_DYNAMIC or fetchType == BaseFetcher.TYP_NORMAL:
46  if logger is not None:
47  logger.info(siteUrl + ', Fetch Type value: ' + str(fetchType))
48  else:
49  logger.debug(siteUrl + ', wrong Fetch Type number: ' + str(fetchType))
50  fetchType = None
51  continue
52  break
53  except Exception, ex:
54  if logger is not None:
55  logger.debug("Fetcher Type Exception: " + str(ex))
56  return fetchType
def getFromProperty(propertyValue, siteUrl, logger=None)
Check the fetcher type by FETCHER_TYPE project property.
Definition: FetcherType.py:32