A
download model.py
Language: Python
LOC: 49
Project Info
geekinfo - Cross-platform system information tool(geekinfo)
Server: Google
Type: svn
Google\g\geekinfo\trunk\
   basesystem.cpp
   basesystem.h
   cpucount.cpp
   cpucount.h
   cpucount_asm.asm
   cpucount_asm.h
   geekinfo.cpp
   geekinfo.h
   geekinfo_c.cpp
   geekinfo_c.h
   geekinfo_c_test.c
   linuxsystem.cpp
   linuxsystem.h
   macosxsystem.cpp
   macosxsystem.h
   Makefile.win32
   Makefile_c.win32
   model.cpp
   model.h
   model.py
   platform.h
   solarissystem.cpp
   solarissystem.h
   system.cpp
   system.h
   types.h
   win32system.cpp
   win32system.h
   wmi.cpp
   wmi.h

#!/usr/bin/python

import os
import re

def main():
	r_model = re.compile( '([\S]*)[\s]*(.*)' )

	i = open( 'model.txt', 'rt' )
	o = open( 'model.cpp', 'wt' )

	models = ''

	for line in i.readlines():
		line = line.strip()
		if len( line ) > 0 and line[0] != '#':
			m = r_model.match( line )
			models += '\t{ "%s", "%s" },\n' % ( m.group(1), m.group(2) ) 

	o.write( '''/*
	model.cpp -- AUTOMATICALLY GENERATED; DO NOT EDIT.

    Copyright 2006 John Poole.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
#include "model.h"

struct Model {
	std::string		id;
	std::string		name;
};

static Model models[] = {
''' + models + '''
\t{ "", "" }
};

std::string getModelName( std::string id )
{
	std::string	name = id;
	
	for( int i = 0; models[i].id.length() > 0; i++ ) {
		if( models[i].id == id ) {
			name = models[i].name;
			break;
		}
	}
	return name;
}
''' ) 
	
if __name__ == '__main__':
	main()

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us