Repository: cuthbertLab/music21 (python)

Issue:
abcFormat does not recognize C# major key signature
It just ignores this key signature and treats the tune as if written in C major.

Pull request description:
Resolves #313: abcFormat ignores C# major key signature.
Missing a few enharmonic keys, now added.

Patch:
diff --git a/music21/abcFormat/__init__.py b/music21/abcFormat/__init__.py
index 962f6a359..c6189eb4b 100644
--- a/music21/abcFormat/__init__.py
+++ b/music21/abcFormat/__init__.py
@@ -416,8 +416,8 @@ class ABCMetadata(ABCToken):
             raise ABCTokenException('no key signature associated with this meta-data')
 
         # abc uses b for flat in key spec only
-        keyNameMatch = ['c', 'g', 'd', 'a', 'e', 'b', 'f#', 'g#',
-                        'f', 'bb', 'eb', 'ab', 'db', 'gb', 'cb',
+        keyNameMatch = ['c', 'g', 'd', 'a', 'e', 'b', 'f#', 'g#', 
+                        'f', 'bb', 'eb', 'd#', 'ab', 'e#', 'db', 'c#', 'gb', 'cb',
                         # HP or Hp are used for highland pipes
                         'hp']
 


Test patch:
diff --git a/music21/abcFormat/testFiles.py b/music21/abcFormat/testFiles.py
index 4ed821443..f84617f86 100644
--- a/music21/abcFormat/testFiles.py
+++ b/music21/abcFormat/testFiles.py
@@ -548,12 +548,22 @@ V:1
 fz((6:4F,//A,//C//F//A//c// e/d/)dz
 '''
 
+czerny_csharp = '''
+X:4
+T:D Fragment
+C:Czerny
+M:C
+K:C#
+L:1/16
+CEDF EGFA GBAc Bdce|]
+'''
+
 #-------------------------------------------------------------------------------
 
 ALL  = [fyrareprisarn, mysteryReel, fullRiggedShip, aleIsDear, kitchGirl,
         williamAndNancy, morrisonsJig, hectorTheHero, kingOfTheFairies,
         sicutRosa, theAleWifesDaughter, theBeggerBoy, theBattleOfTheSnaBas,
-
+        czerny_csharp,
         draughtOfAle,
         valentineJigg,
         testPrimitive, testPrimitivePolyphonic, testPrimitiveTuplet
@@ -587,7 +597,8 @@ class Test(unittest.TestCase):
 
         for i, tf in enumerate(ALL):
             ah = af.readstr(tf)
-            environLocal.printDebug([ah.getTitle()])
+            title = ah.getTitle()
+            environLocal.printDebug([title])
             s = translate.abcToStreamScore(ah)
             # run musicxml processing to look for internal errors
             #print(repr(s.metadata._workIds['localeOfComposition']._data))
@@ -597,7 +608,12 @@ class Test(unittest.TestCase):
             except UnicodeDecodeError as ude:
                 environLocal.warn("About to fail on ABC file #{}".format(i))
                 raise ude
+            
+            if title == 'D Fragment':
+                sharps = s.parts[0].keySignature.sharps
+                self.assertEquals(sharps, 7, "C# key signature should be parsed as 7 sharps")
 
+        
 if __name__ == "__main__":
     import music21
     #music21.converter.parse(reelsABC21, format='abc').scores[1].show()