def ShowStrings(screen_object,SoupObject,TagName,TagIndexes,dictionary):
    GlobalIndex  = LocalIndex = tagindex = 1
    Result = "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n"

    for tag in SoupObject.findAll(re.compile(TagName)):
        if str(tagindex) in TagIndexes:
            LocalIndex = 1
            Result += f"\nTag Number : {tagindex}            Tag Name : <{tag.name}>\n\n\n"
            for element in tag.contents:
                if 'String' in str(type(element)) and RemoveCharacterFromString(String = str(element),DiscardThings = ['\n',' ']) != '':
                    Result += f"-----Global Index : {GlobalIndex}   -----Local Index : {LocalIndex}\n\n{element}\n\n"
                    LocalIndex += 1
                    GlobalIndex += 1
            Result += '\n\n'
        tagindex += 1

    if Result == "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n":
        showerror('Show Error','No Match Found !!!')

    else:
        dictionary['Indexes'] = TagIndexes
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')

        if dictionary['AIM'] == 'Wrap':
            GetModificationWindow(root = screen_object,function = WrapStrings,dictionary = dictionary,Question1 = 'Enter Global Index : ',Question2 = 'Wrapped With : ')

        elif dictionary['AIM'] == 'Unwrap':
            GetModificationWindow(root = screen_object,function = WrapStrings,dictionary = dictionary,Question1 = 'Enter Global Index : ',Question2 = 'Tag to be Unwrapped : ')
def ConfigureAttributesAndValues(screen_object):

    SoupObject = GetSoupObject()
    Result = "\n\t\t\t\t----------------- Results of Your Experiment -----------------\n\n\n"
    TagNumber = AttributeNumber = signal = 1

    for tag in SoupObject.findAll():

        Result += f"\n\nTag Number  =  {TagNumber}          Tag Name  =  {tag.name}\n"
        for attribute,value in tag.attrs.items():

            if AttributeNumber == 1:
                Result += f"\n            Attribute Number     Attribute Name     Attribute's Value\n"
                signal = 0
            Result += f"----------- {AddWhiteSpaces(length = len(str(AttributeNumber)),maxlength = 21,string = str(AttributeNumber))}{AddWhiteSpaces(length = len(str(attribute)),maxlength = 19,string = str(attribute))}{value}\n"
            AttributeNumber+=1

        if AttributeNumber == 1:
            Result += "\n########## No Attributes to Show ##########\n\n"

        AttributeNumber = 1
        TagNumber+=1

    if signal:
        showerror('Show Error','No Results to Show!!')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
def ShowTagElements(screen_object,SoupObject,TagName,TagIndexes):
    GlobalIndex  = LocalIndex = 1
    tagindex = 1
    Result = "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n"

    for tag in SoupObject.findAll(re.compile(TagName)):
        if str(tagindex) in TagIndexes:
            LocalIndex = 1
            Result += f"\nTag Number : {tagindex}            Tag Name : <{tag.name}>\n\n\n"
            for element in tag.contents:
                if RemoveCharacterFromString(String = str(element),DiscardThings = ['\n',' ']) != '':
                    Result += f"-----Global Index : {GlobalIndex}   -----Local Index : {LocalIndex}\n\n{element}\n\n"
                    LocalIndex += 1
                    GlobalIndex += 1
            Result += '\n\n'
        tagindex += 1

    if Result == "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n":
        showerror('Show Error','No Match Found !!!')

    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
        ContentIndexes = GetSearchBar(screen_object = screen_object,Question = 'Global Index : ',BarType = 'Searching')
        Button(screen_object, text='Delete', bd=0, fg='white', bg='blue', activeforeground='blue',activebackground='white',command=lambda: DeleteTag_Contents(screen_object=screen_object, SoupObject=SoupObject,TagName=TagName,TagIndexes = TagIndexes, ContentIndexes = str(ContentIndexes.get()).split(','),AIM='DeleteContents')).place(x=910, y=6)
