1 1001
I realize that I forgot to post the sample code:). Below is my
implementation:
#DSL data
#12345678901234 567890123456789 012345678901234 567890123456789 0,
dsldata=(
'SVCLFOWLER 10101MS01200503 13............. ............',
'SVCLHOHPE 10201DX03200503 15............. ...........',
'SVCLTWO x10301MRP220050 329............ ............... ...',
'USGE10301TWO x50214..7050329 ............... ............... .')
#Class mappings
Mappings={'svcl ':{
(4,18):'Custome rName',
(19,23):'Custom erID',
(24,27) :'CallTypeCode' ,
(28,35) : 'DateOfCallStri ng'},
'usge':{(4,8) :'CustomerID',
(9,22):'Custome rName',
(30,30):'Cycle' ,
(31,36): 'ReadDate'}}
def generateClass(d ata):
'generate the class and instance with attributes'
className = data[:4].lower() #1)
mappingData= Mappings[className] #2)
class Klass:pass #3)
Klass. __name__=classN ame #4)
# print Klass
for key in mappingData.key s(): #5)
fielddata=data[key[0]:key[1]]
print 'actual data->',fielddata
setattr(Klass,m appingData[key],fielddata) #6)
return Klass
def parseData():
'parse the data and generate a list of objects'
classes= [generateClass(i tem) for item in dsldata]
return classes
def printKlassData( Klass):
print Klass
for key in Klass.__dict__:
print ('attr->%s value->%s')%(key,Klas s.__dict__[key])
if __name__=='__ma in__':
for Klass in parseData():
printKlassData (Klass) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ville Vainio |
last post by:
I don't know if you have seen this before, but here goes:
http://text.userlinux.com/white_paper.html
There is a jab at Python, though, mentioning that Ruby is more
"refined".
--
Ville Vainio http://www.students.tut.fi/~vainio24
|
by: has |
last post by:
<BLUSH> Careless talk costs lives, as they say. In my case, a
throwaway comment that Python could trounce the notoriously
underpowered and undersupported AppleScript language for "serious
number crunching". (And Perl could beat Python, and Fortran could kick
all their butts, etc...) Well, you'd think me and the other guy would
be old enough to know better, or at least have more important things
to do, but nooooo...
Ah well, too late...
|
by: Quest Master |
last post by:
I am interested in developing an application where the user has an
ample amount of power to customize the application to their needs, and
I feel this would best be accomplished if a scripting language was
available. However, I want to code this application in Python, and I
have not yet heard of an implementation of another scripting language
into Python.
An example of what I mean is this (an implementation of Lua into Ruby
-- which I'd...
|
by: marina madeleine |
last post by:
Could some clarify for me - I thought the scripting language for Access
was SQL and that to script in Access one would need to learn SQL. Why
then is the Access database under visual basic? What do you need to
know to know, SQL or VB, to work optimally in Access?
Also, is it possible to hook up Access datasets to a pre-made pivot
table in Excel. How does this work, any more elaborate info on this
would be much appreciated.
Marina...
|
by: Matt |
last post by:
Some people identify Microsoft C# is Proprietary programming language.
What is Proprietary programming language then? How does it differ
from other languages such as C++, or Java??
Please advise. thanks!!
| |
by: Dave |
last post by:
I want to spend two minutes on my soapbox.
I love C#. I am so productive in it it's ridiculous. But it's so easy to
write code that uses poor design principles. Example: just making
variables public instead of using properties. Another example: passing
references to forms to other classes so they can modify things (tight
coupling). So in essence, there are so many ways to do things that many of
them are just flat-out poor...
|
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple command set consisting of several single letter
commands which take no arguments. A few additional single letter
commands take arguments:
|
by: notnorwegian |
last post by:
(might not be the right forum for this but...)
what is the definition of a highlevel-language?
well there isnt one specifically and wikipedia and the like gives just
a very general description obv you can say it abstracts away lowlever
operations.
yes but how?
|
by: edgy |
last post by:
Hello,
I am a beginner with PHP, and I have made a language switcher on a site
that I am looking for your feedback on.
First of all, the page is http://www.mankar.ca
My question regarding usage is - well, does it work? Can you continue
browsing in your selected language? I am especially interested in people
using an IE browser with a locale setting that is not english or french.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |