Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)

        def buildIndex(inputbz2Archive, outidxname, outblockname, callback = None):
 # 1. gzip force ascii handlers, dunno how to fix, 2. gzip.open refuses utf8 names
 zindexfile = gzip.GzipFile(fileobj=open(outidxname, 'w'), filename="")
 blocksfile = open(outblockname, 'w')
 f = bz2.BZ2File(inputbz2Archive)
 #print f.tellbzblock()
 #f.readline()
 #print f.tellbzblock()
 if f.readline()[0:10] != "\n":
		start = f.tell()
                break
	if l == "":
		raise StopIteration

   #print "article found at (unziped) offset : ", start

   while 1:
        l = f.readline()
	bzblocks2 = f.tellbzblock()
	if bzblocks2[0] != blocknum:
		blocknum = writeBlock(bzblocks2)
		print numarticles, " articles found"
	if l[0:11] == '    ':
		titleline = l
        if l == "  </page>\n":
		ending = f.tell()
                break
	if l == "":
		raise StopIteration
   
   D = parseString(titleline)
   n = D.getElementsByTagName('title')
   title = n[0].firstChild.nodeValue
   numarticles += 1

   zindexfile.write( ("%s\t%s\t%d\t%d\n" % (title, bzblocks1[0], start - (bzblocks1[1][0] + bzblocks1[1][1] * maxL), ending - start) ).encode('utf-8') )
 except StopIteration:
   print "End of that block : ", `f.name`
        </pre>
    </div><br/><br/></div>

<a href="/codes/show/src%40t%40a%40tawiktionary-offline-HEAD%40PyQT4%40Karthika.py/405/mparser.buildIndex/python" class="filelink">src/t/a/tawiktionary-offline-HEAD/PyQT4/Karthika.py</a>   <strong><a href="/projects/show/56841">tawiktionary-offline</a></strong>(<a href="git://github.com/thamizha/tawiktionary-offline.git">Download</a>)<div class="codebox"><input type="hidden" name="filename" value="src/t/a/tawiktionary-offline-HEAD/PyQT4/Karthika.py"><input type="hidden" name="codename" value="mparser.buildIndex"><div><pre class="brush: python; first-line: 403; highlight:[405] ">
				sys.exit(0)
		try:
			mparser.buildIndex(inputbz2Archive, outidxname, outblockname, callback)
		except EOFError, e:
			QtGui.QMessageBox.critical(None, "Index creation problem", unicode(e))
</pre></div></div><br/>            <div style="margin-top:10px">
            <script type="text/javascript"><!--
            google_ad_client = "ca-pub-7605927754820076";
            /* nullege bottom links */
            google_ad_slot = "4117027950";
            google_ad_width = 468;
            google_ad_height = 15;
            //-->
            </script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>
        </div>
</div></div>

<script type="text/javascript">
	$(function() {
            // layout
            console.log($('#main').height());
            var main_height = $(window).height() - 110;
            main_height = main_height < 500 ? 500 : main_height;
            $('#main').height(main_height);
            $('#main').layout( {
                applyDefaultStyles: true,
                center: {
                    //paneSelector: '#mainsrc',
                    //minHeight: main_height
                },
                west__size : 315
            });
            $('#west-wrapper').layout( {
                center__paneSelector: '#cetree_wrapper',
                south__paneSelector: '#ad_wrapper',
                south__size: 250
            });
            
            // syntax highlight
            SyntaxHighlighter.highlight();

            // hook show implementation function
            $('#showimp').bind('click', function(e) {
                $('#showimpdiv').hide();
                $('#impsrc').css('display', 'block');
                return false;
            });

            // Make line numbers and each line of code clickable.
            base = "/codes/show";
            $('div.codebox').each(function() {
                var src_input = $(this).find('input[name=filename]');
                if (!src_input || src_input.length === 0) return;
                
                var sfile = src_input.val().replace(/\//g, '@');
                var codename = $(this).find('input[name=codename]').val();
                var start_line = parseInt($($(this).find('td.gutter > div.line')[0]).text(), 10);

                // wrap line numbers in <a>
                $(this).find('td.gutter > div.line').each(function() {
                    url = base + '/' + sfile + '/' + $(this).text() + '/' + codename + '/python';
                    $(this).wrap('<a href="' + url + '">');
                });

                // wrap each line of code in an <a>
                $(this).find('td.code div.line').each(function(idx) {
                    url = base + '/' + sfile + '/' + (idx + start_line) + '/' + codename + '/python';
                    $(this).wrap('<a class="hlcode" href="' + url + '">');
                });
            });

            // generate left side tree
            var open_nodes = [];
            var current_id = 626817;
            var current_selected = false;

            window.open_one_layer = function() {
                var next = open_nodes.shift();
                if(next) {
                    $('#cetree').jstree("open_node", $('#jst' + next));
                }
                else if(!current_selected) {
                    $('#cetree').jstree("select_node", $('#jst' + current_id));
                    current_selected = true;
                }
            };

            $("#cetree")
            .bind("loaded.jstree open_node.jstree", function(event, data) {
                setTimeout("open_one_layer()", 500);
            })
            .bind("select_node.jstree", function(event, data) {
                if(data.rslt.obj.attr("id") !== "jst" + current_id) {
                    url = "/codes/search/" +
                                    data.rslt.obj.attr("name") + "/python";
                    window.location.replace(url);
                }
            })
            .jstree({
                "plugins" : ["themes", "json_data", "ui"],
                "core" : { "animation" : 300 },
                "json_data" : {
                    "progressive_render" : true,
                    "data" : [ [{"data":null,"state":"leaf","attr":{"id":"jst","name":null}}] ],
                    "ajax" : {
                        "url" : "/code_entities/jstree_data_json",
                        "data" : function(n) { return { "id" : n.attr ? n.attr("id").substr(3) : -1};}
                    }
                }
                //"ui" : { "initially_select" : ["mparser.buildIndex".replace(/([ #;&,.+*~\':"!^$[\]()=>|\/])/g,'\\$1')] }
            });

            function fix_height() {
                $('#mainsrc').height($('#main').height());
                console.log('here' + $('#mainsrc').height());
            }
            window.setTimeout(fix_height, 1000);
	});
</script>
<script type='text/javascript' src='/min/b=js&f=shCore.js,shBrushPython.js,jquery.layout.js,jquery.jstree.js'></script></div>
            </div>
            <div id="footer">
                <a href="/pages/about">About Us (Contact Us)</a> |
                <a href="/pages/privacy">Privacy</a> |
                <a href="http://twitter.com/nullege">Twitter</a> |
                <a href="http://www.facebook.com/pages/nullege/208737708787">Facebook</a> |
                <a href="javascript:UserVoice.showPopupWidget();" title="Open feedback & support dialog (powered by UserVoice)">Feedback</a>
                            </div>
        </div>
                <script type='text/javascript' src='/min/b=js&f=jquery.autocomplete.js'></script>
        <!-- user voice -->
        <script type="text/javascript">
            (function() {
                var uv = document.createElement('script'); uv.type = 'text/javascript'; uv.async = true;
                uv.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'widget.uservoice.com/ed9ETa1MDOo2yB4DbS4gQ.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(uv, s);
            })();
        </script>
    </body>
</html>