Input:
CODE <module>()
  DOC 'Modality'
  RESUME 0
  LOAD_CONST ('Modality', '$\\log_2 K$')
  LOAD_CONST <code plot_best_worst_fits>
  MAKE_FUNCTION defaults
  STORE_NAME plot_best_worst_fits
  RETURN_CONST None
END
CODE plot_best_worst_fits(assignments_df, data, modality_col, score)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 2
  STORE_FAST ncols
  LOAD_GLOBAL NULL + len
  LOAD_FAST assignments_df
  LOAD_ATTR NULL|self + groupby
  LOAD_FAST modality_col
  CALL 1
  LOAD_ATTR groups
  LOAD_ATTR NULL|self + keys
  CALL 0
  CALL 1
  STORE_FAST nrows
  LOAD_GLOBAL plt
  LOAD_ATTR NULL|self + subplots
  LOAD_FAST nrows
  LOAD_FAST ncols
  LOAD_FAST nrows
  LOAD_CONST 4
  BINARY_OP *
  LOAD_FAST ncols
  LOAD_CONST 6
  BINARY_OP *
  BUILD_TUPLE 2
  KW_NAMES ('nrows', 'ncols', 'figsize')
  CALL 3
  UNPACK_SEQUENCE 2
  STORE_FAST fig
  STORE_FAST axes
  LOAD_FAST axes
  LOAD_ATTR flat
  STORE_FAST axes_iter
  LOAD_CONST ('Highest', 'Lowest')
  STORE_FAST fits
  LOAD_FAST assignments_df
  LOAD_ATTR NULL|self + groupby
  LOAD_FAST modality_col
  CALL 1
  GET_ITER
L1:
  FOR_ITER L7
  UNPACK_SEQUENCE 2
  STORE_FAST modality
  STORE_FAST df
  LOAD_FAST df
  LOAD_ATTR NULL|self + sort_values
  LOAD_FAST score
  CALL 1
  STORE_FAST df
  LOAD_GLOBAL MODALITY_TO_COLOR
  LOAD_FAST modality
  BINARY_SUBSCR
  STORE_FAST color
  LOAD_FAST fits
  GET_ITER
L2:
  FOR_ITER L6
  STORE_FAST fit
  LOAD_FAST fit
  LOAD_CONST 'Highest'
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L3
  LOAD_FAST df
  LOAD_CONST 'Feature ID'
  BINARY_SUBSCR
  LOAD_CONST -10
  LOAD_CONST None
  BINARY_SLICE
  STORE_FAST ids
  JUMP_FORWARD L4
L3:
  LOAD_FAST df
  LOAD_CONST 'Feature ID'
  BINARY_SUBSCR
  LOAD_CONST None
  LOAD_CONST 10
  BINARY_SLICE
  STORE_FAST ids
L4:
  LOAD_FAST data
  LOAD_FAST ids
  BINARY_SUBSCR
  STORE_FAST fit_psi
  LOAD_FAST fit_psi
  LOAD_ATTR NULL|self + stack
  CALL 0
  LOAD_ATTR NULL|self + reset_index
  CALL 0
  STORE_FAST tidy_fit_psi
  LOAD_FAST tidy_fit_psi
  LOAD_ATTR NULL|self + rename
  LOAD_CONST 'Sample ID'
  LOAD_CONST 'Feature ID'
  LOAD_CONST '$\\Psi$'
  LOAD_CONST ('level_0', 'level_1', 0)
  BUILD_CONST_KEY_MAP 3
  KW_NAMES ('columns',)
  CALL 1
  STORE_FAST tidy_fit_psi
  LOAD_FAST tidy_fit_psi
  LOAD_ATTR empty
  POP_JUMP_IF_FALSE L5
  JUMP_BACKWARD L2
L5:
  LOAD_GLOBAL six
  LOAD_ATTR NULL|self + next
  LOAD_FAST axes_iter
  CALL 1
  STORE_FAST ax
  LOAD_GLOBAL NULL + violinplot
  LOAD_CONST 'Feature ID'
  LOAD_CONST '$\\Psi$'
  LOAD_FAST tidy_fit_psi
  LOAD_FAST color
  LOAD_FAST ax
  KW_NAMES ('x', 'y', 'data', 'color', 'ax')
  CALL 5
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set
  LOAD_CONST '{} {} {}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST fit
  LOAD_FAST score
  LOAD_FAST modality
  CALL 3
  BUILD_LIST 0
  KW_NAMES ('title', 'xticks')
  CALL 2
  POP_TOP
  JUMP_BACKWARD L2
L6:
  END_FOR
  JUMP_BACKWARD L1
L7:
  END_FOR
  LOAD_GLOBAL sns
  LOAD_ATTR NULL|self + despine
  CALL 0
  POP_TOP
  LOAD_FAST fig
  LOAD_ATTR NULL|self + tight_layout
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def plot_best_worst_fits(assignments_df, data, modality_col='Modality', score='$\\log_2 K$'):
    """pass"""
    ncols = 2
    nrows = len(assignments_df.groupby(modality_col).groups.keys())
    fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(nrows * 4, ncols * 6))
    axes_iter = axes.flat
    fits = ('Highest', 'Lowest')
    for modality, df in assignments_df.groupby(modality_col):
        df = df.sort_values(score)
        color = MODALITY_TO_COLOR[modality]
        for fit in fits:
            if fit == 'Highest':
                ids = df['Feature ID'][-10:]
            else:
                ids = df['Feature ID'][:10]
            fit_psi = data[ids]
            tidy_fit_psi = fit_psi.stack().reset_index()
            tidy_fit_psi = tidy_fit_psi.rename(columns={'level_0': 'Sample ID', 'level_1': 'Feature ID', 0: '$\\Psi$'})
            if tidy_fit_psi.empty:
                continue
            ax = six.next(axes_iter)
            violinplot(x='Feature ID', y='$\\Psi$', data=tidy_fit_psi, color=color, ax=ax)
            ax.set(title='{} {} {}'.format(fit, score, modality), xticks=[])
    sns.despine()
    fig.tight_layout()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None, 0.2, 'width', None, None)
  LOAD_CONST <code violinplot>
  MAKE_FUNCTION defaults
  STORE_NAME violinplot
  RETURN_CONST None
END
CODE violinplot(x, y, data, bw, scale, inner, ax, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST ax
  POP_JUMP_IF_NOT_NONE L1
  LOAD_GLOBAL plt
  LOAD_ATTR NULL|self + gca
  CALL 0
  STORE_FAST ax
L1:
  LOAD_GLOBAL NULL + sns
  LOAD_ATTR violinplot
  LOAD_FAST x
  LOAD_FAST y
  BUILD_TUPLE 2
  LOAD_FAST data
  LOAD_FAST bw
  LOAD_FAST scale
  LOAD_FAST inner
  LOAD_FAST ax
  LOAD_CONST ('data', 'bw', 'scale', 'inner', 'ax')
  BUILD_CONST_KEY_MAP 5
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set
  LOAD_CONST (0, 1)
  LOAD_CONST (0, 0.5, 1)
  KW_NAMES ('ylim', 'yticks')
  CALL 2
  POP_TOP
  LOAD_FAST ax
  RETURN_VALUE
END

def violinplot(x=None, y=None, data=None, bw=0.2, scale='width', inner=None, ax=None, **kwargs):
    """pass"""
    if ax is None:
        ax = plt.gca()
    sns.violinplot(x, y, data=data, bw=bw, scale=scale, inner=inner, ax=ax, **kwargs)
    ax.set(ylim=(0, 1), yticks=(0, 0.5, 1))
    return ax

code-search-net/code_search_net (python, train split)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, True)
  LOAD_CONST <code bar>
  MAKE_FUNCTION defaults
  STORE_NAME bar
  RETURN_CONST None
END
CODE bar(self, counts, phenotype_to_color, ax, percentages)
  DOC 'pass'
  RESUME 0
  LOAD_FAST percentages
  POP_JUMP_IF_FALSE L1
  LOAD_CONST 100
  LOAD_FAST counts
  LOAD_ATTR T
  LOAD_FAST counts
  LOAD_ATTR T
  LOAD_ATTR NULL|self + sum
  CALL 0
  BINARY_OP /
  LOAD_ATTR T
  BINARY_OP *
  STORE_FAST counts
L1:
  LOAD_FAST ax
  POP_JUMP_IF_NOT_NONE L2
  LOAD_GLOBAL plt
  LOAD_ATTR NULL|self + gca
  CALL 0
  STORE_FAST ax
L2:
  LOAD_CONST 0.8
  STORE_FAST full_width
  LOAD_FAST full_width
  LOAD_FAST counts
  LOAD_ATTR shape
  LOAD_CONST 0
  BINARY_SUBSCR
  BINARY_OP /
  STORE_FAST width
  LOAD_GLOBAL NULL + enumerate
  LOAD_FAST counts
  LOAD_ATTR NULL|self + iterrows
  CALL 0
  CALL 1
  GET_ITER
L3:
  FOR_ITER L10
  UNPACK_SEQUENCE 2
  STORE_FAST i
  UNPACK_SEQUENCE 2
  STORE_FAST group
  STORE_FAST series
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + arange
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR modality_order
  CALL 1
  CALL 1
  LOAD_FAST i
  LOAD_FAST width
  BINARY_OP *
  BINARY_OP +
  STORE_FAST left
  LOAD_FAST self
  LOAD_ATTR modality_order
  GET_ITER
  LOAD_FAST_AND_CLEAR i
  SWAP 2
L4:
  BUILD_LIST 0
  SWAP 2
L5:
  FOR_ITER L8
  STORE_FAST i
  LOAD_FAST i
  LOAD_FAST series
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L6
  LOAD_FAST series
  LOAD_FAST i
  BINARY_SUBSCR
  JUMP_FORWARD L7
L6:
  LOAD_CONST 0
L7:
  LIST_APPEND 2
  JUMP_BACKWARD L5
L8:
  END_FOR
L9:
  STORE_FAST height
  STORE_FAST i
  LOAD_FAST phenotype_to_color
  LOAD_FAST group
  BINARY_SUBSCR
  STORE_FAST color
  LOAD_FAST ax
  LOAD_ATTR NULL|self + bar
  LOAD_FAST left
  LOAD_FAST height
  LOAD_FAST width
  LOAD_FAST color
  LOAD_FAST group
  LOAD_CONST 0.5
  LOAD_CONST 'k'
  KW_NAMES ('width', 'color', 'label', 'linewidth', 'edgecolor')
  CALL 7
  POP_TOP
  JUMP_BACKWARD L3
L10:
  END_FOR
  LOAD_FAST percentages
  POP_JUMP_IF_FALSE L11
  LOAD_CONST 'Percentage of events'
  JUMP_FORWARD L12
L11:
  LOAD_CONST 'Number of events'
L12:
  STORE_FAST ylabel
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set_ylabel
  LOAD_FAST ylabel
  CALL 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set_xticks
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + arange
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR modality_order
  CALL 1
  CALL 1
  LOAD_FAST full_width
  LOAD_CONST 2
  BINARY_OP /
  BINARY_OP +
  CALL 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set_xticklabels
  LOAD_FAST self
  LOAD_ATTR modality_order
  CALL 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set_xlabel
  LOAD_CONST 'Splicing modality'
  CALL 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + set_xlim
  LOAD_CONST 0
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR modality_order
  CALL 1
  CALL 2
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + legend
  LOAD_CONST 'best'
  KW_NAMES ('loc',)
  CALL 1
  POP_TOP
  LOAD_FAST ax
  LOAD_ATTR NULL|self + grid
  LOAD_CONST 'y'
  LOAD_CONST '-'
  LOAD_CONST 0.5
  KW_NAMES ('axis', 'linestyle', 'linewidth')
  CALL 3
  POP_TOP
  LOAD_GLOBAL sns
  LOAD_ATTR NULL|self + despine
  CALL 0
  POP_TOP
  RETURN_CONST None
L13:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST i
  RERAISE 0
  EXC try=L4..L9 -> handler=L13 depth=3 lasti=False
END

def bar(self, counts, phenotype_to_color=None, ax=None, percentages=True):
    """pass"""
    if percentages:
        counts = 100 * (counts.T / counts.T.sum()).T
    if ax is None:
        ax = plt.gca()
    full_width = 0.8
    width = full_width / counts.shape[0]
    for i, (group, series) in enumerate(counts.iterrows()):
        left = np.arange(len(self.modality_order)) + i * width
        height = [series[i] if i in series else 0 for i in self.modality_order]
        color = phenotype_to_color[group]
        ax.bar(left, height, width=width, color=color, label=group, linewidth=0.5, edgecolor='k')
    ylabel = 'Percentage of events' if percentages else 'Number of events'
    ax.set_ylabel(ylabel)
    ax.set_xticks(np.arange(len(self.modality_order)) + full_width / 2)
    ax.set_xticklabels(self.modality_order)
    ax.set_xlabel('Splicing modality')
    ax.set_xlim(0, len(self.modality_order))
    ax.legend(loc='best')
    ax.grid(axis='y', linestyle='-', linewidth=0.5)
    sns.despine()


Input:
CODE <module>()
  DOC ''
  RESUME 0
  LOAD_CONST ('',)
  LOAD_CONST <code event_estimation>
  MAKE_FUNCTION defaults
  STORE_NAME event_estimation
  RETURN_CONST None
