'Return a Python CITDL expression preceding the given trigger.
The expression drops newlines, whitespace, and function call
arguments -- basically any stuff that is not used by the codeintel
database system for determining the resultant object type of the
expression. For example (in which <|> represents the given position):
GIVEN                       RETURN
foo<|>.                     foo
foo(bar<|>.                 bar
foo(bar,blam)<|>.           foo()
foo(bar,                    foo()
blam)<|>.
@foo<|>(                    foo
If (trg.form == TRG_FORM_DEFN), then it\'s similar to above, except it
looks forward to grab additional characters.
GIVEN                       RETURN
foo<|>.                     foo
f<|>oo.bar                  foo.bar
foo(bar<|>.                 bar
foo(bar,blam)<|>.           foo()
foo(bar,                    foo().bar
blam).b<|>ar'

def citdl_expr_from_trg(self, buf, trg):

    DEBUG = False
    if DEBUG:
        print banner(('Python-style    citdl_expr_from_trg    @    %d' % trg.pos))
    if (trg.form == TRG_FORM_DEFN):
        pos = trg.pos
        expr = self._citdl_expr_from_pos(buf, pos, implicit=True, trg=trg, include_forwards=True, DEBUG=DEBUG)
        if expr:
            return expr.rstrip('.')
        return expr
    else:
        if (trg.type == 'array-members'):
            pos = (trg.extra.get('bracket_pos') - 1)
        else:
            pos = (trg.pos - 2)
        return self._citdl_expr_from_pos(buf, pos, implicit=trg.implicit, DEBUG=DEBUG, trg=trg)
