Need to pull out player information from string table
975723
def parse_string_table(self, tables):
        
        self.info("String table: %s" % (tables.tables, ))

        for table in tables.tables:
            if table.table_name == "userinfo":
                for item in table.items:
                    if len(item.data) > 0:
                        if len(item.data) == 140:
                            p = PlayerInfo()
                            ctypes.memmove(ctypes.addressof(p), item.data, 140)
                            p.str = item.str
                            self.run_hooks(p)
            if table.table_name == "CombatLogNames":
                self.combat_log_names = dict(enumerate(
                    (item.str for item in table.items)))
397895
def ensure_table_strings(table):
    
    for row in range(len(table)):
        for column in range(len(table[row])):
            table[row][column] = str(table[row][column])
    return table
289592
def from_string(cls, s):
        """"""
        for num, text in cls._STATUS_TABLE.items():
            if text == s: return cls(num)
        else:
            #raise ValueError("Wrong string %s" % s)
            logger.warning("Got unknown status: %s" % s)
            return cls.from_string("UNKNOWN")
804347
private void extractTablesFromAPage(ArrayList<TextPiece> linesOfAPage,
	    ArrayList<Table> tables, ArrayList<TextPiece> wordsOfAPage, int i,
	    File pdfFile, ArrayList<ArrayList<TextPiece>> linesByPage) {
	if (linesOfAPage.size() > 30) {
	    /*
	     * Checks for table keywords
	     */
	    boolean tableKwdExist = false;
	    int prevTableEndIndex = 0;
	    for (TextPiece t : linesOfAPage) {
		String textWithoutSpace = t.getText().replace(" ", "");
		if (getMatchedTabledKeyword(textWithoutSpace) != null) {
		    tableKwdExist = true;
		    break;
		}
	    }

	    /*
	     * TODO [improve]: keywords are searched twice, no need to do the
	     * first search in the future
	     */
	    if (tableKwdExist == true) {
		for (int k = 0; k < linesOfAPage.size();) {
		    TextPiece line = linesOfAPage.get(k);
		    TextPiece prevLine = (k == 0) ? null : linesOfAPage
			    .get(k - 1);
		    String textWithoutSpace = line.getText().replace(" ", "");
		    String keyword = getMatchedTabledKeyword(textWithoutSpace);

		    if (keyword != null
			    && (textWithoutSpace.startsWith("tableofcontent") == false)
			    && (textWithoutSpace.startsWith("TABLEOFCONTENT") == false)
			    && (textWithoutSpace.startsWith("TableofContent") == false)) {
			char lastCharInKwd = keyword
				.charAt(keyword.length() - 1);
			String oldKwd = line.getText().substring(0,
				line.getText().indexOf(lastCharInKwd) + 1);
			String newLine = "Table"
				+ line.getText()
					.substring(
						line.getText().indexOf(
							lastCharInKwd) + 1,
						line.getText().length());
			// linesOfAPage.get(k).setText(newLine);

			if (prevLine != null && line.getY() == prevLine.getY())
			    k++;
			else {
			    /*
			     * try to extract this table
			     */
			    TableCandidate tc = new TableCandidate();
			    tc.setKeyword(keyword);
			    // tc.setXMLDoc(xml_doc); // to add all table
			    // metadata elements in TableCandidate

			    k = extractOneTable(k, linesOfAPage, keyword, tc,
				    wordsOfAPage, i, prevTableEndIndex,
				    linesByPage);
			    if (tc.isValid()) {
				if (tc.isTopCaption())
				    prevTableEndIndex = tc.getBodyEndLine();
				else
				    prevTableEndIndex = tc.getCaptionEndLine();
				if (Config.DEBUG_MODE)
				    tc.print();
				String metadata_StructureLevel = tc
					.getMetadata_StructureLevel();
				String tableMeta_thisDoc = m_docInfo
					.getTableMetaInThisDoc();
				String tableMetaHighLevel = tc
					.getMetadata_HighLevel();
				String latestMetaData = tableMeta_thisDoc
					+ tableMetaHighLevel
					+ metadata_StructureLevel;
				m_docInfo.setTableMetadata(latestMetaData);

				/*
				 * Generates the extracted table list, then XML
				 * output from each table
				 */
				// System.out.println(Integer.toString(i)+" Adding");
				Table oneTable = new Table();
				oneTable.setValidTable(tc);
				tables.add(oneTable);

				oneTable.setPageNumber(i + 1);
			    }
			}
		    } else
			k++;
		}
	    } else {// TODO: log
	    }
	} else {
	    /*
	     * Impossible to contain tables because of few texts in the page
	     */
	}
    }