END
CODE event_estimation(self, event, logliks, logsumexps, renamed)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + _ModelLoglikPlotter
  CALL 0
  STORE_FAST plotter
  LOAD_FAST plotter
  LOAD_ATTR NULL|self + plot
  LOAD_FAST event
  LOAD_FAST logliks
  LOAD_FAST logsumexps
  LOAD_FAST self
  LOAD_ATTR modality_to_color
  LOAD_FAST renamed
  KW_NAMES ('renamed',)
  CALL 5
  POP_TOP
  LOAD_FAST plotter
  RETURN_VALUE
END

def event_estimation(self, event, logliks, logsumexps, renamed=''):
    """pass"""
    plotter = _ModelLoglikPlotter()
    plotter.plot(event, logliks, logsumexps, self.modality_to_color, renamed=renamed)
    return plotter


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code predict>
  MAKE_FUNCTION 0
  STORE_NAME predict
  RETURN_CONST None
END
CODE predict(self, fitted)
  DOC 'pass'
  RESUME 0
  LOAD_FAST fitted
  LOAD_ATTR shape
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR modalities
  CALL 1
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST "This data doesn't look like it had the distance between it and the five modalities calculated"
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_FAST fitted
  LOAD_ATTR NULL|self + idxmin
  CALL 0
  RETURN_VALUE
END

def predict(self, fitted):
    """pass"""
    if fitted.shape[0] != len(self.modalities):
        raise ValueError("This data doesn't look like it had the distance between it and the five modalities calculated")
    return fitted.idxmin()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code logliks>
  MAKE_FUNCTION 0
  STORE_NAME logliks
  RETURN_CONST None
END
CODE logliks(self, x)
  DOC 'pass'
  RESUME 0
  LOAD_FAST x
  LOAD_ATTR NULL|self + copy
  CALL 0
  STORE_FAST x
  LOAD_GLOBAL VERY_SMALL_NUMBER
  LOAD_FAST x
  LOAD_FAST x
  LOAD_CONST 0
  COMPARE_OP ==
  STORE_SUBSCR
  LOAD_CONST 1
  LOAD_GLOBAL VERY_SMALL_NUMBER
  BINARY_OP -
  LOAD_FAST x
  LOAD_FAST x
  LOAD_CONST 1
  COMPARE_OP ==
  STORE_SUBSCR
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + array
  LOAD_GLOBAL NULL + zip
  LOAD_FAST self
  LOAD_ATTR prob_parameters
  LOAD_FAST self
  LOAD_ATTR rvs
  CALL 2
  GET_ITER
  LOAD_FAST_AND_CLEAR prob
  LOAD_FAST_AND_CLEAR rv
  SWAP 3
L1:
  BUILD_LIST 0
  SWAP 2
L2:
  FOR_ITER L3
  UNPACK_SEQUENCE 2
  STORE_FAST prob
  STORE_FAST rv
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + log
  LOAD_FAST prob
  CALL 1
  LOAD_FAST rv
  LOAD_ATTR NULL|self + logpdf
  LOAD_FAST x
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + isfinite
  LOAD_FAST x
  CALL 1
  BINARY_SUBSCR
  CALL 1
  LOAD_ATTR NULL|self + sum
  CALL 0
  BINARY_OP +
  LIST_APPEND 2
  JUMP_BACKWARD L2
L3:
  END_FOR
L4:
  SWAP 3
  STORE_FAST rv
  STORE_FAST prob
  CALL 1
  RETURN_VALUE
L5:
  SWAP 2
  POP_TOP
  SWAP 3
  STORE_FAST rv
  STORE_FAST prob
  RERAISE 0
  EXC try=L1..L4 -> handler=L5 depth=5 lasti=False
END

def logliks(self, x):
    """pass"""
    x = x.copy()
    x[x == 0] = VERY_SMALL_NUMBER
    x[x == 1] = 1 - VERY_SMALL_NUMBER
    return np.array([np.log(prob) + rv.logpdf(x[np.isfinite(x)]).sum() for prob, rv in zip(self.prob_parameters, self.rvs)])


Input:
CODE <module>()
  DOC 'default'
  RESUME 0
  LOAD_CONST ('default', 1, None)
  LOAD_CONST False
  LOAD_CONST None
  LOAD_CONST ('nowait', 'using')
  BUILD_CONST_KEY_MAP 2
  LOAD_CONST <code get_next_value>
  MAKE_FUNCTION defaults, kwdefaults
  STORE_NAME get_next_value
  RETURN_CONST None
END
CODE get_next_value(sequence_name, initial_value, reset_value, *, nowait, using)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 1
  LOAD_CONST ('Sequence',)
  IMPORT_NAME models
  IMPORT_FROM Sequence
  STORE_FAST Sequence
  POP_TOP
  LOAD_FAST reset_value
  POP_JUMP_IF_NONE L1
  LOAD_FAST initial_value
  LOAD_FAST reset_value
  COMPARE_OP <
  POP_JUMP_IF_TRUE L1
  LOAD_ASSERTION_ERROR
  RAISE_VARARGS 1
L1:
  LOAD_FAST using
  POP_JUMP_IF_NOT_NONE L2
  LOAD_GLOBAL router
  LOAD_ATTR NULL|self + db_for_write
  LOAD_FAST Sequence
  CALL 1
  STORE_FAST using
L2:
  LOAD_GLOBAL connections
  LOAD_FAST using
  BINARY_SUBSCR
  STORE_FAST connection
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST connection
  LOAD_CONST 'pg_version'
  LOAD_CONST 0
  CALL 3
  LOAD_CONST 90500
  COMPARE_OP >=
  POP_JUMP_IF_FALSE L5
  LOAD_FAST reset_value
  POP_JUMP_IF_NOT_NONE L5
  LOAD_FAST nowait
  POP_JUMP_IF_TRUE L5
  LOAD_FAST connection
  LOAD_ATTR NULL|self + cursor
  CALL 0
  BEFORE_WITH
L3:
  STORE_FAST cursor
  LOAD_FAST cursor
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL UPSERT_QUERY
  LOAD_FAST sequence_name
  LOAD_FAST initial_value
  BUILD_LIST 2
  CALL 2
  POP_TOP
  LOAD_FAST cursor
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 1
  STORE_FAST last
L4:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  LOAD_FAST last
  RETURN_VALUE
L5:
  LOAD_GLOBAL transaction
  LOAD_ATTR NULL|self + atomic
  LOAD_FAST using
  LOAD_CONST False
  KW_NAMES ('using', 'savepoint')
  CALL 2
  BEFORE_WITH
L6:
  POP_TOP
  LOAD_FAST Sequence
  LOAD_ATTR objects
  LOAD_ATTR NULL|self + select_for_update
  LOAD_FAST nowait
  KW_NAMES ('nowait',)
  CALL 1
  LOAD_ATTR NULL|self + get_or_create
  LOAD_FAST sequence_name
  LOAD_CONST 'last'
  LOAD_FAST initial_value
  BUILD_MAP 1
  KW_NAMES ('name', 'defaults')
  CALL 2
  UNPACK_SEQUENCE 2
  STORE_FAST sequence
  STORE_FAST created
  LOAD_FAST created
  POP_JUMP_IF_TRUE L8
  LOAD_FAST sequence
  COPY 1
  LOAD_ATTR last
  LOAD_CONST 1
  BINARY_OP +=
  SWAP 2
  STORE_ATTR last
  LOAD_FAST reset_value
  POP_JUMP_IF_NONE L7
  LOAD_FAST sequence
  LOAD_ATTR last
  LOAD_FAST reset_value
  COMPARE_OP >=
  POP_JUMP_IF_FALSE L7
  LOAD_FAST initial_value
  LOAD_FAST sequence
  STORE_ATTR last
L7:
  LOAD_FAST sequence
  LOAD_ATTR NULL|self + save
  CALL 0
  POP_TOP
L8:
  LOAD_FAST sequence
  LOAD_ATTR last
L9:
  SWAP 2
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  RETURN_VALUE
L10:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L11
  RERAISE 2
L11:
  POP_TOP
L12:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  LOAD_FAST_CHECK last
  RETURN_VALUE
L13:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L14:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L15
  RERAISE 2
L15:
  POP_TOP
L16:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  RETURN_CONST None
L17:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L3..L4 -> handler=L10 depth=1 lasti=True
  EXC try=L6..L9 -> handler=L14 depth=1 lasti=True
  EXC try=L10..L12 -> handler=L13 depth=3 lasti=True
  EXC try=L14..L16 -> handler=L17 depth=3 lasti=True
END

def get_next_value(sequence_name='default', initial_value=1, reset_value=None, *, nowait=False, using=None):
    """pass"""
    from .models import Sequence
    if reset_value is not None:
        assert initial_value < reset_value
    if using is None:
        using = router.db_for_write(Sequence)
    connection = connections[using]
    if getattr(connection, 'pg_version', 0) >= 90500 and reset_value is None and (not nowait):
        with connection.cursor() as cursor:
            cursor.execute(UPSERT_QUERY, [sequence_name, initial_value])
            last, = cursor.fetchone()
        return last
    else:
        with transaction.atomic(using=using, savepoint=False):
            sequence, created = Sequence.objects.select_for_update(nowait=nowait).get_or_create(name=sequence_name, defaults={'last': initial_value})
            if not created:
                sequence.last += 1
                if reset_value is not None and sequence.last >= reset_value:
                    sequence.last = initial_value
                sequence.save()
            return sequence.last


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code check>
  MAKE_FUNCTION 0
  STORE_NAME check
  RETURN_CONST None
END
CODE check(self, final_line_count)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'version'
  BINARY_SUBSCR
  POP_JUMP_IF_FALSE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + _process_version_lines
  CALL 0
  POP_TOP
L1:
  LOAD_FAST self
  LOAD_ATTR NULL|self + _process_plan_lines
  LOAD_FAST final_line_count
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def check(self, final_line_count):
    """pass"""
    if self._lines_seen['version']:
        self._process_version_lines()
    self._process_plan_lines(final_line_count)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _process_version_lines>
  MAKE_FUNCTION 0
  STORE_NAME _process_version_lines
  RETURN_CONST None
END
CODE _process_version_lines(self)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'version'
  BINARY_SUBSCR
  CALL 1
  LOAD_CONST 1
  COMPARE_OP >
  POP_JUMP_IF_FALSE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'Multiple version lines appeared.'
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L1:
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'version'
  BINARY_SUBSCR
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST 1
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L2
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'The version must be on the first line.'
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L2:
  RETURN_CONST None
END

def _process_version_lines(self):
    """pass"""
    if len(self._lines_seen['version']) > 1:
        self._add_error(_('Multiple version lines appeared.'))
    elif self._lines_seen['version'][0] != 1:
        self._add_error(_('The version must be on the first line.'))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _process_plan_lines>
  MAKE_FUNCTION 0
  STORE_NAME _process_plan_lines
  RETURN_CONST None
END
CODE _process_plan_lines(self, final_line_count)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'plan'
  BINARY_SUBSCR
  POP_JUMP_IF_TRUE L1
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'Missing a plan.'
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L1:
  LOAD_GLOBAL NULL + len
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'plan'
  BINARY_SUBSCR
  CALL 1
  LOAD_CONST 1
  COMPARE_OP >
  POP_JUMP_IF_FALSE L2
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'Only one plan line is permitted per file.'
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L2:
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'plan'
  BINARY_SUBSCR
  LOAD_CONST 0
  BINARY_SUBSCR
  UNPACK_SEQUENCE 2
  STORE_FAST plan
  STORE_FAST at_line
  LOAD_FAST self
  LOAD_ATTR NULL|self + _plan_on_valid_line
  LOAD_FAST at_line
  LOAD_FAST final_line_count
  CALL 2
  POP_JUMP_IF_TRUE L3
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'A plan must appear at the beginning or end of the file.'
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
L3:
  LOAD_FAST plan
  LOAD_ATTR expected_tests
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'test'
  BINARY_SUBSCR
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L4
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'Expected {expected_count} tests but only {seen_count} ran.'
  CALL 1
  LOAD_ATTR NULL|self + format
  LOAD_FAST plan
  LOAD_ATTR expected_tests
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'test'
  BINARY_SUBSCR
  KW_NAMES ('expected_count', 'seen_count')
  CALL 2
  CALL 1
  POP_TOP
  RETURN_CONST None
L4:
  RETURN_CONST None
END

def _process_plan_lines(self, final_line_count):
    """pass"""
    if not self._lines_seen['plan']:
        self._add_error(_('Missing a plan.'))
        return
    if len(self._lines_seen['plan']) > 1:
        self._add_error(_('Only one plan line is permitted per file.'))
        return
    plan, at_line = self._lines_seen['plan'][0]
    if not self._plan_on_valid_line(at_line, final_line_count):
        self._add_error(_('A plan must appear at the beginning or end of the file.'))
        return
    if plan.expected_tests != self._lines_seen['test']:
        self._add_error(_('Expected {expected_count} tests but only {seen_count} ran.').format(expected_count=plan.expected_tests, seen_count=self._lines_seen['test']))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _plan_on_valid_line>
  MAKE_FUNCTION 0
  STORE_NAME _plan_on_valid_line
  RETURN_CONST None
END
CODE _plan_on_valid_line(self, at_line, final_line_count)
  DOC 'pass'
  RESUME 0
  LOAD_FAST at_line
  LOAD_CONST 1
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L1
  LOAD_FAST at_line
  LOAD_FAST final_line_count
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L2
L1:
  RETURN_CONST True
L2:
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'version'
  BINARY_SUBSCR
  COPY 1
  POP_JUMP_IF_FALSE L3
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _lines_seen
  LOAD_CONST 'version'
  BINARY_SUBSCR
  LOAD_CONST 0
  BINARY_SUBSCR
  LOAD_CONST 1
  COMPARE_OP ==
  COPY 1
  POP_JUMP_IF_FALSE L3
  POP_TOP
  LOAD_FAST at_line
  LOAD_CONST 2
  COMPARE_OP ==
L3:
  STORE_FAST after_version
  LOAD_FAST after_version
  POP_JUMP_IF_FALSE L4
  RETURN_CONST True
L4:
  RETURN_CONST False
END

def _plan_on_valid_line(self, at_line, final_line_count):
    """pass"""
    if at_line == 1 or at_line == final_line_count:
        return True
    after_version = self._lines_seen['version'] and self._lines_seen['version'][0] == 1 and (at_line == 2)
    if after_version:
        return True
    return False


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code handle_bail>
  MAKE_FUNCTION 0
  STORE_NAME handle_bail
  RETURN_CONST None
END
CODE handle_bail(self, bail)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + _add_error
  LOAD_GLOBAL NULL + _
  LOAD_CONST 'Bailed: {reason}'
  CALL 1
  LOAD_ATTR NULL|self + format
  LOAD_FAST bail
  LOAD_ATTR reason
  KW_NAMES ('reason',)
  CALL 1
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def handle_bail(self, bail):
    """pass"""
    self._add_error(_('Bailed: {reason}').format(reason=bail.reason))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code handle_skipping_plan>
  MAKE_FUNCTION 0
  STORE_NAME handle_skipping_plan
  RETURN_CONST None
END
CODE handle_skipping_plan(self, skip_plan)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + Result
  LOAD_CONST True
  LOAD_CONST None
  LOAD_FAST skip_plan
  LOAD_ATTR directive
  LOAD_ATTR text
  LOAD_GLOBAL NULL + Directive
  LOAD_CONST 'SKIP'
  CALL 1
  CALL 4
  STORE_FAST skip_line
  LOAD_FAST self
  LOAD_ATTR _suite
  LOAD_ATTR NULL|self + addTest
  LOAD_GLOBAL NULL + Adapter
  LOAD_FAST self
  LOAD_ATTR _filename
  LOAD_FAST skip_line
  CALL 2
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def handle_skipping_plan(self, skip_plan):
    """pass"""
    skip_line = Result(True, None, skip_plan.directive.text, Directive('SKIP'))
    self._suite.addTest(Adapter(self._filename, skip_line))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code mptt_before_insert>
  MAKE_FUNCTION 0
  STORE_NAME mptt_before_insert
  RETURN_CONST None
END
CODE mptt_before_insert(mapper, connection, instance)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + _get_tree_table
  LOAD_FAST mapper
  CALL 1
  STORE_FAST table
  LOAD_FAST instance
  LOAD_ATTR NULL|self + get_pk_column
  CALL 0
  STORE_FAST db_pk
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_FAST db_pk
  LOAD_ATTR name
  CALL 2
  STORE_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR parent_id
  POP_JUMP_IF_NOT_NONE L2
  LOAD_CONST 1
  LOAD_FAST instance
  STORE_ATTR left
  LOAD_CONST 2
  LOAD_FAST instance
  STORE_ATTR right
  LOAD_FAST instance
  LOAD_ATTR NULL|self + get_default_level
  CALL 0
  LOAD_FAST instance
  STORE_ATTR level
  LOAD_FAST connection
  LOAD_ATTR NULL|self + scalar
  LOAD_GLOBAL NULL + select
  LOAD_GLOBAL func
  LOAD_ATTR NULL|self + max
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  CALL 1
  LOAD_CONST 1
  BINARY_OP +
  BUILD_LIST 1
  CALL 1
  CALL 1
  COPY 1
  POP_JUMP_IF_TRUE L1
  POP_TOP
  LOAD_CONST 1
L1:
  STORE_FAST tree_id
  LOAD_FAST tree_id
  LOAD_FAST instance
  STORE_ATTR tree_id
  RETURN_CONST None
L2:
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  BUILD_LIST 4
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR parent_id
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 4
  STORE_FAST parent_pos_left
  STORE_FAST parent_pos_right
  STORE_FAST parent_tree_id
  STORE_FAST parent_level
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_FAST table
  LOAD_ATTR NULL|self + update
  LOAD_GLOBAL NULL + and_
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST parent_pos_right
  COMPARE_OP >=
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST parent_tree_id
  COMPARE_OP ==
  CALL 2
  CALL 1
  LOAD_ATTR NULL|self + values
  LOAD_GLOBAL NULL + case
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST parent_pos_right
  COMPARE_OP >
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_CONST 2
  BINARY_OP +
  BUILD_TUPLE 2
  BUILD_LIST 1
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  KW_NAMES ('else_',)
  CALL 2
  LOAD_GLOBAL NULL + case
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST parent_pos_right
  COMPARE_OP >=
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_CONST 2
  BINARY_OP +
  BUILD_TUPLE 2
  BUILD_LIST 1
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  KW_NAMES ('else_',)
  CALL 2
  KW_NAMES ('lft', 'rgt')
  CALL 2
  CALL 1
  POP_TOP
  LOAD_FAST parent_level
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST instance
  STORE_ATTR level
  LOAD_FAST parent_tree_id
  LOAD_FAST instance
  STORE_ATTR tree_id
  LOAD_FAST parent_pos_right
  LOAD_FAST instance
  STORE_ATTR left
  LOAD_FAST parent_pos_right
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST instance
  STORE_ATTR right
  RETURN_CONST None
END

def mptt_before_insert(mapper, connection, instance):
    """pass"""
    table = _get_tree_table(mapper)
    db_pk = instance.get_pk_column()
    table_pk = getattr(table.c, db_pk.name)
    if instance.parent_id is None:
        instance.left = 1
        instance.right = 2
        instance.level = instance.get_default_level()
        tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1])) or 1
        instance.tree_id = tree_id
    else:
        parent_pos_left, parent_pos_right, parent_tree_id, parent_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()
        connection.execute(table.update(and_(table.c.rgt >= parent_pos_right, table.c.tree_id == parent_tree_id)).values(lft=case([(table.c.lft > parent_pos_right, table.c.lft + 2)], else_=table.c.lft), rgt=case([(table.c.rgt >= parent_pos_right, table.c.rgt + 2)], else_=table.c.rgt)))
        instance.level = parent_level + 1
        instance.tree_id = parent_tree_id
        instance.left = parent_pos_right
        instance.right = parent_pos_right + 1


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code mptt_before_update>
  MAKE_FUNCTION 0
  STORE_NAME mptt_before_update
  RETURN_CONST None
END
CODE mptt_before_update(mapper, connection, instance)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST instance
  LOAD_FAST instance
  LOAD_ATTR NULL|self + get_pk_name
  CALL 0
  CALL 2
  STORE_FAST node_id
  LOAD_GLOBAL NULL + _get_tree_table
  LOAD_FAST mapper
  CALL 1
  STORE_FAST table
  LOAD_FAST instance
  LOAD_ATTR NULL|self + get_pk_column
  CALL 0
  STORE_FAST db_pk
  LOAD_FAST instance
  LOAD_ATTR NULL|self + get_default_level
  CALL 0
  STORE_FAST default_level
  LOAD_GLOBAL NULL + getattr
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_FAST db_pk
  LOAD_ATTR name
  CALL 2
  STORE_FAST table_pk
  LOAD_CONST None
  STORE_FAST mptt_move_inside
  LOAD_CONST None
  STORE_FAST left_sibling
  LOAD_CONST None
  STORE_FAST left_sibling_tree_id
  LOAD_GLOBAL NULL + hasattr
  LOAD_FAST instance
  LOAD_CONST 'mptt_move_inside'
  CALL 2
  POP_JUMP_IF_FALSE L1
  LOAD_FAST instance
  LOAD_ATTR mptt_move_inside
  STORE_FAST mptt_move_inside
L1:
  LOAD_GLOBAL NULL + hasattr
  LOAD_FAST instance
  LOAD_CONST 'mptt_move_before'
  CALL 2
  EXTENDED_ARG 1
  POP_JUMP_IF_FALSE L3
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR parent_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  BUILD_LIST 5
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR mptt_move_before
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 5
  STORE_FAST right_sibling_left
  STORE_FAST right_sibling_right
  STORE_FAST right_sibling_parent
  STORE_FAST right_sibling_level
  STORE_FAST right_sibling_tree_id
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR parent_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  BUILD_LIST 4
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_GLOBAL NULL + and_
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  LOAD_FAST right_sibling_level
  COMPARE_OP ==
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST right_sibling_tree_id
  COMPARE_OP ==
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST right_sibling_left
  COMPARE_OP <
  CALL 3
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchall
  CALL 0
  STORE_FAST current_lvl_nodes
  LOAD_FAST current_lvl_nodes
  POP_JUMP_IF_FALSE L2
  LOAD_FAST current_lvl_nodes
  LOAD_CONST -1
  BINARY_SUBSCR
  UNPACK_SEQUENCE 4
  STORE_FAST left_sibling_left
  STORE_FAST left_sibling_right
  STORE_FAST left_sibling_parent
  STORE_FAST left_sibling_tree_id
  LOAD_FAST left_sibling_parent
  LOAD_FAST instance
  STORE_ATTR parent_id
  LOAD_FAST left_sibling_left
  LOAD_FAST left_sibling_right
  LOAD_CONST False
  LOAD_CONST ('lft', 'rgt', 'is_parent')
  BUILD_CONST_KEY_MAP 3
  STORE_FAST left_sibling
  JUMP_FORWARD L3
L2:
  LOAD_FAST right_sibling_parent
  POP_JUMP_IF_TRUE L3
  LOAD_FAST right_sibling_tree_id
  LOAD_CONST 1
  BINARY_OP -
  STORE_FAST left_sibling_tree_id
L3:
  LOAD_GLOBAL NULL + hasattr
  LOAD_FAST instance
  LOAD_CONST 'mptt_move_after'
  CALL 2
  POP_JUMP_IF_FALSE L4
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR parent_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  BUILD_LIST 4
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR mptt_move_after
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 4
  STORE_FAST left_sibling_left
  STORE_FAST left_sibling_right
  STORE_FAST left_sibling_parent
  STORE_FAST left_sibling_tree_id
  LOAD_FAST left_sibling_parent
  LOAD_FAST instance
  STORE_ATTR parent_id
  LOAD_FAST left_sibling_left
  LOAD_FAST left_sibling_right
  LOAD_CONST False
  LOAD_CONST ('lft', 'rgt', 'is_parent')
  BUILD_CONST_KEY_MAP 3
  STORE_FAST left_sibling
L4:
  NOP
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table_pk
  BUILD_LIST 1
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_GLOBAL NULL + and_
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST instance
  LOAD_ATTR left
  COMPARE_OP >=
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST instance
  LOAD_ATTR right
  COMPARE_OP <=
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST instance
  LOAD_ATTR tree_id
  COMPARE_OP ==
  CALL 3
  CALL 1
  LOAD_ATTR NULL|self + order_by
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchall
  CALL 0
  STORE_FAST subtree
  LOAD_FAST subtree
  GET_ITER
  LOAD_FAST_AND_CLEAR x
  SWAP 2
L5:
  BUILD_LIST 0
  SWAP 2
L6:
  FOR_ITER L7
  STORE_FAST x
  LOAD_FAST x
  LOAD_CONST 0
  BINARY_SUBSCR
  LIST_APPEND 2
  JUMP_BACKWARD L6
L7:
  END_FOR
L8:
  STORE_FAST subtree
  STORE_FAST x
  NOP
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR parent_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  BUILD_LIST 5
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST node_id
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 5
  STORE_FAST node_pos_left
  STORE_FAST node_pos_right
  STORE_FAST node_tree_id
  STORE_FAST node_parent_id
  STORE_FAST node_level
  LOAD_FAST left_sibling
  POP_JUMP_IF_TRUE L9
  LOAD_GLOBAL NULL + str
  LOAD_FAST node_parent_id
  CALL 1
  LOAD_GLOBAL NULL + str
  LOAD_FAST instance
  LOAD_ATTR parent_id
  CALL 1
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L9
  LOAD_FAST mptt_move_inside
  POP_JUMP_IF_TRUE L9
  LOAD_FAST left_sibling_tree_id
  POP_JUMP_IF_NOT_NONE L9
  RETURN_CONST None
L9:
  LOAD_FAST instance
  LOAD_ATTR parent_id
  POP_JUMP_IF_NONE L10
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table_pk
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  BUILD_LIST 5
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR parent_id
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 5
  STORE_FAST parent_id
  STORE_FAST parent_pos_right
  STORE_FAST parent_pos_left
  STORE_FAST parent_tree_id
  STORE_FAST parent_level
  LOAD_FAST node_parent_id
  POP_JUMP_IF_NOT_NONE L10
  LOAD_FAST node_tree_id
  LOAD_FAST parent_tree_id
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L10
  LOAD_CONST None
  LOAD_FAST instance
  STORE_ATTR parent_id
  RETURN_CONST None
