# Path: corpkit/constants.py
# STRINGTYPE = str if PYTHON_VERSION == 3 else basestring
# 
# PYTHON_VERSION = sys.version_info.major
# 
# INPUTFUNC = input if PYTHON_VERSION == 3 else raw_input


from corpkit.constants import STRINGTYPE, PYTHON_VERSION, INPUTFUNC
    from corpkit.interrogation import Interrogation
            from corpkit.other import load
            from corpkit.other import load
    from time import localtime, strftime
    from corpkit.process import makesafe, sanitise_dict
    from corpkit.interrogation import Interrogation
    from corpkit.corpus import Corpus, Datalist
            from types import ModuleType, FunctionType, BuiltinMethodType, BuiltinFunctionType
    from corpkit.other import load
    from time import strftime, localtime
    from time import localtime, strftime
    from other import load
    from process import makesafe
    from interrogation import Interrodict
    from corpkit.constants import transshow, transobjs
    from corpkit.interrogation import Interrodict, Interrogation
    from corpkit.interrogation import Interrogation, Interrodict
    import corpkit
    import pandas as pd
    import numpy as np
    import os
    import corpkit
    import corpkit
    import pandas as pd
        import os
        import os
        import cPickle as pickle
        import pickle as pickle
    import os
    import corpkit
        import cPickle as pickle
        import pickle as pickle
    import os
    import glob
    import os
    import corpkit
    import corpkit
    import os
    import shutil
    import stat
    import platform
        import os
    import os
    import corpkit
    import pandas as pd
    import corpkit
    import re
    import numpy as np
    import pandas as pd
    import corpkit
        import pandas as pd
        import numpy as np
    import corpkit
    import pandas as pd
    :param only_concs: Set to True if loading concordance lines
    :type only_concs: bool

    :returns: loaded data
    """    
    try:
    except ImportError:
    if not savename.endswith('.p'):
        savename = savename + '.p'

    if loaddir:
        if '/' not in savename:
            fullpath = os.path.join(loaddir, savename)
        else:
            fullpath = savename
    else:
        fullpath = savename

    with open(fullpath, 'rb') as fo:
        data = pickle.load(fo)
    return data

def loader(savedir='saved_interrogations'):
    """Show a list of data that can be loaded, and then load by user input of index"""
    fs = [i for i in glob.glob(r'%s/*' % savedir) if not os.path.basename(i).startswith('.')]
    string_to_show = '\nFiles in %s:\n' % savedir
    most_digits = max([len(str(i)) for i, j in enumerate(fs)])
    for index, fname in enumerate(fs):
        string_to_show += str(index).rjust(most_digits) + ':\t' + os.path.basename(fname) + '\n'
    print(string_to_show)

# Path: corpkit/constants.py
# STRINGTYPE = str if PYTHON_VERSION == 3 else basestring
# 
# PYTHON_VERSION = sys.version_info.major
# 
# INPUTFUNC = input if PYTHON_VERSION == 3 else raw_input


# Path: corpkit/other.py
from corpkit.constants import STRINGTYPE, PYTHON_VERSION, INPUTFUNC
    from corpkit.interrogation import Interrogation
            from corpkit.other import load
            from corpkit.other import load
    from time import localtime, strftime
    from corpkit.process import makesafe, sanitise_dict
    from corpkit.interrogation import Interrogation
    from corpkit.corpus import Corpus, Datalist
            from types import ModuleType, FunctionType, BuiltinMethodType, BuiltinFunctionType
    from corpkit.other import load
    from time import strftime, localtime
    from time import localtime, strftime
    from other import load
    from process import makesafe
    from interrogation import Interrodict
    from corpkit.constants import transshow, transobjs
    from corpkit.interrogation import Interrodict, Interrogation
    from corpkit.interrogation import Interrogation, Interrodict
    import corpkit
    import pandas as pd
    import numpy as np
    import os
    import corpkit
    import corpkit
    import pandas as pd
        import os
        import os
        import cPickle as pickle
        import pickle as pickle
    import os
    import corpkit
        import cPickle as pickle
        import pickle as pickle
    import os
    import glob
    import os
    import corpkit
    import corpkit
    import os
    import shutil
    import stat
    import platform
        import os
    import os
    import corpkit
    import pandas as pd
    import corpkit
    import re
    import numpy as np
    import pandas as pd
    import corpkit
        import pandas as pd
        import numpy as np
    import corpkit
    import pandas as pd

    :param only_concs: Set to True if loading concordance lines
    :type only_concs: bool

    :returns: loaded data
    """    
    try:
    except ImportError:
    if not savename.endswith('.p'):
        savename = savename + '.p'

    if loaddir:
        if '/' not in savename:
            fullpath = os.path.join(loaddir, savename)
        else:
            fullpath = savename
    else:
        fullpath = savename

    with open(fullpath, 'rb') as fo:
        data = pickle.load(fo)
    return data

def loader(savedir='saved_interrogations'):
    """Show a list of data that can be loaded, and then load by user input of index"""
    fs = [i for i in glob.glob(r'%s/*' % savedir) if not os.path.basename(i).startswith('.')]
    string_to_show = '\nFiles in %s:\n' % savedir
    most_digits = max([len(str(i)) for i, j in enumerate(fs)])
    for index, fname in enumerate(fs):
        string_to_show += str(index).rjust(most_digits) + ':\t' + os.path.basename(fname) + '\n'
    print(string_to_show)

    INPUTFUNC('Enter index of item to load: ')