Exemple #4
0
    def get_file_pannel(self):
        Canvas(self.screen, width=1366, height=768, bg='black').place(x=0, y=0)
        Canvas(self.screen, width=1366, height=35, bg='lightgray').place(x=0,
                                                                         y=0)

        Button(
            self.screen,
            text='Original Document',
            fg='black',
            bg='lightgray',
            activebackground='lightblue',
            bd=0,
            command=lambda: configure_documents(
                screen_object=self.screen, DocType='OriginalDocument')).place(
                    x=15, y=4)
        Button(
            self.screen,
            text='Duplicate Document',
            fg='black',
            bg='lightgray',
            activebackground='lightblue',
            bd=0,
            command=lambda: configure_documents(
                screen_object=self.screen, DocType='DuplicateDocument')).place(
                    x=200, y=4)
        Button(
            self.screen,
            text='Experiment Results',
            fg='black',
            bg='lightgray',
            activebackground='lightblue',
            bd=0,
            command=lambda: configure_documents(
                screen_object=self.screen, DocType='ExperimentResult')).place(
                    x=385, y=4)
    def GetResult(ResultType):
        if ResultType == 'Previous':
            Button(screen_object,text = '  Actual Result   ',fg = 'white', bg = 'purple',activeforeground = 'purple',activebackground = 'white', command = lambda: GetResult(ResultType = 'Actual')).place(x=50,y=630)
            SetResultTextBoxData(DocType = 'ExperimentResult',Data = PreviousResult)

        else:
            Button(screen_object,text = 'Previous Result ', fg='white', bg='purple',activeforeground = 'purple',activebackground = 'white',command=lambda: GetResult(ResultType='Previous')).place(x=50, y=630)
            SetResultTextBoxData(DocType = 'ExperimentResult',Data = ActualResult)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
def GetErrorOrSuccess(Result,dictionary):
    if Result:
        SetResultTextBoxData(DocType = 'DuplicateDocument',Data = str(dictionary['SoupObject']))
        showerror('Succession','Changes Applied successfully!!')
        try:
            dictionary['temprary_window'].destroy()
        except:
            pass
        configure_documents(screen_object = dictionary['root_screen'],DocType = 'DuplicateDocument')

    else:
        showerror('Show Error','Error While Making Changes')
def ViewTagsContent(screen_object):
    DocType = GetDocumentName()
    global TagNames_TagValues
    try:
        if TagNames_TagValues[DocType] == '':
            showerror('Show Error','Error with Document Type')
        else:
            Result = TagNames_TagValues[DocType]
            SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
            configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')

    except:
        pass
def GetTagsSearched(screen_object, StringToFind, SoupObject):
    Result = '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n'
    if StringToFind == '':
        for item in SoupObject.findAll():
            Result += str(item) + '\n'
    else:
        for item in SoupObject.findAll(StringToFind):
            Result += str(item) + '\n'
    if Result == '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n':
        showerror('Show Error','No Match Found!!!')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = StringToFind)
        configure_documents(screen_object = screen_object, DocType = 'ExperimentResult')
def GetTagsUsingValues(screen_object, SoupObject, StringToFind):
    Result = "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n"
    TagNumber = 1
    for tag in SoupObject.findAll():
        ListOfValues = [tag.attrs[attribute] for attribute in tag.attrs]
        if StringToFind in ListOfValues:
            Result += f"\n\nTag Number  =  {TagNumber}          Tag Name  =  {tag.name}\n\n{str(tag)}\n"
        TagNumber+=1

    if Result == "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n":
        showerror('Show Error','No Results to Show')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = StringToFind)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
Exemple #10
0
def SearchingTagsWithRelatedNames(screen_object, StringToFind, SoupObject, Signal):
    Result = "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n"
    index = 1
    for tag in SoupObject.findAll(re.compile(StringToFind)):
        if Signal == 'WithIndex':
            Result += str(index) + '. )    ' + str(tag) + '\n\n\n'
        else:
            Result += str(tag) + '\n\n'
        index += 1
    if Result == "\n\t\t\t----------------- Results that Matches to your Search -----------------\n\n\n\n":
        showerror('Show Error','No Match Found')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = StringToFind)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