L10:
  LOAD_GLOBAL NULL + mptt_before_delete
  LOAD_FAST mapper
  LOAD_FAST connection
  LOAD_FAST instance
  LOAD_CONST False
  CALL 4
  POP_TOP
  LOAD_FAST instance
  LOAD_ATTR parent_id
  POP_JUMP_IF_NONE L12
  NOP
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_GLOBAL NULL + select
  LOAD_FAST table_pk
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  BUILD_LIST 5
  CALL 1
  LOAD_ATTR NULL|self + where
  LOAD_FAST table_pk
  LOAD_FAST instance
  LOAD_ATTR parent_id
  COMPARE_OP ==
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + fetchone
  CALL 0
  UNPACK_SEQUENCE 5
  STORE_FAST parent_id
  STORE_FAST parent_pos_right
  STORE_FAST parent_pos_left
  STORE_FAST parent_tree_id
  STORE_FAST parent_level
  LOAD_FAST node_pos_right
  LOAD_FAST node_pos_left
  BINARY_OP -
  LOAD_CONST 1
  BINARY_OP +
  STORE_FAST node_size
  LOAD_FAST left_sibling
  POP_JUMP_IF_TRUE L11
  LOAD_FAST parent_pos_left
  LOAD_FAST parent_pos_right
  LOAD_CONST True
  LOAD_CONST ('lft', 'rgt', 'is_parent')
  BUILD_CONST_KEY_MAP 3
  STORE_FAST left_sibling
L11:
  LOAD_FAST parent_tree_id
  LOAD_FAST instance
  STORE_ATTR tree_id
  LOAD_GLOBAL NULL + _insert_subtree
  LOAD_FAST table
  LOAD_FAST connection
  LOAD_FAST node_size
  LOAD_FAST node_pos_left
  LOAD_FAST node_pos_right
  LOAD_FAST parent_pos_left
  LOAD_FAST parent_pos_right
  LOAD_FAST subtree
  LOAD_FAST parent_tree_id
  LOAD_FAST parent_level
  LOAD_FAST node_level
  LOAD_FAST left_sibling
  LOAD_FAST table_pk
  CALL 13
  POP_TOP
  RETURN_CONST None
L12:
  LOAD_FAST left_sibling_tree_id
  POP_JUMP_IF_TRUE L13
  LOAD_FAST left_sibling_tree_id
  LOAD_CONST 0
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L14
L13:
  LOAD_FAST left_sibling_tree_id
  LOAD_CONST 1
  BINARY_OP +
  STORE_FAST tree_id
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_FAST table
  LOAD_ATTR NULL|self + update
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_FAST left_sibling_tree_id
  COMPARE_OP >
  CALL 1
  LOAD_ATTR NULL|self + values
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  LOAD_CONST 1
  BINARY_OP +
  KW_NAMES ('tree_id',)
  CALL 1
  CALL 1
  POP_TOP
  JUMP_FORWARD L15
L14:
  LOAD_FAST connection
  LOAD_ATTR NULL|self + scalar
  LOAD_GLOBAL NULL + select
  LOAD_GLOBAL func
  LOAD_ATTR NULL|self + max
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR tree_id
  CALL 1
  LOAD_CONST 1
  BINARY_OP +
  BUILD_LIST 1
  CALL 1
  CALL 1
  STORE_FAST tree_id
L15:
  LOAD_FAST connection
  LOAD_ATTR NULL|self + execute
  LOAD_FAST table
  LOAD_ATTR NULL|self + update
  LOAD_FAST table_pk
  LOAD_ATTR NULL|self + in_
  LOAD_FAST subtree
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + values
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR lft
  LOAD_FAST node_pos_left
  BINARY_OP -
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR rgt
  LOAD_FAST node_pos_left
  BINARY_OP -
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST table
  LOAD_ATTR c
  LOAD_ATTR level
  LOAD_FAST node_level
  BINARY_OP -
  LOAD_FAST default_level
  BINARY_OP +
  LOAD_FAST tree_id
  KW_NAMES ('lft', 'rgt', 'level', 'tree_id')
  CALL 4
  CALL 1
  POP_TOP
  RETURN_CONST None
L16:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST x
  RERAISE 0
  EXC try=L5..L8 -> handler=L16 depth=2 lasti=False
END

def mptt_before_update(mapper, connection, instance):
    """pass"""
    node_id = getattr(instance, instance.get_pk_name())
    table = _get_tree_table(mapper)
    db_pk = instance.get_pk_column()
    default_level = instance.get_default_level()
    table_pk = getattr(table.c, db_pk.name)
    mptt_move_inside = None
    left_sibling = None
    left_sibling_tree_id = None
    if hasattr(instance, 'mptt_move_inside'):
        mptt_move_inside = instance.mptt_move_inside
    if hasattr(instance, 'mptt_move_before'):
        right_sibling_left, right_sibling_right, right_sibling_parent, right_sibling_level, right_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.level, table.c.tree_id]).where(table_pk == instance.mptt_move_before)).fetchone()
        current_lvl_nodes = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(and_(table.c.level == right_sibling_level, table.c.tree_id == right_sibling_tree_id, table.c.lft < right_sibling_left))).fetchall()
        if current_lvl_nodes:
            left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = current_lvl_nodes[-1]
            instance.parent_id = left_sibling_parent
            left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}
        elif not right_sibling_parent:
            left_sibling_tree_id = right_sibling_tree_id - 1
    if hasattr(instance, 'mptt_move_after'):
        left_sibling_left, left_sibling_right, left_sibling_parent, left_sibling_tree_id = connection.execute(select([table.c.lft, table.c.rgt, table.c.parent_id, table.c.tree_id]).where(table_pk == instance.mptt_move_after)).fetchone()
        instance.parent_id = left_sibling_parent
        left_sibling = {'lft': left_sibling_left, 'rgt': left_sibling_right, 'is_parent': False}
    ' Get subtree from node\n\n        SELECT id, name, level FROM my_tree\n        WHERE left_key >= $left_key AND right_key <= $right_key\n        ORDER BY left_key\n    '
    subtree = connection.execute(select([table_pk]).where(and_(table.c.lft >= instance.left, table.c.rgt <= instance.right, table.c.tree_id == instance.tree_id)).order_by(table.c.lft)).fetchall()
    subtree = [x[0] for x in subtree]
    ' step 0: Initialize parameters.\n\n        Put there left and right position of moving node\n    '
    node_pos_left, node_pos_right, node_tree_id, node_parent_id, node_level = connection.execute(select([table.c.lft, table.c.rgt, table.c.tree_id, table.c.parent_id, table.c.level]).where(table_pk == node_id)).fetchone()
    if not left_sibling and str(node_parent_id) == str(instance.parent_id) and (not mptt_move_inside):
        if left_sibling_tree_id is None:
            return
    if instance.parent_id is not None:
        parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()
        if node_parent_id is None and node_tree_id == parent_tree_id:
            instance.parent_id = None
            return
    mptt_before_delete(mapper, connection, instance, False)
    if instance.parent_id is not None:
        ' Put there right position of new parent node (there moving node\n            should be moved)\n        '
        parent_id, parent_pos_right, parent_pos_left, parent_tree_id, parent_level = connection.execute(select([table_pk, table.c.rgt, table.c.lft, table.c.tree_id, table.c.level]).where(table_pk == instance.parent_id)).fetchone()
        node_size = node_pos_right - node_pos_left + 1
        if not left_sibling:
            left_sibling = {'lft': parent_pos_left, 'rgt': parent_pos_right, 'is_parent': True}
        instance.tree_id = parent_tree_id
        _insert_subtree(table, connection, node_size, node_pos_left, node_pos_right, parent_pos_left, parent_pos_right, subtree, parent_tree_id, parent_level, node_level, left_sibling, table_pk)
    else:
        if left_sibling_tree_id or left_sibling_tree_id == 0:
            tree_id = left_sibling_tree_id + 1
            connection.execute(table.update(table.c.tree_id > left_sibling_tree_id).values(tree_id=table.c.tree_id + 1))
        else:
            tree_id = connection.scalar(select([func.max(table.c.tree_id) + 1]))
        connection.execute(table.update(table_pk.in_(subtree)).values(lft=table.c.lft - node_pos_left + 1, rgt=table.c.rgt - node_pos_left + 1, level=table.c.level - node_level + default_level, tree_id=tree_id))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code after_flush_postexec>
  MAKE_FUNCTION 0
  STORE_NAME after_flush_postexec
  RETURN_CONST None
END
CODE after_flush_postexec(self, session, context)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR instances
  LOAD_FAST session
  BINARY_SUBSCR
  STORE_FAST instances
L1:
  LOAD_FAST instances
  POP_JUMP_IF_FALSE L7
L2:
  LOAD_FAST instances
  LOAD_ATTR NULL|self + pop
  CALL 0
  STORE_FAST instance
  LOAD_FAST instance
  LOAD_FAST session
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L3
  JUMP_BACKWARD L1
L3:
  LOAD_FAST self
  LOAD_ATTR NULL|self + get_parent_value
  LOAD_FAST instance
  CALL 1
  STORE_FAST parent
  LOAD_FAST parent
  LOAD_GLOBAL NO_VALUE
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L5
  LOAD_FAST parent
  POP_JUMP_IF_NONE L5
L4:
  LOAD_FAST instances
  LOAD_ATTR NULL|self + discard
  LOAD_FAST parent
  CALL 1
  POP_TOP
  LOAD_FAST session
  LOAD_ATTR NULL|self + expire
  LOAD_FAST parent
  BUILD_LIST 0
  LOAD_CONST ('left', 'right', 'tree_id', 'level')
  LIST_EXTEND 1
  CALL 2
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + get_parent_value
  LOAD_FAST parent
  CALL 1
  STORE_FAST parent
  LOAD_FAST parent
  LOAD_GLOBAL NO_VALUE
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L5
  LOAD_FAST parent
  POP_JUMP_IF_NONE L5
  JUMP_BACKWARD L4
L5:
  LOAD_FAST session
  LOAD_ATTR NULL|self + expire
  LOAD_FAST instance
  BUILD_LIST 0
  LOAD_CONST ('left', 'right', 'tree_id', 'level')
  LIST_EXTEND 1
  CALL 2
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + expire_session_for_children
  LOAD_FAST session
  LOAD_FAST instance
  CALL 2
  POP_TOP
  LOAD_FAST instances
  POP_JUMP_IF_FALSE L6
  JUMP_BACKWARD L2
L6:
  RETURN_CONST None
L7:
  RETURN_CONST None
END

def after_flush_postexec(self, session, context):
    """pass"""
    instances = self.instances[session]
    while instances:
        instance = instances.pop()
        if instance not in session:
            continue
        parent = self.get_parent_value(instance)
        while parent != NO_VALUE and parent is not None:
            instances.discard(parent)
            session.expire(parent, ['left', 'right', 'tree_id', 'level'])
            parent = self.get_parent_value(parent)
        else:
            session.expire(instance, ['left', 'right', 'tree_id', 'level'])
            self.expire_session_for_children(session, instance)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (False,)
  LOAD_CONST <code is_ancestor_of>
  MAKE_FUNCTION defaults
  STORE_NAME is_ancestor_of
  RETURN_CONST None
END
CODE is_ancestor_of(self, other, inclusive)
  DOC 'pass'
  RESUME 0
  LOAD_FAST inclusive
  POP_JUMP_IF_FALSE L1
  LOAD_FAST self
  LOAD_ATTR tree_id
  LOAD_FAST other
  LOAD_ATTR tree_id
  COMPARE_OP ==
  LOAD_FAST self
  LOAD_ATTR left
  LOAD_FAST other
  LOAD_ATTR left
  COMPARE_OP <=
  BINARY_OP &
  LOAD_FAST other
  LOAD_ATTR right
  LOAD_FAST self
  LOAD_ATTR right
  COMPARE_OP <=
  BINARY_OP &
  RETURN_VALUE
L1:
  LOAD_FAST self
  LOAD_ATTR tree_id
  LOAD_FAST other
  LOAD_ATTR tree_id
  COMPARE_OP ==
  LOAD_FAST self
  LOAD_ATTR left
  LOAD_FAST other
  LOAD_ATTR left
  COMPARE_OP <
  BINARY_OP &
  LOAD_FAST other
  LOAD_ATTR right
  LOAD_FAST self
  LOAD_ATTR right
  COMPARE_OP <
  BINARY_OP &
  RETURN_VALUE
END

def is_ancestor_of(self, other, inclusive=False):
    """pass"""
    if inclusive:
        return (self.tree_id == other.tree_id) & (self.left <= other.left) & (other.right <= self.right)
    return (self.tree_id == other.tree_id) & (self.left < other.left) & (other.right < self.right)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code move_inside>
  MAKE_FUNCTION 0
  STORE_NAME move_inside
  RETURN_CONST None
END
CODE move_inside(self, parent_id)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL Session
  LOAD_ATTR NULL|self + object_session
  LOAD_FAST self
  CALL 1
  STORE_FAST session
  LOAD_FAST parent_id
  LOAD_FAST self
  STORE_ATTR parent_id
  LOAD_FAST parent_id
  LOAD_FAST self
  STORE_ATTR mptt_move_inside
  LOAD_FAST session
  LOAD_ATTR NULL|self + add
  LOAD_FAST self
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def move_inside(self, parent_id):
    """pass"""
    session = Session.object_session(self)
    self.parent_id = parent_id
    self.mptt_move_inside = parent_id
    session.add(self)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code move_after>
  MAKE_FUNCTION 0
  STORE_NAME move_after
  RETURN_CONST None
END
CODE move_after(self, node_id)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL Session
  LOAD_ATTR NULL|self + object_session
  LOAD_FAST self
  CALL 1
  STORE_FAST session
  LOAD_FAST self
  LOAD_ATTR parent_id
  LOAD_FAST self
  STORE_ATTR parent_id
  LOAD_FAST node_id
  LOAD_FAST self
  STORE_ATTR mptt_move_after
  LOAD_FAST session
  LOAD_ATTR NULL|self + add
  LOAD_FAST self
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def move_after(self, node_id):
    """pass"""
    session = Session.object_session(self)
    self.parent_id = self.parent_id
    self.mptt_move_after = node_id
    session.add(self)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, 600)
  LOAD_CONST <code make_request>
  MAKE_FUNCTION defaults
  STORE_NAME make_request
  RETURN_CONST None
