Coverage for Options.py: 14%

44 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-28 16:41 +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#import L10n 

20##_ = L10n.get_translation() 

21 

22import sys 

23from optparse import OptionParser 

24# http://docs.python.org/library/optparse.html 

25 

26def fpdb_options(): 

27 

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

29 parser = OptionParser() 

30 parser.add_option("-x", "--errorsToConsole", 

31 action="store_true", 

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

33 parser.add_option("-d", "--databaseName", 

34 dest="dbname", 

35 help=("Specifies a database name.")) 

36 parser.add_option("-c", "--configFile", 

37 dest="config", default=None, 

38 help=("Specifies the full path to a configuration file.")) 

39 parser.add_option("-r", "--rerunPython", 

40 action="store_true", 

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

42 parser.add_option("-k", "--konverter", 

43 dest="hhc", default="PokerStarsToFpdb", 

44 help=("Module name for Hand History Converter")) 

45 parser.add_option("-s", "--sitename", 

46 dest="sitename", default=None, 

47 help=("A sitename")) 

48 parser.add_option("-l", "--logging", 

49 dest = "log_level", 

50 choices = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'EMPTY'), 

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

52 default = 'EMPTY') 

53 parser.add_option("-v", "--version", action = "store_true", 

54 help = ("Print version information and exit.")) 

55 parser.add_option("-i", "--initialrun", action = "store_true", dest="initialRun", 

56 help = ("Force initial-run dialog")) 

57 parser.add_option("-u", "--usage", action="store_true", dest="usage", default=False, 

58 help=("Print some useful one liners")) 

59 # The following options are used for SplitHandHistory.py 

60 parser.add_option("-f", "--file", dest="filename", metavar="FILE", default=None, 

61 help=("Input file")) 

62 parser.add_option("-D", "--directory", dest="directory", metavar="FILE", default=None, 

63 help=("Input directory")) 

64 parser.add_option("-o", "--outpath", dest="outpath", metavar="FILE", default=None, 

65 help=("Out path in quiet mode")) 

66 parser.add_option("-a", "--archive", action="store_true", dest="archive", default=False, 

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

68 parser.add_option("-t", "--testdata", action="store_true", dest="testData", default=False, 

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

70 parser.add_option("-n", "--numhands", dest="hands", default="100", type="int", 

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

72 parser.add_option("--xloc", dest="xloc", default=None, type="int", 

73 help=("X location to open window")) 

74 parser.add_option("--yloc", dest="yloc", default=None, type="int", 

75 help=("Y location to open window")) 

76 parser.add_option("--autoimport", action="store_true", dest="autoimport", 

77 help=("Auto-start Auto-import")) 

78 parser.add_option("--minimized", action="store_true", dest="minimized", 

79 help=("Start Minimized")) 

80 parser.add_option("--hidden", action="store_true", dest="hidden", 

81 help=("Start Hidden")) 

82 

83 

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

85 return (options, argv) 

86 

87def site_alias(alias): 

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

89 tmp = alias 

90 aliases = { 

91 "Absolute" : "Absolute", 

92 "AP" : "Absolute", 

93 "Betfair" : "Betfair", 

94 "BetOnline" : "BetOnline", 

95 "Boss" : "Boss", 

96 "Bovada" : "Bovada", 

97 "Cake" : "Cake", 

98 "Enet" : "Enet", 

99 "Entraction" : "Entraction", 

100 "Everest" : "Everest", 

101 "Everleaf" : "Everleaf", 

102 "FTP" : "Full Tilt Poker", 

103 "Full Tilt Poker": "Full Tilt Poker", 

104 "iPoker" : "iPoker", 

105 "Merge" : "Merge", 

106 "Microgaming" : "Microgaming", 

107 "OnGame" : "OnGame", 

108 "PacificPoker" : "PacificPoker", 

109 "Pacific" : "PacificPoker", 

110 "Party" : "PartyPoker", 

111 "PartyPoker" : "PartyPoker", 

112 "Pkr" : "Pkr", 

113 "PKR" : "Pkr", 

114 "PokerStars" : "PokerStars", 

115 "SealsWithClubs" : "SealsWithClubs", 

116 "Stars" : "PokerStars", 

117 "PT" : "PokerTracker", 

118 "PokerTracker" : "PokerTracker", 

119 "UltimateBet" : "UltimateBet", 

120 "UB" : "UltimateBet", 

121 "Winamax" : "Winamax", 

122 "Win2day" : "Boss", 

123 } 

124 try: 

125 tmp = aliases[alias] 

126 except KeyError as e: 

127 tmp = False 

128 print (("Alias '%s' unknown") % alias) 

129 

130 return tmp 

131 

132if __name__== "__main__": 

133 (options, argv) = fpdb_options() 

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

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

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

137 

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

139 sys.stdin.readline()