Exemple #11
0
    def ApplyChanges():
        if NewTagName.get() == '':
            showerror('Show Error','Error While Applying Changes')
        else:
            SelectedTagNumbers = dictionary['TagNumbers'].split(',')
            index = 1

            for tag in dictionary['SoupObject'].findAll(dictionary['TagtoSearch']):
                if str(index) in SelectedTagNumbers:
                    tag.name = str(NewTagName.get())
                index += 1
            SetResultTextBoxData(DocType = 'DuplicateDocument',Data = str(dictionary['SoupObject']))
            configure_documents(screen_object = dictionary['root_screen'],DocType = 'DuplicateDocument')
            CloseNavigateAndSearchBar(screen_object = dictionary['root_screen'],BarType = 'Searching')
            showerror('Succession', 'Changes Applied Successfully!!')
Exemple #12
0
def GetHelp(screen_object, Position):

    try:
        HelpingContent = Position + "\n\n\t\t\t\t*************** WEB--SCRAPPER'S DOCUMENTATION ***************\n"

        with open('Documentation.txt','r') as f:
            HelpingContent += f.read()

        HelpingContent += "\n\n\t\t\t\t*************** END of DOCUMENTATION ***************\n"


        SetResultTextBoxData(DocType = 'ExperimentResult',Data = HelpingContent)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult_Documentation')

    except:
        showerror('Show Error',"Sorry!!! We Can't Help You !!!  \n  Documentation File Missing  ")
Exemple #13
0
def ShowTags(screen_object, SoupObject, TagtoSearch, ResultStartingLine, BarType):
    # Result = "\n\t\t\t----------------- Enter TagNumber to find that Tag's Parent -----------------\n\n\n\n"
    Result = ResultStartingLine
    index = 1
    for tag in SoupObject.findAll(TagtoSearch):
        Result += str(index) + '.)   ' + str(tag) + '\n\n\n'
        index+=1
    if Result == ResultStartingLine:
        showerror('Show Error','No Match Found')
        return False,0,0
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = TagtoSearch)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
        TagNumber = GetSearchBar(screen_object = screen_object,Question = 'Enter TagNumber : ',BarType = BarType)
        return True,TagNumber,Result
Exemple #14
0
def GetNumberthTag(screen_object, SoupObject, SearchingItem):
    if not SearchingItem.endswith(','):
        SearchingItem += ','
    SearchingIndexes = str(SearchingItem).split(',')
    Result = '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n'
    index = 1
    for tag in SoupObject.findAll():
        if str(index) in SearchingIndexes or SearchingItem == ',':
            Result += str(tag) + '\n'
        index+=1
    if Result == '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n':
        showerror('Show Error','No Match Found')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = SearchingItem)
        configure_documents(screen_object=screen_object, DocType='ExperimentResult')
Exemple #15
0
def ViewOnlyTagNames(screen_object):
    DocType = GetDocumentName()
    Document = GetDocument(DocType = DocType)
    global TagNames_TagValues
    try:
        TagNames_TagValues[DocType] = str(Document.get('0.1',END))
    except:
        TagNames_TagValues[DocType] = str(Document)
    SoupObject = BeautifulSoup(TagNames_TagValues[DocType], 'html.parser')
    Result = "\n\t\t\t\t----------------- Results of Your Experiment -----------------\n\n\n\n"

    for tag in SoupObject.findAll():
        Result += tag.name + '\n\n'

    if Result == "\n\t\t\t\t----------------- Results of Your Experiment -----------------\n\n\n\n":
        showerror('Show Error','Error with Document Type')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        configure_documents(screen_object = screen_object,DocType = 'ExperimentResult')