END
CODE make_request(cls, url, method, params, basic_auth, timeout)
  DOC 'pass'
  RESUME 0
  LOAD_FAST params
  POP_JUMP_IF_NOT_NONE L1
  BUILD_MAP 0
  JUMP_FORWARD L2
L1:
  LOAD_FAST params
L2:
  STORE_FAST params
  LOAD_FAST cls
  COPY 1
  LOAD_ATTR request_id
  LOAD_CONST 1
  BINARY_OP +=
  SWAP 2
  STORE_ATTR request_id
  LOAD_FAST params
  LOAD_ATTR NULL|self + items
  CALL 0
  GET_ITER
  LOAD_FAST_AND_CLEAR k
  LOAD_FAST_AND_CLEAR v
  SWAP 3
L3:
  BUILD_MAP 0
  SWAP 2
L4:
  FOR_ITER L7
  UNPACK_SEQUENCE 2
  STORE_FAST k
  STORE_FAST v
  LOAD_FAST v
  POP_JUMP_IF_NOT_NONE L6
L5:
  JUMP_BACKWARD L4
L6:
  LOAD_FAST k
  LOAD_FAST v
  MAP_ADD 2
  JUMP_BACKWARD L4
L7:
  END_FOR
L8:
  STORE_FAST params
  STORE_FAST k
  STORE_FAST v
  LOAD_FAST method
  LOAD_FAST params
  LOAD_CONST '2.0'
  LOAD_FAST cls
  LOAD_ATTR request_id
  LOAD_CONST ('method', 'params', 'jsonrpc', 'id')
  BUILD_CONST_KEY_MAP 4
  STORE_FAST data
  LOAD_CONST 'application/json-rpc'
  LOAD_CONST 'LBRY python3-api'
  LOAD_CONST ('Content-Type', 'user-agent')
  BUILD_CONST_KEY_MAP 2
  STORE_FAST headers
  LOAD_GLOBAL requests
  LOAD_ATTR NULL|self + Request
  LOAD_CONST 'POST'
  LOAD_FAST url
  LOAD_FAST data
  LOAD_FAST headers
  LOAD_FAST basic_auth
  KW_NAMES ('json', 'headers', 'auth')
  CALL 5
  STORE_FAST request
  LOAD_FAST request
  LOAD_ATTR NULL|self + prepare
  CALL 0
  STORE_FAST prepared
  NOP
L9:
  LOAD_GLOBAL requests
  LOAD_ATTR NULL|self + Session
  CALL 0
  STORE_FAST sesh
  LOAD_FAST sesh
  LOAD_ATTR NULL|self + send
  LOAD_FAST prepared
  LOAD_FAST timeout
  KW_NAMES ('timeout',)
  CALL 2
  STORE_FAST response
  LOAD_FAST response
  LOAD_ATTR NULL|self + json
  CALL 0
  STORE_FAST response_json
  LOAD_CONST 'result'
  LOAD_FAST response_json
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L11
  LOAD_FAST response_json
  LOAD_CONST 'result'
  BINARY_SUBSCR
  LOAD_FAST response
  BUILD_TUPLE 2
L10:
  RETURN_VALUE
L11:
  LOAD_CONST 'error'
  LOAD_FAST response_json
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L12
  LOAD_GLOBAL LBRYUtils
  LOAD_ATTR NULL|self + LBRYException
  LOAD_CONST 'POST Request made to LBRY received an error'
  LOAD_FAST response_json
  LOAD_FAST response
  LOAD_ATTR status_code
  LOAD_FAST prepared
  CALL 4
  RAISE_VARARGS 1
L12:
  RETURN_CONST None
L13:
  SWAP 2
  POP_TOP
  SWAP 3
  STORE_FAST v
  STORE_FAST k
  RERAISE 0
L14:
  PUSH_EXC_INFO
  LOAD_GLOBAL requests
  LOAD_ATTR HTTPError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L18
  STORE_FAST HE
L15:
  LOAD_GLOBAL NULL + print
  LOAD_FAST HE
  CALL 1
  POP_TOP
L16:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST HE
  DELETE_FAST HE
  RETURN_CONST (None, None)
L17:
  LOAD_CONST None
  STORE_FAST HE
  DELETE_FAST HE
  RERAISE 1
L18:
  LOAD_GLOBAL requests
  LOAD_ATTR RequestException
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L22
  STORE_FAST RE
L19:
  LOAD_GLOBAL NULL + print
  LOAD_FAST RE
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Printing Request Created:\n'
  CALL 1
  POP_TOP
  LOAD_GLOBAL LBRYUtils
  LOAD_ATTR NULL|self + print_request
  LOAD_FAST prepared
  CALL 1
  POP_TOP
L20:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST RE
  DELETE_FAST RE
  RETURN_CONST (None, None)
L21:
  LOAD_CONST None
  STORE_FAST RE
  DELETE_FAST RE
  RERAISE 1
L22:
  RERAISE 0
L23:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L3..L5 -> handler=L13 depth=3 lasti=False
  EXC try=L6..L8 -> handler=L13 depth=3 lasti=False
  EXC try=L9..L10 -> handler=L14 depth=0 lasti=False
  EXC try=L11..L12 -> handler=L14 depth=0 lasti=False
  EXC try=L14..L15 -> handler=L23 depth=1 lasti=True
  EXC try=L15..L16 -> handler=L17 depth=1 lasti=True
  EXC try=L17..L19 -> handler=L23 depth=1 lasti=True
  EXC try=L19..L20 -> handler=L21 depth=1 lasti=True
  EXC try=L21..L23 -> handler=L23 depth=1 lasti=True
END

def make_request(cls, url, method, params=None, basic_auth=None, timeout=600):
    """pass"""
    params = {} if params is None else params
    cls.request_id += 1
    params = {k: v for k, v in params.items() if v is not None}
    data = {'method': method, 'params': params, 'jsonrpc': '2.0', 'id': cls.request_id}
    headers = {'Content-Type': 'application/json-rpc', 'user-agent': 'LBRY python3-api'}
    request = requests.Request('POST', url, json=data, headers=headers, auth=basic_auth)
    prepared = request.prepare()
    try:
        sesh = requests.Session()
        response = sesh.send(prepared, timeout=timeout)
        response_json = response.json()
        if 'result' in response_json:
            return (response_json['result'], response)
        elif 'error' in response_json:
            raise LBRYUtils.LBRYException('POST Request made to LBRY received an error', response_json, response.status_code, prepared)
    except requests.HTTPError as HE:
        print(HE)
        return (None, None)
    except requests.RequestException as RE:
        print(RE)
        print('Printing Request Created:\n')
        LBRYUtils.print_request(prepared)
        return (None, None)


Input:
CODE <module>()
  DOC 'info'
  RESUME 0
  LOAD_CONST 'info'
  LOAD_NAME dict
  LOAD_CONST 'return'
  LOAD_NAME dict
  BUILD_TUPLE 4
  LOAD_CONST <code adjust_status>
  MAKE_FUNCTION annotations
  STORE_NAME adjust_status
  RETURN_CONST None
END
CODE adjust_status(info)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + deepcopy
  LOAD_FAST info
  CALL 1
  STORE_FAST modified_info
  LOAD_FAST modified_info
  LOAD_ATTR NULL|self + update
  LOAD_GLOBAL NULL + get_nearest_by_numeric_key
  LOAD_GLOBAL STATUS_MAP
  LOAD_GLOBAL NULL + int
  LOAD_FAST info
  LOAD_CONST 'level'
  BINARY_SUBSCR
  CALL 1
  CALL 2
  LOAD_FAST info
  LOAD_CONST 'level2'
  BINARY_SUBSCR
  POP_JUMP_IF_NOT_NONE L1
  LOAD_GLOBAL STATUS_MAP
  LOAD_CONST 99
  BINARY_SUBSCR
  JUMP_FORWARD L2
L1:
  LOAD_GLOBAL NULL + get_nearest_by_numeric_key
  LOAD_GLOBAL STATUS_MAP
  LOAD_GLOBAL NULL + int
  LOAD_FAST info
  LOAD_CONST 'level2'
  BINARY_SUBSCR
  CALL 1
  CALL 2
L2:
  LOAD_CONST ('level', 'level2')
  BUILD_CONST_KEY_MAP 2
  CALL 1
  POP_TOP
  LOAD_FAST modified_info
  RETURN_VALUE
END

def adjust_status(info: dict) -> dict:
    """pass"""
    modified_info = deepcopy(info)
    modified_info.update({'level': get_nearest_by_numeric_key(STATUS_MAP, int(info['level'])), 'level2': STATUS_MAP[99] if info['level2'] is None else get_nearest_by_numeric_key(STATUS_MAP, int(info['level2']))})
    return modified_info


Input:
CODE <module>()
  DOC 'latitude'
  RESUME 0
  LOAD_CONST 'latitude'
  LOAD_NAME float
  LOAD_CONST 'longitude'
  LOAD_NAME float
  LOAD_CONST 'return'
  LOAD_NAME dict
  BUILD_TUPLE 6
  LOAD_CONST <code status_by_coordinates>
  MAKE_FUNCTION annotations
  STORE_NAME status_by_coordinates
  RETURN_CONST None
END
CODE status_by_coordinates(self, latitude, longitude)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + raw_cdc_data
  CALL 0
  GET_AWAITABLE 0
  LOAD_CONST None
L2:
  SEND L5
L3:
  YIELD_VALUE 2
L4:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L2
L5:
  END_SEND
  STORE_FAST cdc_data
  LOAD_FAST self
  LOAD_ATTR NULL|self + nearest_by_coordinates
  LOAD_FAST latitude
  LOAD_FAST longitude
  CALL 2
  GET_AWAITABLE 0
  LOAD_CONST None
L6:
  SEND L9
L7:
  YIELD_VALUE 2
L8:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L6
L9:
  END_SEND
  STORE_FAST nearest
  LOAD_GLOBAL NULL + adjust_status
  LOAD_FAST cdc_data
  LOAD_FAST nearest
  LOAD_CONST 'state'
  BINARY_SUBSCR
  LOAD_CONST 'name'
  BINARY_SUBSCR
  BINARY_SUBSCR
  CALL 1
  RETURN_VALUE
L10:
  CLEANUP_THROW
L11:
  JUMP_BACKWARD L5
L12:
  CLEANUP_THROW
L13:
  JUMP_BACKWARD L9
L14:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L14 depth=0 lasti=True
  EXC try=L3..L4 -> handler=L10 depth=2 lasti=False
  EXC try=L4..L7 -> handler=L14 depth=0 lasti=True
  EXC try=L7..L8 -> handler=L12 depth=2 lasti=False
  EXC try=L8..L11 -> handler=L14 depth=0 lasti=True
  EXC try=L12..L13 -> handler=L14 depth=0 lasti=True
END

async def status_by_coordinates(self, latitude: float, longitude: float) -> dict:
    """pass"""
    cdc_data = await self.raw_cdc_data()
    nearest = await self.nearest_by_coordinates(latitude, longitude)
    return adjust_status(cdc_data[nearest['state']['name']])


Input:
CODE <module>()
  DOC 'state'
  RESUME 0
  LOAD_CONST 'state'
  LOAD_NAME str
  LOAD_CONST 'return'
  LOAD_NAME dict
  BUILD_TUPLE 4
  LOAD_CONST <code status_by_state>
  MAKE_FUNCTION annotations
  STORE_NAME status_by_state
  RETURN_CONST None
END
CODE status_by_state(self, state)
  DOC 'pass'
  MAKE_CELL state
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + raw_cdc_data
  CALL 0
  GET_AWAITABLE 0
  LOAD_CONST None
L2:
  SEND L5
L3:
  YIELD_VALUE 2
L4:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L2
L5:
  END_SEND
  STORE_FAST data
L6:
  NOP
L7:
  LOAD_GLOBAL NULL + next
  LOAD_CLOSURE state
  BUILD_TUPLE 1
  LOAD_CONST <code status_by_state.<locals>.<genexpr>>
  MAKE_FUNCTION closure
  LOAD_FAST data
  LOAD_ATTR NULL|self + items
  CALL 0
  GET_ITER
  CALL 0
  CALL 1
  STORE_FAST info
L8:
  LOAD_GLOBAL NULL + adjust_status
  LOAD_FAST info
  CALL 1
  RETURN_VALUE
L9:
  CLEANUP_THROW
L10:
  JUMP_BACKWARD L5
L11:
  PUSH_EXC_INFO
  LOAD_GLOBAL StopIteration
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L13
  POP_TOP
  BUILD_MAP 0
  SWAP 2
L12:
  POP_EXCEPT
  RETURN_VALUE
L13:
  RERAISE 0
L14:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L15:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L15 depth=0 lasti=True
  EXC try=L3..L4 -> handler=L9 depth=2 lasti=False
  EXC try=L4..L6 -> handler=L15 depth=0 lasti=True
  EXC try=L7..L8 -> handler=L11 depth=0 lasti=False
  EXC try=L8..L10 -> handler=L15 depth=0 lasti=True
  EXC try=L11..L12 -> handler=L14 depth=1 lasti=True
  EXC try=L12..L13 -> handler=L15 depth=0 lasti=True
  EXC try=L13..L14 -> handler=L14 depth=1 lasti=True
  EXC try=L14..L15 -> handler=L15 depth=0 lasti=True