1337673
def parse_information
      s0 = @current_pos
      s1 = parse_players
      s1 = nil if s1 == :failed
      s2 = parse_headers
      if s2 != :failed
        @reported_pos = s0
        s0 = { "players" => s1, "header" => s2 }
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
855544
private static List<String> extractInfo(String str) {
        int beg = 0;
        int end = 0;
        int len = str.length();
        List<String> parts = new ArrayList<>();
        while (end < len && !Character.isSpaceChar(str.charAt(end)))
            end++;
        parts.add(str.substring(beg,end));
        while (end < len && Character.isSpaceChar(str.charAt(end)))
            end++;
        beg = end;
        while (end < len && !Character.isSpaceChar(str.charAt(end)))
            end++;
        parts.add(str.substring(beg,end));
        return parts;
    }
968759
def get_string_from_data(self, offset, data):
        """"""
        s = self.get_bytes_from_data(offset, data)
        end = s.find(b'\0')
        if end >= 0:
            s = s[:end]
        return s
518621
def find(str)
      index = items.index {|i| i.index > current_row && i.name.start_with?(str)} || items.index {|i| i.name.start_with? str}
      move_cursor index if index
    end
379182
def string_for_count(dictionary, count):
    """"""
    string_to_print = ""
    if count is not None:
        if count == 0:
            return ""
        ranger = count
    else:
        ranger = 2
    for index in range(ranger):
        string_to_print += "{} ".format(get_random_word(dictionary))

    return string_to_print.strip()
714525
def _print_value(self):
        """"""
        for line in range(self.Lines_num):
            for col, length in zip(self.Table, self.AttributesLength):
                vals = list(col.values())[0]
                val = vals[line] if len(vals) != 0 and line < len(vals) else ''
                self.StrTable += "| "
                self.StrTable += self._pad_string(val, length * 2)
            self.StrTable += "|" + '\n'
            self._print_divide()
1153321
function pickup (/*len, dict || dict */) {
	var str = '', pos;
	var len, dict;

	if (arguments.length === 1) {
		dict = arguments[0];
		len = 1;
	} else if (arguments.length === 2) {
		len = arguments[0];
		dict = arguments[1];
	} else {
		return string();
	}

	for (var i=0; i< len; i++) {
		pos = dice(dict.length - 1);
		str += dict.substring(pos, pos + 1);
	}

	return str;
}
12322
def dos_from_table(table, header=None):
    
    start_row = 0
    if not table:
        return table
    if not header:
        header = table[0]
        start_row = 1
    header_list = header
    if header and isinstance(header, basestring):
        header_list = header.split('\t')
        if len(header_list) != len(table[0]):
            header_list = header.split(',')
        if len(header_list) != len(table[0]):
            header_list = header.split(' ')
    ans = {}
    for i, k in enumerate(header):
        ans[k] = [row[i] for row in table[start_row:]]
    return ans
1179026
function(data) {
        var members = [],
            space = new RegExp(String.fromCharCode(65533), 'g');

        for (var i = 1; i < data.length; i++) {
            var member = data[i];
            members.push({
                player: member[0].replace(space, ' '),
                rank: member[1],
                exp: Number(member[2]),
                kills: Number(member[3])
            });
        }

        return members;
    }
