Пример #1
0
def ToRest(import_name):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, '%s.pkl' % import_name)

    pf = PickleFile(pickle_file)
    library_class = pf.read()

    pf = PickleFile(os.path.join(sphinxDir, 'class_summary.pkl'))
    class_summary = pf.read()

    library_class.Walk(library_class, class_summary)
Пример #2
0
def ToRest(import_name):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, '%s.pkl' % import_name)

    pf = PickleFile(pickle_file)
    library_class = pf.read()

    pf = PickleFile(os.path.join(sphinxDir, 'class_summary.pkl'))
    class_summary = pf.read()

    library_class.Walk(library_class, class_summary)
Пример #3
0
def ToRest(import_name):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, 'wx%s.pkl' % import_name)

    fid = open(pickle_file, 'rb')
    library_class = pickle.load(fid)
    fid.close()

    fid = open(os.path.join(sphinxDir, 'class_summary.lst'), 'rb')
    class_summary = pickle.load(fid)
    fid.close()

    library_class.Walk(library_class, class_summary)
Пример #4
0
def ToRest(import_name):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, 'wx%s.pkl'%import_name)

    fid = open(pickle_file, 'rb')
    library_class = pickle.load(fid)
    fid.close()

    fid = open(os.path.join(sphinxDir, 'class_summary.lst'), 'rb')
    class_summary = pickle.load(fid)
    fid.close()

    library_class.Walk(library_class, class_summary)
Пример #5
0
def ToRest(import_name):

    sphinxDir = os.path.join(phoenixDir(), "docs", "sphinx")
    pickle_file = os.path.join(sphinxDir, "wx%s.pkl" % import_name)

    fid = open(pickle_file, "rb")
    library_class = pickle.load(fid)
    fid.close()

    fid = open(os.path.join(sphinxDir, "class_summary.lst"), "rb")
    class_summary = pickle.load(fid)
    fid.close()

    library_class.Walk(library_class, class_summary)
Пример #6
0
def Class2Module():

    global ALL_ITEMS

    if ALL_ITEMS:
        return ALL_ITEMS

    etg_files = glob.glob(os.path.join(phoenixDir(), 'etg') + '/*.py')
    etg_files = [files for files in etg_files if not files.startswith('_')]

    for files in etg_files:
        split = os.path.split(os.path.splitext(files)[0])[1]
        module = imp.load_source(split, files)

        current_module = MODULENAME_REPLACE.get(module.MODULE, '')

        for item in module.ITEMS:

            item = RemoveWxPrefix(item)
            ALL_ITEMS[item] = current_module

    ALL_ITEMS.update(NO_MODULE)

    return ALL_ITEMS
Пример #7
0
def Class2Module():

    global ALL_ITEMS

    if ALL_ITEMS:
        return ALL_ITEMS

    etg_files = glob.glob(os.path.join(phoenixDir(), "etg") + "/*.py")
    etg_files = [files for files in etg_files if not files.startswith("_")]

    for files in etg_files:
        split = os.path.split(os.path.splitext(files)[0])[1]
        module = imp.load_source(split, files)

        current_module = MODULENAME_REPLACE.get(module.MODULE, "")

        for item in module.ITEMS:

            item = RemoveWxPrefix(item)
            ALL_ITEMS[item] = current_module

    ALL_ITEMS.update(NO_MODULE)

    return ALL_ITEMS
Пример #8
0
    '_webkit': 'wx.webkit.',
    '_media': 'wx.media.',
    '_msw': 'wx.msw.',
    '_ribbon': 'wx.ribbon.',
    '_propgrid': 'wx.propgrid.',
    '_aui': 'wx.aui.',
}

# Other C++ specific things to strip away
CPP_ITEMS = ['*', '&', 'const', 'unsigned', '(size_t)', 'size_t', 'void']

# Series of paths containing the input data for Sphinx and for the scripts
# building the ReST docs:

# The location of the Phoenix main folder
PHOENIXROOT = phoenixDir()

# The location of the Sphinx main folder
SPHINXROOT = os.path.join(PHOENIXROOT, 'docs', 'sphinx')

# Where the snippets found in the XML docstrings live (There are C++, unconverted and
# converted Python snippets in 3 sub-folders
SNIPPETROOT = os.path.join(SPHINXROOT, 'rest_substitutions', 'snippets')

