6 @link: http://hierarchical-cluster-engine.com/ 7 @copyright: Copyright © 2013-2014 IOIX Ukraine 8 @license: http://hierarchical-cluster-engine.com/license/ 12 from cement.core
import foundation
14 import Constants
as CONSTANTS
21 logger = logging.getLogger(APP_CONSTS.LOGGER_NAME)
33 label = CONSTANTS.APP_NAME
39 foundation.CementApp.__init__(self)
58 fd = open(fileName,
'r') 62 jsonString = fd.read()
64 value = Utils.getPath(
None, jsonString, path)
67 self.
fillError(CONSTANTS.ERROR_STR3, CONSTANTS.ERROR_BAD_JSON)
68 except (TypeError, KeyError, IndexError):
69 self.
fillError(CONSTANTS.ERROR_STR4, CONSTANTS.ERROR_PATH_NOT_FOUND)
71 self.
fillError(CONSTANTS.ERROR_STR2, CONSTANTS.ERROR_FILE)
80 valueList = value.split(CONSTANTS.VALUE_SEPARATOR)
81 for item
in valueList:
86 self.
fillError(CONSTANTS.ERROR_STR5, CONSTANTS.ERROR_VALUE_NOT_FOUND)
92 foundation.CementApp.setup(self)
93 self.args.add_argument(
"-path",
"--path", action=
"store")
94 self.args.add_argument(
"-value",
"--value", action=
"store")
95 self.args.add_argument(
"-file",
"--file", action=
"store")
101 foundation.CementApp.run(self)
103 if self.pargs.path ==
None or self.pargs.file ==
None:
104 self.
fillError(CONSTANTS.ERROR_STR1, CONSTANTS.ERROR_ARG1)
106 jsonValue = self.
readJSONValue(self.pargs.file, self.pargs.path)
107 if jsonValue !=
None and self.pargs.value !=
None:
115 foundation.CementApp.close(self)
JsonChecker Class contents main functional of JsonChecker application, class inherits from foundation...
def valueChecker(self, jsonValue, value)
valueChecker method Method compares incoming jsonValue with value, or find jsonValue in value if valu...
def __init__(self)
constructor initialise all class variable
def run(self)
run method Method contains main application functionality
def setup(self)
setup method Method calls before run application
def fillError(self, errorStr, errorCode)
fillError method calls from error-code point from main processing
def readJSONValue(self, fileName, path)
readJSONValue method Method reads json string from file and search alue by path
def close(self)
close method Method calls after application run