Coverage for Options.py: 17%

47 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-18 00:10 +0000

1#!/usr/bin/env python 

2# -*- coding: utf-8 -*- 

3 

4# Copyright 2008-2011 Ray E. Barker 

5# This program is free software: you can redistribute it and/or modify 

6# it under the terms of the GNU Affero General Public License as published by 

7# the Free Software Foundation, version 3 of the License. 

8# 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU General Public License for more details. 

13# 

14# You should have received a copy of the GNU Affero General Public License 

15# along with this program. If not, see <http://www.gnu.org/licenses/>. 

16# In the "official" distribution you can find the license in agpl-3.0.txt. 

17 

18from __future__ import print_function 

19 

20# import L10n 

21##_ = L10n.get_translation() 

22 

23import sys 

24from optparse import OptionParser 

25 

26 

27import logging 

28 

29log = logging.getLogger("parser") 

30 

31 

32def fpdb_options(): 

33 """Process command line options for fpdb and HUD_main.""" 

34 parser = OptionParser() # Initialize option parser 

35 # Option for sending error messages to console instead of log file 

36 parser.add_option( 

37 "-x", 

38 "--errorsToConsole", 

39 action="store_true", 

40 help=("Send error messages to the console rather than the log file."), 

41 ) 

42 # Option to specify database name 

43 parser.add_option("-d", "--databaseName", dest="dbname", help=("Specifies a database name.")) 

44 # Option to specify configuration file path 

45 parser.add_option( 

46 "-c", "--configFile", dest="config", default=None, help=("Specifies the full path to a configuration file.") 

47 ) 

48 # Option indicating program was restarted with a different path 

49 parser.add_option( 

50 "-r", 

51 "--rerunPython", 

52 action="store_true", 

53 help=("Indicates program was restarted with a different path (only allowed once)."), 

54 ) 

55 # Option to specify hand history converter module name 

56 parser.add_option( 

57 "-k", "--konverter", dest="hhc", default="PokerStarsToFpdb", help=("Module name for Hand History Converter") 

58 ) 

59 # Option to specify a site name 

60 parser.add_option("-s", "--sitename", dest="sitename", default=None, help=("A sitename")) 

61 # Option to set the logging level 

62 parser.add_option( 

63 "-l", 

64 "--logging", 

65 dest="log_level", 

66 choices=("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "EMPTY"), 

67 help=("Error logging level:") + " (DEBUG, INFO, WARNING, ERROR, CRITICAL, EMPTY)", 

68 default="EMPTY", 

69 ) 

70 # Option to print version information and exit 

71 parser.add_option("-v", "--version", action="store_true", help=("Print version information and exit.")) 

72 # Option to force the initial run dialog 

73 parser.add_option("-i", "--initialrun", action="store_true", dest="initialRun", help=("Force initial-run dialog")) 

74 # Option to print useful usage lines 

75 parser.add_option( 

76 "-u", "--usage", action="store_true", dest="usage", default=False, help=("Print some useful one liners") 

77 ) 

78 # The following options are used for SplitHandHistory.py (not used anymore) 

79 # Option to specify input file 

80 parser.add_option("-f", "--file", dest="filename", metavar="FILE", default=None, help=("Input file")) 

81 # Option to specify input directory 

82 parser.add_option("-D", "--directory", dest="directory", metavar="FILE", default=None, help=("Input directory")) 

83 # Option to specify output path in quiet mode 

84 parser.add_option("-o", "--outpath", dest="outpath", metavar="FILE", default=None, help=("Out path in quiet mode")) 

85 # Option for handling archive files from PokerStars or Full Tilt Poker 

86 parser.add_option( 

87 "-a", 

88 "--archive", 

89 action="store_true", 

90 dest="archive", 

91 default=False, 

92 help=("File to be split is a PokerStars or Full Tilt Poker archive file"), 

93 ) 

94 # Developer option to print regression test data 

95 parser.add_option( 

96 "-t", 

97 "--testdata", 

98 action="store_true", 

99 dest="testData", 

100 default=False, 

101 help=("Developer option to print regression test data"), 

102 ) 

103 # Option to specify the number of hands to be saved in each file 

104 parser.add_option( 

105 "-n", 

106 "--numhands", 

107 dest="hands", 

108 default="100", 

109 type="int", 

110 help=("How many hands do you want saved to each file. Default is 100"), 

111 ) 

112 # Option to specify the X location for opening the window 

113 parser.add_option("--xloc", dest="xloc", default=None, type="int", help=("X location to open window")) 

114 # Option to specify the Y location for opening the window 

115 parser.add_option("--yloc", dest="yloc", default=None, type="int", help=("Y location to open window")) 

116 # Option to auto-start the auto-import feature 

117 parser.add_option("--autoimport", action="store_true", dest="autoimport", help=("Auto-start Auto-import")) 

118 # Option to start minimized 

119 parser.add_option("--minimized", action="store_true", dest="minimized", help=("Start Minimized")) 

120 # Option to start hidden 

121 parser.add_option("--hidden", action="store_true", dest="hidden", help=("Start Hidden")) 

122 

123 (options, argv) = parser.parse_args() 

124 return (options, argv) 

125 

126 

127def site_alias(alias): 

128 """Function for converting various site aliases to the FPDB name""" 

129 tmp = alias # Initialize with the original alias (not really up to date) 

130 aliases = { 

131 "Absolute": "Absolute", 

132 "AP": "Absolute", 

133 "Betfair": "Betfair", 

134 "BetOnline": "BetOnline", 

135 "Boss": "Boss", 

136 "Bovada": "Bovada", 

137 "Cake": "Cake", 

138 "Enet": "Enet", 

139 "Entraction": "Entraction", 

140 "Everest": "Everest", 

141 "Everleaf": "Everleaf", 

142 "FTP": "Full Tilt Poker", 

143 "Full Tilt Poker": "Full Tilt Poker", 

144 "iPoker": "iPoker", 

145 "Merge": "Merge", 

146 "Microgaming": "Microgaming", 

147 "OnGame": "OnGame", 

148 "PacificPoker": "PacificPoker", 

149 "Pacific": "PacificPoker", 

150 "Party": "PartyPoker", 

151 "PartyPoker": "PartyPoker", 

152 "Pkr": "Pkr", 

153 "PKR": "Pkr", 

154 "PokerStars": "PokerStars", 

155 "SealsWithClubs": "SealsWithClubs", 

156 "Stars": "PokerStars", 

157 "PT": "PokerTracker", 

158 "PokerTracker": "PokerTracker", 

159 "UltimateBet": "UltimateBet", 

160 "UB": "UltimateBet", 

161 "Winamax": "Winamax", 

162 "Win2day": "Boss", 

163 } 

164 

165 try: 

166 tmp = aliases[alias] 

167 except KeyError as e: 

168 tmp = False 

169 log.error(("Alias '%s' unknown") % alias) 

170 log.error(f"Exception: {e}") 

171 

172 return tmp 

173 

174 

175if __name__ == "__main__": 

176 (options, argv) = fpdb_options() 

177 

178 print("errorsToConsole =", options.errorsToConsole) 

179 print("database name =", options.dbname) 

180 print("config file =", options.config) 

181 

182 print(("press enter to end")) 

183 sys.stdin.readline()