Author: sebastien.lelong
Date: Sat Dec 20 02:18:01 2008
New Revision: 627
Modified:
trunk/tools/jalapi.py
trunk/tools/jalapi_html.tmpl
Log:
issue 40: quick and dirty fix
Modified: trunk/tools/jalapi.py
==============================================================================
--- trunk/tools/jalapi.py (original)
+++ trunk/tools/jalapi.py Sat Dec 20 02:18:01 2008
@@ -91,26 +91,31 @@
return (dhead,dproc,dfunc,dvarconst,ddeps)
-def get_samples_info(samples):
+def get_samples_info(samples,local=False):
dsamples = {}
for sample in samples:
- # yeah, that's a system call again, for svn...
- # in english please so we can parse...
- stdin,stdout,stderr = os.popen3("LANG=C svn info %s | grep
^URL:" %
sample)
- stderr = stderr.read()
- if stderr:
- print >> sys.stderr, "Skip extracting SVN URL for
sample %s
because: %s" % (sample,stderr)
- continue
- fullurl = stdout.read().replace("URL:","").strip()
- stdin,stdout,stderr = os.popen3("LANG=C svn info %s | grep
^Repository\
Root:" % sample)
- stderr = stderr.read()
- if stderr:
- print >> sys.stderr, "Skip extracting SVN Repository
Root for sample %s
because: %s" % (sample,stderr)
- reposroot = stdout.read().replace("Repository Root:","").strip()
- svnbrowserurl = fullurl.replace(reposroot,SVN_BROWSER_ROOT)
- remain, fsample = os.path.split(sample)
- _trash, pic = os.path.split(remain)
- dsamples[(pic,fsample)] = svnbrowserurl
+ if not local:
+ # yeah, that's a system call again, for svn...
+ # in english please so we can parse...
+ stdin,stdout,stderr = os.popen3("LANG=C svn info %s |
grep ^URL:" %
sample)
+ stderr = stderr.read()
+ if stderr:
+ print >> sys.stderr, "Skip extracting SVN URL
for sample %s
because: %s" % (sample,stderr)
+ continue
+ fullurl = stdout.read().replace("URL:","").strip()
+ stdin,stdout,stderr = os.popen3("LANG=C svn info %s |
grep ^Repository\
Root:" % sample)
+ stderr = stderr.read()
+ if stderr:
+ print >> sys.stderr, "Skip extracting SVN
Repository Root for
sample %s because: %s" % (sample,stderr)
+ reposroot = stdout.read().replace("Repository
Root:","").strip()
+ svnbrowserurl =
fullurl.replace(reposroot,SVN_BROWSER_ROOT)
+ remain, fsample = os.path.split(sample)
+ _trash, pic = os.path.split(remain)
+ dsamples[(pic,fsample)] = svnbrowserurl
+ else:
+ remain, fsample = os.path.split(sample)
+ _trash, pic = os.path.split(remain)
+ dsamples[(pic,fsample)] = None
return dsamples
@@ -128,6 +133,17 @@
print >> sys.stderr, "Please provide a template and jal library
file"
sys.exit(255)
+ # Issue 40: generate local links to samples
+ # instead links to SVN repository on GC
+ localsamples = False
+ sampledir = None
+ if "-l" in sys.argv:
+ localsamples = True
+ # if local, then sample dir must be on the same dir
+ # as the lib dir passed as arg (ok, this is very very ugly...)
+ # (this is to check if sample actually exists, when releasing)
+ sampledir =
os.path.join(os.path.split(os.path.split(filename)[0])[0],'sample')
+
# first validate it !
jallib.validate(filename)
if jallib.errors:
@@ -155,7 +171,7 @@
sys.exit(3)
print >> sys.stderr, "Samples using %s:\n%s" % (filename,stdout)
sample_files = stdout.split()
- dsamples = get_samples_info(sample_files)
+ dsamples = get_samples_info(sample_files,local=localsamples)
# extract doc
dhead,dproc,dfunc,dvarconst,ddeps = extract_doc(filename)
@@ -163,6 +179,8 @@
tmplsrc = "".join(file(tmpl_file,"r").readlines())
klass = Cheetah.Template.Template.compile(tmplsrc)
tmpl = klass()
+ tmpl.localsamples = localsamples
+ tmpl.sampledir = sampledir
tmpl.dhead = dhead
tmpl.dproc = dproc
tmpl.dfunc = dfunc
Modified: trunk/tools/jalapi_html.tmpl
==============================================================================
--- trunk/tools/jalapi_html.tmpl (original)
+++ trunk/tools/jalapi_html.tmpl Sat Dec 20 02:18:01 2008
@@ -1,5 +1,5 @@
## Use to generate safe anchor
-#import md5
+#import md5, os, sys
#def txt2html(what)
## Convert GC wiki to html, *BUT* keep line feed as <br> !
@@ -10,7 +10,8 @@
## Single line header: strip
#set title = $dhead['Title'].strip()
#set author = $dhead['Author'].strip()
- #set adapted_by = $dhead['Adapted-by'].strip()
+ ## Adapted-by is not mandatory
+ #set adapted_by = $dhead.get('Adapted-by') and
$dhead.get('Adapted-by').strip() or ""
#set compiler = $dhead['Compiler'].strip()
## Multiline header
#set description = $dhead['Description']
@@ -161,9 +162,20 @@
Here are the list of samples which use this library:<br/><br/>
<table border=1>
#for (pic,file),url in sorted($dsamples.items(),lambda x,y:
cmp(x[0][0],y[0][0]))
- <tr>
- <td><b>$pic</b></td><td><a href="$url"
target="_blank">$file</a></td>
- </tr>
+ #if $localsamples
+ ## ensure it actually exists !
+ #if not os.path.isfile(os.path.join('%s' %
$sampledir,'by_device','%s' % $pic,'%s' % $file))
+ #silent print >> sys.stderr, "sample %s does
not exist" %
os.path.join('%s' % $sampledir,'by_device','%s' % $pic,'%s' % $file)
+ #continue
+ #end if
+ <tr>
+ <td><b>$pic</b></td><td><a
href="../../sample/by_device/$pic/$file"
target="_blank">$file</a></td>
+ </tr>
+ #else
+ <tr>
+ <td><b>$pic</b></td><td><a href="$url"
target="_blank">$file</a></td>
+ </tr>
+ #end if
#end for
</table>
#else
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---