brlib 0.0.2__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. {brlib-0.0.2 → brlib-0.1.0}/.github/workflows/test.yml +4 -3
  2. {brlib-0.0.2 → brlib-0.1.0}/PKG-INFO +11 -7
  3. {brlib-0.0.2 → brlib-0.1.0}/README.md +9 -5
  4. {brlib-0.0.2 → brlib-0.1.0}/pyproject.toml +1 -1
  5. brlib-0.1.0/src/brlib/__init__.py +33 -0
  6. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/abbreviations_manager.py +1 -2
  7. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/constants.py +6 -5
  8. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/no_hitter_dicts.py +14 -6
  9. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/utils.py +5 -1
  10. brlib-0.1.0/src/brlib/all_major_leaguers.py +72 -0
  11. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/find_asg.py +32 -5
  12. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/find_games.py +65 -12
  13. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/find_teams.py +44 -5
  14. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/game.py +239 -26
  15. brlib-0.0.2/src/brlib/games.py → brlib-0.1.0/src/brlib/game_set.py +178 -3
  16. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/get_games.py +30 -0
  17. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/get_players.py +30 -0
  18. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/get_teams.py +30 -0
  19. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/options.py +174 -0
  20. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/player.py +226 -68
  21. brlib-0.1.0/src/brlib/player_set.py +227 -0
  22. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/team.py +154 -63
  23. brlib-0.0.2/src/brlib/teams.py → brlib-0.1.0/src/brlib/team_set.py +113 -3
  24. {brlib-0.0.2/tests/abbreviations_manager → brlib-0.1.0/tests}/_helpers/test_abbreviations_manager.py +34 -6
  25. brlib-0.1.0/tests/_helpers/test_no_hitter_dicts.py +84 -0
  26. brlib-0.1.0/tests/conftest.py +114 -0
  27. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/batting.csv +46 -0
  28. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/fielding.csv +41 -0
  29. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/info.csv +2 -0
  30. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/linescore.csv +3 -0
  31. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/pitching.csv +15 -0
  32. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/players.json +1 -0
  33. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/team_info.csv +3 -0
  34. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/teams.json +1 -0
  35. brlib-0.1.0/tests/expected/games/original/1961-allstar-game-1/ump_info.csv +7 -0
  36. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/batting.csv +42 -0
  37. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/fielding.csv +60 -0
  38. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/info.csv +2 -0
  39. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/linescore.csv +3 -0
  40. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/pitching.csv +27 -0
  41. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/players.json +1 -0
  42. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/team_info.csv +3 -0
  43. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/teams.json +1 -0
  44. brlib-0.1.0/tests/expected/games/original/2025-allstar-game/ump_info.csv +7 -0
  45. brlib-0.1.0/tests/expected/games/original/BOS201708250/batting.csv +27 -0
  46. brlib-0.1.0/tests/expected/games/original/BOS201708250/fielding.csv +32 -0
  47. brlib-0.1.0/tests/expected/games/original/BOS201708250/info.csv +2 -0
  48. brlib-0.1.0/tests/expected/games/original/BOS201708250/linescore.csv +3 -0
  49. brlib-0.1.0/tests/expected/games/original/BOS201708250/pitching.csv +11 -0
  50. brlib-0.1.0/tests/expected/games/original/BOS201708250/players.json +1 -0
  51. brlib-0.1.0/tests/expected/games/original/BOS201708250/team_info.csv +3 -0
  52. brlib-0.1.0/tests/expected/games/original/BOS201708250/teams.json +1 -0
  53. brlib-0.1.0/tests/expected/games/original/BOS201708250/ump_info.csv +5 -0
  54. brlib-0.1.0/tests/expected/games/original/FLO199407290/batting.csv +36 -0
  55. brlib-0.1.0/tests/expected/games/original/FLO199407290/fielding.csv +32 -0
  56. brlib-0.1.0/tests/expected/games/original/FLO199407290/info.csv +2 -0
  57. brlib-0.1.0/tests/expected/games/original/FLO199407290/linescore.csv +3 -0
  58. brlib-0.1.0/tests/expected/games/original/FLO199407290/pitching.csv +12 -0
  59. brlib-0.1.0/tests/expected/games/original/FLO199407290/players.json +1 -0
  60. brlib-0.1.0/tests/expected/games/original/FLO199407290/team_info.csv +3 -0
  61. brlib-0.1.0/tests/expected/games/original/FLO199407290/teams.json +1 -0
  62. brlib-0.1.0/tests/expected/games/original/FLO199407290/ump_info.csv +5 -0
  63. brlib-0.1.0/tests/expected/games/original/MLA190105301/batting.csv +21 -0
  64. brlib-0.1.0/tests/expected/games/original/MLA190105301/fielding.csv +21 -0
  65. brlib-0.1.0/tests/expected/games/original/MLA190105301/info.csv +2 -0
  66. brlib-0.1.0/tests/expected/games/original/MLA190105301/linescore.csv +3 -0
  67. brlib-0.1.0/tests/expected/games/original/MLA190105301/pitching.csv +5 -0
  68. brlib-0.1.0/tests/expected/games/original/MLA190105301/players.json +1 -0
  69. brlib-0.1.0/tests/expected/games/original/MLA190105301/team_info.csv +3 -0
  70. brlib-0.1.0/tests/expected/games/original/MLA190105301/teams.json +1 -0
  71. brlib-0.1.0/tests/expected/games/original/MLA190105301/ump_info.csv +2 -0
  72. brlib-0.1.0/tests/expected/games/original/NYN200908230/batting.csv +31 -0
  73. brlib-0.1.0/tests/expected/games/original/NYN200908230/fielding.csv +28 -0
  74. brlib-0.1.0/tests/expected/games/original/NYN200908230/info.csv +2 -0
  75. brlib-0.1.0/tests/expected/games/original/NYN200908230/linescore.csv +3 -0
  76. brlib-0.1.0/tests/expected/games/original/NYN200908230/pitching.csv +12 -0
  77. brlib-0.1.0/tests/expected/games/original/NYN200908230/players.json +1 -0
  78. brlib-0.1.0/tests/expected/games/original/NYN200908230/team_info.csv +3 -0
  79. brlib-0.1.0/tests/expected/games/original/NYN200908230/teams.json +1 -0
  80. brlib-0.1.0/tests/expected/games/original/NYN200908230/ump_info.csv +5 -0
  81. brlib-0.1.0/tests/expected/games/original/PHI202211020/batting.csv +22 -0
  82. brlib-0.1.0/tests/expected/games/original/PHI202211020/fielding.csv +30 -0
  83. brlib-0.1.0/tests/expected/games/original/PHI202211020/info.csv +2 -0
  84. brlib-0.1.0/tests/expected/games/original/PHI202211020/linescore.csv +3 -0
  85. brlib-0.1.0/tests/expected/games/original/PHI202211020/pitching.csv +13 -0
  86. brlib-0.1.0/tests/expected/games/original/PHI202211020/players.json +1 -0
  87. brlib-0.1.0/tests/expected/games/original/PHI202211020/team_info.csv +3 -0
  88. brlib-0.1.0/tests/expected/games/original/PHI202211020/teams.json +1 -0
  89. brlib-0.1.0/tests/expected/games/original/PHI202211020/ump_info.csv +7 -0
  90. brlib-0.1.0/tests/expected/games/original/PIT192010023/batting.csv +22 -0
  91. brlib-0.1.0/tests/expected/games/original/PIT192010023/fielding.csv +22 -0
  92. brlib-0.1.0/tests/expected/games/original/PIT192010023/info.csv +2 -0
  93. brlib-0.1.0/tests/expected/games/original/PIT192010023/linescore.csv +3 -0
  94. brlib-0.1.0/tests/expected/games/original/PIT192010023/pitching.csv +5 -0
  95. brlib-0.1.0/tests/expected/games/original/PIT192010023/players.json +1 -0
  96. brlib-0.1.0/tests/expected/games/original/PIT192010023/team_info.csv +3 -0
  97. brlib-0.1.0/tests/expected/games/original/PIT192010023/teams.json +1 -0
  98. brlib-0.1.0/tests/expected/games/original/PIT192010023/ump_info.csv +3 -0
  99. brlib-0.1.0/tests/expected/games/original/SEA197805231/batting.csv +24 -0
  100. brlib-0.1.0/tests/expected/games/original/SEA197805231/fielding.csv +24 -0
  101. brlib-0.1.0/tests/expected/games/original/SEA197805231/info.csv +2 -0
  102. brlib-0.1.0/tests/expected/games/original/SEA197805231/linescore.csv +3 -0
  103. brlib-0.1.0/tests/expected/games/original/SEA197805231/pitching.csv +6 -0
  104. brlib-0.1.0/tests/expected/games/original/SEA197805231/players.json +1 -0
  105. brlib-0.1.0/tests/expected/games/original/SEA197805231/team_info.csv +3 -0
  106. brlib-0.1.0/tests/expected/games/original/SEA197805231/teams.json +1 -0
  107. brlib-0.1.0/tests/expected/games/original/SEA197805231/ump_info.csv +5 -0
  108. brlib-0.1.0/tests/expected/games/original/SEA201208150/batting.csv +23 -0
  109. brlib-0.1.0/tests/expected/games/original/SEA201208150/fielding.csv +22 -0
  110. brlib-0.1.0/tests/expected/games/original/SEA201208150/info.csv +2 -0
  111. brlib-0.1.0/tests/expected/games/original/SEA201208150/linescore.csv +3 -0
  112. brlib-0.1.0/tests/expected/games/original/SEA201208150/pitching.csv +6 -0
  113. brlib-0.1.0/tests/expected/games/original/SEA201208150/players.json +1 -0
  114. brlib-0.1.0/tests/expected/games/original/SEA201208150/team_info.csv +3 -0
  115. brlib-0.1.0/tests/expected/games/original/SEA201208150/teams.json +1 -0
  116. brlib-0.1.0/tests/expected/games/original/SEA201208150/ump_info.csv +5 -0
  117. brlib-0.1.0/tests/expected/games/original/SEA201804190/batting.csv +24 -0
  118. brlib-0.1.0/tests/expected/games/original/SEA201804190/fielding.csv +30 -0
  119. brlib-0.1.0/tests/expected/games/original/SEA201804190/info.csv +2 -0
  120. brlib-0.1.0/tests/expected/games/original/SEA201804190/linescore.csv +3 -0
  121. brlib-0.1.0/tests/expected/games/original/SEA201804190/pitching.csv +11 -0
  122. brlib-0.1.0/tests/expected/games/original/SEA201804190/players.json +1 -0
  123. brlib-0.1.0/tests/expected/games/original/SEA201804190/team_info.csv +3 -0
  124. brlib-0.1.0/tests/expected/games/original/SEA201804190/teams.json +1 -0
  125. brlib-0.1.0/tests/expected/games/original/SEA201804190/ump_info.csv +5 -0
  126. brlib-0.1.0/tests/expected/games/original/SEA201905270/batting.csv +21 -0
  127. brlib-0.1.0/tests/expected/games/original/SEA201905270/fielding.csv +27 -0
  128. brlib-0.1.0/tests/expected/games/original/SEA201905270/info.csv +2 -0
  129. brlib-0.1.0/tests/expected/games/original/SEA201905270/linescore.csv +3 -0
  130. brlib-0.1.0/tests/expected/games/original/SEA201905270/pitching.csv +11 -0
  131. brlib-0.1.0/tests/expected/games/original/SEA201905270/players.json +1 -0
  132. brlib-0.1.0/tests/expected/games/original/SEA201905270/team_info.csv +3 -0
  133. brlib-0.1.0/tests/expected/games/original/SEA201905270/teams.json +1 -0
  134. brlib-0.1.0/tests/expected/games/original/SEA201905270/ump_info.csv +5 -0
  135. brlib-0.1.0/tests/expected/games/original/SEA202210150/batting.csv +26 -0
  136. brlib-0.1.0/tests/expected/games/original/SEA202210150/fielding.csv +40 -0
  137. brlib-0.1.0/tests/expected/games/original/SEA202210150/info.csv +2 -0
  138. brlib-0.1.0/tests/expected/games/original/SEA202210150/linescore.csv +3 -0
  139. brlib-0.1.0/tests/expected/games/original/SEA202210150/pitching.csv +21 -0
  140. brlib-0.1.0/tests/expected/games/original/SEA202210150/players.json +1 -0
  141. brlib-0.1.0/tests/expected/games/original/SEA202210150/team_info.csv +3 -0
  142. brlib-0.1.0/tests/expected/games/original/SEA202210150/teams.json +1 -0
  143. brlib-0.1.0/tests/expected/games/original/SEA202210150/ump_info.csv +7 -0
  144. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/batting.csv +46 -0
  145. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/fielding.csv +41 -0
  146. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/info.csv +2 -0
  147. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/linescore.csv +3 -0
  148. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/pitching.csv +15 -0
  149. brlib-0.1.0/tests/expected/games/updated/1961-allstar-game-1/team_info.csv +3 -0
  150. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/batting.csv +42 -0
  151. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/fielding.csv +60 -0
  152. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/info.csv +2 -0
  153. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/linescore.csv +3 -0
  154. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/pitching.csv +27 -0
  155. brlib-0.1.0/tests/expected/games/updated/2025-allstar-game/team_info.csv +3 -0
  156. brlib-0.1.0/tests/expected/games/updated/BOS201708250/batting.csv +27 -0
  157. brlib-0.1.0/tests/expected/games/updated/BOS201708250/fielding.csv +32 -0
  158. brlib-0.1.0/tests/expected/games/updated/BOS201708250/info.csv +2 -0
  159. brlib-0.1.0/tests/expected/games/updated/BOS201708250/linescore.csv +3 -0
  160. brlib-0.1.0/tests/expected/games/updated/BOS201708250/pitching.csv +11 -0
  161. brlib-0.1.0/tests/expected/games/updated/BOS201708250/team_info.csv +3 -0
  162. brlib-0.1.0/tests/expected/games/updated/FLO199407290/batting.csv +36 -0
  163. brlib-0.1.0/tests/expected/games/updated/FLO199407290/fielding.csv +32 -0
  164. brlib-0.1.0/tests/expected/games/updated/FLO199407290/info.csv +2 -0
  165. brlib-0.1.0/tests/expected/games/updated/FLO199407290/linescore.csv +3 -0
  166. brlib-0.1.0/tests/expected/games/updated/FLO199407290/pitching.csv +12 -0
  167. brlib-0.1.0/tests/expected/games/updated/FLO199407290/team_info.csv +3 -0
  168. brlib-0.1.0/tests/expected/games/updated/MLA190105301/batting.csv +21 -0
  169. brlib-0.1.0/tests/expected/games/updated/MLA190105301/fielding.csv +21 -0
  170. brlib-0.1.0/tests/expected/games/updated/MLA190105301/info.csv +2 -0
  171. brlib-0.1.0/tests/expected/games/updated/MLA190105301/linescore.csv +3 -0
  172. brlib-0.1.0/tests/expected/games/updated/MLA190105301/pitching.csv +5 -0
  173. brlib-0.1.0/tests/expected/games/updated/MLA190105301/team_info.csv +3 -0
  174. brlib-0.1.0/tests/expected/games/updated/NYN200908230/batting.csv +31 -0
  175. brlib-0.1.0/tests/expected/games/updated/NYN200908230/fielding.csv +28 -0
  176. brlib-0.1.0/tests/expected/games/updated/NYN200908230/info.csv +2 -0
  177. brlib-0.1.0/tests/expected/games/updated/NYN200908230/linescore.csv +3 -0
  178. brlib-0.1.0/tests/expected/games/updated/NYN200908230/pitching.csv +12 -0
  179. brlib-0.1.0/tests/expected/games/updated/NYN200908230/team_info.csv +3 -0
  180. brlib-0.1.0/tests/expected/games/updated/PHI202211020/batting.csv +22 -0
  181. brlib-0.1.0/tests/expected/games/updated/PHI202211020/fielding.csv +30 -0
  182. brlib-0.1.0/tests/expected/games/updated/PHI202211020/info.csv +2 -0
  183. brlib-0.1.0/tests/expected/games/updated/PHI202211020/linescore.csv +3 -0
  184. brlib-0.1.0/tests/expected/games/updated/PHI202211020/pitching.csv +13 -0
  185. brlib-0.1.0/tests/expected/games/updated/PHI202211020/team_info.csv +3 -0
  186. brlib-0.1.0/tests/expected/games/updated/PIT192010023/batting.csv +22 -0
  187. brlib-0.1.0/tests/expected/games/updated/PIT192010023/fielding.csv +22 -0
  188. brlib-0.1.0/tests/expected/games/updated/PIT192010023/info.csv +2 -0
  189. brlib-0.1.0/tests/expected/games/updated/PIT192010023/linescore.csv +3 -0
  190. brlib-0.1.0/tests/expected/games/updated/PIT192010023/pitching.csv +5 -0
  191. brlib-0.1.0/tests/expected/games/updated/PIT192010023/team_info.csv +3 -0
  192. brlib-0.1.0/tests/expected/games/updated/SEA197805231/batting.csv +24 -0
  193. brlib-0.1.0/tests/expected/games/updated/SEA197805231/fielding.csv +24 -0
  194. brlib-0.1.0/tests/expected/games/updated/SEA197805231/info.csv +2 -0
  195. brlib-0.1.0/tests/expected/games/updated/SEA197805231/linescore.csv +3 -0
  196. brlib-0.1.0/tests/expected/games/updated/SEA197805231/pitching.csv +6 -0
  197. brlib-0.1.0/tests/expected/games/updated/SEA197805231/team_info.csv +3 -0
  198. brlib-0.1.0/tests/expected/games/updated/SEA201208150/batting.csv +23 -0
  199. brlib-0.1.0/tests/expected/games/updated/SEA201208150/fielding.csv +22 -0
  200. brlib-0.1.0/tests/expected/games/updated/SEA201208150/info.csv +2 -0
  201. brlib-0.1.0/tests/expected/games/updated/SEA201208150/linescore.csv +3 -0
  202. brlib-0.1.0/tests/expected/games/updated/SEA201208150/pitching.csv +6 -0
  203. brlib-0.1.0/tests/expected/games/updated/SEA201208150/team_info.csv +3 -0
  204. brlib-0.1.0/tests/expected/games/updated/SEA201804190/batting.csv +24 -0
  205. brlib-0.1.0/tests/expected/games/updated/SEA201804190/fielding.csv +30 -0
  206. brlib-0.1.0/tests/expected/games/updated/SEA201804190/info.csv +2 -0
  207. brlib-0.1.0/tests/expected/games/updated/SEA201804190/linescore.csv +3 -0
  208. brlib-0.1.0/tests/expected/games/updated/SEA201804190/pitching.csv +11 -0
  209. brlib-0.1.0/tests/expected/games/updated/SEA201804190/team_info.csv +3 -0
  210. brlib-0.1.0/tests/expected/games/updated/SEA201905270/batting.csv +21 -0
  211. brlib-0.1.0/tests/expected/games/updated/SEA201905270/fielding.csv +27 -0
  212. brlib-0.1.0/tests/expected/games/updated/SEA201905270/info.csv +2 -0
  213. brlib-0.1.0/tests/expected/games/updated/SEA201905270/linescore.csv +3 -0
  214. brlib-0.1.0/tests/expected/games/updated/SEA201905270/pitching.csv +11 -0
  215. brlib-0.1.0/tests/expected/games/updated/SEA201905270/team_info.csv +3 -0
  216. brlib-0.1.0/tests/expected/games/updated/SEA202210150/batting.csv +26 -0
  217. brlib-0.1.0/tests/expected/games/updated/SEA202210150/fielding.csv +40 -0
  218. brlib-0.1.0/tests/expected/games/updated/SEA202210150/info.csv +2 -0
  219. brlib-0.1.0/tests/expected/games/updated/SEA202210150/linescore.csv +3 -0
  220. brlib-0.1.0/tests/expected/games/updated/SEA202210150/pitching.csv +21 -0
  221. brlib-0.1.0/tests/expected/games/updated/SEA202210150/team_info.csv +3 -0
  222. brlib-0.1.0/tests/expected/players/original/aloumo01/batting.csv +40 -0
  223. brlib-0.1.0/tests/expected/players/original/aloumo01/bling.csv +2 -0
  224. brlib-0.1.0/tests/expected/players/original/aloumo01/fielding.csv +80 -0
  225. brlib-0.1.0/tests/expected/players/original/aloumo01/info.csv +2 -0
  226. brlib-0.1.0/tests/expected/players/original/aloumo01/pitching.csv +1 -0
  227. brlib-0.1.0/tests/expected/players/original/aloumo01/relatives.json +1 -0
  228. brlib-0.1.0/tests/expected/players/original/aloumo01/teams.json +1 -0
  229. brlib-0.1.0/tests/expected/players/original/bendech01/batting.csv +33 -0
  230. brlib-0.1.0/tests/expected/players/original/bendech01/bling.csv +2 -0
  231. brlib-0.1.0/tests/expected/players/original/bendech01/fielding.csv +43 -0
  232. brlib-0.1.0/tests/expected/players/original/bendech01/info.csv +2 -0
  233. brlib-0.1.0/tests/expected/players/original/bendech01/pitching.csv +33 -0
  234. brlib-0.1.0/tests/expected/players/original/bendech01/relatives.json +1 -0
  235. brlib-0.1.0/tests/expected/players/original/bendech01/teams.json +1 -0
  236. brlib-0.1.0/tests/expected/players/original/colli05/batting.csv +4 -0
  237. brlib-0.1.0/tests/expected/players/original/colli05/bling.csv +2 -0
  238. brlib-0.1.0/tests/expected/players/original/colli05/fielding.csv +3 -0
  239. brlib-0.1.0/tests/expected/players/original/colli05/info.csv +2 -0
  240. brlib-0.1.0/tests/expected/players/original/colli05/pitching.csv +1 -0
  241. brlib-0.1.0/tests/expected/players/original/colli05/relatives.json +1 -0
  242. brlib-0.1.0/tests/expected/players/original/colli05/teams.json +1 -0
  243. brlib-0.1.0/tests/expected/players/original/gibsojo99/batting.csv +34 -0
  244. brlib-0.1.0/tests/expected/players/original/gibsojo99/bling.csv +2 -0
  245. brlib-0.1.0/tests/expected/players/original/gibsojo99/fielding.csv +66 -0
  246. brlib-0.1.0/tests/expected/players/original/gibsojo99/info.csv +2 -0
  247. brlib-0.1.0/tests/expected/players/original/gibsojo99/pitching.csv +4 -0
  248. brlib-0.1.0/tests/expected/players/original/gibsojo99/relatives.json +1 -0
  249. brlib-0.1.0/tests/expected/players/original/gibsojo99/teams.json +1 -0
  250. brlib-0.1.0/tests/expected/players/original/hallaro01/batting.csv +25 -0
  251. brlib-0.1.0/tests/expected/players/original/hallaro01/bling.csv +2 -0
  252. brlib-0.1.0/tests/expected/players/original/hallaro01/fielding.csv +21 -0
  253. brlib-0.1.0/tests/expected/players/original/hallaro01/info.csv +2 -0
  254. brlib-0.1.0/tests/expected/players/original/hallaro01/pitching.csv +27 -0
  255. brlib-0.1.0/tests/expected/players/original/hallaro01/relatives.json +1 -0
  256. brlib-0.1.0/tests/expected/players/original/hallaro01/teams.json +1 -0
  257. brlib-0.1.0/tests/expected/players/original/jacksre01/batting.csv +46 -0
  258. brlib-0.1.0/tests/expected/players/original/jacksre01/bling.csv +2 -0
  259. brlib-0.1.0/tests/expected/players/original/jacksre01/fielding.csv +94 -0
  260. brlib-0.1.0/tests/expected/players/original/jacksre01/info.csv +2 -0
  261. brlib-0.1.0/tests/expected/players/original/jacksre01/pitching.csv +1 -0
  262. brlib-0.1.0/tests/expected/players/original/jacksre01/relatives.json +1 -0
  263. brlib-0.1.0/tests/expected/players/original/jacksre01/teams.json +1 -0
  264. brlib-0.1.0/tests/expected/players/original/kigerma01/batting.csv +4 -0
  265. brlib-0.1.0/tests/expected/players/original/kigerma01/bling.csv +2 -0
  266. brlib-0.1.0/tests/expected/players/original/kigerma01/fielding.csv +1 -0
  267. brlib-0.1.0/tests/expected/players/original/kigerma01/info.csv +2 -0
  268. brlib-0.1.0/tests/expected/players/original/kigerma01/pitching.csv +1 -0
  269. brlib-0.1.0/tests/expected/players/original/kigerma01/relatives.json +1 -0
  270. brlib-0.1.0/tests/expected/players/original/kigerma01/teams.json +1 -0
  271. brlib-0.1.0/tests/expected/players/original/pressry01/batting.csv +27 -0
  272. brlib-0.1.0/tests/expected/players/original/pressry01/bling.csv +2 -0
  273. brlib-0.1.0/tests/expected/players/original/pressry01/fielding.csv +25 -0
  274. brlib-0.1.0/tests/expected/players/original/pressry01/info.csv +2 -0
  275. brlib-0.1.0/tests/expected/players/original/pressry01/pitching.csv +34 -0
  276. brlib-0.1.0/tests/expected/players/original/pressry01/relatives.json +1 -0
  277. brlib-0.1.0/tests/expected/players/original/pressry01/teams.json +1 -0
  278. brlib-0.1.0/tests/expected/players/original/vogtst01/batting.csv +29 -0
  279. brlib-0.1.0/tests/expected/players/original/vogtst01/bling.csv +2 -0
  280. brlib-0.1.0/tests/expected/players/original/vogtst01/fielding.csv +52 -0
  281. brlib-0.1.0/tests/expected/players/original/vogtst01/info.csv +2 -0
  282. brlib-0.1.0/tests/expected/players/original/vogtst01/pitching.csv +1 -0
  283. brlib-0.1.0/tests/expected/players/original/vogtst01/relatives.json +1 -0
  284. brlib-0.1.0/tests/expected/players/original/vogtst01/teams.json +1 -0
  285. brlib-0.1.0/tests/expected/players/updated/aloumo01/info.csv +2 -0
  286. brlib-0.1.0/tests/expected/players/updated/aloumo01/pitching.csv +1 -0
  287. brlib-0.1.0/tests/expected/players/updated/bendech01/info.csv +2 -0
  288. brlib-0.1.0/tests/expected/players/updated/bendech01/pitching.csv +33 -0
  289. brlib-0.1.0/tests/expected/players/updated/colli05/info.csv +2 -0
  290. brlib-0.1.0/tests/expected/players/updated/colli05/pitching.csv +1 -0
  291. brlib-0.1.0/tests/expected/players/updated/gibsojo99/info.csv +2 -0
  292. brlib-0.1.0/tests/expected/players/updated/gibsojo99/pitching.csv +4 -0
  293. brlib-0.1.0/tests/expected/players/updated/hallaro01/info.csv +2 -0
  294. brlib-0.1.0/tests/expected/players/updated/hallaro01/pitching.csv +27 -0
  295. brlib-0.1.0/tests/expected/players/updated/jacksre01/info.csv +2 -0
  296. brlib-0.1.0/tests/expected/players/updated/jacksre01/pitching.csv +1 -0
  297. brlib-0.1.0/tests/expected/players/updated/kigerma01/info.csv +2 -0
  298. brlib-0.1.0/tests/expected/players/updated/kigerma01/pitching.csv +1 -0
  299. brlib-0.1.0/tests/expected/players/updated/pressry01/info.csv +2 -0
  300. brlib-0.1.0/tests/expected/players/updated/pressry01/pitching.csv +34 -0
  301. brlib-0.1.0/tests/expected/players/updated/vogtst01/info.csv +2 -0
  302. brlib-0.1.0/tests/expected/players/updated/vogtst01/pitching.csv +1 -0
  303. brlib-0.1.0/tests/expected/teams/original/BBB1924/batting.csv +26 -0
  304. brlib-0.1.0/tests/expected/teams/original/BBB1924/fielding.csv +22 -0
  305. brlib-0.1.0/tests/expected/teams/original/BBB1924/info.csv +2 -0
  306. brlib-0.1.0/tests/expected/teams/original/BBB1924/pitching.csv +10 -0
  307. brlib-0.1.0/tests/expected/teams/original/BBB1924/players.json +1 -0
  308. brlib-0.1.0/tests/expected/teams/original/BEG1939/batting.csv +45 -0
  309. brlib-0.1.0/tests/expected/teams/original/BEG1939/fielding.csv +37 -0
  310. brlib-0.1.0/tests/expected/teams/original/BEG1939/info.csv +2 -0
  311. brlib-0.1.0/tests/expected/teams/original/BEG1939/pitching.csv +17 -0
  312. brlib-0.1.0/tests/expected/teams/original/BEG1939/players.json +1 -0
  313. brlib-0.1.0/tests/expected/teams/original/CHC2020/batting.csv +49 -0
  314. brlib-0.1.0/tests/expected/teams/original/CHC2020/fielding.csv +69 -0
  315. brlib-0.1.0/tests/expected/teams/original/CHC2020/info.csv +2 -0
  316. brlib-0.1.0/tests/expected/teams/original/CHC2020/pitching.csv +36 -0
  317. brlib-0.1.0/tests/expected/teams/original/CHC2020/players.json +1 -0
  318. brlib-0.1.0/tests/expected/teams/original/HOU2022/batting.csv +52 -0
  319. brlib-0.1.0/tests/expected/teams/original/HOU2022/fielding.csv +75 -0
  320. brlib-0.1.0/tests/expected/teams/original/HOU2022/info.csv +2 -0
  321. brlib-0.1.0/tests/expected/teams/original/HOU2022/pitching.csv +37 -0
  322. brlib-0.1.0/tests/expected/teams/original/HOU2022/players.json +1 -0
  323. brlib-0.1.0/tests/expected/teams/original/LAA2012/batting.csv +39 -0
  324. brlib-0.1.0/tests/expected/teams/original/LAA2012/fielding.csv +45 -0
  325. brlib-0.1.0/tests/expected/teams/original/LAA2012/info.csv +2 -0
  326. brlib-0.1.0/tests/expected/teams/original/LAA2012/pitching.csv +25 -0
  327. brlib-0.1.0/tests/expected/teams/original/LAA2012/players.json +1 -0
  328. brlib-0.1.0/tests/expected/teams/original/SEA2012/batting.csv +38 -0
  329. brlib-0.1.0/tests/expected/teams/original/SEA2012/fielding.csv +39 -0
  330. brlib-0.1.0/tests/expected/teams/original/SEA2012/info.csv +2 -0
  331. brlib-0.1.0/tests/expected/teams/original/SEA2012/pitching.csv +20 -0
  332. brlib-0.1.0/tests/expected/teams/original/SEA2012/players.json +1 -0
  333. brlib-0.1.0/tests/expected/teams/original/WSH1904/batting.csv +31 -0
  334. brlib-0.1.0/tests/expected/teams/original/WSH1904/fielding.csv +29 -0
  335. brlib-0.1.0/tests/expected/teams/original/WSH1904/info.csv +2 -0
  336. brlib-0.1.0/tests/expected/teams/original/WSH1904/pitching.csv +11 -0
  337. brlib-0.1.0/tests/expected/teams/original/WSH1904/players.json +1 -0
  338. brlib-0.1.0/tests/expected/teams/updated/BBB1924/pitching.csv +10 -0
  339. brlib-0.1.0/tests/expected/teams/updated/BEG1939/pitching.csv +17 -0
  340. brlib-0.1.0/tests/expected/teams/updated/CHC2020/pitching.csv +36 -0
  341. brlib-0.1.0/tests/expected/teams/updated/HOU2022/pitching.csv +37 -0
  342. brlib-0.1.0/tests/expected/teams/updated/LAA2012/pitching.csv +25 -0
  343. brlib-0.1.0/tests/expected/teams/updated/SEA2012/pitching.csv +20 -0
  344. brlib-0.1.0/tests/expected/teams/updated/WSH1904/pitching.csv +11 -0
  345. brlib-0.1.0/tests/test_game.py +119 -0
  346. brlib-0.1.0/tests/test_player.py +79 -0
  347. brlib-0.1.0/tests/test_team.py +57 -0
  348. brlib-0.0.2/src/brlib/__init__.py +0 -1334
  349. brlib-0.0.2/src/brlib/all_major_leaguers.py +0 -29
  350. brlib-0.0.2/src/brlib/players.py +0 -96
  351. {brlib-0.0.2 → brlib-0.1.0}/.github/workflows/publish.yml +0 -0
  352. {brlib-0.0.2 → brlib-0.1.0}/.gitignore +0 -0
  353. {brlib-0.0.2 → brlib-0.1.0}/LICENSE.txt +0 -0
  354. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/__init__.py +0 -0
  355. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/inputs.py +0 -0
  356. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/requests_manager.py +0 -0
  357. {brlib-0.0.2 → brlib-0.1.0}/src/brlib/_helpers/singleton.py +0 -0