# A folder where some of the difficult-to-translate-to-ReST tables are. There are 4 of
# them up to now, for various reasons:
# 1. The wx.Sizer flags table is a grid table, very difficult to ReSTify automatically
# 2. The wx.ColourDatabase table of colour comes up all messy when ReSTified from XML
# 3. The "wxWidgets 2.8 Compatibility Functions" table for wx.VScrolledWindow
# 4. The wx.ArtProvider table
TABLEROOT = os.path.join(SPHINXROOT, 'rest_substitutions', 'tables')
Пример #9
0
                      '_media'   : 'wx.media.',
                      '_msw'     : 'wx.msw.',
                      '_ribbon'  : 'wx.ribbon.',
                      '_propgrid': 'wx.propgrid.',
                      '_aui'     : 'wx.aui.',
                      }


# Other C++ specific things to strip away
CPP_ITEMS = ['*', '&', 'const', 'unsigned', '(size_t)', 'size_t', 'void']

# Series of paths containing the input data for Sphinx and for the scripts
# building the ReST docs:

# The location of the Phoenix main folder
PHOENIXROOT          = phoenixDir()

# The location of the Sphinx main folder
SPHINXROOT           = os.path.join(PHOENIXROOT, 'docs', 'sphinx')

# Where the snippets found in the XML docstrings live (There are C++, unconverted and
# converted Python snippets in 3 sub-folders
SNIPPETROOT          = os.path.join(SPHINXROOT,  'rest_substitutions', 'snippets')

# A folder where some of the difficult-to-translate-to-ReST tables are. There are 4 of
# them up to now, for various reasons:
# 1. The wx.Sizer flags table is a grid table, very difficult to ReSTify automatically
# 2. The wx.ColourDatabase table of colour comes up all messy when ReSTified from XML
# 3. The "wxWidgets 2.8 Compatibility Functions" table for wx.VScrolledWindow
# 4. The wx.ArtProvider table
TABLEROOT            = os.path.join(SPHINXROOT,  'rest_substitutions', 'tables')
Пример #10
0
def ModuleHunter(init_name, import_name, version):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, '%s.pkl' % import_name)

    # TODO: instead of just skipping to generating the ReST files, do some
    # dependency checking and rescan those files that are newer than the
    # pickle file.
    if os.path.isfile(pickle_file):
        ToRest(import_name)
        return

    directory, module_name = os.path.split(init_name)
    path = list(sys.path)

    mainmod = Import(init_name, import_name)

    if mainmod is None:
        return

    message = "Importing main library '%s'..." % import_name
    print('Message: %s' % message)

    module_name = os.path.splitext(getfile(mainmod))[0] + '.py'
    contents = open(module_name, 'rt').read()
    constants = CONSTANT_RE.findall(contents)

    library_class, count = describe_module(mainmod,
                                           kind=object_types.LIBRARY,
                                           constants=constants)
    library_class.name = '%s-%s' % (import_name, version)

    message = "Main library '%s' imported..." % library_class.name
    print('Message: %s' % message)

    message = "Importing sub-modules and sub-packages...\n"
    print('Message: %s' % message)

    looped_names = []
    ancestors_dict = {import_name: library_class}

    for importer, module_name, ispkg in pkgutil.walk_packages(
            path=[directory], prefix=import_name + '.',
            onerror=lambda x: None):
        import_string = module_name
        splitted = module_name.split('.')

        fromlist = splitted[-1]
        parent_name = '.'.join(splitted[0:-1])

        parent_class = ancestors_dict[parent_name]
        module_class, count = SubImport(import_string, fromlist, parent_class,
                                        ispkg)

        if module_class is None:
            continue

        looped_names = PrintProgress(module_name, looped_names)

        if module_name not in ancestors_dict:
            ancestors_dict[module_name] = module_class

    major, minor, micro, release = sys.version_info[0:-1]
    pythonVersion = '%d.%d.%d-%s' % (major, minor, micro, release)

    library_class.python_version = pythonVersion
    library_class.Save()

    sys.path[:] = path  # restore

    pf = PickleFile(pickle_file)
    pf.write(library_class)

    ToRest(import_name)