END
CODE status_by_state.<locals>.<genexpr>(.0)
  COPY_FREE_VARS 1
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST .0
L2:
  FOR_ITER L5
  UNPACK_SEQUENCE 2
  STORE_FAST k
  STORE_FAST v
  LOAD_DEREF state
  LOAD_FAST k
  CONTAINS_OP 0
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST v
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L5:
  END_FOR
  RETURN_CONST None
L6:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L6 depth=0 lasti=True
  EXC try=L4..L6 -> handler=L6 depth=0 lasti=True
END

async def status_by_state(self, state: str) -> dict:
    """pass"""
    data = await self.raw_cdc_data()
    try:
        info = next((v for k, v in data.items() if state in k))
    except StopIteration:
        return {}
    return adjust_status(info)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code insert>
  MAKE_FUNCTION 0
  STORE_NAME insert
  RETURN_CONST None
END
CODE insert(self, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR is_valid
  POP_JUMP_IF_FALSE L4
  LOAD_FAST self
  LOAD_ATTR NULL|self + before_insert
  CALL 0
  STORE_FAST before
  LOAD_FAST before
  POP_JUMP_IF_FALSE L1
  LOAD_FAST before
  RETURN_VALUE
L1:
  NOP
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + insert_one
  LOAD_FAST self
  LOAD_ATTR _document
  CALL 1
  LOAD_FAST self
  LOAD_ATTR _document
  LOAD_CONST '_id'
  STORE_SUBSCR
  LOAD_FAST self
  LOAD_ATTR NULL|self + after_insert
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _document
L3:
  RETURN_VALUE
L4:
  LOAD_FAST self
  LOAD_ATTR _errors
  RETURN_VALUE
L5:
  PUSH_EXC_INFO
  LOAD_GLOBAL PyMongoException
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L10
  STORE_FAST exc
L6:
  LOAD_GLOBAL NULL + PyMongoError
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'errmsg'
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'err'
  LOAD_CONST 'PyMongoError.'
  CALL 2
  CALL 2
  LOAD_CONST 'insert'
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _document
  KW_NAMES ('error_message', 'operation', 'collection', 'document')
  CALL 4
L7:
  SWAP 2
L8:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RETURN_VALUE
L9:
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RERAISE 1
L10:
  RERAISE 0
L11:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L3 -> handler=L5 depth=0 lasti=False
  EXC try=L5..L6 -> handler=L11 depth=1 lasti=True
  EXC try=L6..L7 -> handler=L9 depth=1 lasti=True
  EXC try=L7..L8 -> handler=L11 depth=1 lasti=True
  EXC try=L9..L11 -> handler=L11 depth=1 lasti=True
END

def insert(self, **kwargs):
    """pass"""
    if self.is_valid:
        before = self.before_insert()
        if before:
            return before
        try:
            self._document['_id'] = self.insert_one(self._document)
            self.after_insert()
            return self._document
        except PyMongoException as exc:
            return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='insert', collection=type(self).__name__, document=self._document)
    return self._errors


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code update>
  MAKE_FUNCTION 0
  STORE_NAME update
  RETURN_CONST None
END
CODE update(self, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR is_valid
  POP_JUMP_IF_FALSE L6
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _document
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L5
  LOAD_FAST self
  LOAD_ATTR NULL|self + find_one
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _id
  BUILD_MAP 1
  CALL 1
  STORE_FAST to_update
  LOAD_FAST to_update
  POP_JUMP_IF_FALSE L4
  LOAD_FAST self
  LOAD_ATTR NULL|self + before_update
  LOAD_FAST to_update
  KW_NAMES ('old',)
  CALL 1
  STORE_FAST before
  LOAD_FAST before
  POP_JUMP_IF_FALSE L1
  LOAD_FAST before
  RETURN_VALUE
L1:
  NOP
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + replace_one
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _id
  BUILD_MAP 1
  LOAD_FAST self
  LOAD_ATTR _document
  CALL 2
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + after_update
  LOAD_FAST to_update
  KW_NAMES ('old',)
  CALL 1
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _document
L3:
  RETURN_VALUE
L4:
  LOAD_GLOBAL NULL + DocumentNotFoundError
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _id
  CALL 2
  RETURN_VALUE
L5:
  LOAD_GLOBAL NULL + UnidentifiedDocumentError
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _document
  CALL 2
  RETURN_VALUE
L6:
  LOAD_FAST self
  LOAD_ATTR _errors
  RETURN_VALUE
L7:
  PUSH_EXC_INFO
  LOAD_GLOBAL PyMongoException
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L12
  STORE_FAST exc
L8:
  LOAD_GLOBAL NULL + PyMongoError
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'errmsg'
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'err'
  LOAD_CONST 'PyMongoError.'
  CALL 2
  CALL 2
  LOAD_CONST 'update'
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _document
  KW_NAMES ('error_message', 'operation', 'collection', 'document')
  CALL 4
L9:
  SWAP 2
L10:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RETURN_VALUE
L11:
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RERAISE 1
L12:
  RERAISE 0
L13:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L3 -> handler=L7 depth=0 lasti=False
  EXC try=L7..L8 -> handler=L13 depth=1 lasti=True
  EXC try=L8..L9 -> handler=L11 depth=1 lasti=True
  EXC try=L9..L10 -> handler=L13 depth=1 lasti=True
  EXC try=L11..L13 -> handler=L13 depth=1 lasti=True
END

def update(self, **kwargs):
    """pass"""
    if self.is_valid:
        if '_id' in self._document:
            to_update = self.find_one({'_id': self._id})
            if to_update:
                before = self.before_update(old=to_update)
                if before:
                    return before
                try:
                    self.replace_one({'_id': self._id}, self._document)
                    self.after_update(old=to_update)
                    return self._document
                except PyMongoException as exc:
                    return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='update', collection=type(self).__name__, document=self._document)
            else:
                return DocumentNotFoundError(type(self).__name__, self._id)
        else:
            return UnidentifiedDocumentError(type(self).__name__, self._document)
    return self._errors


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code delete>
  MAKE_FUNCTION 0
  STORE_NAME delete
  RETURN_CONST None
