AnsweredAssumed Answered

if else

Question asked by jpilbeam on Dec 7, 2017
Latest reply on Dec 8, 2017 by Dan_Patterson

ArcMap Version: 10.4.1

 

I have a script that uses a metadata module to check what the metadata of a feature class is. It's probably something simple, but I can't explain why only two of the four if else statements are working the way I want them to. I'm trying to print the title, tags, summary and description. And when there is no text my script is supposed to tell it to print the else statement. Title and tags seem to work but not summary and description.

 

As you can see from the PrtScn the feature class has no info except for the title.

 

import arcpy
import arcpy_metadata as md

metadata = md.MetadataEditor(r'\\gisfile\GISstaff\Jared\Attractions.gdb\RT66')

def meta2txt():
    title = metadata.title
    tags = metadata.tags
    purpose = metadata.purpose
    abstract = metadata.abstract
       
    if title == metadata.title:
        print('Title:\n{}\n'.format(title))
    else:
        print('Title: \nThere is no title.\n')

    if tags == metadata.tags:
        print('Tags:\n{}\n'.format(tags))
    else:
        print("Tags: \nThere are no tags.\n")

    if purpose == metadata.purpose:
        print('Summary:\n{}\n'.format(purpose))
    else:
        print('Summary: \nThere is no summary.\n')

    if abstract == metadata.abstract:
        print('Description:\n{}\n'.format(abstract))
    else:
        print('Description: \nThere is no description.\n')
##
meta2txt()

 

 

As you can see the title has been printed and the tags' else condition has printed the string too. The Summary and the Description is supposed to print 'There are no tags.' as Tags has. Using the debugger, it stops on lines 23 and 28 as if it wants to print them, but doesn't. That's what I don't understand.

Outcomes