Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse of EitSupport as standalone application #274

Open
WolfgangFahl opened this issue Nov 9, 2020 · 4 comments
Open

Reuse of EitSupport as standalone application #274

WolfgangFahl opened this issue Nov 9, 2020 · 4 comments

Comments

@WolfgangFahl
Copy link

Thank you for your great software. I have been using an extract of your software for EIT parsing since 2016. I am now in the process of creating a standalone version and would love to make sure that the standalone version can stay in sync with your original code.

For python3 the byte handling seems to need to be modified. Please find my changes at:

https://github.com/WolfgangFahl/eitparser/blob/main/eit/eitparser.py

I'd appreciate some feedback whether the code could be changed to a common base class used by both projects. I'd like to avoid the dependencies

#from Components.config import config
#from Components.Language import language
#from EMCTasker import emcDebugOut
#from IsoFileSupport import IsoSupport

and for that only minor changes where necessary. I also added a main function and some static methods.

@dhwz
Copy link
Collaborator

dhwz commented Nov 9, 2020

This is not matching our current code, there is a lot of wrong and obsolete code in your code.

@WolfgangFahl
Copy link
Author

I in the process of refactoring and suggest using something like:

class Event(object):
    
    def __init__(self,name):
        self.name=name
        self.descriptor = []
        
        self.descriptor_multi = []
        self.codepage = None
        
    def readDescription(self,data,pos,lenOfs,startOfs):
        '''
        read my description
        '''
        event_name_length = bord(data[pos+lenOfs])
        self.description= Bytes()
        for i in range (pos+startOfs,pos+startOfs+event_name_length):
            try:
                if str(bord(data[i]))=="10" or int(str(bord(data[i])))>31:
                    self.description.add(data[i])
            except IndexError as e:
                emcDebugOut("[META] Exception in readEitFile: " + str(e))
                
    def readCodePage(self,data,pos,startOfs):
        if not self.codepage:
            try:
                byte1 = str(bord(data[pos+startOfs]))
            except:
                byte1 = ''
            if byte1=="1": self.codepage = 'iso-8859-5'
            elif byte1=="2": self.codepage = 'iso-8859-6'
            elif byte1=="3": self.codepage = 'iso-8859-7'
            elif byte1=="4": self.codepage = 'iso-8859-8'
            elif byte1=="5": self.codepage = 'iso-8859-9'
            elif byte1=="6": self.codepage = 'iso-8859-10'
            elif byte1=="7": self.codepage = 'iso-8859-11'
            elif byte1=="9": self.codepage = 'iso-8859-13'
            elif byte1=="10": self.codepage = 'iso-8859-14'
            elif byte1=="11": self.codepage = 'iso-8859-15'
            elif byte1=="21": self.codepage = 'utf-8'
            if self.codepage:
                emcDebugOut("[META] Found name_event encoding-type: " + self.codepage)

please stay tuned for the next commit

@WolfgangFahl
Copy link
Author

WolfgangFahl/eitparser@b72cc5e has a refactoring state that is close to what i am up to. It uses a Bytes and Event class and makes debugging simpler.

@WolfgangFahl
Copy link
Author

WolfgangFahl commented Nov 9, 2020

https://pypi.org/project/eitparser/ version 0.0.1 is out now. It passes the testing against the 392 eit files from my Vu+ Duo²
I'd need a proper set of eit files for testing it with all possible encodings and there is lots more todo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants