예제 #1
0
파일: base.py 프로젝트: glennimoss/precog
 def get_location (self, with_line=True):
   if not self.create_location:
     if self.deferred:
       if self._referenced_by:
         return "referenced by: {}".format(', '.join(
           _with_location(ref.from_) for ref in self._referenced_by))
       return 'deferred'
     return 'unknown'
   parts = ['in "{}"'.format(self.create_location[0])]
   if with_line and len(self.create_location) > 1:
     parts.append('line {}'.format(self.create_location[1]))
   return ', '.join(parts)
예제 #2
0
  def _diff_props (self, other):
    prop_diff = super()._diff_props(other)

    if 'source' in prop_diff:
      sourcediff = list(difflib.unified_diff(other.props['source'].splitlines(),
                                             self.props['source'].splitlines(),
                                             _with_location(other),
                                             _with_location(self), lineterm=''))
      # Look to see if the the only changes have --@ volatile and ignore diffs
      # only containing these volatile changes. Useful for things like
      # svn:keywords $Id$ etc.
      adds = [line for line in sourcediff[2:] if line[0] == '+']
      subs = [line for line in sourcediff[2:] if line[0] == '-']
      if len(adds) == len(subs) and not [1 for line in adds
                                         if not _volatile(line)]:
        del prop_diff['source']

      self.unified_diff = ''.join('-- {}\n'.format(diffline)
                                  for diffline in sourcediff)

    return prop_diff
예제 #3
0
 def __init__ (self, plsql_obj, errors):
   self.plsql_obj = plsql_obj
   self.errors = errors
   parts = ["{} has {} {}s".format(plsql_obj.pretty_name, len(errors),
                                   errors[0]['attribute'].lower())]
   for error_props in errors:
     line = error_props['line']
     source_line = line
     if len(plsql_obj.create_location) > 1:
       source_line += plsql_obj.create_location[1] - 1
     parts.append(str(SyntaxError(
       "PL/SQL compile {}:".format(error_props['attribute'].lower()),
       _with_location(plsql_obj, False), source_line,
       error_props['position'] - 1, plsql_obj.sql().split('\n')[line-1],
       error_props['text'])))
   super().__init__("\n".join(parts))
예제 #4
0
 def __init__ (self, obj):
   self.obj = obj
   super().__init__(_with_location(self.obj))
예제 #5
0
 def __str__ (self):
   return super().__str__() + "\n  ".join(line for obj in self.unsatisfied
                                          for line in (
     ['', "{} referenced by:".format(obj.pretty_name)] +
     ["  {}".format(_with_location(ref.from_))
      for ref in obj._referenced_by]))
예제 #6
0
 def __str__ (self):
   return "{}, is present in schema as {}".format(
     super().__str__(), _with_location(self.other))