Exemple #16
0
def GetAttributeSearched(screen_object, StringTofind, SoupObject, signal):

    Result = '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n'

    for tag in SoupObject.findAll():
        for attribute, value in tag.attrs.items():

            if signal == 'Tags&Attributes':
                if StringTofind == str(attribute) or StringTofind == '':
                    Result += str(tag) + '\n'
            elif signal == 'Values&Attributes':
                if StringTofind == str(attribute) or StringTofind == '':
                    Result += f"Attribute Name  :  {str(attribute)}          Attributes's Value  :  {str(value)}\n"
            elif signal == 'Attributes&Values':
                if StringTofind == str(value) or StringTofind == '':
                    Result += f"Attribute Name  :  {str(attribute)}          Attributes's Value  :  {str(value)}\n"

    if Result == '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n':
        showerror('Show Error','No Match Found!!!')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = StringTofind)
        configure_documents(screen_object = screen_object, DocType = 'ExperimentResult')
Exemple #17
0
def NavigatingTagsRelatives(screen_object, SoupObject, TagNumber, TagName, RelativeType, PreviousResult):
    if not str(TagNumber).endswith(','):
        TagNumber += ','
    TagNumberList = str(TagNumber).split(',')
    index = 1
    signal = False
    Result = '\n\t\t\t\t--------------- Results that Matches to your Search ---------------\n\n\n\n'
    for tag in SoupObject.findAll(TagName):
        if str(index) in TagNumberList:

            if RelativeType == 'parent' and tag.parent != '\n':
                signal = True
                Result += f"\t********** Parent Tag of TagNumber : {index} **********\n\n{str(tag.parent)}"

            elif RelativeType == 'direct child':
                Result += f"\t********** Child Tag of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for child in tag.children:
                    if child != '\n':
                        Result += f"*****Child Number = {ResultNumber}*****\n" + str(child) +'\n\n'
                        signal = True
                        ResultNumber += 1


            elif RelativeType == 'descendants':
                Result += f"\t********** Descendant Tag/Tags of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for descendant in tag.descendants:
                    if descendant != '\n' and descendant != ',\n' and descendant != None:
                        Result += f"*****Descendant Number = {ResultNumber}*****\n" + str(descendant) +'\n\n'
                        signal = True
                        ResultNumber += 1


            elif RelativeType == 'next siblings':
                Result += f"\t**********  Next Sibling/Siblings of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for nextsibling in tag.next_siblings:
                    if nextsibling != None and nextsibling != '\n':
                        signal = True
                        Result += f"*****Sibling Number = {ResultNumber}*****\n" + str(nextsibling) +'\n\n'
                        ResultNumber += 1


            elif RelativeType == 'previous siblings':
                Result += f"\t**********  Previous Sibling/Siblings of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for previoussibling in tag.previous_siblings:
                    if previoussibling != None and previoussibling != '\n':
                        signal = True
                        Result += f"*****Sibling Number = {ResultNumber}*****\n" + str(previoussibling) +'\n\n'
                        ResultNumber += 1

            elif RelativeType == 'next elements':
                Result += f"\t**********  Next Element/Elements of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for nextelement in tag.next_elements:
                    if nextelement != None and nextelement != '\n':
                        signal = True
                        Result += f"*****Element Number = {ResultNumber}*****\n" + str(nextelement) +'\n\n'
                        ResultNumber += 1

            elif RelativeType == 'previous elements':
                Result += f"\t**********  Previous Element/Elements of TagNumber : {index} **********\n\n\n"
                ResultNumber = 1
                for previouselement in tag.previous_elements:
                    if previouselement != None and previouselement != '\n':
                        signal = True
                        Result += f"*****Element Number = {ResultNumber}*****\n" + str(previouselement) +'\n\n'
                        ResultNumber += 1

        index+=1

    Result += "\n\n"

    if not signal:
        showerror('Show Error','No Match Found')
    else:
        SetResultTextBoxData(DocType = 'ExperimentResult',Data = Result)
        AddSearchHistory(ThingToAdd = TagName)
        configure_documents(screen_object = screen_object, DocType = 'ExperimentResult')
        PreviousandActualResult(screen_object = screen_object,PreviousResult = PreviousResult,ActualResult = Result)