示例#1
0
def FormatMarkdown():
    global DIR_html

    FILE_index = ConcatPaths((DIR_html, 'index.html'))

    if os.path.isfile(FILE_index):
        print('Formatting markdown ...')

        FILE_BUFFER = open(FILE_index, 'r')
        text = FILE_BUFFER.read()
        FILE_BUFFER.close()

        # Bold & italic text
        new_text = re.sub(r'\*\*\*(.*?)\*\*\*', r'<b><i>\1</i></b>', text)
        new_text = re.sub(r'\*\*(.*?)\*\*', r'<b>\1</b>', new_text)
        new_text = re.sub(r'\*(.*?)\*', r'<i>\1</i>', new_text)

        # Anchors
        lines = new_text.split('\n')
        for INDEX in range(len(lines)):
            LINE = lines[INDEX]

            if '<h3>' in LINE:
                name = LINE.strip(' \t><').replace(
                    '><',
                    '').split('>')[-1].split('<')[0].lower().replace(' ', '-')

                LINE = LINE.replace('<h3>', '<h3 id="{}">'.format(name))
                if LINE != lines[INDEX]:
                    lines[INDEX] = LINE

        new_text = '\n'.join(lines)

        if new_text != text:
            FILE_BUFFER = open(FILE_index, 'w')
            FILE_BUFFER.write(new_text)
            FILE_BUFFER.close()

            return True

    else:
        print('ERROR: Index file not found: {}'.format(FILE_index))

    return False
示例#2
0
# Characters/Strings to be replaced in source code
# 
#    original: (replacement, (exclude-file-list))
replacements = {
    ' -> ': (' ➜ ', ('build', 'files',)),
    ' (C) ': (' © ',),
    ' (c) ': (' © ',),
    ' **bullet**': ('•',),
    }

# For running test without risk of making changes to regular files
TESTING = False

if TESTING:
    test_file = ConcatPaths(DIR_root, 'test.py')
    
    if not os.path.isfile(test_file):
        FILE_BUFFER = open(test_file, 'w')
        FILE_BUFFER.write('\n\
arrow1 = \' -> "sub-sub"\'\n\n\
arrow2 = \'  -> \'\n\n\
arrow3 = \' ->\'\n\n\
arrow4 = \'-> \'\n\n\
arrow5 = "  ->  \\\'\\\'"\n\n\
arrow6 = arrow5\n\n\
arrow7 = "->   \\r  "\n\n\
finaltest = " - outer-pre - \\" - inner - \\" - outer-pro - "\n')
        FILE_BUFFER.close()
    
    # Replaceable string for testing
示例#3
0
from scripts_globals import ConcatPaths
from scripts_globals import GetInfoValue
from scripts_globals import required_locale_files
from scripts_globals import DIR_root


# FIXME: This script used the deprecated module 'commands'


for F in required_locale_files:
	if not os.path.isfile(F):
		print('[ERROR] Required file not found: {}'.format(F))
		sys.exit(errno.ENOENT)

DIR_locale = ConcatPaths(DIR_root, 'locale')

if not os.path.isdir(DIR_locale):
	print('ERROR: Locale directory does not exist: {}'.format(DIR_locale))
	sys.exit(1)


if sys.argv[1:]:
	cmd = sys.argv[1]
	if cmd.lower() == 'compile':
		print('\nCompiling locales ...')

		#gt_sources = []
		for ROOT, DIRS, FILES in os.walk(DIR_locale):
			for source_file in FILES:
				if source_file.endswith('.po'):
示例#4
0
## Formats HTML Doxygen files for customized view

# MIT licensing
# See: docs/LICENSE.txt


import os, re, sys

from scripts_globals import ConcatPaths
from scripts_globals import DIR_root


print('\nOptimizing & customizing Doxygen HTML docs for Python ...\n')

DIR_html = ConcatPaths((DIR_root, 'docs/doxygen/html'))

if not os.path.isdir(DIR_html):
    print('ERROR: Doxygen directory does not exist, exiting ...')
    
    sys.exit(1)


files_root = []
files_rest = []

# Set files lists
for ROOT, DIRS, FILES in os.walk(DIR_html):
    for HTML in FILES:
        if HTML.lower().endswith('.html') and '_TEST' not in HTML:
            HTML = ConcatPaths((ROOT, HTML))