@@ -37,6 +37,7 @@ function test_cpp_include(line) {
3737
3838
3939// test line to see if valid python import/process.load/etc
40+ // returns sanitized python part of line (e.g. RecoJets.config.blah)
4041function test_py_import ( line ) {
4142 // patterns to do python matching
4243 var py_pattern1 = / f r o m \s .* \s i m p o r t \s .* / ;
@@ -141,21 +142,31 @@ for (var i = 0; i < rows.length; ++i) {
141142 // PYTHON BIT //
142143 ////////////////
143144 // tests for python imports/fragments
144- var config = test_py_import ( line ) ;
145+ var pyImportPart = test_py_import ( line ) ;
145146 // if we have a valid python config, turn it into a path
146- if ( config != "" ) {
147- config = config . replace ( / [ ' " ] / g, "" ) ;
148- var path = config . replace ( / \. / g, "/" ) ;
147+ if ( pyImportPart != "" ) {
148+ pyImportPart = pyImportPart . replace ( / [ ' " ] / g, "" ) ; // remove quotations
149+ var path = pyImportPart . replace ( / \. / g, "/" ) ; // replace . with /
149150 var parts = path . split ( "/" ) ;
150- path = path . replace ( parts [ parts . length - 1 ] , "python/" + parts [ parts . length - 1 ] + ".py" )
151+ // Now insert the missing 'python' directory
152+ // Need to handle possible directories inside of python dir
153+ // In CMSSW python is assumed to be AAA/BBB/python,
154+ // so that AAA/BBB/python/CCC is OK
155+ // but AAA/BBB/CCC/python is not OK
156+ // path = path.replace(parts[2],"python/"+parts[2]+".py")
157+ parts . splice ( 2 , 0 , "python" ) ;
158+ // Add in the .py ending
159+ parts . splice ( - 1 , 1 , parts . slice ( - 1 ) [ 0 ] + ".py" ) ;
160+ // Turn back into string
161+ path = parts . join ( "/" ) ;
151162 var link = rootURL . concat ( path )
152163
153164 // get color of original text by getting class name of <span> or <td> tag that houses it,
154165 // then ask style sheet for color attribute for that class
155166 // should probably put this as a function since we do the same for py and c++
156167 var header_class = "" ;
157168 for ( var k = 0 ; k < cell . childNodes . length ; k ++ ) {
158- if ( cell . childNodes [ k ] . textContent . indexOf ( config ) != - 1 ) {
169+ if ( cell . childNodes [ k ] . textContent . indexOf ( pyImportPart ) != - 1 ) {
159170 header_class = cell . childNodes [ k ] . className ;
160171 }
161172 }
@@ -166,8 +177,8 @@ for (var i = 0; i < rows.length; ++i) {
166177
167178 // let's replace the text with a link
168179 // keep same colour as before, but underline it to make it noticeable for user
169- var newText = "<a href=\"" + link + "\" style=\"text-decoration:underline;color:" + color + "\">" + config + "</a>" ;
170- cell . innerHTML = cell . innerHTML . replace ( config , newText ) ;
180+ var newText = "<a href=\"" + link + "\" style=\"text-decoration:underline;color:" + color + "\">" + pyImportPart + "</a>" ;
181+ cell . innerHTML = cell . innerHTML . replace ( pyImportPart , newText ) ;
171182 }
172183 }
173184 }
0 commit comments