END
CODE delete(self, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR is_valid
  POP_JUMP_IF_FALSE L6
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _document
  CONTAINS_OP 0
  POP_JUMP_IF_FALSE L5
  LOAD_FAST self
  LOAD_ATTR NULL|self + find_one
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _id
  BUILD_MAP 1
  CALL 1
  STORE_FAST to_delete
  LOAD_FAST to_delete
  POP_JUMP_IF_FALSE L4
  LOAD_FAST self
  LOAD_ATTR NULL|self + before_delete
  CALL 0
  STORE_FAST before
  LOAD_FAST before
  POP_JUMP_IF_FALSE L1
  LOAD_FAST before
  RETURN_VALUE
L1:
  NOP
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + delete_one
  LOAD_CONST '_id'
  LOAD_FAST self
  LOAD_ATTR _id
  BUILD_MAP 1
  CALL 1
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + after_delete
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _document
L3:
  RETURN_VALUE
L4:
  LOAD_GLOBAL NULL + DocumentNotFoundError
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _id
  CALL 2
  RETURN_VALUE
L5:
  LOAD_GLOBAL NULL + UnidentifiedDocumentError
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _document
  CALL 2
  RETURN_VALUE
L6:
  RETURN_CONST None
L7:
  PUSH_EXC_INFO
  LOAD_GLOBAL PyMongoException
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L12
  STORE_FAST exc
L8:
  LOAD_GLOBAL NULL + PyMongoError
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'errmsg'
  LOAD_FAST exc
  LOAD_ATTR details
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'err'
  LOAD_CONST 'PyMongoError.'
  CALL 2
  CALL 2
  LOAD_CONST 'delete'
  LOAD_GLOBAL NULL + type
  LOAD_FAST self
  CALL 1
  LOAD_ATTR __name__
  LOAD_FAST self
  LOAD_ATTR _document
  KW_NAMES ('error_message', 'operation', 'collection', 'document')
  CALL 4
L9:
  SWAP 2
L10:
  POP_EXCEPT
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RETURN_VALUE
L11:
  LOAD_CONST None
  STORE_FAST exc
  DELETE_FAST exc
  RERAISE 1
L12:
  RERAISE 0
L13:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L3 -> handler=L7 depth=0 lasti=False
  EXC try=L7..L8 -> handler=L13 depth=1 lasti=True
  EXC try=L8..L9 -> handler=L11 depth=1 lasti=True
  EXC try=L9..L10 -> handler=L13 depth=1 lasti=True
  EXC try=L11..L13 -> handler=L13 depth=1 lasti=True
END

def delete(self, **kwargs):
    """pass"""
    if self.is_valid:
        if '_id' in self._document:
            to_delete = self.find_one({'_id': self._id})
            if to_delete:
                before = self.before_delete()
                if before:
                    return before
                try:
                    self.delete_one({'_id': self._id})
                    self.after_delete()
                    return self._document
                except PyMongoException as exc:
                    return PyMongoError(error_message=exc.details.get('errmsg', exc.details.get('err', 'PyMongoError.')), operation='delete', collection=type(self).__name__, document=self._document)
            else:
                return DocumentNotFoundError(type(self).__name__, self._id)
        else:
            return UnidentifiedDocumentError(type(self).__name__, self._document)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code find_one>
  MAKE_FUNCTION defaults
  STORE_NAME find_one
  RETURN_CONST None
END
CODE find_one(cls, filter, *args, **kwargs)
  DOC 'pass'
  RESUME 0
  PUSH_NULL
  LOAD_FAST cls
  LOAD_ATTR collection
  LOAD_ATTR find_one
  LOAD_FAST filter
  BUILD_LIST 1
  LOAD_FAST args
  LIST_EXTEND 1
  CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  RETURN_VALUE
END

def find_one(cls, filter=None, *args, **kwargs):
    """pass"""
    return cls.collection.find_one(filter, *args, **kwargs)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code find>
  MAKE_FUNCTION 0
  STORE_NAME find
  RETURN_CONST None
END
CODE find(cls, *args, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + list
  PUSH_NULL
  LOAD_FAST cls
  LOAD_ATTR collection
  LOAD_ATTR find
  LOAD_FAST args
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  CALL 1
  RETURN_VALUE
END

def find(cls, *args, **kwargs):
    """pass"""
    return list(cls.collection.find(*args, **kwargs))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code aggregate>
  MAKE_FUNCTION defaults
  STORE_NAME aggregate
  RETURN_CONST None
END
CODE aggregate(cls, pipeline, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + list
  PUSH_NULL
  LOAD_FAST cls
  LOAD_ATTR collection
  LOAD_ATTR aggregate
  LOAD_FAST pipeline
  COPY 1
  POP_JUMP_IF_TRUE L1
  POP_TOP
  BUILD_LIST 0
L1:
  BUILD_TUPLE 1
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  CALL 1
  RETURN_VALUE
END

def aggregate(cls, pipeline=None, **kwargs):
    """pass"""
    return list(cls.collection.aggregate(pipeline or [], **kwargs))


Input:
CODE <module>()
  DOC 'fn'
  RESUME 0
  LOAD_CONST 'fn'
  LOAD_NAME str
  LOAD_CONST 'return'
  LOAD_NAME Iterator
  LOAD_NAME Statement
  BINARY_SUBSCR
  BUILD_TUPLE 4
  LOAD_CONST <code in_file>
  MAKE_FUNCTION annotations
  STORE_NAME in_file
  RETURN_CONST None
END
CODE in_file(self, fn)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR __file_to_statements
  LOAD_ATTR NULL|self + get
  LOAD_FAST fn
  BUILD_LIST 0
  CALL 2
  GET_YIELD_FROM_ITER
  LOAD_CONST None
L2:
  SEND L5
L3:
  YIELD_VALUE 2
L4:
  RESUME 2
  JUMP_BACKWARD_NO_INTERRUPT L2
L5:
  END_SEND
  POP_TOP
  RETURN_CONST None
L6:
  CLEANUP_THROW
L7:
  JUMP_BACKWARD L5
L8:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L8 depth=0 lasti=True
  EXC try=L3..L4 -> handler=L6 depth=2 lasti=False
  EXC try=L4..L7 -> handler=L8 depth=0 lasti=True
END

def in_file(self, fn: str) -> Iterator[Statement]:
    """pass"""
    yield from self.__file_to_statements.get(fn, [])


Input:
CODE <module>()
  DOC 'line'
  RESUME 0
  LOAD_CONST 'line'
  LOAD_NAME FileLine
  LOAD_CONST 'return'
  LOAD_NAME Iterator
  LOAD_NAME Statement
  BINARY_SUBSCR
  BUILD_TUPLE 4
  LOAD_CONST <code at_line>
  MAKE_FUNCTION annotations
  STORE_NAME at_line
  RETURN_CONST None
END
CODE at_line(self, line)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST line
  LOAD_ATTR num
  STORE_FAST num
  LOAD_FAST self
  LOAD_ATTR NULL|self + in_file
  LOAD_FAST line
  LOAD_ATTR filename
  CALL 1
  GET_ITER
L2:
  FOR_ITER L5
  STORE_FAST stmt
  LOAD_FAST stmt
  LOAD_ATTR location
  LOAD_ATTR start
  LOAD_ATTR line
  LOAD_FAST num
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST stmt
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L5:
  END_FOR
  RETURN_CONST None
L6:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L6 depth=0 lasti=True
  EXC try=L4..L6 -> handler=L6 depth=0 lasti=True
END

def at_line(self, line: FileLine) -> Iterator[Statement]:
    """pass"""
    num = line.num
    for stmt in self.in_file(line.filename):
        if stmt.location.start.line == num:
            yield stmt


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (70,)
  LOAD_CONST <code wrap>
  MAKE_FUNCTION defaults
  STORE_NAME wrap
  RETURN_CONST None
END
CODE wrap(text, width, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + ParagraphWrapper
  LOAD_CONST ()
  LOAD_CONST 'width'
  LOAD_FAST width
  BUILD_MAP 1
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST w
  LOAD_FAST w
  LOAD_ATTR NULL|self + wrap
  LOAD_FAST text
  CALL 1
  RETURN_VALUE
END

def wrap(text, width=70, **kwargs):
    """pass"""
    w = ParagraphWrapper(width=width, **kwargs)
    return w.wrap(text)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (70,)
  LOAD_CONST <code fill>
  MAKE_FUNCTION defaults
  STORE_NAME fill
  RETURN_CONST None
END
CODE fill(text, width, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + ParagraphWrapper
  LOAD_CONST ()
  LOAD_CONST 'width'
  LOAD_FAST width
  BUILD_MAP 1
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST w
  LOAD_FAST w
  LOAD_ATTR NULL|self + fill
  LOAD_FAST text
  CALL 1
  RETURN_VALUE
END

def fill(text, width=70, **kwargs):
    """pass"""
    w = ParagraphWrapper(width=width, **kwargs)
    return w.fill(text)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code split>
  MAKE_FUNCTION 0
  STORE_NAME split
  RETURN_CONST None
END
CODE split(cls, text)
  DOC 'pass'
  RESUME 0
  LOAD_FAST cls
  LOAD_ATTR parasep_re
  LOAD_ATTR NULL|self + split
  LOAD_FAST text
  CALL 1
  GET_ITER
  LOAD_FAST_AND_CLEAR line
  SWAP 2
L1:
  BUILD_LIST 0
  SWAP 2
L2:
  FOR_ITER L3
  STORE_FAST line
  LOAD_FAST line
  LOAD_ATTR NULL|self + strip
  LOAD_CONST '\n'
  CALL 1
  LIST_APPEND 2
  JUMP_BACKWARD L2
L3:
  END_FOR
L4:
  STORE_FAST result
  STORE_FAST line
  LOAD_FAST result
  LOAD_CONST ''
  LOAD_CONST ''
  BUILD_LIST 2
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L5
  LOAD_CONST ''
  BUILD_LIST 1
  STORE_FAST result
L5:
  LOAD_FAST result
  RETURN_VALUE
L6:
  SWAP 2
  POP_TOP
  SWAP 2
  STORE_FAST line
  RERAISE 0
  EXC try=L1..L4 -> handler=L6 depth=2 lasti=False
END

def split(cls, text):
    """pass"""
    result = [line.strip('\n') for line in cls.parasep_re.split(text)]
    if result == ['', '']:
        result = ['']
    return result


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code wrap>
  MAKE_FUNCTION 0
  STORE_NAME wrap
  RETURN_CONST None
END
CODE wrap(self, text)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST lines
  LOAD_GLOBAL NULL + partial
  LOAD_GLOBAL textwrap
  LOAD_ATTR TextWrapper
  LOAD_ATTR wrap
  LOAD_FAST self
  CALL 2
  STORE_FAST linewrap
  LOAD_FAST self
  LOAD_ATTR NULL|self + split
  LOAD_FAST text
  CALL 1
  GET_ITER
L1:
  FOR_ITER L2
  STORE_FAST para
  LOAD_FAST lines
  LOAD_ATTR NULL|self + extend
  PUSH_NULL
  LOAD_FAST linewrap
  LOAD_FAST para
  CALL 1
  CALL 1
  POP_TOP
  LOAD_FAST lines
  LOAD_ATTR NULL|self + append
  LOAD_CONST ''
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L2:
  END_FOR
  LOAD_FAST lines
  LOAD_CONST None
  LOAD_CONST -1
  BINARY_SLICE
  STORE_FAST lines
  LOAD_FAST lines
  RETURN_VALUE
END

def wrap(self, text):
    """pass"""
    lines = []
    linewrap = partial(textwrap.TextWrapper.wrap, self)
    for para in self.split(text):
        lines.extend(linewrap(para))
        lines.append('')
    lines = lines[:-1]
    return lines


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code getSenderNumberMgtURL>
  MAKE_FUNCTION 0
  STORE_NAME getSenderNumberMgtURL
  RETURN_CONST None
END
CODE getSenderNumberMgtURL(self, CorpNum, UserID)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + _httpget
  LOAD_CONST '/FAX/?TG=SENDER'
  LOAD_FAST CorpNum
  LOAD_FAST UserID
  CALL 3
  STORE_FAST result
  LOAD_FAST result
  LOAD_ATTR url
  RETURN_VALUE
END

def getSenderNumberMgtURL(self, CorpNum, UserID):
    """pass"""
    result = self._httpget('/FAX/?TG=SENDER', CorpNum, UserID)
    return result.url


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code getUnitCost>
  MAKE_FUNCTION 0
  STORE_NAME getUnitCost
  RETURN_CONST None
END
CODE getUnitCost(self, CorpNum)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + _httpget
  LOAD_CONST '/FAX/UnitCost'
  LOAD_FAST CorpNum
  CALL 2
  STORE_FAST result
  LOAD_GLOBAL NULL + int
  LOAD_FAST result
  LOAD_ATTR unitCost
  CALL 1
  RETURN_VALUE
END

def getUnitCost(self, CorpNum):
    """pass"""
    result = self._httpget('/FAX/UnitCost', CorpNum)
    return int(result.unitCost)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code getFaxResult>
  MAKE_FUNCTION defaults
  STORE_NAME getFaxResult
  RETURN_CONST None
END
CODE getFaxResult(self, CorpNum, ReceiptNum, UserID)
  DOC 'pass'
  RESUME 0
  LOAD_FAST ReceiptNum
  LOAD_CONST None
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L1
  LOAD_GLOBAL NULL + len
  LOAD_FAST ReceiptNum
  CALL 1
  LOAD_CONST 18
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L2
L1:
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '접수번호가 올바르지 않습니다.'
  CALL 2
  RAISE_VARARGS 1
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + _httpget
  LOAD_CONST '/FAX/'
  LOAD_FAST ReceiptNum
  BINARY_OP +
  LOAD_FAST CorpNum
  LOAD_FAST UserID
  CALL 3
  RETURN_VALUE
END

def getFaxResult(self, CorpNum, ReceiptNum, UserID=None):
    """pass"""
    if ReceiptNum == None or len(ReceiptNum) != 18:
        raise PopbillException(-99999999, '접수번호가 올바르지 않습니다.')
    return self._httpget('/FAX/' + ReceiptNum, CorpNum, UserID)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code getFaxResultRN>
  MAKE_FUNCTION defaults
  STORE_NAME getFaxResultRN
  RETURN_CONST None
END
CODE getFaxResultRN(self, CorpNum, RequestNum, UserID)
  DOC 'pass'
  RESUME 0
  LOAD_FAST RequestNum
  LOAD_CONST None
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L1
  LOAD_FAST RequestNum
  LOAD_CONST ''
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L2
L1:
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '요청번호가 입력되지 않았습니다.'
  CALL 2
  RAISE_VARARGS 1
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + _httpget
  LOAD_CONST '/FAX/Get/'
  LOAD_FAST RequestNum
  BINARY_OP +
  LOAD_FAST CorpNum
  LOAD_FAST UserID
  CALL 3
  RETURN_VALUE
END

def getFaxResultRN(self, CorpNum, RequestNum, UserID=None):
    """pass"""
    if RequestNum == None or RequestNum == '':
        raise PopbillException(-99999999, '요청번호가 입력되지 않았습니다.')
    return self._httpget('/FAX/Get/' + RequestNum, CorpNum, UserID)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None, False, None, None)
  LOAD_CONST <code sendFax>
  MAKE_FUNCTION defaults
  STORE_NAME sendFax
  RETURN_CONST None
END
CODE sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST receivers
  LOAD_FAST receivers
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + FaxReceiver
  LOAD_FAST ReceiverNum
  LOAD_FAST ReceiverName
  KW_NAMES ('receiveNum', 'receiveName')
  CALL 2
  CALL 1
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + sendFax_multi
  LOAD_FAST CorpNum
  LOAD_FAST SenderNum
  LOAD_FAST receivers
  LOAD_FAST FilePath
  LOAD_FAST ReserveDT
  LOAD_FAST UserID
  LOAD_FAST SenderName
  LOAD_FAST adsYN
  LOAD_FAST title
  LOAD_FAST RequestNum
  CALL 10
  RETURN_VALUE
END

def sendFax(self, CorpNum, SenderNum, ReceiverNum, ReceiverName, FilePath, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):
    """pass"""
    receivers = []
    receivers.append(FaxReceiver(receiveNum=ReceiverNum, receiveName=ReceiverName))
    return self.sendFax_multi(CorpNum, SenderNum, receivers, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None, False, None, None)
  LOAD_CONST <code sendFax_multi>
  MAKE_FUNCTION defaults
  STORE_NAME sendFax_multi
  RETURN_CONST None
END
CODE sendFax_multi(self, CorpNum, SenderNum, Receiver, FilePath, ReserveDT, UserID, SenderName, adsYN, title, RequestNum)
  DOC 'pass'
  RESUME 0
  LOAD_FAST SenderNum
  LOAD_CONST None
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L1
  LOAD_FAST SenderNum
  LOAD_CONST ''
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L2
L1:
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '발신자 번호가 입력되지 않았습니다.'
  CALL 2
  RAISE_VARARGS 1
L2:
  LOAD_FAST Receiver
  LOAD_CONST None
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L3
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '수신자 정보가 입력되지 않았습니다.'
  CALL 2
  RAISE_VARARGS 1
L3:
  LOAD_GLOBAL NULL + type
  LOAD_FAST Receiver
  CALL 1
  LOAD_GLOBAL str
  IS_OP 0
  POP_JUMP_IF_TRUE L4
  LOAD_GLOBAL NULL + type
  LOAD_FAST Receiver
  CALL 1
  LOAD_GLOBAL FaxReceiver
  IS_OP 0
  POP_JUMP_IF_TRUE L4
  LOAD_GLOBAL NULL + type
  LOAD_FAST Receiver
  CALL 1
  LOAD_GLOBAL list
  IS_OP 0
  POP_JUMP_IF_TRUE L4
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST "'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'."
  CALL 2
  RAISE_VARARGS 1
L4:
  LOAD_FAST FilePath
  LOAD_CONST None
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L5
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '발신 파일경로가 입력되지 않았습니다.'
  CALL 2
  RAISE_VARARGS 1
L5:
  LOAD_GLOBAL NULL + type
  LOAD_FAST FilePath
  CALL 1
  LOAD_GLOBAL str
  IS_OP 0
  POP_JUMP_IF_TRUE L6
  LOAD_GLOBAL NULL + type
  LOAD_FAST FilePath
  CALL 1
  LOAD_GLOBAL list
  IS_OP 0
  POP_JUMP_IF_TRUE L6
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '발신 파일은 파일경로 또는 경로목록만 입력 가능합니다.'
  CALL 2
  RAISE_VARARGS 1
L6:
  LOAD_GLOBAL NULL + type
  LOAD_FAST FilePath
  CALL 1
  LOAD_GLOBAL list
  IS_OP 0
  POP_JUMP_IF_FALSE L8
  LOAD_GLOBAL NULL + len
  LOAD_FAST FilePath
  CALL 1
  LOAD_CONST 1
  COMPARE_OP <
  POP_JUMP_IF_TRUE L7
  LOAD_GLOBAL NULL + len
  LOAD_FAST FilePath
  CALL 1
  LOAD_CONST 20
  COMPARE_OP >
  POP_JUMP_IF_FALSE L8
L7:
  LOAD_GLOBAL NULL + PopbillException
  LOAD_CONST -99999999
  LOAD_CONST '파일은 1개 이상, 20개 까지 전송 가능합니다.'
  CALL 2
  RAISE_VARARGS 1
L8:
  LOAD_FAST SenderNum
  LOAD_FAST SenderName
  LOAD_GLOBAL NULL + type
  LOAD_FAST FilePath
  CALL 1
  LOAD_GLOBAL str
  IS_OP 0
  POP_JUMP_IF_FALSE L9
  LOAD_CONST 1
  JUMP_FORWARD L10
L9:
  LOAD_GLOBAL NULL + len
  LOAD_FAST FilePath
  CALL 1
L10:
  BUILD_LIST 0
  LOAD_CONST None
  LOAD_CONST ('snd', 'sndnm', 'fCnt', 'rcvs', 'sndDT')
  BUILD_CONST_KEY_MAP 5
  STORE_FAST req
  LOAD_GLOBAL NULL + type
  LOAD_FAST Receiver
  CALL 1
  LOAD_GLOBAL str
  IS_OP 0
  POP_JUMP_IF_FALSE L11
  LOAD_GLOBAL NULL + FaxReceiver
  LOAD_FAST Receiver
  KW_NAMES ('receiveNum',)
  CALL 1
  STORE_FAST Receiver
L11:
  LOAD_GLOBAL NULL + type
  LOAD_FAST Receiver
  CALL 1
  LOAD_GLOBAL FaxReceiver
  IS_OP 0
  POP_JUMP_IF_FALSE L12
  LOAD_FAST Receiver
  BUILD_LIST 1
  STORE_FAST Receiver
L12:
  LOAD_FAST adsYN
  POP_JUMP_IF_FALSE L13
  LOAD_CONST True
  LOAD_FAST req
  LOAD_CONST 'adsYN'
  STORE_SUBSCR
L13:
  LOAD_FAST Receiver
  GET_ITER
L14:
  FOR_ITER L15
  STORE_FAST r
  LOAD_FAST req
  LOAD_CONST 'rcvs'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + append
  LOAD_FAST r
  LOAD_ATTR receiveNum
  LOAD_FAST r
  LOAD_ATTR receiveName
  LOAD_CONST ('rcv', 'rcvnm')
  BUILD_CONST_KEY_MAP 2
  CALL 1
  POP_TOP
  JUMP_BACKWARD L14
L15:
  END_FOR
  LOAD_FAST ReserveDT
  LOAD_CONST None
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L16
  LOAD_FAST ReserveDT
  LOAD_FAST req
  LOAD_CONST 'sndDT'
  STORE_SUBSCR
L16:
  LOAD_FAST title
  LOAD_CONST None
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L17
  LOAD_FAST title
  LOAD_FAST req
  LOAD_CONST 'title'
  STORE_SUBSCR
L17:
  LOAD_FAST RequestNum
  LOAD_CONST None
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L18
  LOAD_FAST RequestNum
  LOAD_FAST req
  LOAD_CONST 'requestNum'
  STORE_SUBSCR
L18:
  LOAD_FAST self
  LOAD_ATTR NULL|self + _stringtify
  LOAD_FAST req
  CALL 1
  STORE_FAST postData
  LOAD_GLOBAL NULL + type
  LOAD_FAST FilePath
  CALL 1
  LOAD_GLOBAL str
  IS_OP 0
  POP_JUMP_IF_FALSE L19
  LOAD_FAST FilePath
  BUILD_LIST 1
  STORE_FAST FilePath
L19:
  BUILD_LIST 0
  STORE_FAST files
  LOAD_FAST FilePath
  GET_ITER
L20:
  FOR_ITER L23
  STORE_FAST filePath
  LOAD_GLOBAL NULL + open
  LOAD_FAST filePath
  LOAD_CONST 'rb'
  CALL 2
  BEFORE_WITH
L21:
  STORE_FAST f
  LOAD_FAST files
  LOAD_ATTR NULL|self + append
  LOAD_GLOBAL NULL + File
  LOAD_CONST 'file'
  LOAD_FAST f
  LOAD_ATTR name
  LOAD_FAST f
  LOAD_ATTR NULL|self + read
  CALL 0
  KW_NAMES ('fieldName', 'fileName', 'fileData')
  CALL 3
  CALL 1
  POP_TOP
L22:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  JUMP_BACKWARD L20
L23:
  END_FOR
  LOAD_FAST self
  LOAD_ATTR NULL|self + _httppost_files
  LOAD_CONST '/FAX'
  LOAD_FAST postData
  LOAD_FAST files
  LOAD_FAST CorpNum
  LOAD_FAST UserID
  CALL 5
  STORE_FAST result
  LOAD_FAST result
  LOAD_ATTR receiptNum
  RETURN_VALUE
L24:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L25
  RERAISE 2
L25:
  POP_TOP
L26:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  JUMP_BACKWARD L20
L27:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L21..L22 -> handler=L24 depth=2 lasti=True
  EXC try=L24..L26 -> handler=L27 depth=4 lasti=True
END

def sendFax_multi(self, CorpNum, SenderNum, Receiver, FilePath, ReserveDT=None, UserID=None, SenderName=None, adsYN=False, title=None, RequestNum=None):
    """pass"""
    if SenderNum == None or SenderNum == '':
        raise PopbillException(-99999999, '발신자 번호가 입력되지 않았습니다.')
    if Receiver == None:
        raise PopbillException(-99999999, '수신자 정보가 입력되지 않았습니다.')
    if not (type(Receiver) is str or type(Receiver) is FaxReceiver or type(Receiver) is list):
        raise PopbillException(-99999999, "'Receiver' argument type error. 'FaxReceiver' or List of 'FaxReceiver'.")
    if FilePath == None:
        raise PopbillException(-99999999, '발신 파일경로가 입력되지 않았습니다.')
    if not (type(FilePath) is str or type(FilePath) is list):
        raise PopbillException(-99999999, '발신 파일은 파일경로 또는 경로목록만 입력 가능합니다.')
    if type(FilePath) is list and (len(FilePath) < 1 or len(FilePath) > 20):
        raise PopbillException(-99999999, '파일은 1개 이상, 20개 까지 전송 가능합니다.')
    req = {'snd': SenderNum, 'sndnm': SenderName, 'fCnt': 1 if type(FilePath) is str else len(FilePath), 'rcvs': [], 'sndDT': None}
    if type(Receiver) is str:
        Receiver = FaxReceiver(receiveNum=Receiver)
    if type(Receiver) is FaxReceiver:
        Receiver = [Receiver]
    if adsYN:
        req['adsYN'] = True
    for r in Receiver:
        req['rcvs'].append({'rcv': r.receiveNum, 'rcvnm': r.receiveName})
    if ReserveDT != None:
        req['sndDT'] = ReserveDT
    if title != None:
        req['title'] = title
    if RequestNum != None:
        req['requestNum'] = RequestNum
    postData = self._stringtify(req)
    if type(FilePath) is str:
        FilePath = [FilePath]
    files = []
    for filePath in FilePath:
        with open(filePath, 'rb') as f:
            files.append(File(fieldName='file', fileName=f.name, fileData=f.read()))
    result = self._httppost_files('/FAX', postData, files, CorpNum, UserID)
    return result.receiptNum


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code model_node>
  MAKE_FUNCTION 0
  STORE_NAME model_node
  RETURN_CONST None
END
CODE model_node(**kwargs)
  DOC 'pass'
  MAKE_CELL kwargs
  RESUME 0
  LOAD_DEREF kwargs
  LOAD_ATTR NULL|self + setdefault
  LOAD_CONST 'default'
  BUILD_MAP 0
  CALL 2
  POP_TOP
  LOAD_CLOSURE kwargs
  BUILD_TUPLE 1
  LOAD_CONST <code model_node.<locals>.decorator>
  MAKE_FUNCTION closure
  STORE_FAST decorator
  LOAD_FAST decorator
  RETURN_VALUE
END
CODE model_node.<locals>.decorator(model)
  COPY_FREE_VARS 1
  RESUME 0
  LOAD_GLOBAL NULL + types
  LOAD_ATTR ModelType
  LOAD_FAST model
  BUILD_TUPLE 1
  BUILD_MAP 0
  LOAD_DEREF kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  RETURN_VALUE
END

def model_node(**kwargs):
    """pass"""
    kwargs.setdefault('default', {})

    def decorator(model):
        return types.ModelType(model, **kwargs)
    return decorator


Input:
CODE <module>()
  DOC 'latitude'
  RESUME 0
  LOAD_CONST 'latitude'
  LOAD_NAME float
  LOAD_CONST 'longitude'
  LOAD_NAME float
  LOAD_CONST 'return'
  LOAD_NAME dict
  BUILD_TUPLE 6
  LOAD_CONST <code status_by_coordinates>
  MAKE_FUNCTION annotations
  STORE_NAME status_by_coordinates
  RETURN_CONST None
END
CODE status_by_coordinates(self, latitude, longitude)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + nearest_by_coordinates
  LOAD_FAST latitude
  LOAD_FAST longitude
  CALL 2
  GET_AWAITABLE 0
  LOAD_CONST None
L2:
  SEND L5
L3:
  YIELD_VALUE 2
L4:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L2
L5:
  END_SEND
  RETURN_VALUE
L6:
  CLEANUP_THROW
L7:
  JUMP_BACKWARD L5
L8:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L8 depth=0 lasti=True
  EXC try=L3..L4 -> handler=L6 depth=2 lasti=False
  EXC try=L4..L7 -> handler=L8 depth=0 lasti=True
END

async def status_by_coordinates(self, latitude: float, longitude: float) -> dict:
    """pass"""
    return await self.nearest_by_coordinates(latitude, longitude)


Input:
CODE <module>()
  DOC 'zip_code'
  RESUME 0
  LOAD_CONST 'zip_code'
  LOAD_NAME str
  LOAD_CONST 'return'
  LOAD_NAME dict
  BUILD_TUPLE 4
  LOAD_CONST <code status_by_zip>
  MAKE_FUNCTION annotations
  STORE_NAME status_by_zip
  RETURN_CONST None
END
CODE status_by_zip(self, zip_code)
  DOC 'pass'
  MAKE_CELL zip_code
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
L2:
  NOP
L3:
  LOAD_GLOBAL NULL + next
  LOAD_CLOSURE zip_code
  BUILD_TUPLE 1
  LOAD_CONST <code status_by_zip.<locals>.<genexpr>>
  MAKE_FUNCTION closure
  LOAD_FAST self
  LOAD_ATTR NULL|self + user_reports
  CALL 0
  GET_AWAITABLE 0
  LOAD_CONST None
L4:
  SEND L7
L5:
  YIELD_VALUE 3
L6:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L4
L7:
  END_SEND
  GET_ITER
  CALL 0
  CALL 1
  STORE_FAST location
L8:
  LOAD_FAST self
  LOAD_ATTR NULL|self + status_by_coordinates
  LOAD_GLOBAL NULL + float
  LOAD_FAST location
  LOAD_CONST 'latitude'
  BINARY_SUBSCR
  CALL 1
  LOAD_GLOBAL NULL + float
  LOAD_FAST location
  LOAD_CONST 'longitude'
  BINARY_SUBSCR
  CALL 1
  CALL 2
  GET_AWAITABLE 0
  LOAD_CONST None
L9:
  SEND L12
L10:
  YIELD_VALUE 2
L11:
  RESUME 3
  JUMP_BACKWARD_NO_INTERRUPT L9
L12:
  END_SEND
  RETURN_VALUE
L13:
  CLEANUP_THROW
L14:
  JUMP_BACKWARD L7
L15:
  PUSH_EXC_INFO
  LOAD_GLOBAL StopIteration
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L17
  POP_TOP
  BUILD_MAP 0
  SWAP 2
L16:
  POP_EXCEPT
  RETURN_VALUE
L17:
  RERAISE 0
L18:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L19:
  CLEANUP_THROW
L20:
  JUMP_BACKWARD L12
L21:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L2 -> handler=L21 depth=0 lasti=True
  EXC try=L3..L5 -> handler=L15 depth=0 lasti=False
  EXC try=L5..L6 -> handler=L13 depth=5 lasti=False
  EXC try=L6..L8 -> handler=L15 depth=0 lasti=False
  EXC try=L8..L10 -> handler=L21 depth=0 lasti=True
  EXC try=L10..L11 -> handler=L19 depth=2 lasti=False
  EXC try=L11..L13 -> handler=L21 depth=0 lasti=True
  EXC try=L13..L14 -> handler=L15 depth=0 lasti=False
  EXC try=L15..L16 -> handler=L18 depth=1 lasti=True
  EXC try=L16..L17 -> handler=L21 depth=0 lasti=True
  EXC try=L17..L18 -> handler=L18 depth=1 lasti=True
  EXC try=L18..L20 -> handler=L21 depth=0 lasti=True
END
CODE status_by_zip.<locals>.<genexpr>(.0)
  DOC 'zip'
  COPY_FREE_VARS 1
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST .0
L2:
  FOR_ITER L5
  STORE_FAST d
  LOAD_FAST d
  LOAD_CONST 'zip'
  BINARY_SUBSCR
  LOAD_DEREF zip_code
  COMPARE_OP ==
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST d
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L5:
  END_FOR
  RETURN_CONST None
L6:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L6 depth=0 lasti=True
  EXC try=L4..L6 -> handler=L6 depth=0 lasti=True
END

async def status_by_zip(self, zip_code: str) -> dict:
    """pass"""
    try:
        location = next((d for d in await self.user_reports() if d['zip'] == zip_code))
    except StopIteration:
        return {}
    return await self.status_by_coordinates(float(location['latitude']), float(location['longitude']))


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code print_request>
  MAKE_FUNCTION 0
  STORE_NAME print_request
  RETURN_CONST None
END
CODE print_request(request)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + print
  LOAD_CONST '{}\n{}\n{}\n\n{}'
  LOAD_ATTR NULL|self + format
  LOAD_CONST '-----------START-----------'
  LOAD_FAST request
  LOAD_ATTR method
  LOAD_CONST ' '
  BINARY_OP +
  LOAD_FAST request
  LOAD_ATTR url
  BINARY_OP +
  LOAD_CONST '\n'
  LOAD_ATTR NULL|self + join
  LOAD_CONST <code print_request.<locals>.<genexpr>>
  MAKE_FUNCTION 0
  LOAD_FAST request
  LOAD_ATTR headers
  LOAD_ATTR NULL|self + items
  CALL 0
  GET_ITER
  CALL 0
  CALL 1
  LOAD_FAST request
  LOAD_ATTR body
  CALL 4
  CALL 1
  POP_TOP
  RETURN_CONST None
END
CODE print_request.<locals>.<genexpr>(.0)
  DOC '{}: {}'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST .0
L2:
  FOR_ITER L3
  UNPACK_SEQUENCE 2
  STORE_FAST k
  STORE_FAST v
  LOAD_CONST '{}: {}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST k
  LOAD_FAST v
  CALL 2
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L3:
  END_FOR
  RETURN_CONST None
L4:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L4 -> handler=L4 depth=0 lasti=True
END

def print_request(request):
    """pass"""
    print('{}\n{}\n{}\n\n{}'.format('-----------START-----------', request.method + ' ' + request.url, '\n'.join(('{}: {}'.format(k, v) for k, v in request.headers.items())), request.body))