original_docstring: 1 if first is empty; 2 if first is a duplicate, 0 otherwise.
docstring: 1 if first is empty; 2 if first is a duplicate, 0 otherwise.
docstring_tokens: 1 if first is empty ; 2 if first is a duplicate 0 otherwise .
code: def isNoteDuplicateOrEmptyInScope(self, note, deck, collection, duplicateScope, duplicateScopeDeckName, duplicateScopeCheckChildren):
          "1 if first is empty; 2 if first is a duplicate, 0 otherwise."
          if duplicateScope != 'deck':
              result = note.dupeOrEmpty()
              if result == False:
                  return 0
              return result
  
          # dupeOrEmpty returns if a note is a global duplicate
          # the rest of the function checks to see if the note is a duplicate in the deck
          val = note.fields[0]
          if not val.strip():
              return 1
          csum = anki.utils.fieldChecksum(val)
  
          did = deck['id']
          if duplicateScopeDeckName is not None:
              deck2 = collection.decks.byName(duplicateScopeDeckName)
              if deck2 is None:
                  # Invalid deck, so cannot be duplicate
                  return 0
              did = deck2['id']
  
          dids = {}
          dids[did] = True
          if duplicateScopeCheckChildren:
              for kv in collection.decks.children(did):
                  dids[kv[1]] = True
  
          for noteId in note.col.db.list(
              "select id from notes where csum = ? and id != ? and mid = ?",
              csum,
              note.id or 0,
              note.mid,
          ):
              for cardDeckId in note.col.db.list(
                  "select did from cards where nid = ?",
                  noteId
              ):
                  if cardDeckId in dids:
                      return 2
          return 0
code_tokens: def isNoteDuplicateOrEmptyInScope ( self , note , deck , collection , duplicateScope , duplicateScopeDeckName , duplicateScopeCheckChildren ) : if duplicateScope != 'deck' : result = note . dupeOrEmpty ( ) if result == False : return 0 return result val = note . fields [ 0 ] if not val . strip ( ) : return 1 csum = anki . utils . fieldChecksum ( val ) did = deck [ 'id' ] if duplicateScopeDeckName is not None : deck2 = collection . decks . byName ( duplicateScopeDeckName ) if deck2 is None : return 0 did = deck2 [ 'id' ] dids = { } dids [ did ] = True if duplicateScopeCheckChildren : for kv in collection . decks . children ( did ) : dids [ kv [ 1 ] ] = True for noteId in note . col . db . list ( "select id from notes where csum = ? and id != ? and mid = ?" , csum , note . id or 0 , note . mid , ) : for cardDeckId in note . col . db . list ( "select did from cards where nid = ?" , noteId ) : if cardDeckId in dids : return 2 return 0
short_docstring: 1 if first is empty; 2 if first is a duplicate, 0 otherwise.
short_docstring_tokens: 1 if first is empty ; 2 if first is a duplicate 0 otherwise .
comment: "1 if first is empty; 2 if first is a duplicate, 0 otherwise."$SEP$# dupeOrEmpty returns if a note is a global duplicate$SEP$# the rest of the function checks to see if the note is a duplicate in the deck$SEP$# Invalid deck, so cannot be duplicate