@@ -1,11 +1,12 @@
1
- name: Run Tests
1
+ name: Tests
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches: '**'
6
6
  schedule:
7
- # run daily tests after the previous day's scores have hopefully been added
8
- - cron: '0 12 * * *'
7
+ # run at 12 UTC, hopefully after BR's daily in-season updates
8
+ # run weekly because any more would be overkill
9
+ - cron: '0 12 * * 6'
9
10
 
10
11
  jobs:
11
12
  pytest:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brlib
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: A library for collecting baseball statistics from Baseball Reference
5
5
  Project-URL: Homepage, https://github.com/john-bieren/brlib
6
- Project-URL: Documentation, https://github.com/john-bieren/brlib/tree/master/docs
6
+ Project-URL: Documentation, https://github.com/john-bieren/brlib/wiki
7
7
  Project-URL: Repository, https://github.com/john-bieren/brlib.git
8
8
  Project-URL: Issues, https://github.com/john-bieren/brlib/issues
9
9
  Author-email: John Bieren <jbieren64@gmail.com>
@@ -32,10 +32,10 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  # brlib
34
34
 
35
- ![Tests](https://github.com/john-bieren/brlib/actions/workflows/test.yml/badge.svg)
36
- [![PyPI Latest Release](https://img.shields.io/pypi/v/brlib.svg)](https://pypi.org/project/brlib)
35
+ [![Tests](https://github.com/john-bieren/brlib/actions/workflows/test.yml/badge.svg)](https://github.com/john-bieren/brlib/actions/workflows/test.yml)
36
+ [![PyPI Latest Release](https://img.shields.io/pypi/v/brlib?label=PyPI&logo=pypi&logoColor=ffe873&color=0073b7)](https://pypi.org/project/brlib)
37
37
 
38
- A Python library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
38
+ A library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
39
39
 
40
40
  > [!IMPORTANT]
41
41
  > brlib is in beta, breaking changes are possible until the release of version 1.
@@ -43,8 +43,8 @@ A Python library for collecting baseball statistics from [Baseball Reference](ht
43
43
  ## Key Features
44
44
 
45
45
  * `Game`, `Player`, and `Team` classes give you easy access to all associated data in one place, with attributes for stats tables, information, and more.
46
- * Aggregate these into `Games`, `Players`, or `Teams` classes, which contain similar attributes, for easy analysis of larger samples.
47
- * Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/bot-traffic.html).
46
+ * Aggregate these into `GameSet`, `PlayerSet`, or `TeamSet` classes, which have similar attributes, for easy analysis of larger samples.
47
+ * Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/429.html).
48
48
 
49
49
  Learn more by reading the documentation on the [wiki](https://github.com/john-bieren/brlib/wiki).
50
50
 
@@ -69,3 +69,7 @@ Once installed, you can import brlib into your Python scripts:
69
69
  ```python
70
70
  import brlib as br
71
71
  ```
72
+
73
+ ## Data Use
74
+
75
+ Since brlib gathers data from Baseball Reference, your use of this data is subject to their [data use policy](https://www.sports-reference.com/data_use.html).
@@ -1,9 +1,9 @@
1
1
  # brlib
2
2
 
3
- ![Tests](https://github.com/john-bieren/brlib/actions/workflows/test.yml/badge.svg)
4
- [![PyPI Latest Release](https://img.shields.io/pypi/v/brlib.svg)](https://pypi.org/project/brlib)
3
+ [![Tests](https://github.com/john-bieren/brlib/actions/workflows/test.yml/badge.svg)](https://github.com/john-bieren/brlib/actions/workflows/test.yml)
4
+ [![PyPI Latest Release](https://img.shields.io/pypi/v/brlib?label=PyPI&logo=pypi&logoColor=ffe873&color=0073b7)](https://pypi.org/project/brlib)
5
5
 
6
- A Python library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
6
+ A library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
7
7
 
8
8
  > [!IMPORTANT]
9
9
  > brlib is in beta, breaking changes are possible until the release of version 1.
@@ -11,8 +11,8 @@ A Python library for collecting baseball statistics from [Baseball Reference](ht
11
11
  ## Key Features
12
12
 
13
13
  * `Game`, `Player`, and `Team` classes give you easy access to all associated data in one place, with attributes for stats tables, information, and more.
14
- * Aggregate these into `Games`, `Players`, or `Teams` classes, which contain similar attributes, for easy analysis of larger samples.
15
- * Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/bot-traffic.html).
14
+ * Aggregate these into `GameSet`, `PlayerSet`, or `TeamSet` classes, which have similar attributes, for easy analysis of larger samples.
15
+ * Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/429.html).
16
16
 
17
17
  Learn more by reading the documentation on the [wiki](https://github.com/john-bieren/brlib/wiki).
18
18
 
@@ -37,3 +37,7 @@ Once installed, you can import brlib into your Python scripts:
37
37
  ```python
38
38
  import brlib as br
39
39
  ```
40
+
41
+ ## Data Use
42
+
43
+ Since brlib gathers data from Baseball Reference, your use of this data is subject to their [data use policy](https://www.sports-reference.com/data_use.html).
@@ -37,7 +37,7 @@ dev = ["pytest>=9.0.0"]
37
37
 
38
38
  [project.urls]
39
39
  Homepage = "https://github.com/john-bieren/brlib"
40
- Documentation = "https://github.com/john-bieren/brlib/tree/master/docs"
40
+ Documentation = "https://github.com/john-bieren/brlib/wiki"
41
41
  Repository = "https://github.com/john-bieren/brlib.git"
42
42
  Issues = "https://github.com/john-bieren/brlib/issues"
43
43
 
@@ -0,0 +1,33 @@
1
+ from .all_major_leaguers import all_major_leaguers
2
+ from .find_asg import find_asg
3
+ from .find_games import find_games
4
+ from .find_teams import find_teams
5
+ from .game import Game
6
+ from .game_set import GameSet
7
+ from .get_games import get_games
8
+ from .get_players import get_players
9
+ from .get_teams import get_teams
10
+ from .options import options
11
+ from .player import Player
12
+ from .player_set import PlayerSet
13
+ from .team import Team
14
+ from .team_set import TeamSet
15
+
16
+ __version__ = "0.1.0"
17
+
18
+ __all__ = [
19
+ "all_major_leaguers",
20
+ "find_asg",
21
+ "find_games",
22
+ "find_teams",
23
+ "Game",
24
+ "GameSet",
25
+ "get_games",
26
+ "get_players",
27
+ "get_teams",
28
+ "options",
29
+ "Player",
30
+ "PlayerSet",
31
+ "Team",
32
+ "TeamSet"
33
+ ]
@@ -58,8 +58,7 @@ class AbbreviationsManager(Singleton):
58
58
  def _load(self) -> None:
59
59
  """Loads abbreviations data from cache."""
60
60
  self.df = pd.read_csv(self._cache_file)
61
- self.df["Alias"] = self.df["Alias"].astype(str)
62
- self.df.loc[self.df["Alias"] == "nan", "Alias"] = ""
61
+ self.df.loc[self.df["Alias"].isna(), "Alias"] = ""
63
62
 
64
63
  def _get(self) -> None:
65
64
  """Gets abbreviations data from Baseball Reference."""
@@ -49,6 +49,7 @@ else:
49
49
  CACHE_TIMEZONE = pytz.timezone("US/Aleutian")
50
50
 
51
51
  # pre-compiled regular expressions
52
+ MULTI_TEAM_REGEX = re.compile("^[1-9]TM$")
52
53
  SEASON_REGEX = re.compile("^[1-2][0-9]{3}$")
53
54
  SEASON_RANGE_REGEX = re.compile("^[1-2][0-9]{3}-[1-2][0-9]{3}$")
54
55
  GAME_DATE_REGEX = re.compile("^[0-9]{4}[0-1][0-9][0-3][0-9]$")
@@ -510,9 +511,9 @@ PLAYER_INFO_COLS = (
510
511
  "Draft Pick",
511
512
  "Draft Year",
512
513
  "Draft Type",
513
- "High School",
514
+ "High Schools",
514
515
  "Schools",
515
- "Debut",
516
+ "Debut Date",
516
517
  "Debut Game ID",
517
518
  "Debut Age",
518
519
  "Debut Age (Days)",
@@ -521,11 +522,11 @@ PLAYER_INFO_COLS = (
521
522
  "Last Game ID",
522
523
  "Last Game Age",
523
524
  "Last Game Age (Days)",
524
- "Exceeded Rookie Limits",
525
- "Full Name",
526
525
  "HOF Year",
527
526
  "HOF Type",
528
527
  "HOF %",
528
+ "Exceeded Rookie Limits",
529
+ "Full Name",
529
530
  "bWAR",
530
531
  "Years Played",
531
532
  "Minimum Career Earnings",
@@ -799,7 +800,7 @@ TEAM_INFO_COLS = (
799
800
  "Pythagorean Losses",
800
801
  "Team Gold Glove",
801
802
  "Pennant",
802
- "Championship"
803
+ "World Series"
803
804
  )
804
805
 
805
806
  TEAM_BATTING_COLS = (
@@ -114,16 +114,19 @@ class NoHitterDicts(Singleton):
114
114
  records = []
115
115
  for row in individual_table.find_all("tr"):
116
116
  record = [ele.text.strip("*") for ele in row.find_all(["th", "td"])]
117
- records.append(record[:8])
117
+ records.append(record[:9])
118
118
  individual_df = pd.DataFrame(
119
119
  records,
120
- columns=("Rk", "Name", "Perfect", "Gcar", "Gtm", "Year", "Date", "Team")
120
+ columns=("Rk", "Name", "Perfect", "Gcar", "Gtm", "Year", "Date", "Team", "Home/Away")
121
121
  )
122
122
  # remove the header rows which appear every 25 rows
123
123
  individual_df = individual_df.loc[individual_df["Name"] != "Name"].reset_index(drop=True)
124
124
  individual_df["Game Type"] = "R"
125
125
  postseason_mask = ((individual_df["Gcar"] == "") &
126
- (individual_df["Year"].astype(int) > FIRST_GAMES_YEAR))
126
+ # before FIRST_GAMES_YEAR, Gcar is always blank
127
+ (individual_df["Year"].astype(int) >= FIRST_GAMES_YEAR) &
128
+ # Gcar is blank and Home/Away is "?" for regular season Negro League NHs
129
+ (individual_df["Home/Away"] != "?"))
127
130
  individual_df.loc[postseason_mask, "Game Type"] = "P"
128
131
  individual_df.loc[individual_df["Perfect"] == "", "Perfect"] = "N"
129
132
  individual_df = individual_df.reindex(
@@ -142,7 +145,11 @@ class NoHitterDicts(Singleton):
142
145
  game_id_column.append(game_id)
143
146
 
144
147
  individual_df["Player ID"] = player_id_column
148
+ # fix the only exception to postseason_mask
149
+ individual_df.loc[individual_df["Player ID"] == "griercl01", "Game Type"] = "P"
150
+
145
151
  individual_df["Game ID"] = individual_df["Game ID"].astype("object")
152
+ # filter out games without box scores and IDs
146
153
  individual_df.loc[
147
154
  (~individual_df["Team"].isin(BML_TEAM_ABVS)) &
148
155
  (individual_df["Year"].astype(int) >= FIRST_GAMES_YEAR),
@@ -156,16 +163,17 @@ class NoHitterDicts(Singleton):
156
163
  records = []
157
164
  for row in combined_table.find_all("tr"):
158
165
  record = [ele.text.strip("*") for ele in row.find_all(["th", "td"])]
159
- records.append(record[:11])
166
+ records.append(record[:9])
160
167
  combined_df = pd.DataFrame(
161
168
  records,
162
- columns=("Rk", "Year", "Date", "Team", "Home/Away", "Opp", "Rslt", "Name", "Gcar", "Gtm", "Inngs")
169
+ columns=("Rk", "Year", "Date", "Team", "Home/Away", "Opp", "Rslt", "Name", "Gcar")
163
170
  )
164
171
  # remove the header rows which appear every 25 rows
165
172
  combined_df = combined_df.loc[combined_df["Name"] != "Name"].reset_index(drop=True)
166
173
  combined_df["Game Type"] = "R"
167
174
  postseason_mask = ((combined_df["Gcar"] == "") &
168
- (combined_df["Inngs"] != ""))
175
+ # Gcar is blank and Home/Away is "?" for regular season Negro League NHs
176
+ (combined_df["Home/Away"] != "?"))
169
177
  combined_df.loc[postseason_mask, "Game Type"] = "P"
170
178
  combined_df = combined_df.reindex(
171
179
  columns=["Player ID", "Perfect", "Combined", "Year", "Team", "Game ID", "Game Type"]
@@ -120,10 +120,14 @@ def str_remove(string: str, *substrings: str) -> str:
120
120
  string = string.replace(substring, "")
121
121
  return string
122
122
 
123
+ def clean_spaces(string: str) -> str:
124
+ """Removes consecutive, leading, and trailing spaces from `string`."""
125
+ return " ".join(string.split()).strip()
126
+
123
127
  def reformat_date(string_date: str) -> str:
124
128
  """
125
129
  Converts `string_date` of "MM DD, YYYY" to "YY-MM-DD" for formatting consistency.
126
- If `string_date` does not match this format, and empty string will be returned.
130
+ If `string_date` does not match this format, an empty string will be returned.
127
131
  """
128
132
  try:
129
133
  date = datetime.strptime(string_date, "%B %d, %Y")
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Defines all_major_leaguers function."""
4
+
5
+ from io import StringIO
6
+
7
+ import pandas as pd
8
+
9
+ from ._helpers.requests_manager import req_man
10
+ from .options import print_page
11
+
12
+
13
+ def all_major_leaguers() -> pd.DataFrame:
14
+ """
15
+ Returns a DataFrame of basic information about all players in major league history.
16
+
17
+ ## Parameters
18
+
19
+ None.
20
+
21
+ ## Returns
22
+
23
+ `pandas.DataFrame`
24
+
25
+ ## Examples
26
+
27
+ The output (as of 2025-26 offseason):
28
+
29
+ ```
30
+ >>> br.all_major_leaguers()
31
+ Player ID Name Career Start Career End Active
32
+ 0 aardsda01 David Aardsma 2004 2015 False
33
+ 1 aaronha01 Henry Aaron 1954 1976 False
34
+ 2 aaronto01 Tommie Aaron 1962 1971 False
35
+ 3 aasedo01 Don Aase 1977 1990 False
36
+ 4 abadan01 Andy Abad 2001 2006 False
37
+ ... ... ... ... ... ...
38
+ 23610 zupofr01 Frank Zupo 1957 1961 False
39
+ 23611 zuvelpa01 Paul Zuvella 1982 1991 False
40
+ 23612 zuverge01 George Zuverink 1951 1959 False
41
+ 23613 zwilldu01 Dutch Zwilling 1910 1916 False
42
+ 23614 zychto01 Tony Zych 2015 2017 False
43
+
44
+ [23615 rows x 5 columns]
45
+ ```
46
+
47
+ You can filter results and convert them into a `get_players` input:
48
+
49
+ ```
50
+ >>> aml = br.all_major_leaguers()
51
+ >>> mask = aml["Player ID"].str.startswith("q")
52
+ >>> aml = aml.loc[mask]
53
+ >>> aml["Player ID"].values.tolist()
54
+ ['quackke01', 'quallch01', 'quallji01', ...]
55
+ ```
56
+ """
57
+ page = req_man.get_page("/short/inc/players_search_list.csv")
58
+ print_page("All MLB Players")
59
+ csv_lines = str(page.content, "UTF-8").strip()
60
+ # add column names, which are not included in the payload
61
+ columns = "Player ID,Name,Career Span,Active,1,2,3,4,5\n"
62
+ players_df = pd.read_csv(StringIO(columns + csv_lines))
63
+
64
+ # split career span into start and end (if span is one year, only year is listed, no range)
65
+ players_df["Career Start"] = players_df["Career Span"].str.split("-", n=1).str[0].astype(int)
66
+ players_df["Career End"] = players_df["Career Span"].str.split("-", n=1).str[-1].astype(int)
67
+ # convert active column from 0/1 to boolean
68
+ players_df["Active"] = players_df["Active"].astype(bool)
69
+
70
+ columns=["Player ID", "Name", "Career Start", "Career End", "Active"]
71
+ players_df = players_df.reindex(columns=columns)
72
+ return players_df
@@ -12,7 +12,36 @@ from .options import write
12
12
 
13
13
 
14
14
  @runtime_typecheck
15
- def find_asg(seasons: str | list[str] = "ALL") -> list[tuple[str, str, str]]:
15
+ def find_asg(seasons: str | list[str] = "all") -> list[tuple[str, str, str]]:
16
+ """
17
+ Returns a list of All-Star Game tuples which can be an input to `get_games`.
18
+
19
+ ## Parameters
20
+
21
+ * `seasons`: `str` or `list[str]`, default `"all"`
22
+
23
+ A year, inclusive range of years (e.g. `"2017-2019"`), `"all"`, or a list of multiple such inputs which specify the seasons from which to find All-Star Games.
24
+
25
+ ## Returns
26
+
27
+ `list[tuple[str, str, str]]`
28
+
29
+ ## Examples
30
+
31
+ Seasons which did not have All-Star Games are taken into account:
32
+
33
+ ```
34
+ >>> br.find_asg("2019-2022")
35
+ [('allstar', '2019', '0'), ('allstar', '2021', '0'), ('allstar', '2022', '0')]
36
+ ```
37
+
38
+ Seasons with two All-Star Games are also accounted for:
39
+
40
+ ```
41
+ >>> br.find_asg("1962")
42
+ [('allstar', '1962', '1'), ('allstar', '1962', '2')]
43
+ ```
44
+ """
16
45
  # process input
17
46
  seasons = [seasons] if not isinstance(seasons, list) else seasons
18
47
  seasons = [s.upper() for s in seasons]
@@ -43,11 +72,9 @@ def find_asg(seasons: str | list[str] = "ALL") -> list[tuple[str, str, str]]:
43
72
  continue
44
73
  year_set.add(seasons_input)
45
74
 
46
- len_before = len(year_set)
47
75
  year_list = [y for y in year_set if y in all_asg_years]
48
- if len_before != len(year_list):
49
- write(f"All-Star Game box scores are only available from {FIRST_ASG_YEAR} through {year_range_end - 1}")
50
- # remove years which had no All-Star Game (silently, so that nothing prints if seasons="ALL")
76
+ if len(year_list) == 0:
77
+ write(f"All-Star Games have only been held from {FIRST_ASG_YEAR} through {year_range_end - 1}")
51
78
  year_list = [y for y in year_list if y not in NO_ASG_YEARS]
52
79
  year_list.sort()
53
80
 
@@ -22,13 +22,69 @@ from .options import options, print_page, write
22
22
 
23
23
  @runtime_typecheck
24
24
  def find_games(
25
- teams: str | list[str] = "ALL",
26
- seasons: str | list[str] = "ALL",
27
- opponents: str | list[str] = "ALL",
28
- dates: str | list[str] = "ALL",
29
- home_away: str = "ALL",
30
- game_type: str = "ALL"
25
+ teams: str | list[str] = "all",
26
+ seasons: str | list[str] = "all",
27
+ opponents: str | list[str] = "all",
28
+ dates: str | list[str] = "all",
29
+ home_away: str = "all",
30
+ game_type: str = "all"
31
31
  ) -> list[tuple[str, str, str]]:
32
+ """
33
+ Returns a list of game tuples which can be an input to `get_games`.
34
+
35
+ ## Parameters
36
+
37
+ * `teams`: `str` or `list[str]`, default `"all"`
38
+
39
+ A team abbreviation (e.g. `"sea"`), `"all"`, or a list of team abbreviations to specify which teams' games should be found. Abbreviations are subject to era adjustment, and aliases are not accepted. [Read more about team abbreviation handling](https://github.com/john-bieren/brlib/wiki/Team-Abbreviation-Handling).
40
+
41
+ * `seasons`: `str` or `list[str]`, default `"all"`
42
+
43
+ A year, inclusive range of years (e.g. `"2017-2019"`), `"all"`, or a list of multiple such inputs which specify the seasons from which to find games.
44
+
45
+ * `opponents`: `str` or `list[str]`, default `"all"`
46
+
47
+ A valid `teams` input specifying the opponents which `teams` must be facing in returned games.
48
+
49
+ * `dates`: `str` or `list[str]`, default `"all"`
50
+
51
+ A string representing a date in MMDD format as a number (e.g. `"0704"`), an inclusive range of such numbers (e.g. `"0314-0325"`), `"all"`, or a list of multiple such inputs which specify the dates from which games should be found.
52
+
53
+ * `home_away`: `str`, default `"all"`
54
+
55
+ `"home"`, `"away"`, or `"all"` to specify the role which `teams` should have in returned games.
56
+
57
+ * `game_type`: `str`, default `"all"`
58
+
59
+ `"reg"`, `"post"`, or `"all"` to specify whether to find regular season and/or postseason games.
60
+
61
+ ## Returns
62
+
63
+ `list[tuple[str, str, str]]`
64
+
65
+ ## Examples
66
+
67
+ Find all games from a team's season:
68
+
69
+ ```
70
+ >>> br.find_games("SEA", "2020")
71
+ [('HOU', '20200724', '0'), ('HOU', '20200725', '0'), ...]
72
+ ```
73
+
74
+ Find matchups between teams:
75
+
76
+ ```
77
+ >>> br.find_games("SEA", "2019", "STL")
78
+ [('SEA', '20190702', '0'), ('SEA', '20190703', '0'), ('SEA', '20190704', '0')]
79
+ ```
80
+
81
+ Abbreviations can match multiple teams due to era adjustment:
82
+
83
+ ```
84
+ >>> br.find_games(teams="BAL", seasons="1915", dates="825-826", home_away="home")
85
+ [('BAL', '19150825', '1'), ('BAL', '19150825', '2'), ('SLB', '19150825', '0'), ('BAL', '19150826', '0'), ('SLB', '19150826', '0')]
86
+ ```
87
+ """
32
88
  # make sure all possible list inputs are lists
33
89
  teams = [teams] if not isinstance(teams, list) else teams
34
90
  seasons = [seasons] if not isinstance(seasons, list) else seasons
@@ -151,18 +207,15 @@ def _find_year_list(
151
207
  continue
152
208
  year_set.add(seasons_input)
153
209
 
154
- len_before = len(year_set)
155
210
  year_set = {y for y in year_set if y in all_game_years}
156
- if len_before != len(year_set):
211
+ if len(year_set) == 0:
157
212
  write(f"box scores are only available from {FIRST_GAMES_YEAR} through {year_range_end - 1}")
158
-
159
213
  if game_type == "POST":
160
- # remove years which had no postseason (silently, so that nothing prints if seasons="ALL")
161
214
  year_set = {y for y in year_set if y not in NO_POSTSEASON_YEARS}
162
215
 
163
216
  # filter years to those which could possibly contain a matchup of the teams and opponents
164
- if teams != ["ALL"] and opponents != ["ALL"]:
165
- valid_years = set(range(FIRST_GAMES_YEAR, year_range_end))
217
+ if teams != ["ALL"] or opponents != ["ALL"]:
218
+ valid_years = set(all_game_years)
166
219
  if teams != ["ALL"]:
167
220
  valid_years.intersection_update(_all_franchise_seasons(teams))
168
221
  if opponents != ["ALL"]:
@@ -17,9 +17,49 @@ from .options import write
17
17
 
18
18
  @runtime_typecheck
19
19
  def find_teams(
20
- teams: str | list[str] = "ALL",
21
- seasons: str | list[str] = "ALL"
20
+ teams: str | list[str] = "all",
21
+ seasons: str | list[str] = "all"
22
22
  ) -> list[tuple[str, str]]:
23
+ """
24
+ Returns a list of team tuples which can be an input to `get_teams`.
25
+
26
+ ## Parameters
27
+
28
+ * `teams`: `str` or `list[str]`, default `"all"`
29
+
30
+ A team abbreviation (e.g. `"sea"`), segregation-era league identifier (i.e. `"bml"` for Black major league teams or `"wml"` for White major league teams), `"all"`, or a list of multiple such inputs to specify which teams' games should be found. Abbreviations are subject to era adjustment, and aliases are not accepted. [Read more about team abbreviation handling](https://github.com/john-bieren/brlib/wiki/Team-Abbreviation-Handling).
31
+
32
+ * `seasons`: `str` or `list[str]`, default `"all"`
33
+
34
+ A year, inclusive range of years (e.g. `"2017-2019"`), `"all"`, or a list of multiple such inputs which specify the years from which to find games.
35
+
36
+ ## Returns
37
+
38
+ `list[tuple[str, str]]`
39
+
40
+ ## Examples
41
+
42
+ Find teams from a range of seasons without worrying about abbreviation changes:
43
+
44
+ ```
45
+ >>> br.find_teams("OAK", "2022-2025")
46
+ [('OAK', '2022'), ('OAK', '2023'), ('OAK', '2024'), ('ATH', '2025')]
47
+ ```
48
+
49
+ Survey entire seasons:
50
+
51
+ ```
52
+ >>> br.find_teams("BML", "1948")
53
+ [('BBB', '1948'), ('BEG', '1948'), ('CAG', '1948'), ('CBE', '1948'), ...]
54
+ ```
55
+
56
+ Abbreviations can match multiple teams due to era adjustment:
57
+
58
+ ```
59
+ >>> br.find_teams("BAL", "1914")
60
+ [('SLB', '1914'), ('BAL', '1914')]
61
+ ```
62
+ """
23
63
  # make sure all possible list inputs are lists
24
64
  teams = [teams] if not isinstance(teams, list) else teams
25
65
  seasons = [seasons] if not isinstance(seasons, list) else seasons
@@ -104,10 +144,9 @@ def _make_year_list(seasons: list[str]) -> list[int]:
104
144
  continue
105
145
  year_set.add(int(seasons_input))
106
146
 
107
- len_before = len(year_set)
108
147
  year_list = [y for y in year_set if y in all_team_years]
109
- if len_before != len(year_list):
110
- write(f"teams are only available from {FIRST_TEAMS_YEAR} through {year_range_end - 1}")
148
+ if len(year_list) == 0:
149
+ write(f"team stats are only available from {FIRST_TEAMS_YEAR} through {year_range_end - 1}")
111
150
  year_list.sort()
112
151
  return year_list
113
152