714130
private void extractTablesFromAPage(ArrayList<TextPiece> linesOfAPage,
    		ArrayList<Table> tables, ArrayList<TextPiece> wordsOfAPage, int i, File pdfFile, ArrayList<ArrayList<TextPiece>> linesByPage) {
    	    	if (linesOfAPage.size() > 30) {
    	    		/*
    	    		 * Checks for table keywords
    	    		 */
    			Pattern tblKP = Pattern.compile("^\\(?(Table|lable|Tble|Tabl)",Pattern.CASE_INSENSITIVE);
    			Pattern tocKP = Pattern.compile("TableOfContent(s)?",Pattern.CASE_INSENSITIVE);
    			Pattern falsePos1 = Pattern.compile("Table");
    			Pattern falsePos2 = Pattern.compile("Table(s)?\\s+[\\d-]+(\\s+)?[\\.:-A-Z]");

    			boolean tableExists = false;
    			boolean tableCaptionFormat = false;
    			int lineNumber = 0; int endCurrentTable = 0;
    			int prevLineEndIndex = 0;
    			
    			TextPiece prevLine = null;
    	    		for (TextPiece t : linesOfAPage) {
    				// remove spaces
    				if(tableExists && lineNumber < endCurrentTable) { 
    					lineNumber++; prevLine = t; continue;
    				}
    				
    				String textFromPage = t.getText();
    	    		String textWithoutSpace = textFromPage.replace(" ", "");
    	    		if(falsePos2.matcher(textFromPage).groupCount() > 0) {
    	    			tableCaptionFormat = true;
    	    		}
    				// match for keywords
    				Matcher tblKM = tblKP.matcher(textWithoutSpace);
    				if(tblKM.find()) {
    					// string which matched
    					String matchString = textWithoutSpace.substring(tblKM.start(0),tblKM.end(0));
    					// string should not match table of contents
    					if(!tocKP.matcher(textWithoutSpace).find()) {
    						if(prevLine != null && t.getY() == prevLine.getY()) {
    							prevLine = t; lineNumber++; continue;
    						 }
    						TableCandidate tc = new TableCandidate();
    						tc.setKeyword(matchString);
    						endCurrentTable = extractOneTable(lineNumber,linesOfAPage, matchString, tc, wordsOfAPage, i, prevLineEndIndex, linesByPage);
    						boolean falsePositive = false;
    						if(tableCaptionFormat) {
    							if(!falsePos2.matcher(tc.getCaption()).find()) {
    							
    								falsePositive = true;
    							}
    						}
    						if(falsePos1.matcher(tc.getCaption()).groupCount() > 1) {
    							falsePositive = true;
    						}
    						
    						if(tc.isValid()) {
    							if(tc.isTopCaption()) {
    								prevLineEndIndex = tc.getBodyEndLine();
    							}
    							else {
    								prevLineEndIndex = tc.getCaptionEndLine();
    							}
    						}
    						String metaStructLevel = tc.getMetadata_StructureLevel();
    						String tableMeta_thisDoc = m_docInfo.getTableMetaInThisDoc();
    						String tableMetaHighLevel = tc.getMetadata_HighLevel();
    						String latestMetadata = tableMeta_thisDoc+tableMetaHighLevel+metaStructLevel;
    						m_docInfo.setTableMetadata(latestMetadata);
    						if(!falsePositive) {
    							Table singleTable = new Table();
    							singleTable.setPageNumber(i+1);
    							singleTable.setValidTable(tc);
    							tables.add(singleTable);
    						}
    					}
    					else { prevLine = t; lineNumber++; continue; }
    				} // match not found	
    				prevLine = t; lineNumber++;
    			} // end for
    	    	} // end if page size

    	   }
943279
def getPlayer(name):
    """"""
    if isinstance(name, PlayerRecord): return name
    try:    return getKnownPlayers()[name.lower()]
    except KeyError:
        raise ValueError("given player name '%s' is not a known player definition"%(name))
590931
def get_item_data(self, item):
        """"""
        filename, line_number_str = get_item_user_text(item).split(self.SEP)
        return filename, int(line_number_str)
747134
def get_table_info(conn, tablename):
    """"""
    r = conn.execute("pragma table_info('{}')".format(tablename))
    ret = TableInfo(((row["name"], row) for row in r))
    return ret