Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixes to regex, added fix for roostats namespace
  • Loading branch information
pmiquelm committed Aug 10, 2016
commit ae6870254ee48398f282c7a08c5e047b15d8513e
18 changes: 14 additions & 4 deletions documentation/doxygen/converttonotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# for the script to work correctly.
gTypesList = ["void", "int", "Int_t", "TF1", "string", "bool", "double", "float", "char",
"TCanvas", "TTree", "TString", "TseqCollection", "Double_t", "TFile", "Long64_t", "Bool_t", "TH1",
"RooDataSet", "RooWorkspace"]
"RooDataSet", "RooWorkspace" , "HypoTestInverterResult" , "TVectorD" , "TArrayF"]

# -------------------------------------
# -------- Fuction definitions---------
Expand Down Expand Up @@ -380,7 +380,7 @@ def split(text):
for cpptype in gTypesList:
functionReString += ("^%s|") % cpptype

functionReString = functionReString[:-1] + r")\s?\*?\s?[\w:]*?\s?\([^\)]*\)\s*\{.*?^\}"
functionReString = functionReString[:-1] + r")\s?\*?&?\s?[\w:]*?\s?\([^\)]*\)\s*\{.*?^\}"

functionRe = re.compile(functionReString, flags = re.DOTALL | re.MULTILINE)
#functionre = re.compile(r'(^void|^int|^Int_t|^TF1|^string|^bool|^double|^float|^char|^TCanvas|^TTree|^TString|^TSeqCollection|^Double_t|^TFile|^Long64_t|^Bool_t)\s?\*?\s?[\w:]*?\s?\([^\)]*\)\s*\{.*?^\}', flags = re.DOTALL | re.MULTILINE)
Expand Down Expand Up @@ -458,7 +458,7 @@ def findFunctionName(text):

#functionnamere = re.compile(r'(?<=(?<=int)|(?<=void)|(?<=TF1)|(?<=Int_t)|(?<=string)|(?<=double)|(?<=Double_t)|(?<=float)|(?<=char)|(?<=TString)|(?<=bool)|(?<=TSeqCollection)|(?<=TCanvas)|(?<=TTree)|(?<=TFile)|(?<=Long64_t)|(?<=Bool_t))\s?\*?\s?[^\s]*?(?=\s?\()', flags = re.DOTALL | re.MULTILINE)
match = functionNameRe.search(text)
functionname = match.group().strip(" *")
functionname = match.group().strip(" *\n")
return functionname


Expand Down Expand Up @@ -527,8 +527,18 @@ def changeString(matchObject):
newcode = re.sub("#\s\s\w\s[\w-]\s\w.*", changeString , code)
return newcode

def roostatsRoofitDeclaceNamespace(code):
if "using namespace RooFit;\nusing namespace RooStats;" in code:
code = code.replace("using namespace RooFit;\nusing namespace RooStats;", "# <codecell>\n%%cpp -d\n// This is a workaround to make sure the namespace is used inside functions\nusing namespace RooFit;\nusing namespace RooStats;")

else:
code = code.replace("using namespace RooFit;", "# <codecell>\n%%cpp -d\n// This is a workaround to make sure the namespace is used inside functions\nusing namespace RooFit;")
code = code.replace("using namespace RooStats;", "# <codecell>\n%%cpp -d\n// This is a workaround to make sure the namespace is used inside functions\nusing namespace RooStats;")
return code


def fixes(code):
codeTransformers=[removePaletteEditor, runEventExe, getLibMathMore, roofitRemoveSpacesComments]
codeTransformers=[removePaletteEditor, runEventExe, getLibMathMore, roofitRemoveSpacesComments, roostatsRoofitDeclaceNamespace]

for transformer in codeTransformers:
code = transformer(code)
Expand Down