<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Construct source for module docs similarly to sphinx.ext.autosummary."""

import sys
import os
import pkgutil
import inspect
import importlib
from types import CodeType

from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment

from sphinx.ext.autosummary.generate import _underline
from sphinx.util.rst import escape as rst_escape

from callgraph import is_newer_than


# Disable nested Options class name fix hack
import sporco.common
def _fix_disable(cls, nstnm):
    return cls
co = sporco.common._fix_nested_class_lookup.__code__
sporco.common._fix_nested_class_lookup.__code__ = CodeType(
    co.co_argcount, co.co_kwonlyargcount, co.co_nlocals,
    co.co_stacksize, co.co_flags, _fix_disable.__code__.co_code,
    co.co_consts, co.co_names, co.co_varnames, co.co_filename,
    co.co_name, co.co_firstlineno, co.co_lnotab, co.co_freevars,
    co.co_cellvars)



def sort_by_list_order(sortlist, reflist, reverse=False, fltr=False,
                       slemap=None):
    """
    Sort a list according to the order of entries in a reference list.

    Parameters
    ----------
    sortlist : list
      List to be sorted
    reflist : list
      Reference list defining sorting order
    reverse : bool, optional (default False)
      Flag indicating whether to sort in reverse order
    fltr : bool, optional (default False)
      Flag indicating whether to filter `sortlist` to remove any entries<commit_msg>Support changes in Python 3.8<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Construct source for module docs similarly to sphinx.ext.autosummary."""

import sys
import os
import pkgutil
import inspect
import importlib
from types import CodeType

from jinja2 import FileSystemLoader
from jinja2.sandbox import SandboxedEnvironment

from sphinx.ext.autosummary.generate import _underline
from sphinx.util.rst import escape as rst_escape

from callgraph import is_newer_than


# Disable nested Options class name fix hack
import sporco.common
def _fix_disable(cls, nstnm):
    return cls
co = sporco.common._fix_nested_class_lookup.__code__
coattr = [co.co_argcount,]
if hasattr(co, 'co_posonlyargcount'):
    coattr.append(co.co_posonlyargcount)
coattr.extend([co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
               co.co_flags, _fix_disable.__code__.co_code, co.co_consts,
               co.co_names, co.co_varnames, co.co_filename, co.co_name,
               co.co_firstlineno, co.co_lnotab, co.co_freevars,
               co.co_cellvars])
sporco.common._fix_nested_class_lookup.__code__ = CodeType(*coattr)



def sort_by_list_order(sortlist, reflist, reverse=False, fltr=False,
                       slemap=None):
    """
    Sort a list according to the order of entries in a reference list.

    Parameters
    ----------
    sortlist : list
      List to be sorted
    reflist : list
      Reference list defining sorting order
    reverse : bool, optional (default False)
      Flag indicating whether to sort in reverse order
    fltr : bool, optional (default False)
      Flag indicating whether to filter `sortlist` to remove any entries
{'fraction_non_alphanumeric': 0.07779171894604768, 'fraction_numerical': 0.002509410288582183, 'mean_word_length': 3.5884892086330935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4194797', 'n_tokens_mistral': 1012, 'n_tokens_neox': 976, 'n_words': 292}