mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 06:32:43 +00:00
doc: update scripts to python3
This commit is contained in:
parent
ccaf0865c0
commit
3789dc732d
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, shutil
|
||||
import re, yaml
|
||||
@ -74,9 +74,9 @@ def main(argv):
|
||||
yml_file = "mkdocs.yml"
|
||||
|
||||
with open(yml_file, 'r') as yin:
|
||||
doc = yaml.load(yin)
|
||||
doc = yaml.load(yin, Loader=yaml.SafeLoader)
|
||||
for page in doc["pages"]:
|
||||
mk_file = page.values()[0]
|
||||
mk_file = list(page.values())[0]
|
||||
source_file = md_template +"/"+ mk_file
|
||||
dest_file = md_final +"/"+ mk_file
|
||||
print("Processing %s -> %s" % (source_file, dest_file))
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, yaml
|
||||
import os, re
|
||||
@ -60,10 +60,10 @@ def main(argv):
|
||||
|
||||
with open(mk_file, 'w') as aout:
|
||||
with open(yml_file, 'r') as yin:
|
||||
doc = yaml.load(yin)
|
||||
doc = yaml.load(yin, Loader=yaml.SafeLoader)
|
||||
for page in doc["pages"]:
|
||||
title = page.keys()[0]
|
||||
md_file = page.values()[0]
|
||||
title = list(page.keys())[0]
|
||||
md_file = list(page.values())[0]
|
||||
with open(docs_folder +"/"+ md_file, 'r') as mdin:
|
||||
aout.write("\n\n#"+ title +"\n\n")
|
||||
for line in mdin:
|
||||
@ -80,7 +80,7 @@ def main(argv):
|
||||
while 1:
|
||||
line = p.readline()
|
||||
if not line: break
|
||||
print line
|
||||
print (line)
|
||||
|
||||
|
||||
# btstatck_root_file = "latex/btstack_gettingstarted.tex"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, shutil, re, pickle
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys, os, shutil, re
|
||||
|
||||
@ -9,7 +9,7 @@ port_item = """
|
||||
|
||||
def get_readme_title(example_path):
|
||||
title = ''
|
||||
with open(example_path, 'rb') as fin:
|
||||
with open(example_path, 'r') as fin:
|
||||
for line in fin:
|
||||
parts = re.match('(##\s)(.*)\n',line)
|
||||
if parts:
|
||||
@ -34,13 +34,13 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
||||
images[file] = port_folder + "/" + port + "/" + file
|
||||
|
||||
with open(ports_file, 'w') as ports:
|
||||
with open(intro_file, 'rb') as fin:
|
||||
with open(intro_file, 'r') as fin:
|
||||
for line in fin:
|
||||
ports.write(line)
|
||||
fin.close()
|
||||
|
||||
for readme_dir, readme_file in sorted(matches.items()):
|
||||
with open(readme_file, 'rb') as fin:
|
||||
with open(readme_file, 'r') as fin:
|
||||
for line in fin:
|
||||
# find title, add reference
|
||||
title_parts = re.match('(#\s+)(.*)\n',line)
|
||||
@ -52,7 +52,7 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
||||
ports.write("\n\n")
|
||||
|
||||
for readme_dir, readme_file in sorted(matches.items()):
|
||||
with open(readme_file, 'rb') as fin:
|
||||
with open(readme_file, 'r') as fin:
|
||||
for line in fin:
|
||||
#increase level of indentation
|
||||
parts = re.match('#(.*)\n',line)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os, sys, getopt, re, pickle
|
||||
|
||||
class State:
|
||||
@ -77,7 +77,7 @@ def writeAPI(apifile, btstackfolder, apis, mk_codeidentation):
|
||||
fout.write(title)
|
||||
|
||||
state = State.SearchStartAPI
|
||||
with open(api_filename, 'rb') as fin:
|
||||
with open(api_filename, 'r') as fin:
|
||||
for line in fin:
|
||||
if state == State.SearchStartAPI:
|
||||
parts = re.match('.*API_START.*',line)
|
||||
@ -103,7 +103,7 @@ def createIndex(btstackfolder, apis, githubfolder):
|
||||
api_lable = api_tuple[2]
|
||||
|
||||
linenr = 0
|
||||
with open(api_filename, 'rb') as fin:
|
||||
with open(api_filename, 'r') as fin:
|
||||
typedefFound = 0
|
||||
multiline_function_def = 0
|
||||
state = State.SearchStartAPI
|
||||
@ -195,11 +195,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,"hiso:",["bfolder=","afile=","gfolder=","ifile="])
|
||||
except getopt.GetoptError:
|
||||
print cmd
|
||||
print (cmd)
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print cmd
|
||||
print (cmd)
|
||||
sys.exit()
|
||||
elif opt in ("-b", "--bfolder"):
|
||||
btstackfolder = arg
|
||||
@ -209,10 +209,10 @@ def main(argv):
|
||||
btstackfolder = arg
|
||||
elif opt in ("-i", "--ifile"):
|
||||
indexfile = arg
|
||||
print 'BTstack folder is :', btstackfolder
|
||||
print 'API file is :', apifile
|
||||
print 'Github path is :', githubfolder
|
||||
print 'Index file is :', indexfile
|
||||
print ('BTstack folder is : ' + btstackfolder)
|
||||
print ('API file is : ' + apifile)
|
||||
print ('Github path is : ' + githubfolder)
|
||||
print ('Index file is : ' + indexfile)
|
||||
|
||||
writeAPI(apifile, btstackfolder, apis, mk_codeidentation)
|
||||
createIndex(btstackfolder, apis, githubfolder)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os, sys, getopt, re
|
||||
|
||||
# Defines the names of example groups. Preserves the order in which the example groups will be parsed.
|
||||
@ -111,7 +111,7 @@ def processTextLine(line, ref_prefix):
|
||||
|
||||
def getExampleTitle(example_path):
|
||||
example_title = ''
|
||||
with open(example_path, 'rb') as fin:
|
||||
with open(example_path, 'r') as fin:
|
||||
for line in fin:
|
||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||
if parts:
|
||||
@ -151,7 +151,7 @@ def writeListings(aout, infile_name, ref_prefix):
|
||||
code_identation = " "
|
||||
skip_code = 0
|
||||
|
||||
with open(infile_name, 'rb') as fin:
|
||||
with open(infile_name, 'r') as fin:
|
||||
for line in fin:
|
||||
if state == State.SearchExampleStart:
|
||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||
@ -256,22 +256,22 @@ def writeListings(aout, infile_name, ref_prefix):
|
||||
parts = re.match('.*(EXAMPLE_END).*',line)
|
||||
if parts:
|
||||
if state != State.SearchListingStart:
|
||||
print "Formating error detected"
|
||||
print("Formating error detected")
|
||||
writeItemizeBlock(aout, 0)
|
||||
writeTextBlock(aout, 0)
|
||||
state = State.ReachedExampleEnd
|
||||
print "Reached end of the example"
|
||||
print("Reached end of the example")
|
||||
|
||||
|
||||
# write list of examples
|
||||
def processExamples(intro_file, examples_folder, examples_ofile):
|
||||
with open(examples_ofile, 'w') as aout:
|
||||
with open(intro_file, 'rb') as fin:
|
||||
with open(intro_file, 'r') as fin:
|
||||
for line in fin:
|
||||
aout.write(line)
|
||||
|
||||
for group_title in list_of_groups:
|
||||
if not list_of_examples.has_key(group_title): continue
|
||||
if not group_title in list_of_examples: continue
|
||||
examples = list_of_examples[group_title]
|
||||
for example in examples:
|
||||
example_path = examples_folder + example[0] + ".c"
|
||||
@ -282,7 +282,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
|
||||
aout.write("\n\n");
|
||||
|
||||
for group_title in list_of_groups:
|
||||
if not list_of_examples.has_key(group_title): continue
|
||||
if not group_title in list_of_examples: continue
|
||||
examples = list_of_examples[group_title]
|
||||
|
||||
group_title = group_title + " example"
|
||||
@ -300,7 +300,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
|
||||
aout.write("\n")
|
||||
|
||||
for group_title in list_of_groups:
|
||||
if not list_of_examples.has_key(group_title): continue
|
||||
if not group_title in list_of_examples: continue
|
||||
examples = list_of_examples[group_title]
|
||||
|
||||
for example in examples:
|
||||
@ -320,11 +320,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,"hiso:",["ffolder=","ifile=","ofile="])
|
||||
except getopt.GetoptError:
|
||||
print cmd
|
||||
print (cmd)
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print cmd
|
||||
print (cmd)
|
||||
sys.exit()
|
||||
elif opt in ("-f", "--ffolder"):
|
||||
inputfolder = arg
|
||||
@ -332,9 +332,9 @@ def main(argv):
|
||||
introfile = arg
|
||||
elif opt in ("-o", "--ofile"):
|
||||
outputfile = arg
|
||||
print 'Input folder is ', inputfolder
|
||||
print 'Intro file is ', introfile
|
||||
print 'Output file is ', outputfile
|
||||
print ('Input folder is : ', inputfolder)
|
||||
print ('Intro file is : ', introfile)
|
||||
print ('Output file is : ', outputfile)
|
||||
|
||||
processExamples(introfile, inputfolder, outputfile)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user