<commit_before>// Code for parsing GBrowse config files
// Output : a JS object

// Based (now *extremely* loosely) on
// https://github.com/shockie/node-iniparser -> released under the MIT license


define(['dojo/_base/declare','JBrowse/Util','JBrowse/ConfigAdaptor/AdaptorUtil'], function(declare,Util,AdaptorUtil) { 
return declare('JBrowse.ConfigAdaptor.gbrowse',null,

    {

        constructor: function() {},

        load: function(args){
            var that = this;
            dojo.xhrGet({
                url: Util.resolveUrl( args.baseUrl || window.location.href, args.config.url ),
                handleAs: 'text',
                load: dojo.hitch( that, function(data) {
                    var gbConfig = this.parse(data);
                    args.onSuccess.call( that, gbConfig );
                }),
                error: function(e) {
                    console.error( '' + e );
                    if( args.onFailure )
                        args.onFailure.call( args.context || this, e );
                }
            });
        },

        parse: function(data){
            this.regex = {
                section:    /^\s*\[\s*([^\]\/]*)\s*\]\s*$/,
                subsection: /^\s*\[\s*([^\]]*)\/([^\]]*)\s*\]\s*$/,
                param:      /^(\w[\w\.\-\_\:\s]+)=\s*(.*?)\s*$/,
                halfParam:  /^(\w[\w\.\-\_\:\s]+)=\s*$/,
                comment:    /^\s*#|(\/\/).*$/,
                emptyLine:  /^\s*$/,
                newLine:    /\r\n|\r|\n/
            };
            this.value = {};
            this.lines = data.split(this.regex.newLine);
            this.section = null;
            this.subsection = null;
            var n = this.lines.length;


            //Process each line
            for (var i = 0; i < n; i++) {
                if (this.regex.comment.test(this.lines[i])) {                      //      #this is a comment
                    // do nothing, since it's a comment.
                } else if (this.regex.halfParam.test(this.lines[i])) {             //      name = 
                    i = this.multiLine(i); // skips lines, so get 'i': where to continue
                } else if (this.regex.param.test(this.lines[i])) {                 //      name = value
                    this.param(i);
                } else if (this.regex.subsection.test(this.lines[i])) {            //      [section_name]
                    this.subSection(i);
                } else if (this.regex.section.test(this.lines[i])){                //      [section/subsection]
                    this.mainSection(i);<commit_msg>fixed bug with '//' appearing partway through a line, causing entire line to register as a comment<commit_after>// Code for parsing GBrowse config files
// Output : a JS object

// Based (now *extremely* loosely) on
// https://github.com/shockie/node-iniparser -> released under the MIT license


define(['dojo/_base/declare','JBrowse/Util','JBrowse/ConfigAdaptor/AdaptorUtil'], function(declare,Util,AdaptorUtil) { 
return declare('JBrowse.ConfigAdaptor.gbrowse',null,

    {

        constructor: function() {},

        load: function(args){
            var that = this;
            dojo.xhrGet({
                url: Util.resolveUrl( args.baseUrl || window.location.href, args.config.url ),
                handleAs: 'text',
                load: dojo.hitch( that, function(data) {
                    var gbConfig = this.parse(data);
                    args.onSuccess.call( that, gbConfig );
                }),
                error: function(e) {
                    console.error( '' + e );
                    if( args.onFailure )
                        args.onFailure.call( args.context || this, e );
                }
            });
        },

        parse: function(data){
            this.regex = {
                section:    /^\s*\[\s*([^\]\/]*)\s*\]\s*$/,
                subsection: /^\s*\[\s*([^\]]*)\/([^\]]*)\s*\]\s*$/,
                param:      /^(\w[\w\.\-\_\:\s]+)=\s*(.*?)\s*$/,
                halfParam:  /^(\w[\w\.\-\_\:\s]+)=\s*$/,
                comment:    /^\s*(#|\/\/).*$/,
                emptyLine:  /^\s*$/,
                newLine:    /\r\n|\r|\n/
            };
            this.value = {};
            this.lines = data.split(this.regex.newLine);
            this.section = null;
            this.subsection = null;
            var n = this.lines.length;


            //Process each line
            for (var i = 0; i < n; i++) {
                if (this.regex.comment.test(this.lines[i])) {                      //      #this is a comment
                    // do nothing, since it's a comment.                           //      // this is also a comment
                } else if (this.regex.halfParam.test(this.lines[i])) {             //      halfParam = 
                    i = this.multiLine(i); // skips lines, so get 'i': where to continue
                } else if (this.regex.param.test(this.lines[i])) {                 //      param = value
                    this.param(i);
                } else if (this.regex.subsection.test(this.lines[i])) {            //      [section_name]
                    this.subSection(i);
                } else if (this.regex.section.test(this.lines[i])){                //      [section/subsection]
                    this.mainSection(i);
{'fraction_non_alphanumeric': 0.16676066929874037, 'fraction_numerical': 0.00037601052829479227, 'mean_word_length': 1.2551928783382789, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3730143', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1510, 'n_words': 299}