Пример #11
0
def ModuleHunter(init_name, import_name, version):

    sphinxDir = os.path.join(phoenixDir(), 'docs', 'sphinx')
    pickle_file = os.path.join(sphinxDir, '%s.pkl' % import_name)

    # TODO: instead of just skipping to generating the ReST files, do some
    # dependency checking and rescan those files that are newer than the
    # pickle file.
    if os.path.isfile(pickle_file):
        ToRest(import_name)
        return

    directory, module_name = os.path.split(init_name)
    path = list(sys.path)
    
    mainmod = Import(init_name, import_name)

    if mainmod is None:
        return
    
    message = "Importing main library '%s'..." % import_name
    print('Message: %s' % message)

    module_name = os.path.splitext(getfile(mainmod))[0] + '.py'
    contents = open(module_name, 'rt').read()
    constants = CONSTANT_RE.findall(contents)

    library_class, count = describe_module(mainmod, kind=object_types.LIBRARY, constants=constants)
    library_class.name = '%s-%s'%(import_name, version)

    message = "Main library '%s' imported..." % library_class.name
    print('Message: %s' % message)
    
    message = "Importing sub-modules and sub-packages...\n"    
    print('Message: %s' % message)

    looped_names = []
    ancestors_dict = {import_name: library_class}
    
    for importer, module_name, ispkg in pkgutil.walk_packages(path=[directory],
                                                              prefix=import_name+'.',
                                                              onerror=lambda x: None):
        import_string = module_name
        splitted = module_name.split('.')

        fromlist = splitted[-1]
        parent_name = '.'.join(splitted[0:-1])
        
        parent_class = ancestors_dict[parent_name]
        module_class, count = SubImport(import_string, fromlist, parent_class, ispkg)

        if module_class is None:
            continue
        
        looped_names = PrintProgress(module_name, looped_names)
        
        if module_name not in ancestors_dict:
            ancestors_dict[module_name] = module_class

    major, minor, micro, release = sys.version_info[0:-1]
    pythonVersion = '%d.%d.%d-%s'%(major, minor, micro, release)

    library_class.python_version = pythonVersion
    library_class.Save()

    sys.path[:] = path # restore

    pf = PickleFile(pickle_file)
    pf.write(library_class)

    ToRest(import_name)
Пример #12
0
def ModuleHunter(init_name, import_name, version):

    sphinxDir = os.path.join(phoenixDir(), "docs", "sphinx")
    pickle_file = os.path.join(sphinxDir, "wx%s.pkl" % import_name)

    if os.path.isfile(pickle_file):
        ToRest(import_name)
        return

    path = list(sys.path)

    directory, module_name = os.path.split(init_name)
    path = list(sys.path)

    mainmod = Import(init_name, import_name)

    if mainmod is None:
        return

    message = "Importing main library '%s'..." % import_name
    print(("Message: %s" % message))

    module_name = os.path.splitext(getfile(mainmod))[0] + ".py"
    contents = open(module_name, "rt").read()
    constants = CONSTANT_RE.findall(contents)

    library_class, count = describe_module(mainmod, kind=object_types.LIBRARY, constants=constants)
    library_class.name = "%s-%s" % (import_name, version)

    message = "Main library '%s' imported..." % library_class.name
    print(("Message: %s" % message))

    message = "Importing sub-modules and sub-packages...\n"
    print(("Message: %s" % message))

    looped_names = []
    ancestors_dict = {import_name: library_class}

    for importer, module_name, ispkg in pkgutil.walk_packages(
        path=[directory], prefix=import_name + ".", onerror=lambda x: None
    ):

        import_string = module_name
        splitted = module_name.split(".")

        fromlist = splitted[-1]
        parent_name = ".".join(splitted[0:-1])

        parent_class = ancestors_dict[parent_name]
        module_class, count = SubImport(import_string, fromlist, parent_class, ispkg)

        if module_class is None:
            continue

        looped_names = PrintProgress(module_name, looped_names)

        if module_name not in ancestors_dict:
            ancestors_dict[module_name] = module_class

    major, minor, micro, release = sys.version_info[0:-1]
    pythonVersion = "%d.%d.%d-%s" % (major, minor, micro, release)

    library_class.python_version = pythonVersion
    library_class.Save()

    sys.path[:] = path  # restore

    fid = open(pickle_file, "wb")
    pickle.dump(library_class, fid)
    fid.close()

    ToRest(import_name)