|
17 | 17 | import sys, os, traceback
|
18 | 18 |
|
19 | 19 | from java.lang import System
|
| 20 | +import java.io.File as JFile |
20 | 21 | import java.io.FileOutputStream as JFileOutputStream
|
21 | 22 | import java.io.IOException as JIOException
|
22 | 23 | import java.io.PrintWriter as JPrintWriter
|
23 | 24 | import oracle.weblogic.deploy.util.TranslateException as TranslateException
|
24 | 25 | from oracle.weblogic.deploy.util import CLAException
|
| 26 | +from oracle.weblogic.deploy.util import FileUtils |
25 | 27 | from oracle.weblogic.deploy.util import VariableException
|
26 | 28 | from oracle.weblogic.deploy.compare import CompareException
|
27 | 29 | from oracle.weblogic.deploy.exception import ExceptionHelper
|
@@ -416,7 +418,7 @@ def compare(self):
|
416 | 418 | # validate models first
|
417 | 419 |
|
418 | 420 | try:
|
419 |
| - if os.path.splitext(self.current_dict_file)[1].lower() == ".yaml": |
| 421 | + if FileUtils.isYamlFile(JFile(os.path.splitext(self.current_dict_file)[1].lower())): |
420 | 422 | model_file_name = self.current_dict_file
|
421 | 423 | FileToPython(model_file_name, True).parse()
|
422 | 424 | model_file_name = self.past_dict_file
|
@@ -572,21 +574,17 @@ def main():
|
572 | 574 | if os.path.isdir(f):
|
573 | 575 | raise CLAException("Model %s is a directory" % f)
|
574 | 576 |
|
575 |
| - model1_ext = os.path.splitext(model1)[1] |
576 |
| - model2_ext = os.path.splitext(model2)[1] |
| 577 | + model1_file = JFile(model1) |
| 578 | + model2_file = JFile(model2) |
577 | 579 |
|
578 |
| - validated = False |
579 |
| - for ext in [ '.yaml', '.json' ]: |
580 |
| - if model1_ext.lower() == ext: |
581 |
| - if model2_ext.lower() != model1_ext.lower(): |
582 |
| - raise CLAException("Model %s is not a %s file " % model2, ext) |
583 |
| - else: |
584 |
| - validated = True |
585 |
| - break |
586 |
| - |
587 |
| - if not validated: |
| 580 | + if not (FileUtils.isYamlFile(model1_file) or FileUtils.isJsonFile(model1_file)): |
588 | 581 | raise CLAException("Model extension must be either yaml or json")
|
589 | 582 |
|
| 583 | + if not (FileUtils.isYamlFile(model1_file) and FileUtils.isYamlFile(model2_file) |
| 584 | + or FileUtils.isJsonFile(model1_file) and FileUtils.isJsonFile(model2_file)): |
| 585 | + ext = os.path.splitext(model1)[1] |
| 586 | + raise CLAException("Model %s is not a %s file " % (model2, ext)) |
| 587 | + |
590 | 588 | obj = ModelFileDiffer(model1, model2, model_context, _outputdir)
|
591 | 589 | rc = obj.compare()
|
592 | 590 | if rc == VALIDATION_FAIL:
|
|
0 commit comments